Cover Move selection and transform clicks before the UI split (#15970)

* Use the document mutator in the damage-history fixture

* Compile the archive driver without framework-only lint dependencies

* Cover dormant Move selection and transform cases

* Check resized pixels when transform click commits

---------

Co-authored-by: FredApps <[email protected]>
This commit is contained in:
FredAppsandFredApps authored and GitHub committed 2026-11-21 00:40:37 +07:00
1 parent c0771fe72b
commit ec247bdcab
2 files changed
+52 -1

No files matched your search

@@ -105,6 +105,46 @@ fn point_clicks_toggle_members_but_keep_the_singleton_and_plain_multi_selection(
assert_eq!(f.bounds(), before, "selection-only gestures move no pixels");
}
#[test]
fn group_auto_select_picks_and_moves_the_enclosing_group() {
let mut f = Fixture::new();
let [a, b, _] = f.layers;
f.select(&[a]);
let group = LayerId(f.app.run("layer.new.groupFromLayers", json!({"name": "G"})).unwrap()["layer"].as_u64().unwrap());
f.select(&[b]);
f.app.ui.tool_options.move_target = "group".into();
let before = f.bounds();
f.gesture([14.0, 14.0], [20.0, 16.0], Modifiers::NONE);
f.assert_selected(&[group]);
assert_eq!(f.bounds()[1], before[1].translate(6, 2), "the group moves its child");
assert_eq!(f.bounds()[2], before[2], "the other layer stays put");
}
#[test]
fn dragging_a_selected_layer_moves_the_whole_selection() {
let mut f = Fixture::new();
let [a, b, _] = f.layers;
f.select(&[a, b]);
let before = f.bounds();
f.gesture([14.0, 14.0], [20.0, 16.0], Modifiers::NONE);
f.assert_selected(&[a, b]);
assert_eq!(f.bounds()[1], before[1].translate(6, 2));
assert_eq!(f.bounds()[2], before[2].translate(6, 2));
}
#[test]
fn shift_click_adds_shape_layers_one_after_another() {
let mut f = Fixture::new();
let ids = [10, 34, 58].map(|x| {
let layer = f.app.run("shape.create", json!({"kind": "rect", "rect": [x, 35, 10, 10], "fill": "#ff0000"})).unwrap();
LayerId(layer["layer"].as_u64().unwrap())
});
f.gesture([15.0, 40.0], [15.0, 40.0], Modifiers::NONE);
f.gesture([39.0, 40.0], [39.0, 40.0], Modifiers::SHIFT);
f.gesture([63.0, 40.0], [63.0, 40.0], Modifiers::SHIFT);
f.assert_selected(&ids);
}
/// Shift-press changes the selected set immediately, and only that set moves on drag (#11102).
#[test]
fn shift_drag_moves_the_layers_selected_after_the_press() {
@@ -89,8 +89,12 @@ fn a_click_on_another_layers_pixels_commits_and_keeps_the_selection() {
app.ui.extras.rulers = false;
app.ui.extras.snap = false;
// "Other" has a blue block at x 120..160, y 120..160; "Paint" a red one at x 20..60, y 20..60.
let mut other = None;
for (name, at, color) in [("Other", 120, "#0000ff"), ("Paint", 20, "#ff0000")] {
let id = app.run("layer.new.layer", json!({"name": name})).unwrap()["layer"].as_u64().unwrap();
if name == "Other" {
other = Some(LayerId(id));
}
app.run("layer.select", json!({"layer": id})).unwrap();
app.run("select.rect", json!({"x": at, "y": at, "width": 40, "height": 40})).unwrap();
app.run("edit.fill", json!({"contents": "color", "color": color})).unwrap();
@@ -99,13 +103,20 @@ fn a_click_on_another_layers_pixels_commits_and_keeps_the_selection() {
let paint = app.session.active().unwrap().active_layer.unwrap();
let app_ctx = app.ctx().clone();
crate::menus::invoke(&mut app, &app_ctx, "edit.freeTransform", json!({})).unwrap();
shift_right(&mut app);
app.ui.transform.as_mut().unwrap().edit_box(|b| *b = b.scaled_about_pivot(2.0, 2.0));
let before = steps(&app);
click(&mut app, [140.0, 140.0]);
assert!(app.ui.transform.is_none(), "committed");
assert_eq!(steps(&app), before + 1);
let bounds = app.session.active().unwrap().doc.layer(paint).unwrap().surface().unwrap().content_bounds();
assert_eq!(bounds, photocraft_geom::Rect::new(0, 0, 80, 80), "the resized pixels are committed");
assert_eq!(app.session.active().unwrap().history.entries().last().map(ToString::to_string).as_deref(), Some("Free Transform"));
assert_eq!(app.session.active().unwrap().selected_layers(), vec![paint], "the selection doesn't change");
app.ui.tool = crate::state::Tool::Move;
app.ui.tool_options.move_auto_select = true;
app.ui.tool_options.move_target = "layer".into();
click(&mut app, [140.0, 140.0]);
assert_eq!(app.session.active().unwrap().selected_layers(), vec![other.unwrap()], "the second click picks the other layer");
}
/// A layer linked to the transformed one after the box opened moves with the commit