From 3c0ac1f77c351cc6219771d7de4bc71cfe17e019 Mon Sep 17 00:00:00 2001 From: alehel Date: Tue, 3 Nov 2026 08:20:01 +0100 Subject: [PATCH] test(ui): wait_for_cursor waits with step_until It hovered fifty times with a 10 ms sleep between, so a busy runner could run out of tries before the page's text or paragraph boxes arrived from their worker threads. It now steps frames with `support::step_until`, as the other waits for background work do, until the cursor is the one wanted or 30 seconds pass. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/tests/it/pointer.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/tests/it/pointer.rs b/crates/ui-egui/tests/it/pointer.rs index 93ad9fbf80..bd25d7e35d 100644 --- a/crates/ui-egui/tests/it/pointer.rs +++ b/crates/ui-egui/tests/it/pointer.rs @@ -245,16 +245,13 @@ fn tip_says(h: &Harness<'_, PdfCraftApp>, text: &str) -> bool { } /// Hovers `p` until `want` accepts the cursor there (text layers and paragraph boxes arrive from -/// worker threads), and returns the last cursor seen. -fn wait_for_cursor(h: &mut Harness<'_, PdfCraftApp>, p: egui::Pos2, want: impl Fn(egui::CursorIcon) -> bool) -> egui::CursorIcon { +/// worker threads, `support::step_until`), and returns the last cursor seen. +fn wait_for_cursor(h: &mut Harness<'static, PdfCraftApp>, p: egui::Pos2, want: impl Fn(egui::CursorIcon) -> bool) -> egui::CursorIcon { let mut cursor = egui::CursorIcon::Default; - for _ in 0..50 { + let _ = crate::support::step_until(h, |h| { cursor = cursor_at(h, p); - if want(cursor) { - break; - } - std::thread::sleep(std::time::Duration::from_millis(10)); - } + want(cursor) + }); cursor } @@ -408,7 +405,7 @@ fn a_comments_tip_shows_with_every_tool_beside_its_cursor() { let mut h = open(comment_on_text_pdf(), "150", false); // Inside the rectangle comment by "Reviewer": where there is no text, and over a word. let (blank, on_text) = (at(&h, 120.0, 315.0), at(&h, 60.0, 303.0)); - let hover = |h: &mut Harness<'_, PdfCraftApp>, tool: QuickTool, p: egui::Pos2, want: egui::CursorIcon| { + let hover = |h: &mut Harness<'static, PdfCraftApp>, tool: QuickTool, p: egui::Pos2, want: egui::CursorIcon| { h.state_mut().quick_tool = tool; h.run_steps(4); let cursor = wait_for_cursor(h, p, |c| c == want);