8255710: Opensource unit/regression tests for CMM
Reviewed-by: pbansal, prr
This commit is contained in:
parent
61c5b95b0d
commit
98ccfbf469
59
test/jdk/java/awt/color/GetInstanceNullData.java
Normal file
59
test/jdk/java/awt/color/GetInstanceNullData.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ICC_Profile;
|
||||
import java.awt.color.ICC_ProfileGray;
|
||||
import java.awt.color.ICC_ProfileRGB;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4176618 7042594
|
||||
* @summary This interactive test verifies that passing null to
|
||||
* ICC_ProfileRGB.getInstance() does not crash the VM.
|
||||
* An IllegalArgumentException: Invalid ICC Profile Data should be
|
||||
* generated.
|
||||
*/
|
||||
public final class GetInstanceNullData {
|
||||
|
||||
public static void main(String[] argv) {
|
||||
byte b[] = null;
|
||||
try {
|
||||
ICC_ProfileRGB p = (ICC_ProfileRGB) ICC_ProfileRGB.getInstance(b);
|
||||
throw new RuntimeException("IllegalArgumentException is expected");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
ICC_ProfileGray p = (ICC_ProfileGray) ICC_ProfileGray.getInstance(b);
|
||||
throw new RuntimeException("IllegalArgumentException is expected");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
ICC_Profile p = ICC_Profile.getInstance(b);
|
||||
throw new RuntimeException("IllegalArgumentException is expected");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
50
test/jdk/java/awt/color/GetNameExceptionTest.java
Normal file
50
test/jdk/java/awt/color/GetNameExceptionTest.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4752851
|
||||
* @summary spec for ColorSpace.getName() does not describe case of wrong param
|
||||
*/
|
||||
public final class GetNameExceptionTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(ColorSpace.getInstance(ColorSpace.CS_sRGB));
|
||||
test(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB));
|
||||
test(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ));
|
||||
test(ColorSpace.getInstance(ColorSpace.CS_PYCC));
|
||||
test(ColorSpace.getInstance(ColorSpace.CS_GRAY));
|
||||
}
|
||||
|
||||
private static void test(ColorSpace cs) {
|
||||
try {
|
||||
cs.getName(cs.getNumComponents());
|
||||
throw new RuntimeException("Method ColorSpace.getName(int) should" +
|
||||
" throw exception for incorrect input");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
65
test/jdk/java/awt/color/GetNameTest.java
Normal file
65
test/jdk/java/awt/color/GetNameTest.java
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4967082
|
||||
* @summary ColorSpace.getName(int) should return significant values for some CS
|
||||
*/
|
||||
public final class GetNameTest {
|
||||
|
||||
private static final Map<Integer, String[]> colorSpaces = new HashMap<>(5);
|
||||
|
||||
static {
|
||||
colorSpaces.put(ColorSpace.CS_CIEXYZ, new String[] {"X", "Y", "Z"});
|
||||
colorSpaces.put(ColorSpace.CS_sRGB,
|
||||
new String[] {"Red", "Green", "Blue"});
|
||||
colorSpaces.put(ColorSpace.CS_LINEAR_RGB,
|
||||
new String[] {"Red", "Green", "Blue"});
|
||||
colorSpaces.put(ColorSpace.CS_GRAY, new String[] {"Gray"});
|
||||
colorSpaces.put(ColorSpace.CS_PYCC,
|
||||
new String[] {"Unnamed color component(0)",
|
||||
"Unnamed color component(1)",
|
||||
"Unnamed color component(2)"});
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int csType : colorSpaces.keySet()) {
|
||||
ColorSpace cs = ColorSpace.getInstance(csType);
|
||||
String[] names = colorSpaces.get(csType);
|
||||
for (int i = 0; i < cs.getNumComponents(); i++) {
|
||||
String name = cs.getName(i);
|
||||
if (!name.equals(names[i])) {
|
||||
System.err.println("ColorSpace with type=" + cs.getType() +
|
||||
" has wrong name of " + i +
|
||||
" component");
|
||||
throw new RuntimeException("Wrong name of the component");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java
Normal file
51
test/jdk/java/awt/color/ICC_ProfileSetNullDataTest.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_Profile;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4823896 7042594
|
||||
* @summary Test checks behavior of the ICC_Profile.setData(int, byte[])
|
||||
*/
|
||||
public final class ICC_ProfileSetNullDataTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(ICC_Profile.getInstance(ColorSpace.CS_sRGB));
|
||||
test(ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB));
|
||||
test(ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ));
|
||||
test(ICC_Profile.getInstance(ColorSpace.CS_PYCC));
|
||||
test(ICC_Profile.getInstance(ColorSpace.CS_GRAY));
|
||||
}
|
||||
|
||||
private static void test(ICC_Profile profile) {
|
||||
byte[] tagData = null;
|
||||
try {
|
||||
profile.setData(ICC_Profile.icSigCmykData, tagData);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return;
|
||||
}
|
||||
throw new RuntimeException("IllegalArgumentException expected");
|
||||
}
|
||||
}
|
87
test/jdk/java/awt/color/MultiThreadCMMTest.java
Normal file
87
test/jdk/java/awt/color/MultiThreadCMMTest.java
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.image.DirectColorModel;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6245283
|
||||
* @summary Checks the behavior of the DirectColorModel.getRed(int)
|
||||
* with multiple threads.
|
||||
*/
|
||||
public final class MultiThreadCMMTest extends Thread {
|
||||
/* Number of concurent threads creating and accessing
|
||||
* DirectColorModel object
|
||||
*/
|
||||
private static final int THREAD_COUNT = 100;
|
||||
private static final int ITERATION_COUNT = 20;
|
||||
|
||||
private static volatile boolean failed = false;
|
||||
private static volatile Exception failureException = null;
|
||||
|
||||
private static synchronized void setStatusFailed(Exception e) {
|
||||
/* Store first occurred exception */
|
||||
if (!failed) {
|
||||
failureException = e;
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String [] args) throws Exception {
|
||||
|
||||
Thread [] threadArray = new Thread [THREAD_COUNT];
|
||||
for (int i = 0; i < ITERATION_COUNT; i++) {
|
||||
for (int j = 0; j < threadArray.length; j++) {
|
||||
threadArray[j] = new MultiThreadCMMTest();
|
||||
};
|
||||
|
||||
for (int j = 0; j < threadArray.length; j++) {
|
||||
threadArray[j].start();
|
||||
}
|
||||
|
||||
/* Ensure that all threads are finished */
|
||||
for (int j = 0; j < threadArray.length; j++) {
|
||||
threadArray[j].join();
|
||||
if (failed) {
|
||||
throw new RuntimeException(failureException);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
int rMask16 = 0xF800;
|
||||
int gMask16 = 0x07C0;
|
||||
int bMask16 = 0x003E;
|
||||
int r;
|
||||
try {
|
||||
for(int i=0; i < 1000; i++) {
|
||||
DirectColorModel dcm =
|
||||
new DirectColorModel(16, rMask16, gMask16, bMask16);
|
||||
r = dcm.getRed(10);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
setStatusFailed(e);
|
||||
}
|
||||
}
|
||||
}
|
55
test/jdk/java/awt/color/StandardProfileTest.java
Normal file
55
test/jdk/java/awt/color/StandardProfileTest.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_Profile;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 5042429
|
||||
* @summary This test verifies if ICC_profile instances for standard ColorSpace
|
||||
* types are created without security exceptions if access to file
|
||||
* system is prohibited.
|
||||
* @run main/othervm/policy=StandardProfileTest.policy StandardProfileTest
|
||||
*/
|
||||
public final class StandardProfileTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (System.getSecurityManager() == null) {
|
||||
throw new RuntimeException("SecurityManager is null");
|
||||
}
|
||||
|
||||
int[] types = {
|
||||
ColorSpace.CS_CIEXYZ,
|
||||
ColorSpace.CS_GRAY,
|
||||
ColorSpace.CS_LINEAR_RGB,
|
||||
ColorSpace.CS_PYCC,
|
||||
ColorSpace.CS_sRGB } ;
|
||||
|
||||
for (int t = 0; t<types.length; t++) {
|
||||
System.out.println("type " + t);
|
||||
ICC_Profile p = ICC_Profile.getInstance(types[t]);
|
||||
p.getPCSType();
|
||||
}
|
||||
}
|
||||
}
|
30
test/jdk/java/awt/color/StandardProfileTest.policy
Normal file
30
test/jdk/java/awt/color/StandardProfileTest.policy
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @bug 5042429
|
||||
* @summary This policy file prohibits access to the file system.
|
||||
*/
|
||||
|
||||
grant {
|
||||
};
|
60
test/jdk/java/awt/color/XYZTest.java
Normal file
60
test/jdk/java/awt/color/XYZTest.java
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_ColorSpace;
|
||||
import java.awt.color.ICC_Profile;
|
||||
import java.awt.color.ICC_ProfileRGB;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4267139
|
||||
* @summary This test verifies that an sRGB color can be accurately converted to
|
||||
* an CIE colorimetric XYZ value.
|
||||
*/
|
||||
public final class XYZTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
float[] rgb = new float[3];
|
||||
rgb[0] = 1.0F;
|
||||
rgb[1] = 1.0F;
|
||||
rgb[2] = 1.0F;
|
||||
ICC_ProfileRGB pf =
|
||||
(ICC_ProfileRGB) ICC_Profile.getInstance(ColorSpace.CS_sRGB);
|
||||
ICC_ColorSpace srgb = new ICC_ColorSpace(pf);
|
||||
float[] xyz = srgb.toCIEXYZ(rgb);
|
||||
float mxyz[] = new float[3];
|
||||
// adjust D50 relative values by a factor which is the ratio
|
||||
// of the device white point (in this case sRGB) divided by
|
||||
// the D50 (PCS) white point
|
||||
mxyz[0] = xyz[0] * (0.9505f / 0.9642f);
|
||||
mxyz[1] = xyz[1] * (1.0000f / 1.0000f);
|
||||
mxyz[2] = xyz[2] * (1.0891f / 0.8249f);
|
||||
if ((Math.abs(mxyz[0] - 0.9505f) > 0.01f) ||
|
||||
(Math.abs(mxyz[1] - 1.0000f) > 0.01f) ||
|
||||
(Math.abs(mxyz[2] - 1.0891f) > 0.01f)) {
|
||||
throw new Error("sRGB (1.0, 1.0, 1.0) doesn't convert " +
|
||||
"correctly to CIEXYZ");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user