From a1cdf0668a50c16f7c47357352d99592bdcd5dce Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 16:08:59 -0800 Subject: [PATCH] Find Font: repeat the pump test's edit when the font generation changes Another test thread that changes the font database between the two pump passes makes the second pass list the fonts again, so the one-listing assertion could fail. The test now repeats the edit until the generation stays the same across both passes, as kept_over_frames does. --- crates/ui-egui/src/find_font.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/find_font.rs b/crates/ui-egui/src/find_font.rs index 170c9df21e..65e2a030d2 100644 --- a/crates/ui-egui/src/find_font.rs +++ b/crates/ui-egui/src/find_font.rs @@ -687,12 +687,21 @@ mod tests { } assert_eq!(FONT_LISTS.get(), 0, "fonts listed with the dialog closed"); open(&mut app); - let opened_lists = FONT_LISTS.get(); - assert_eq!(opened_lists, 1, "opening lists the fonts once"); - app.session.execute("shape.rectangle", &json!({"x": 60, "y": 0, "width": 5, "height": 5})).unwrap(); - pump_now(&mut app); - pump_now(&mut app); - assert_eq!(FONT_LISTS.get(), opened_lists + 1, "an edit lists the fonts again once while the dialog is open"); + assert_eq!(FONT_LISTS.get(), 1, "opening lists the fonts once"); + // Another test thread that changes the available fonts during the two passes makes the + // second pass list them again, so the edit is repeated until the generation stays the same. + for i in 0..20 { + let generation = vectorcraft_text::FontDb::global().generation(); + let before = FONT_LISTS.get(); + app.session.execute("shape.rectangle", &json!({"x": 60 + i, "y": 0, "width": 5, "height": 5})).unwrap(); + pump_now(&mut app); + pump_now(&mut app); + if vectorcraft_text::FontDb::global().generation() == generation { + assert_eq!(FONT_LISTS.get(), before + 1, "an edit lists the fonts again once while the dialog is open"); + return; + } + } + panic!("the available fonts kept changing") } /// Find In passes Find the active artboard, or the selected layers (else the current