diff --git a/crates/engine-paint/src/cmd/fill_cmds/indexed_palette_tests.rs b/crates/engine-paint/src/cmd/fill_cmds/indexed_palette_tests.rs index 9c6e90ecbb..a9667aef56 100644 --- a/crates/engine-paint/src/cmd/fill_cmds/indexed_palette_tests.rs +++ b/crates/engine-paint/src/cmd/fill_cmds/indexed_palette_tests.rs @@ -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"); } } diff --git a/crates/engine-paint/src/fill_quick_mask_gray_weights_tests.rs b/crates/engine-paint/src/fill_quick_mask_gray_weights_tests.rs index 89581efa1b..efcf7896fa 100644 --- a/crates/engine-paint/src/fill_quick_mask_gray_weights_tests.rs +++ b/crates/engine-paint/src/fill_quick_mask_gray_weights_tests.rs @@ -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"); diff --git a/crates/engine-paint/src/fill_quick_mask_mode_gray_tests.rs b/crates/engine-paint/src/fill_quick_mask_mode_gray_tests.rs index c7c301dd9d..037ce208b0 100644 --- a/crates/engine-paint/src/fill_quick_mask_mode_gray_tests.rs +++ b/crates/engine-paint/src/fill_quick_mask_mode_gray_tests.rs @@ -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 }