From 3f18a53d511da61bd692e15a9286bdd5f5eee2f0 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Sat, 17 Oct 2026 21:32:16 -0600 Subject: [PATCH] Wait for the text layer in text_selection_action_icons The test dragged a selection after a fixed four frames, but the page's text layer arrives from the render pool in the background; under load it was sometimes not in yet, the drag selected nothing and the assertion failed (3 of 20 runs of the editing binary locally). Wait until DocView reports the page's text instead, via a new has_page_text accessor. --- crates/ui-egui/src/canvas.rs | 6 ++++++ crates/ui-egui/tests/editing.rs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 2b3366e9c2..bef7451976 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1464,6 +1464,12 @@ impl DocView { self.texts.get(&page).cloned() } + /// Whether `page`'s text layer has arrived from the renderer. Selecting text, the I-beam and + /// find matches on a page all wait for it (tests and automation). + pub fn has_page_text(&self, page: usize) -> bool { + self.texts.contains_key(&page) + } + pub(crate) fn clear_selection(&mut self) { self.selection = None; } diff --git a/crates/ui-egui/tests/editing.rs b/crates/ui-egui/tests/editing.rs index 6efab8114a..cb7d4a0ecd 100644 --- a/crates/ui-egui/tests/editing.rs +++ b/crates/ui-egui/tests/editing.rs @@ -3052,7 +3052,9 @@ fn tiny_image_crop_handle_drag_does_not_panic() { #[test] fn text_selection_action_icons() { let mut h = harness(1, |_| {}); - h.run_steps(4); + // Dragging selects only once the page's text layer is in, and it comes from the render pool + // in the background: under load a fixed number of frames was sometimes not enough. + support::wait_until(&mut h, "page 1's text layer", |app| app.views[0].has_page_text(0)); let r = h.state().views[0].page_screen_rect(0).expect("on screen"); let p0 = egui::pos2(r.left() + 40.0 / 200.0 * r.width(), r.top() + (300.0 - 158.0) / 300.0 * r.height()); let p1 = egui::pos2(r.left() + 100.0 / 200.0 * r.width(), r.top() + (300.0 - 158.0) / 300.0 * r.height());