Preferences tests follow the one-page structure: no page clicks, scroll to the row, segmented choices by radio group (L-311)

This commit is contained in:
Dylan M. Taylor
2026-11-22 16:23:02 -05:00
parent 7f8afe4f65
commit fa75e56f08
7 changed files with 57 additions and 42 deletions
-2
View File
@@ -32,8 +32,6 @@ fn the_identity_name_signs_new_comments_and_is_remembered() {
}
});
h.run_steps(4);
h.get_by_label("Comment").click();
h.run_steps(2);
// Replace the name in the field (the preferences scroll to it in a 900-point window).
h.get_by_role_and_label(Role::TextInput, "Name on new comments").scroll_to_me();
h.run_steps(4);
+1 -1
View File
@@ -241,7 +241,7 @@ fn document_scripts_and_preferences() {
h.run_steps(2);
h.state_mut().open_preferences();
h.run_steps(2);
h.get_by_role_and_label(egui::accesskit::Role::ListItem, "JavaScript").click();
h.get_by_label("Enable Acrobat JavaScript").scroll_to_me();
h.run_steps(4);
h.get_by_label("Enable Acrobat JavaScript").click();
h.run_steps(2);
+28 -17
View File
@@ -39,19 +39,39 @@ fn harness() -> H {
h
}
/// Whether the Preferences window is on screen: its page list names the first page while it is open.
/// Whether the Preferences window is on screen: its search field shows while it is open.
fn preferences_shown(h: &H) -> bool {
h.query_by_role_and_label(egui::accesskit::Role::ListItem, "General & Interface").is_some()
h.query_by_role_and_label(egui::accesskit::Role::TextInput, "Search settings").is_some()
}
fn click(h: &mut H, label: &str) {
// Preferences is one scrolling page: bring the row into view first.
h.get_by(|node| !node.is_hidden() && node.role() != egui::accesskit::Role::Label && node.label().as_deref() == Some(label)).scroll_to_me();
h.run_steps(3);
h.get_by(|node| !node.is_hidden() && node.role() != egui::accesskit::Role::Label && node.label().as_deref() == Some(label)).click();
h.run_steps(3);
}
/// Picks `option` of the choice row `row`: a short choice is a row of segments (a radio group), a long one a
/// drop-down whose options show once it opens.
fn choose(h: &mut H, row: &str, option: &str) {
use egui::accesskit::Role;
if h.query_by_role_and_label(Role::RadioGroup, row).is_some() {
h.get_by_role_and_label(Role::RadioGroup, row).scroll_to_me();
h.run_steps(3);
h.get_by_role_and_label(Role::RadioGroup, row).get_by_label(option).click();
h.run_steps(3);
} else {
click(h, row);
click(h, option);
}
}
/// Replaces the text of the field named `label` through the keyboard, as a user would.
fn type_into(h: &mut H, label: &str, text: &str) {
let role = if label == "Recent files to keep" { egui::accesskit::Role::SpinButton } else { egui::accesskit::Role::TextInput };
h.get_by_role_and_label(role, label).scroll_to_me();
h.run_steps(3);
h.get_by_role_and_label(role, label).click();
h.run_steps(2);
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
@@ -67,8 +87,7 @@ fn cases() -> Vec<Case> {
page: "Documents and view",
edit: |h| {
// A choice row is a drop-down: its options show once it opens.
click(h, "Default workspace mode");
click(h, "E-Sign");
choose(h, "Default workspace mode", "E-Sign");
},
applied: |a| a.default_mode == Mode::Sign,
},
@@ -77,8 +96,7 @@ fn cases() -> Vec<Case> {
page: "Documents and view",
edit: |h| {
// A choice row is a drop-down: its options show once it opens.
click(h, "Default page display");
click(h, "Two-page view");
choose(h, "Default page display", "Two-page view");
click(h, "Continuous scrolling");
},
applied: |a| {
@@ -90,8 +108,7 @@ fn cases() -> Vec<Case> {
name: "units",
page: "Documents and view",
edit: |h| {
click(h, "Units");
click(h, Unit::Millimetres.label());
choose(h, "Units", Unit::Millimetres.label());
},
applied: |a| a.units == Unit::Millimetres,
},
@@ -100,10 +117,8 @@ fn cases() -> Vec<Case> {
page: "General & Interface",
edit: |h| {
// Each side row is a drop-down of Left and Right.
click(h, "Tools panel side");
click(h, "Right");
click(h, "Navigation rail side");
click(h, "Left");
choose(h, "Tools panel side", "Right");
choose(h, "Navigation rail side", "Left");
},
applied: |a| {
let dock = side_panels::state(a);
@@ -114,8 +129,7 @@ fn cases() -> Vec<Case> {
name: "animation effects",
page: "General & Interface",
edit: |h| {
click(h, "Animation effects");
click(h, "Off");
choose(h, "Animation effects", "Off");
},
applied: |a| a.animation_effects == MotionChoice::Off,
},
@@ -145,9 +159,6 @@ fn edited(case: &Case) -> H {
let mut h = harness();
h.state_mut().open_preferences();
h.run_steps(4);
// The page list's row, not the heading of the page it shows.
h.get_by(|node| !node.is_hidden() && node.role() == egui::accesskit::Role::ListItem && node.label().as_deref() == Some(case.page)).click();
h.run_steps(3);
(case.edit)(&mut h);
h
}
+2 -6
View File
@@ -72,6 +72,8 @@ fn pending_pages_use_document_reading_background() {
/// Picks `option` in the Appearance page's Reading colours row, a select whose options show once it is opened.
fn pick_reading_colours(h: &mut Harness<'static, PdfCraftApp>, option: &str) {
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Reading colours").scroll_to_me();
h.run_steps(3);
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Reading colours").click();
h.run_steps(3);
h.get_all_by_label(option).last().unwrap_or_else(|| panic!("the {option:?} option is on screen")).click();
@@ -98,8 +100,6 @@ fn reading_colours_preference_round_trips() {
});
h.run_steps(4);
assert_eq!(h.state().reading_colors, ReadingColors::default());
h.get_by_label("Appearance").click();
h.run_steps(3);
pick_reading_colours(&mut h, "White on black");
assert_eq!(h.state().reading_colors, ReadingColors::WHITE_ON_BLACK, "the row applies immediately");
h.get_by_label("OK").click();
@@ -140,8 +140,6 @@ fn reading_presets_follow_appearance_and_do_not_change_the_interface_theme() {
}
});
h.run_steps(6);
h.get_by_label("Appearance").click();
h.run_steps(3);
// The document's own colours: the row starts on Off.
let row = h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Reading colours");
assert_eq!(row.value().as_deref(), Some("Off"));
@@ -160,8 +158,6 @@ fn reading_presets_follow_appearance_and_do_not_change_the_interface_theme() {
assert_eq!(h.state().theme_preference, theme);
h.state_mut().open_preferences();
h.run_steps(4);
h.get_by_label("Appearance").click();
h.run_steps(3);
}
if let Ok(path) = std::env::var("PDFCRAFT_READING_SHOT") {
h.render().unwrap().save(path).unwrap();
+8 -3
View File
@@ -104,9 +104,14 @@ fn posted_notices(h: &Harness<'static, PdfCraftApp>) -> Vec<String> {
/// list's.
fn pick_preference(h: &mut Harness<'static, PdfCraftApp>, page: Option<&str>, row: &str, option: &str) {
use egui::accesskit::Role;
if let Some(page) = page {
h.get_by_label(page).click();
h.run_steps(3);
// Preferences is one scrolling page: `page` needs no opening.
let _ = page;
if h.query_by_role_and_label(Role::RadioGroup, row).is_some() {
h.get_by_role_and_label(Role::RadioGroup, row).scroll_to_me();
h.run_steps(4);
h.get_by_role_and_label(Role::RadioGroup, row).get_by_label(option).click();
h.run_steps(2);
return;
}
h.get_by_role_and_label(Role::ComboBox, row).scroll_to_me();
h.run_steps(4);
+16 -11
View File
@@ -55,10 +55,8 @@ fn rect(h: &Harness<'static, PdfCraftApp>, page: usize) -> Option<egui::Rect> {
h.state().views[0].page_screen_rect(page)
}
/// Turns on the Preferences row `label` on the Documents and view page and applies it with OK, as a user does.
/// Turns on the Preferences row `label` in the Documents and view card and applies it with OK, as a user does.
fn choose_in_documents_preferences(h: &mut Harness<'static, PdfCraftApp>, label: &str) {
h.get_by_label("Documents and view").click();
h.run_steps(3);
h.get_by_label(label).scroll_to_me();
h.run_steps(4);
h.get_by_label(label).click();
@@ -70,14 +68,21 @@ fn choose_in_documents_preferences(h: &mut Harness<'static, PdfCraftApp>, label:
/// Picks `option` in the Preferences choice row `row` on the Documents and view page and applies it with OK, as a
/// user does: the row is a select, whose options show once it is opened.
fn pick_in_documents_preferences(h: &mut Harness<'static, PdfCraftApp>, row: &str, option: &str) {
h.get_by_label("Documents and view").click();
h.run_steps(3);
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, row).scroll_to_me();
h.run_steps(4);
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, row).click();
h.run_steps(3);
h.get_all_by_label(option).last().unwrap_or_else(|| panic!("the {option:?} option is on screen")).click();
h.run_steps(2);
let group = egui::accesskit::Role::RadioGroup;
if h.query_by_role_and_label(group, row).is_some() {
// A short choice is a row of segments.
h.get_by_role_and_label(group, row).scroll_to_me();
h.run_steps(4);
h.get_by_role_and_label(group, row).get_by_label(option).click();
h.run_steps(2);
} else {
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, row).scroll_to_me();
h.run_steps(4);
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, row).click();
h.run_steps(3);
h.get_all_by_label(option).last().unwrap_or_else(|| panic!("the {option:?} option is on screen")).click();
h.run_steps(2);
}
h.get_by_label("OK").click();
h.run_steps(3);
}
+2 -2
View File
@@ -68,8 +68,8 @@ fn checkbox_and_multiple_documents_do_not_edit_pdf_state() {
h.set_option("dialog", "preferences").unwrap();
h.run_steps(3);
assert_eq!(h.state().settings_snapshot().behavior.show_page_edge_shadows, Some(true));
// Preferences shows one page at a time; the shadows are on Appearance.
h.get_by_label("Appearance").click();
// Preferences is one scrolling page; the shadows are in the Appearance card.
h.get_by_label("Show Page Edge Shadows").scroll_to_me();
h.run_steps(3);
let checkbox = h.get_by_label("Show Page Edge Shadows");
checkbox.click();