blob: ed8ca053e496f2d30049cd538d37a7b90041ce14 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24import java.awt.color.ColorSpace;
25import java.awt.image.BufferedImage;
26import java.awt.image.DataBuffer;
27
28public abstract class ColConvTest implements Runnable {
29
30 /* Parameters of the testing subimage */
31 static final int SI_X = 10;
32 static final int SI_Y = 10;
33 static final int SI_W = 100;
34 static final int SI_H = 100;
35
36 private boolean passed = false;
37
38 static String getCSName(int cs) {
39 switch(cs) {
40 case ColorSpace.CS_GRAY:
41 return "CS_GRAY";
42 case ColorSpace.CS_CIEXYZ:
43 return "CS_CIEXYZ";
44 case ColorSpace.CS_LINEAR_RGB:
45 return "CS_LINEAR_RGB";
46 case ColorSpace.CS_PYCC:
47 return "CS_PYCC";
48 case ColorSpace.CS_sRGB:
49 return "CS_sRGB";
50 }
51 return "UNKNOWN";
52 }
53
54 static String getDTName(int dType) {
55 switch(dType) {
56 case DataBuffer.TYPE_BYTE:
57 return "TYPE_BYTE";
58 case DataBuffer.TYPE_DOUBLE:
59 return "TYPE_DOUBLE";
60 case DataBuffer.TYPE_FLOAT:
61 return "TYPE_FLOAT";
62 case DataBuffer.TYPE_INT:
63 return "TYPE_INT";
64 case DataBuffer.TYPE_SHORT:
65 return "TYPE_SHORT";
66 case DataBuffer.TYPE_USHORT:
67 return "TYPE_USHORT";
68 case DataBuffer.TYPE_UNDEFINED:
69 return "TYPE_UNDEFINED";
70 }
71 return "UNKNOWN";
72 }
73
74 static String getImageTypeName(int type) {
75 switch(type) {
76 case BufferedImage.TYPE_INT_ARGB:
77 return "TYPE_INT_ARGB";
78 case BufferedImage.TYPE_INT_RGB:
79 return "TYPE_INT_RGB";
80 case BufferedImage.TYPE_INT_BGR:
81 return "TYPE_INT_BGR";
82 case BufferedImage.TYPE_INT_ARGB_PRE:
83 return "TYPE_INT_ARGB_PRE";
84 case BufferedImage.TYPE_3BYTE_BGR:
85 return "TYPE_3BYTE_BGR";
86 case BufferedImage.TYPE_4BYTE_ABGR:
87 return "TYPE_4BYTE_ABGR";
88 case BufferedImage.TYPE_4BYTE_ABGR_PRE:
89 return "TYPE_4BYTE_ABGR_PRE";
90 case BufferedImage.TYPE_BYTE_BINARY:
91 return "TYPE_BYTE_BINARY";
92 case BufferedImage.TYPE_BYTE_GRAY:
93 return "TYPE_BYTE_GRAY";
94 case BufferedImage.TYPE_BYTE_INDEXED:
95 return "TYPE_BYTE_INDEXED";
96 case BufferedImage.TYPE_USHORT_555_RGB:
97 return "TYPE_USHORT_555_RGB";
98 case BufferedImage.TYPE_USHORT_565_RGB:
99 return "TYPE_USHORT_565_RGB";
100 case BufferedImage.TYPE_USHORT_GRAY:
101 return "TYPE_USHORT_GRAY";
102 }
103 return "UNKNOWN";
104 }
105
106 /* Actual tests should override this method and put initialization logic
107 * into it
108 */
109 public abstract void init();
110
111 /* Actual tests should override this method and put test logic into it */
112 public abstract void runTest();
113
114 public final void run() {
115 try {
116 runTest();
117 passed = true;
118 } catch (Throwable ex) {
119 ex.printStackTrace();
120 passed = false;
121 throw new RuntimeException(ex);
122 }
123 }
124
125 /* returns result of the test */
126 public boolean isPassed() {
127 return passed;
128 }
129}