test(engine): cover opaque Dissolve fill endpoint

Exercise the maximum hash coordinate through edit.fill at 8, 16 and 32 bits, including zero/full opacity and undo/redo.
This commit is contained in:
Mex authored and GitHub committed 2026-11-15 19:56:50 +01:00
1 parent 3109c80fc6
commit e27d4e7775
1 file changed
+19
+19
View File
@@ -84,6 +84,25 @@ fn opacity_mode_and_preserve_transparency() {
}));
}
#[test]
fn opaque_dissolve_fill_covers_the_largest_noise_sample_at_every_depth() {
// (8, 246) hashes to the largest noise sample: it must still be below full coverage.
for depth in [8, 16, 32] {
let mut s = Session::new();
s.execute("file.new", json!({"width": 9, "height": 247, "depth": depth, "background": "transparent"})).unwrap();
s.execute(CMD, json!({"contents": "white", "mode": "dissolve", "opacity": 0})).unwrap();
assert_eq!(px(&s, 8, 246)[3], 0.0, "{depth}-bit zero-opacity fill");
s.execute(CMD, json!({"contents": "white", "mode": "dissolve", "opacity": 100})).unwrap();
assert_eq!(px(&s, 8, 246), [1.0; 4], "{depth}-bit opaque fill at the largest noise sample");
assert_eq!(px(&s, 0, 0), [1.0; 4], "{depth}-bit opaque fill at an ordinary sample");
assert!(s.undo());
assert_eq!(px(&s, 8, 246)[3], 0.0, "{depth}-bit undo");
assert!(s.redo());
assert_eq!(px(&s, 8, 246), [1.0; 4], "{depth}-bit redo");
}
}
#[test]
fn preserve_transparency_blends_source_atop_on_semi_transparent_pixels() {
// White at 50%, then black at 50% keeping alpha: Photoshop gives (127,127,127,128), the