From bfc160809c007450b2a85e49bbbdee1b5d602f54 Mon Sep 17 00:00:00 2001 From: Lucas Batista Vargas Date: Wed, 25 Nov 2026 12:35:00 -0300 Subject: [PATCH] Font download: restore test for short window opt-out and close buttons (#7317) (#7530) --- crates/ui-egui/src/font_download/tests.rs | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/crates/ui-egui/src/font_download/tests.rs b/crates/ui-egui/src/font_download/tests.rs index 09a93baf1a..741e19a74c 100644 --- a/crates/ui-egui/src/font_download/tests.rs +++ b/crates/ui-egui/src/font_download/tests.rs @@ -207,6 +207,37 @@ fn fonts_of_one_download_are_listed_together() { assert_eq!((g[1].fonts.as_slice(), g[1].url), (["Cascadia Code"].as_slice(), "https://c")); } +/// As many downloads as the box lists, in a short window and a very short one: what is above +/// the row with Close scrolls, so the opt-out and Close stay on screen and the box in the window. +#[test] +fn many_downloads_in_a_short_window_leave_the_opt_out_and_close_on_screen() { + for height in [600.0, 400.0] { + let mut a = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Lanterns")), crate::Services::default()); + let fonts: Vec = (0..LISTED) + .map(|i| Row { + font: format!("Harbour Face {i}"), + shown_as: vec!["Carlito".into()], + download: format!("Harbour Face {i}"), + publisher: "Lantern Works".into(), + url: format!("https://example.org/{i}"), + restricted: false, + }) + .collect(); + open_with(&mut a, None, FontBox::new(fonts, false), DialogHooks { prepare: None, settle }); + let h = harness_sized(a, egui::vec2(1000.0, height)); + // The steps are still there, to scroll to. + assert!(h.query_by_label("Add Font…").is_some()); + for label in ["Don't show this again", "Close"] { + // Close is also the window's close box: every match is on screen. + let rects: Vec = h.query_all_by_label(label).map(|n| n.rect()).collect(); + assert!(!rects.is_empty(), "no {label}"); + for r in rects { + assert!(r.min.y >= 0.0 && r.max.y <= height, "{label} is at {r:?}, outside the {height} pt window"); + } + } + } +} + /// A font whose publisher limits its use says so on its card, and has a card of its own. #[test] fn a_font_with_a_limited_licence_says_so() {