Revert "Update test to pass on JDK 19."

This reverts commit 081f2efea22d2f73fa991e198803b07279f29df6.
This commit is contained in:
Harald Kuhr 2022-10-15 11:55:34 +02:00
parent 1919d77a45
commit b5856fd110

View File

@ -32,40 +32,46 @@ package com.twelvemonkeys.imageio.color;
import org.junit.Test; import org.junit.Test;
import java.awt.color.*; import java.awt.color.ColorSpace;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.mockito.Mockito.*;
public class KCMSSanitizerStrategyTest { public class KCMSSanitizerStrategyTest {
private static final byte[] XYZ = new byte[] {'X', 'Y', 'Z', ' '}; private static final byte[] XYZ = new byte[] {'X', 'Y', 'Z', ' '};
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testFixProfileNullProfile() { public void testFixProfileNullProfile() throws Exception {
new KCMSSanitizerStrategy().fixProfile(null); new KCMSSanitizerStrategy().fixProfile(null);
} }
@Test @Test
public void testFixProfile() { public void testFixProfile() throws Exception {
new KCMSSanitizerStrategy().fixProfile(((ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB)).getProfile()); new KCMSSanitizerStrategy().fixProfile(((ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB)).getProfile());
} }
@Test @Test
public void testFixProfileUpdateHeader() throws IOException { public void testFixProfileUpdateHeader() throws Exception {
ICC_Profile profile = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/adobe_rgb_1998.icc")); byte[] header = new byte[128];
header[ICC_Profile.icHdrRenderingIntent + 3] = 1;
// Mangle the profile slightly... ICC_Profile profile = mock(ICC_Profile.class);
byte[] header = profile.getData(ICC_Profile.icSigHead); when(profile.getData(ICC_Profile.icSigHead)).thenReturn(header);
header[ICC_Profile.icHdrRenderingIntent + 3] = 42;
// Can't test that the values are actually changed, as the LCMS-backed implementation
// of ICC_Profile does not change based on this invocation.
new KCMSSanitizerStrategy().fixProfile(profile); new KCMSSanitizerStrategy().fixProfile(profile);
assertArrayEquals(new byte[] {0, 0, 0, ICC_Profile.icPerceptual}, Arrays.copyOfRange(profile.getData(ICC_Profile.icSigHead), ICC_Profile.icHdrRenderingIntent, ICC_Profile.icHdrRenderingIntent + 4)); // Verify that the method was invoked
verify(profile).setData(eq(ICC_Profile.icSigHead), any(byte[].class));
} }
@Test @Test
public void testFixProfileCorbisRGB() throws IOException { public void testFixProfileCorbisRGB() throws IOException {
// TODO: Consider re-writing this using mocks, to avoid dependencies on the CMS implementation
ICC_Profile corbisRGB = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/Corbis RGB.icc")); ICC_Profile corbisRGB = ICC_Profile.getInstance(getClass().getResourceAsStream("/profiles/Corbis RGB.icc"));
new KCMSSanitizerStrategy().fixProfile(corbisRGB); new KCMSSanitizerStrategy().fixProfile(corbisRGB);