From e75fa054b3b787d0ecb417add26efea9223602b9 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 18 Nov 2026 21:32:06 -0500 Subject: [PATCH] app red 4 (g4) (swarm/red4); committed by the lead --- crates/ui-egui/src/panes.rs | 2 ++ crates/ui-egui/tests/it/find_replace.rs | 15 +++++++++++---- crates/ui-egui/tests/it/viewer.rs | 10 ++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index b69ebd80c4..02fce9ce16 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -436,6 +436,7 @@ pub(crate) fn page_area(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let active = usize::from(app.active.and_then(|i| app.views.get(i)).is_some_and(|v| v.pane.place == Place::Second)); // The drop rule reads the open views up front: the views closure below borrows the app. let open: HashSet = app.views.iter().map(|v| v.pane.key).collect(); + eprintln!("DIAG fit_visible_zooms_to_the_content_width: page_area avail {:?}", ui.available_rect_before_wrap()); let views = SplitViews::new(tl!("Pages").to_string(), layout, Bind::bound(&mut at)) .count(1) .active(active) @@ -448,6 +449,7 @@ pub(crate) fn page_area(app: &mut PdfCraftApp, ui: &mut egui::Ui) { strip(app, ui, place); } let room = ui.available_rect_before_wrap(); + eprintln!("DIAG fit_visible_zooms_to_the_content_width: pane {:?} room {room:?} max {:?}", pane.rect, ui.max_rect()); let mut body_ui = ui.new_child(egui::UiBuilder::new().max_rect(room).id_salt("body")); body_ui.shrink_clip_rect(room); // The strip may have closed or moved a tab just now: look the pane's tab up again (a diff --git a/crates/ui-egui/tests/it/find_replace.rs b/crates/ui-egui/tests/it/find_replace.rs index 19d5726b09..cdcf416274 100644 --- a/crates/ui-egui/tests/it/find_replace.rs +++ b/crates/ui-egui/tests/it/find_replace.rs @@ -47,6 +47,13 @@ fn has_field(h: &Harness<'static, PdfCraftApp>, placeholder: &str) -> bool { h.query_all_by(|n| n.placeholder() == Some(placeholder)).next().is_some() } +/// The find bar's Replace with field: a text field named by its label, with no placeholder. +const REPLACE_WITH: &str = "Replace with:"; + +fn has_replace_field(h: &Harness<'static, PdfCraftApp>) -> bool { + h.query_by_role_and_label(egui::accesskit::Role::TextInput, REPLACE_WITH).is_some() +} + #[test] fn replace_all_from_the_find_bar_is_one_undo_step() { let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|cc| { @@ -64,13 +71,13 @@ fn replace_all_from_the_find_bar_is_one_undo_step() { h.run_steps(3); assert!(h.state().views[0].find.is_some()); assert!(has_field(&h, "Find text")); - assert!(!has_field(&h, "Replace with"), "outside Edit text the find bar doesn't replace"); + assert!(!has_replace_field(&h), "outside Edit text the find bar doesn't replace"); // ⇧⌘H: Edit text, and the Replace row. h.key_press_modifiers(Modifiers::COMMAND | Modifiers::SHIFT, Key::H); h.run_steps(3); assert_eq!(h.state().quick_tool, QuickTool::EditText); assert!(h.state().views[0].find.as_ref().is_some_and(|f| f.replacing)); - assert!(has_field(&h, "Replace with"), "the Replace row shows in Edit text"); + assert!(has_replace_field(&h), "the Replace row shows in Edit text"); h.query_by(|n| n.placeholder() == Some("Find text")).expect("find field").type_text("cat"); // Both pages' text loads in the background before every match is listed. for _ in 0..400 { @@ -81,9 +88,9 @@ fn replace_all_from_the_find_bar_is_one_undo_step() { std::thread::sleep(std::time::Duration::from_millis(5)); } assert_eq!(h.state().views[0].find.as_ref().map(|f| f.matches.len()), Some(3)); - h.query_by(|n| n.placeholder() == Some("Replace with")).expect("replace field").click(); + h.get_by_role_and_label(egui::accesskit::Role::TextInput, REPLACE_WITH).click(); h.run_steps(2); - h.query_by(|n| n.placeholder() == Some("Replace with")).expect("replace field").type_text("dog"); + h.get_by_role_and_label(egui::accesskit::Role::TextInput, REPLACE_WITH).type_text("dog"); h.run_steps(1); assert_eq!(h.state().views[0].find.as_ref().map(|f| (f.query.as_str(), f.replacement.as_str())), Some(("cat", "dog"))); // The row may settle over a few frames once the status text changes its width. diff --git a/crates/ui-egui/tests/it/viewer.rs b/crates/ui-egui/tests/it/viewer.rs index d877669528..68278ebc89 100644 --- a/crates/ui-egui/tests/it/viewer.rs +++ b/crates/ui-egui/tests/it/viewer.rs @@ -2036,7 +2036,13 @@ fn diag_page_nodes(h: &Harness<'static, PdfCraftApp>) { /// A thumbnail in the Pages panel (the panel lists pages as "Page n" buttons). fn thumbnail(h: &Harness<'static, PdfCraftApp>, label: &str) -> egui::Pos2 { diag_page_nodes(h); - h.get_all_by_label(label).find(|n| n.rect().left() > 1000.0).expect("the Pages panel thumbnail").rect().center() + h.get_all_by_label(label).find(is_thumbnail).expect("the Pages panel thumbnail").rect().center() +} + +/// Whether `node` is a thumbnail of the Pages panel: the panel lists its pages as list items. +fn is_thumbnail(node: &egui_kittest::Node<'_>) -> bool { + use egui_kittest::kittest::NodeT; + node.accesskit_node().role() == egui::accesskit::Role::ListItem } /// Press and release `button` at `at`. @@ -2080,7 +2086,7 @@ fn pages_panel_thumbnails_have_a_context_menu() { /// Where the Pages panel draws page `n`'s thumbnail. fn thumbnail_rect(h: &Harness<'static, PdfCraftApp>, n: usize) -> egui::Rect { diag_page_nodes(h); - h.get_all_by_label(&format!("Page {n}")).find(|t| t.rect().left() > 1000.0).expect("the Pages panel thumbnail").rect() + h.get_all_by_label(&format!("Page {n}")).find(is_thumbnail).expect("the Pages panel thumbnail").rect() } /// Whether `r` lies wholly in the part of the Pages panel in view.