Batch fix-up: Fill tests after #18135, #18035 and #18039 meet

#18135 gives Quick Mask its own swatch pair, so the Quick Mask grey tests
of #17487 (main) and #18070 now pick their colour after entering Quick
Mask instead of before. #18039 refuses every blend mode but Threshold and
Dissolve and the Content-Aware fill in Indexed Color, so #18035's "other
contents and blend modes stay inside the table" test checks that those
fills are refused and leave the pixels unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-12-01 00:31:14 +01:00
1 parent a9e76540b6
commit f6d6f7309f
3 files changed
+11 -5

No files matched your search

@@ -146,6 +146,8 @@ fn dissolve_paints_a_share_of_pixels_in_the_full_table_colour() {
#[test]
fn other_contents_and_blend_modes_stay_inside_the_table() {
// The blend modes and contents that would mix towards colours outside the table are refused in Indexed Color
// (#17476), so they leave the pixels as they were.
for params in [
// Red screened over blue is magenta, which the table lacks.
json!({"contents": "foreground", "mode": "screen"}),
@@ -155,9 +157,11 @@ fn other_contents_and_blend_modes_stay_inside_the_table() {
] {
let mut s = indexed();
let palette = table(&s);
s.execute(CMD, params.clone()).unwrap_or_else(|e| panic!("{params}: {e}"));
let off: Vec<[u8; 3]> = pixels(&s).into_iter().map(|(_, c)| c).filter(|c| !palette.contains(c)).collect();
assert!(off.is_empty(), "{params}: {} pixels outside the table, e.g. {:?}", off.len(), off.first());
let before = pixels(&s);
assert!(s.execute(CMD, params.clone()).is_err(), "{params}: refused in Indexed Color");
let after = pixels(&s);
assert!(after.iter().all(|(_, c)| palette.contains(c)), "{params}: every pixel stays in the table");
assert_eq!(after, before, "{params}: nothing changed");
}
}
@@ -46,8 +46,9 @@ fn quick_mask_16_bit_ties_round_up() {
#[test]
fn quick_mask_foreground_fill_takes_the_same_grey() {
let mut s = session(8);
s.tools.foreground = [1.0, 0.0, 0.0, 1.0];
// Quick Mask keeps its own swatch pair (#17490): the colour is picked in it.
s.execute("select.editInQuickMaskMode", json!({"on": true})).unwrap();
s.tools.foreground = [1.0, 0.0, 0.0, 1.0];
s.execute("edit.fill", json!({"contents": "foreground"})).unwrap();
let got = quick_mask_level(&s, 10, 10).round();
assert_eq!(got, 77.0, "foreground red into the Quick Mask");
@@ -12,9 +12,10 @@ const RED: [f32; 4] = [200.0 / 255.0, 30.0 / 255.0, 30.0 / 255.0, 1.0];
fn session(mode: &str, depth: u32) -> Session {
let mut s = crate::session();
s.execute("file.new", json!({"width": 40, "height": 20, "mode": mode, "depth": depth, "background": "white"})).unwrap();
// Quick Mask keeps its own swatch pair (#17490): the colours are picked once in it.
s.execute("select.editInQuickMaskMode", json!({"on": true})).unwrap();
s.tools.foreground = RED;
s.tools.background = RED;
s.execute("select.editInQuickMaskMode", json!({"on": true})).unwrap();
s
}