mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-04 01:29:57 +00:00
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.
This commit is contained in:
1 parent
6eaec60aba
commit
3f18a53d51
2 files changed
+9
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user