From 48109c9fe0f4629938561f5bc1b460b4eeb49851 Mon Sep 17 00:00:00 2001 From: DuBearte <130190089+DuBearte@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:02:38 -0500 Subject: [PATCH] Type options bar tests: load the fonts before building the harness (#13408) The bar shows a "Loading fonts..." placeholder until the font library is ready. When the background load finished mid-test, the next frame swapped in the real menus and a queued click could miss. The bar harness helpers now call photocraft_text::shared() first, as canvas_tests.rs already does. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs | 2 ++ crates/ui-egui/src/tools/type_tool/panels_toggle_tests.rs | 2 ++ crates/ui-egui/src/tools/type_tool/size_presets_tests.rs | 2 ++ .../ui-egui/src/tools/type_tool/vertical_align_buttons_tests.rs | 2 ++ 4 files changed, 8 insertions(+) diff --git a/crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs b/crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs index a41a0e2f2c5..700d00a073f 100644 --- a/crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs @@ -22,6 +22,8 @@ fn app() -> PhotocraftApp { /// `draw` in a row, once the app's fonts are set up (the first pass has none). fn harness(draw: fn(&mut PhotocraftApp, &mut egui::Ui)) -> Harness<'static, PhotocraftApp> { + // Load the fonts first: if they finish mid-test the bar swaps "Loading fonts…" for its menus and a click is lost (#13408). + let _ = photocraft_text::shared(); let mut h = Harness::builder().with_size(vec2(1400.0, 600.0)).build_ui_state( move |ui, app| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { diff --git a/crates/ui-egui/src/tools/type_tool/panels_toggle_tests.rs b/crates/ui-egui/src/tools/type_tool/panels_toggle_tests.rs index 893a5a90ba1..f1d3fd34a1a 100644 --- a/crates/ui-egui/src/tools/type_tool/panels_toggle_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/panels_toggle_tests.rs @@ -47,6 +47,8 @@ fn editing(mut app: PhotocraftApp, id: LayerId) -> PhotocraftApp { /// The options bar in a row, once the app's fonts are set up (the first pass has none). fn harness(app: PhotocraftApp) -> Harness<'static, PhotocraftApp> { + // Load the fonts first: if they finish mid-test the bar swaps "Loading fonts…" for its menus and a click is lost (#13408). + let _ = photocraft_text::shared(); let mut h = Harness::builder().with_size(vec2(1400.0, 200.0)).with_max_steps(16).build_ui_state( |ui, app| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { diff --git a/crates/ui-egui/src/tools/type_tool/size_presets_tests.rs b/crates/ui-egui/src/tools/type_tool/size_presets_tests.rs index f39294be5a3..eb1e623d9e0 100644 --- a/crates/ui-egui/src/tools/type_tool/size_presets_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/size_presets_tests.rs @@ -39,6 +39,8 @@ fn app_with_layer(size: f32) -> (PhotocraftApp, LayerId) { /// `draw` in a window tall enough for the list, once the app's fonts are set up. Up to 16 passes, /// because the font list arrives in batches (see `canvas_tests::controls`). fn harness(app: PhotocraftApp, draw: fn(&mut PhotocraftApp, &mut egui::Ui)) -> Harness<'static, PhotocraftApp> { + // Load the fonts first: if they finish mid-test the bar swaps "Loading fonts…" for its menus and a click is lost (#13408). + let _ = photocraft_text::shared(); let mut h = Harness::builder().with_size(vec2(1400.0, 800.0)).with_max_steps(16).build_ui_state( move |ui, app| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { diff --git a/crates/ui-egui/src/tools/type_tool/vertical_align_buttons_tests.rs b/crates/ui-egui/src/tools/type_tool/vertical_align_buttons_tests.rs index 25b99939432..45ac0c9ae47 100644 --- a/crates/ui-egui/src/tools/type_tool/vertical_align_buttons_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/vertical_align_buttons_tests.rs @@ -31,6 +31,8 @@ fn text_layer(app: &mut PhotocraftApp, orientation: &str) -> LayerId { } pub(super) fn bar(app: PhotocraftApp) -> Harness<'static, PhotocraftApp> { + // Load the fonts first: if they finish mid-test the bar swaps "Loading fonts…" for its menus and a click is lost (#13408). + let _ = photocraft_text::shared(); let mut h = Harness::builder().with_size(egui::vec2(1200.0, 60.0)).build_ui_state( |ui, app: &mut PhotocraftApp| { ui.horizontal(|ui| super::options_bar(app, ui));