From 7b9603bb874c059b0377e3542a2409fee9c4e242 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 23:50:12 -0800 Subject: [PATCH] Tests: the Slices keyboard test checks Line Color and starts from the search field keyboard_focus_on_a_slices_row_shows_its_description stopped at Show Slice Numbers, so nothing checked that keyboard focus on Line Color shows its sentence, and the test passed even when the first Tab did not start from the search field. It now uses tab_to_each, as the Hyphenation test does: it asserts the search field has the keyboard first, then tabs to Show Slice Numbers and Line Color in that order and checks that each focused control carries its sentence. --- crates/ui-egui/src/prefs_dialog/tests.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index c79ca22470..bfce328bf7 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -2439,8 +2439,9 @@ fn hovering_a_slices_row_shows_its_description() { assert!(painted(&after, color) && !painted(&after, numbers), "the Line Color row's sentence shows: {after:?}"); } -/// Tab from the search field reaches Slices' first control, the Show Slice Numbers box: the line -/// shows its sentence and a screen reader gets it as the control's description. +/// Tab from the search field reaches Slices' Show Slice Numbers box and then its Line Color control, +/// in that order: the line shows each one's sentence in turn, and a screen reader gets it as the +/// focused control's description. #[test] fn keyboard_focus_on_a_slices_row_shows_its_description() { let mut a = app(); @@ -2451,16 +2452,11 @@ fn keyboard_focus_on_a_slices_row_shows_its_description() { description_frame(&mut a, &ctx, vec![]); description_frame(&mut a, &ctx, vec![]); let numbers = descriptions::description("showSliceNumbers").expect("Show Slice Numbers has a sentence"); - let mut shown = None; - for _ in 0..40 { - let (texts, described) = description_frame(&mut a, &ctx, key_press(egui::Key::Tab, egui::Modifiers::NONE)); - if painted(&texts, numbers) { - shown = Some(described); - break; - } + let color = descriptions::description("sliceLineColor").expect("Line Color has a sentence"); + let first = tab_to_each(&mut a, &ctx, &[numbers, color]); + for ((described, _), sentence) in first.iter().zip([numbers, color]) { + assert_eq!(described.as_deref(), Some(sentence), "the focused control carries the sentence"); } - let described = shown.expect("Tab reaches the Show Slice Numbers row and its sentence shows"); - assert!(described.iter().any(|d| d == numbers), "the focused control carries the sentence: {described:?}"); } /// Whether `sentence` is one of `texts` and is drawn on the description line of the frame that