From 75bc29f6c5cedd265ca996cdbe7e2bfc7ddab8c2 Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 29 Oct 2026 17:02:09 +0100 Subject: [PATCH] Tests: the Move marquee test reads the slanted ant edges main's device-pixel ants draw Main's #7530 draws marching ants as a pixel mesh plus white base segments for slanted edges, so the rotated Move-tool marquee is no longer one white closed path. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/marquee_tests.rs | 32 +++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/marquee_tests.rs b/crates/ui-egui/src/marquee_tests.rs index af590ea9f28..6cf286b52ba 100644 --- a/crates/ui-egui/src/marquee_tests.rs +++ b/crates/ui-egui/src/marquee_tests.rs @@ -455,7 +455,7 @@ fn the_live_outline_matches_the_committed_selection_in_a_rotated_view() { } /// The closed outlines the last frame drew as a solid white line under black dashes: the Type -/// tools' drag box and the Move tool's layer marquee (four corners, the first repeated). +/// tools' drag box (four corners, the first repeated). fn white_box_outlines(h: &Harness<'static, PhotocraftApp>) -> Vec> { h.output() .shapes @@ -473,6 +473,20 @@ fn white_box_outlines(h: &Harness<'static, PhotocraftApp>) -> Vec> { .collect() } +/// The slanted edges the last frame drew as marching ants (#7530): each is a white base segment +/// under black dashes (`ants::shapes`); upright edges go into a pixel mesh instead. The Move tool's +/// layer marquee in a rotated view. +fn white_ant_edges(h: &Harness<'static, PhotocraftApp>) -> Vec<[Pos2; 2]> { + h.output() + .shapes + .iter() + .filter_map(|c| match &c.shape { + egui::Shape::LineSegment { points, stroke } if stroke.color == egui::Color32::WHITE => Some(*points), + _ => None, + }) + .collect() +} + /// Every drawn corner of `outline` maps back, through the view, to the document corner of `want` /// ([x0, y0, x1, y1]) with the same index, clockwise from the top-left. fn assert_doc_box(xf: &ViewXform, outline: &[Pos2], want: [f64; 4], what: &str) { @@ -532,9 +546,19 @@ fn the_move_layer_marquee_follows_the_document_axes_in_a_rotated_view() { move_to(&mut h, 150.0, 90.0); assert!(h.state().layer_box.is_some(), "{rotation}°: the drag draws the layer marquee"); let xf = view_xform(&h); - let drawn = white_box_outlines(&h); - assert_eq!(drawn.len(), 1, "{rotation}°: one marquee is drawn: {drawn:?}"); - assert_doc_box(&xf, &drawn[0], [50.0, 50.0, 150.0, 90.0], &format!("{rotation}°: the layer marquee")); + // Four slanted ant edges, each from one corner of the document box to the next. An upright + // screen box would have none (its edges go into the ants' pixel mesh). + let edges = white_ant_edges(&h); + assert_eq!(edges.len(), 4, "{rotation}°: the marquee's four edges are drawn slanted: {edges:?}"); + let ends: Vec = edges.iter().map(|e| e[0]).collect(); + assert_doc_box(&xf, &ends, [50.0, 50.0, 150.0, 90.0], &format!("{rotation}°: the layer marquee (edge starts)")); + let ends: Vec = edges.iter().map(|e| e[1]).collect(); + assert_doc_box( + &xf, + &ends[3..].iter().chain(&ends[..3]).copied().collect::>(), + [50.0, 50.0, 150.0, 90.0], + &format!("{rotation}°: the layer marquee (edge ends)"), + ); release_at(&mut h, 150.0, 90.0, Modifiers::NONE); } }