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.
This commit is contained in:
dotCooCoo committed 2026-11-25 02:42:47 -08:00
1 parent 01c602dc40
commit fd572c960b
1 file changed
+6 -4
+6 -4
View File
@@ -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());