Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Harness::run to run until no more repaints are requested #5580

Merged
merged 6 commits into from
Jan 7, 2025

Conversation

lucasmerlin
Copy link
Collaborator

@lucasmerlin lucasmerlin commented Jan 3, 2025

Previously, Harness::run just called Harness::step 3 times. If that wasn't enough, tests would often call run multiple times so all animations would finish properly.

Also, I introduced HarnessBuilder::with_step_dt to customize with how big of a dt each frame is called. I set the default to 1.0 / 6.0 (~6fps) so we don't waste cpu in tests waiting on animations.

HarnessBuilder::max_steps allows us to control how many steps Harness::run should run before panicing.
The default is 6, so we run for up to 1.0 logical seconds (six frames at 6 fps), which should be enough to finish most animations.

Turns out a lot of snapshots where rendered before fully shown and had a light opacity, those are now fixed.

  • I have followed the instructions in the PR template

@lucasmerlin lucasmerlin added feature New feature or request tests Unit tests, regression tests, manual tests, … egui_kittest labels Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

Preview available at https://egui-pr-preview.github.io/pr/5580-lucaskittest-run-until-no-more-repaints
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

crates/egui_kittest/src/lib.rs Show resolved Hide resolved
crates/egui_kittest/src/lib.rs Outdated Show resolved Hide resolved
@lucasmerlin lucasmerlin mentioned this pull request Jan 3, 2025
1 task
crates/egui_demo_app/tests/test_demo_app.rs Outdated Show resolved Hide resolved
crates/egui_kittest/src/builder.rs Outdated Show resolved Hide resolved
crates/egui_demo_lib/src/demo/modals.rs Outdated Show resolved Hide resolved
@lucasmerlin lucasmerlin force-pushed the lucas/kittest-run-until-no-more-repaints branch from 5cd20ef to 51facca Compare January 6, 2025 13:43
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful!

emilk

This comment was marked as duplicate.

@emilk emilk merged commit 52060c0 into master Jan 7, 2025
46 checks passed
@emilk emilk deleted the lucas/kittest-run-until-no-more-repaints branch January 7, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui_kittest feature New feature or request tests Unit tests, regression tests, manual tests, …
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants