From fd572c960b681e16119577c6dd8729ae8fa5630b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 02:42:47 -0800 Subject: [PATCH] Tests: the screenshot trial waits for the request's own deadline a_screenshot_is_issued_by_the_apps_frames_and_written runs frames until one issues the screenshot, and stopped after 5 seconds of wall clock. The settle delay runs on the wall clock and needs three passes, so a frame that takes more than about 1.7 seconds (as in a loaded full run of the crate's tests) used up the 5 seconds first. The request's own deadline answers it with an error after 8 seconds, so the trial now ends on that reply and shows it, and has no wall-clock bound of its own. --- crates/ui-egui/src/tests/automation.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tests/automation.rs b/crates/ui-egui/src/tests/automation.rs index f3640869de..d8cc9f9d04 100644 --- a/crates/ui-egui/src/tests/automation.rs +++ b/crates/ui-egui/src/tests/automation.rs @@ -1121,8 +1121,9 @@ fn a_screenshot_is_issued_by_the_apps_frames_and_written() { let path = base.join("out/shot.png"); let (req, reply) = ControlRequest::new("ui.screenshot", json!({"path": s(path.clone()), "focus": false})); tx.send(req).unwrap(); - // The settle delay runs on the wall clock: frames come until it is over, as an idle window's do. - let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + // The settle delay runs on the wall clock: frames come until it is over, as an idle window's do. The + // request's own deadline (`craft::automation::screenshot::DEADLINE`) answers it with an error when no + // frame issues it in time, so the loop ends on the reply. let callback = loop { let out = crate::testing::app_frame(&mut app, &ctx, raw()); let sent = out.viewport_output.get(&egui::ViewportId::ROOT).and_then(|root| { @@ -1131,8 +1132,9 @@ fn a_screenshot_is_issued_by_the_apps_frames_and_written() { if let Some(callback) = sent { break callback; } - assert!(reply.try_recv().is_err(), "the screenshot was answered before it was taken"); - assert!(std::time::Instant::now() < deadline, "no frame issued the screenshot"); + if let Ok(r) = reply.try_recv() { + panic!("the screenshot was answered before it was taken: {r}"); + } }; callback.complete(std::sync::Arc::new(egui::ColorImage::filled([800, 600], egui::Color32::WHITE))); crate::testing::app_frame(&mut app, &ctx, raw());