From 973d64f33e7583f00fdc7e770d7f9e91de9ca1f3 Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 26 Nov 2026 19:14:40 +0100 Subject: [PATCH] Test: each flyout row's painted mark column, not only its accessible state A row that painted a check while reporting itself unchecked passed: the test read the accessible state and looked only for empty rings. It now reads what each row paints before its tool icon: one check (a stroked path) for the shown tool, nothing for the others (CodeRabbit). Co-Authored-By: Claude Opus 5.5 --- .../src/panels/toolbar_flyout_mark_tests.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/ui-egui/src/panels/toolbar_flyout_mark_tests.rs b/crates/ui-egui/src/panels/toolbar_flyout_mark_tests.rs index 9bf85868821..cdf7a83a8c0 100644 --- a/crates/ui-egui/src/panels/toolbar_flyout_mark_tests.rs +++ b/crates/ui-egui/src/panels/toolbar_flyout_mark_tests.rs @@ -46,6 +46,23 @@ fn the_shape_flyout_checks_the_shown_tool_and_marks_no_other() { let checked: Vec<&str> = rows.iter().filter(|(_, on, _)| *on == Some(Toggled::True)).map(|(name, _, _)| name.as_str()).collect(); assert_eq!(checked, ["Rectangle Tool"], "only the shown tool is checked: {rows:?}"); assert!(rows.iter().any(|(name, _, _)| name == "Ellipse Tool"), "the flyout lists the other shape tools: {rows:?}"); + // What each row paints in its mark column, the room before its tool icon (the row's image): the shown tool's + // check (a stroked path), nothing at all for the others. The accessible state alone would not catch a row that + // paints a mark it does not report. + let shapes = &h.output().shapes; + for (name, _, row) in &rows { + let inside: Vec<&egui::Shape> = + shapes.iter().map(|clipped| &clipped.shape).filter(|shape| row.contains(shape.visual_bounding_rect().center())).collect(); + let icon = inside.iter().find(|shape| matches!(shape, egui::Shape::Mesh(_))).map(|shape| shape.visual_bounding_rect()); + let icon = icon.unwrap_or_else(|| panic!("the {name} row paints its tool icon")); + let marks: Vec<&&egui::Shape> = + inside.iter().filter(|shape| !matches!(shape, egui::Shape::Text(_)) && shape.visual_bounding_rect().max.x <= icon.min.x).collect(); + if name == "Rectangle Tool" { + assert!(matches!(marks[..], [egui::Shape::Path(_)]), "the shown tool's row paints one check before its icon: {marks:?}"); + } else { + assert!(marks.is_empty(), "the {name} row paints nothing before its icon: {marks:?}"); + } + } // No empty ring (a stroked circle without fill) inside the flyout's rows. let flyout = rows.iter().fold(Rect::NOTHING, |all, (_, _, rect)| all.union(*rect)); let rings = h