From 0c7ff149a0c300286456ca7eb001e53fcf93a6a0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 10:28:48 -0800 Subject: [PATCH] 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. --- crates/ui-egui/src/tests/dialog_layout.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/tests/dialog_layout.rs b/crates/ui-egui/src/tests/dialog_layout.rs index 842d69c9fc..2e2e4f2260 100644 --- a/crates/ui-egui/src/tests/dialog_layout.rs +++ b/crates/ui-egui/src/tests/dialog_layout.rs @@ -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:?}")); }