Tests: point the empty description line test at a row that has no sentence

Show Slice Numbers now has a sentence. The test goes to the first
category other than Units that still has a row without one (Slices when
none is left) and points at that row.
This commit is contained in:
dotCooCoo
2026-11-18 01:31:26 -08:00
parent d9ba46255f
commit 7dc76c4f39
+18 -9
View File
@@ -1836,8 +1836,11 @@ fn a_row_without_a_description_leaves_the_line_empty() {
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "General:"))]);
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
assert!(painted(&texts, general), "the General row's sentence shows: {texts:?}");
// Go to the Slices category and point at a row with no sentence.
let button = at(&texts, "Slices");
// Go to the first other category that still has a row with no sentence (Slices when none is
// left) and point at that row.
let bare = settings().find(|s| s.category != "Units" && descriptions::description(s.key).is_none());
let category = bare.map_or("Slices", |s| s.category);
let button = at(&texts, category);
let press = |pressed| egui::Event::PointerButton { pos: button, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(button), press(true), press(false)]);
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
@@ -1851,13 +1854,19 @@ fn a_row_without_a_description_leaves_the_line_empty() {
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
empty(&after, "on the line after changing category");
assert_eq!(descriptions::description("showSliceNumbers"), None);
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "Show Slice Numbers"))]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
empty(&after, "on Show Slice Numbers");
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
empty(&after, "on the line after Show Slice Numbers");
if bare.is_some() {
// A checkbox shows its label as it is; other rows show it with a colon.
let (label, pos) = settings()
.filter(|s| s.category == category && descriptions::description(s.key).is_none())
.find_map(|s| texts.iter().find(|(t, _)| *t == s.label || *t == format!("{}:", s.label)).map(|(_, r)| (s.label, r.center())))
.unwrap_or_else(|| panic!("no row of {category} without a sentence is drawn: {texts:?}"));
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(pos)]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
empty(&after, &format!("on {label}"));
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
empty(&after, &format!("on the line after {label}"));
}
assert_eq!(preferences_window(&ctx).size(), size);
}