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