mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Change Harness::run to run until no more repaints are requested (#5580)
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. * [x] I have followed the instructions in the PR template
This commit is contained in:
@@ -49,7 +49,7 @@ fn test_demo_app() {
|
||||
// Load a local image where we know it exists and loads quickly
|
||||
#[cfg(feature = "image_viewer")]
|
||||
Anchor::ImageViewer => {
|
||||
harness.run();
|
||||
harness.step();
|
||||
|
||||
harness
|
||||
.get_by_role_and_label(Role::TextInput, "URI:")
|
||||
@@ -65,7 +65,8 @@ fn test_demo_app() {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
harness.run();
|
||||
// Can't use Harness::run because fractal clock keeps requesting repaints
|
||||
harness.run_steps(2);
|
||||
|
||||
if let Err(e) = harness.try_snapshot(&anchor.to_string()) {
|
||||
results.push(e);
|
||||
|
||||
Reference in New Issue
Block a user