From 797fcf16dbc2bea6a6e45ed0426aed3ead07008b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 14 Nov 2026 09:37:35 +0700 Subject: [PATCH] Tests: font menu tests draw until the menu stays put egui places an Area by the size it had the frame before. When a family name measured late (a face added for its script, a font found in the background) widened the menu on the helper's last frame, that frame drew it where the narrower menu fit, and a_menu_wider_than_its_field_stays_in_the_window saw it 0.7 pt past the window's edge (three failed CI runs on 2026-11-13). The helper now draws until the menu stops moving. --- crates/ui-egui/src/tests/font_menu.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/ui-egui/src/tests/font_menu.rs b/crates/ui-egui/src/tests/font_menu.rs index 2c600d1aa3..ff249bbed4 100644 --- a/crates/ui-egui/src/tests/font_menu.rs +++ b/crates/ui-egui/src/tests/font_menu.rs @@ -1040,6 +1040,22 @@ fn open_menu_with(id: &str, left: f32, width: f32, screen: egui::Vec2, look: Men assert!(frames < 1000, "the menu's samples are still rendering after {frames} frames"); shapes = frame(vec![]); } + // egui places the menu by the size it had the frame before. When a name measured late (a face + // added for its script, a font found in the background) widens it on that frame, the menu sits + // where the narrower one fit until the next: draw until it stays put. + let filter_at = |shapes: &[egui::epaint::ClippedShape]| { + shapes.iter().find_map(|s| match &s.shape { + egui::Shape::Text(t) if t.galley.text() == crate::i18n::t("Any Kind") => Some(t.pos), + _ => None, + }) + }; + for _ in 0..100 { + let before = filter_at(&shapes); + shapes = frame(vec![]); + if filter_at(&shapes) == before && !crate::font_menu::wait_for_samples(&ctx) { + break; + } + } let mut texts = vec![]; let mut samples = vec![]; let mut tints = vec![];