From c207d6eb0f91e1436d29b18fd6ca8e701c970af5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 06:20:34 -0700 Subject: [PATCH] Tests: the Notes-button test clicks where the button is laid out, so it passes without Inter status::tests::a_long_language_name_leaves_the_notes_button_clickable clicked x 150 for the gap before the status bar's controls and x 200 for the Notes button. Those positions hold for Inter. With a craft-fonts checkout that has no fonts/latin-manifest.txt, the interface text is set in BIZ UDPGothic. Labels set in BIZ UDPGothic are wider than in Inter, so the Notes button starts at x 149. The first click then toggled the notes pane and the second toggled it back. The status bar's Notes and Comments buttons now report widget info with their names. The test reads the Notes button's rect, clicks midway between x 132 and its left edge, and then clicks its center. --- crates/ui-egui/src/status.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/status.rs b/crates/ui-egui/src/status.rs index 2fc91aab..f3ec9592 100644 --- a/crates/ui-egui/src/status.rs +++ b/crates/ui-egui/src/status.rs @@ -113,6 +113,7 @@ fn labeled(ui: &mut Ui, icon: Icon, label: &str, on: bool) -> egui::Response { let t = Tokens::get(ui.ctx()); let w = 22.0 + ui.fonts_mut(|f| f.layout_no_wrap(label.into(), theme::font(12.0), t.text).size().x) + 8.0; let (r, resp) = ui.allocate_exact_size(vec2(w, 20.0), Sense::click()); + resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, on, label)); if on || resp.hovered() { ui.painter().rect_filled(r, CornerRadius::same(4), if on { t.selected } else { t.hover }); } @@ -267,6 +268,7 @@ mod tests { use deckcraft_engine::Session; use egui::{Event, Modifiers, PointerButton}; use egui_kittest::Harness; + use egui_kittest::kittest::Queryable; use serde_json::json; use crate::{Services, SlideApp}; @@ -289,12 +291,13 @@ mod tests { ); h.run_steps(3); assert!(!h.state().ui.notes); - // The controls on the right start 560 points from the bar's right edge (x 132); the Notes - // button is the leftmost of them (x 167..231 at this width). The bar ends 8 points above - // the bottom edge and is 28 points high. - let y = size.y - 8.0 - 14.0; - let click = |h: &mut Harness<'_, SlideApp>, x: f32| { - let at = egui::pos2(x, y); + // The controls on the right start 560 points from the bar's right edge, which is 8 points + // inside the window (x 132); the Notes button is the leftmost of them. Its position depends + // on the interface font's widths, so the clicks use the position it was laid out at. + let right_x = size.x - 8.0 - 560.0; + let notes = h.get_by_label("Notes").rect(); + assert!(notes.left() > right_x + 2.0, "the Notes button ({notes:?}) starts after x {right_x}"); + let click = |h: &mut Harness<'_, SlideApp>, at: egui::Pos2| { h.hover_at(at); h.run_steps(1); for pressed in [true, false] { @@ -303,9 +306,10 @@ mod tests { h.run_steps(3); }; // The gap before the controls is outside the language name's clickable area. - click(&mut h, 150.0); + click(&mut h, egui::pos2((right_x + notes.left()) / 2.0, notes.center().y)); assert!(h.state().dialog.is_none(), "the Language dialog stayed closed"); - click(&mut h, 200.0); + assert!(!h.state().ui.notes, "the click in the gap did not reach the Notes button"); + click(&mut h, notes.center()); assert!(h.state().ui.notes, "the click reached the Notes button"); assert!(h.state().dialog.is_none(), "the Language dialog stayed closed"); }