diff --git a/tests/files/issue-159.png b/tests/files/issue-159.png deleted file mode 100644 index cd5585ab..00000000 Binary files a/tests/files/issue-159.png and /dev/null differ diff --git a/tests/files/palette_should_be_reduced_with_bkgd.png b/tests/files/palette_should_be_reduced_with_bkgd.png new file mode 100644 index 00000000..773b4d1e Binary files /dev/null and b/tests/files/palette_should_be_reduced_with_bkgd.png differ diff --git a/tests/reduction.rs b/tests/reduction.rs index 752de3a2..88f7fc0a 100644 --- a/tests/reduction.rs +++ b/tests/reduction.rs @@ -1048,6 +1048,45 @@ fn palette_should_be_reduced_with_unused() { remove_file(output).ok(); } +#[test] +fn palette_should_be_reduced_with_bkgd() { + let input = PathBuf::from("tests/files/palette_should_be_reduced_with_bkgd.png"); + let (output, opts) = get_opts(&input); + + let png = PngData::new(&input, &opts).unwrap(); + + assert_eq!(png.raw.ihdr.color_type.png_header_code(), INDEXED); + assert_eq!(png.raw.ihdr.bit_depth, BitDepth::One); + assert_eq!(&png.aux_chunks[0].name, b"bKGD"); + if let ColorType::Indexed { palette } = &png.raw.ihdr.color_type { + assert_eq!(palette.len(), 3); + } + + match oxipng::optimize(&InFile::Path(input), &output, &opts) { + Ok(_) => (), + Err(x) => panic!("{}", x), + }; + let output = output.path().unwrap(); + assert!(output.exists()); + + let png = match PngData::new(output, &opts) { + Ok(x) => x, + Err(x) => { + remove_file(output).ok(); + panic!("{}", x) + } + }; + + assert_eq!(png.raw.ihdr.color_type.png_header_code(), INDEXED); + assert_eq!(png.raw.ihdr.bit_depth, BitDepth::One); + assert_ne!(&png.aux_chunks[0].name, b"bKGD"); + if let ColorType::Indexed { palette } = &png.raw.ihdr.color_type { + assert_eq!(palette.len(), 2); + } + + remove_file(output).ok(); +} + #[test] fn palette_should_be_reduced_with_both() { let input = PathBuf::from("tests/files/palette_should_be_reduced_with_both.png"); diff --git a/tests/regression.rs b/tests/regression.rs index 586663fa..765a04f5 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -161,18 +161,6 @@ fn issue_140() { ); } -#[test] -fn issue_159() { - test_it_converts( - "tests/files/issue-159.png", - None, - INDEXED, - BitDepth::One, - INDEXED, - BitDepth::One, - ); -} - #[test] fn issue_171() { test_it_converts(