Tests: the short-screen dialog test checks what is in view at every scroll step

It looked only at the first frame and the frame after scrolling to the end, so
a row or button that is in view only part way down counted as unreachable. The
wheel now moves 50 points at a time and the test collects the texts in view
after each step.
This commit is contained in:
dotCooCoo committed 2026-11-30 10:28:48 -08:00
1 parent 0aa7179dd6
commit 0c7ff149a0
1 file changed
+12 -7
+12 -7
View File
@@ -149,22 +149,27 @@ fn seen(h: &Window, screen: Rect) -> Vec<(String, Rect)> {
found
}
/// Scroll the wheel down over the middle of the screen, far enough to reach the end of a window.
fn scroll_down(h: &mut Window, screen: Rect) {
/// Scroll the wheel down over the middle of the screen in small steps, far enough to reach the end of a window;
/// the texts [`seen`] on the way.
fn scroll_down(h: &mut Window, screen: Rect) -> Vec<(String, Rect)> {
let mut found = vec![];
h.input_mut().events.push(egui::Event::PointerMoved(screen.center()));
for _ in 0..20 {
for _ in 0..80 {
h.input_mut().events.push(egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, -200.0),
delta: egui::vec2(0.0, -50.0),
phase: egui::TouchPhase::Move,
modifiers: egui::Modifiers::default(),
source: egui::MouseWheelSource::Unknown,
});
step(h);
found.extend(seen(h, screen));
}
for _ in 0..4 {
step(h);
}
found.extend(seen(h, screen));
found
}
/// Dialogs whose lists or rows fit themselves to the screen stay on a short screen with every
@@ -216,15 +221,15 @@ fn dialogs_on_a_short_screen_keep_their_buttons_and_rows_in_reach() {
step(&mut h);
}
let top = seen(&h, screen);
scroll_down(&mut h, screen);
let scrolled = scroll_down(&mut h, screen);
let end = seen(&h, screen);
let reached = |label: &str| top.iter().chain(&end).any(|(s, _)| s == label);
let reached = |label: &str| top.iter().chain(&scrolled).any(|(s, _)| s == label);
for label in labels {
if !reached(label) {
wrong.push(format!("{name} at {height}: {label} cannot be scrolled into view: {top:?} {end:?}"));
}
}
let row_reached = |row: &str| top.iter().chain(&end).any(|(s, _)| s.contains(row));
let row_reached = |row: &str| top.iter().chain(&scrolled).any(|(s, _)| s.contains(row));
if rows_seen && !rows.iter().any(|r| row_reached(r)) {
wrong.push(format!("{name} at {height}: its lists or rows cannot be scrolled into view: {top:?} {end:?}"));
}