mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
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 <[email protected]>
This commit is contained in:
1 parent
57bcbfaba9
commit
75bc29f6c5
1 file changed
+28
-4
@@ -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<Vec<Pos2>> {
|
||||
h.output()
|
||||
.shapes
|
||||
@@ -473,6 +473,20 @@ fn white_box_outlines(h: &Harness<'static, PhotocraftApp>) -> Vec<Vec<Pos2>> {
|
||||
.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<Pos2> = 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<Pos2> = edges.iter().map(|e| e[1]).collect();
|
||||
assert_doc_box(
|
||||
&xf,
|
||||
&ends[3..].iter().chain(&ends[..3]).copied().collect::<Vec<_>>(),
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user