Image Size test: expect the selection dropped, check Crop's resample keeps it

image_size_keeps_canvas_edges_opaque asserted the old behaviour (a scaled
full selection after Image Size). Image Size now drops it (#13856); the
corner check moves to resample_doc, which the Crop tool's W x H x
Resolution mode still uses.
This commit is contained in:
qvest-ssels committed 2026-11-13 18:26:00 +01:00
1 parent d6475da125
commit 70a1f99b31
1 file changed
+12 -5
+12 -5
View File
@@ -205,8 +205,20 @@ fn image_size_keeps_canvas_edges_opaque() {
let mut s = Session::new();
s.execute("file.new", json!({"width": 30, "height": 20, "depth": depth, "background": "#336699"})).unwrap();
s.execute("select.all", json!({})).unwrap();
// The Crop tool's W x H x Resolution mode still resamples the selection with the
// pixels: a full selection keeps reaching the canvas edges.
let mut cropped = (*doc(&s)).clone();
let ch = (20 * w + 15) / 30;
resample_doc(&mut cropped, "test", w, ch, Resample::Bicubic).unwrap();
let sel = cropped.selection.as_ref().unwrap();
let (x1, y1) = (cropped.size.width as i32 - 1, cropped.size.height as i32 - 1);
for (x, y) in [(0, 0), (x1, 0), (0, y1), (x1, y1)] {
assert!(sel.pixel(x, y)[0] > 0.99, "{depth} {resample}: selection at ({x},{y})");
}
s.execute("image.imageSize", json!({"width": w, "resample": resample})).unwrap();
let d = doc(&s);
// Image Size drops the selection when it resamples (#13856).
assert!(d.selection.is_none(), "{depth} {resample}: Image Size dropped the selection");
let flat = photocraft_compose::flatten(d);
let (w, h) = (flat.rect.width() as usize, flat.rect.height() as usize);
let mid = flat.px[(h / 2) * w + w / 2];
@@ -215,11 +227,6 @@ fn image_size_keeps_canvas_edges_opaque() {
let off = p.iter().zip(mid).map(|(a, b)| (a - b).abs()).fold(0.0f32, f32::max);
assert!(off < 0.01, "{depth} {resample} {w}: {p:?} vs {mid:?}");
}
let sel = d.selection.as_ref().unwrap();
let (x1, y1) = (d.size.width as i32 - 1, d.size.height as i32 - 1);
for (x, y) in [(0, 0), (x1, 0), (0, y1), (x1, y1)] {
assert!(sel.pixel(x, y)[0] > 0.99, "{depth} {resample}: selection at ({x},{y})");
}
}
}
}