M8: the canvas drag test waits for renders instead of fixed sleeps (#93)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
BFlat
2026-10-10 20:43:52 +07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent e27f2751d4
commit ebe403c49a
+10 -7
View File
@@ -40,19 +40,22 @@ fn a_drag_shows_on_the_canvas_while_it_moves() {
// A move every frame, each one a new document and a new render request.
u.app.canvas.render_work = None;
let before = u.app.session.ds().unwrap().doc.clone();
for k in 1..=30 {
u.frame(vec![Event::PointerMoved(p + vec2(k as f32 * 3.0, k as f32))]);
// At least 30 moves, then on until a finished render shows (slow machines need longer).
for k in 1..=300 {
u.frame(vec![Event::PointerMoved(p + vec2(k as f32, k as f32 / 3.0))]);
std::thread::sleep(Duration::from_millis(15));
if k >= 30 && u.app.canvas.render_work.is_some() {
break;
}
}
assert!(!Arc::ptr_eq(&before, &u.app.session.ds().unwrap().doc), "the drag moved the layer");
assert!(u.app.canvas.render_work.is_some(), "renders finished during the drag are shown");
// Held still: the same move each frame keeps the preview, and the canvas settles.
let held = u.app.session.ds().unwrap().doc.clone();
for _ in 0..5 {
u.frame(vec![]);
std::thread::sleep(Duration::from_millis(15));
}
// Frames until the last render lands (slow machines take a while): a drag held still makes
// no new documents, so the worker runs dry.
settle(&mut u);
assert!(Arc::ptr_eq(&held, &u.app.session.ds().unwrap().doc));
assert!(u.app.worker.as_ref().is_some_and(|w| !w.in_flight), "nothing left to render");
u.button(p + vec2(90.0, 30.0), false);
u.button(p + vec2(30.0, 10.0), false);
}