6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.prism.impl.shape;
27
28 import com.sun.javafx.geom.PathIterator;
29 import com.sun.prism.BasicStroke;
30 import org.junit.Test;
31
32 public class NativePiscesRasterizerTest {
33 static final int JOIN_BEVEL = BasicStroke.JOIN_BEVEL;
34 static final int JOIN_MITER = BasicStroke.JOIN_MITER;
35 static final int JOIN_ROUND = BasicStroke.JOIN_ROUND;
36
37 static final int CAP_SQUARE = BasicStroke.CAP_SQUARE;
38 static final int CAP_ROUND = BasicStroke.CAP_ROUND;
39 static final int CAP_BUTT = BasicStroke.CAP_BUTT;
40
41 static final byte SEG_MOVETO = PathIterator.SEG_MOVETO;
42 static final byte SEG_LINETO = PathIterator.SEG_LINETO;
43 static final byte SEG_QUADTO = PathIterator.SEG_QUADTO;
44 static final byte SEG_CUBICTO = PathIterator.SEG_CUBICTO;
45 static final byte SEG_CLOSE = PathIterator.SEG_CLOSE;
46
47 static final float coords6[] = new float[6];
48 static final float coords1[] = new float[1];
49 static final float coords3[] = new float[3];
50 static final float coords5[] = new float[5];
51 static final float coords7[] = new float[7];
52 static final byte move_arr[] = { SEG_MOVETO };
53 static final byte moveline_arr[] = { SEG_MOVETO, SEG_LINETO };
54 static final byte movequad_arr[] = { SEG_MOVETO, SEG_QUADTO };
55 static final byte movecubic_arr[] = { SEG_MOVETO, SEG_CUBICTO };
56 static final int bounds10[] = { 0, 0, 10, 10 };
57 static final byte mask1k[] = new byte[1024];
58
59 @Test(expected=java.lang.NullPointerException.class)
60 public void FillNullCoords() {
61 NativePiscesRasterizer.produceFillAlphas(null, move_arr, 1, true,
62 1, 0, 0, 0, 1, 0,
63 bounds10, mask1k);
64 }
65
66 @Test(expected=java.lang.NullPointerException.class)
67 public void FillNullCommands() {
68 NativePiscesRasterizer.produceFillAlphas(coords6, null, 1, true,
69 1, 0, 0, 0, 1, 0,
70 bounds10, mask1k);
71 }
72
73 @Test(expected=java.lang.NullPointerException.class)
74 public void FillNullBounds() {
75 NativePiscesRasterizer.produceFillAlphas(coords6, move_arr, 1, true,
76 1, 0, 0, 0, 1, 0,
77 null, mask1k);
78 }
79
80 @Test(expected=java.lang.NullPointerException.class)
81 public void FillNullMask() {
82 NativePiscesRasterizer.produceFillAlphas(coords6, move_arr, 1, true,
83 1, 0, 0, 0, 1, 0,
84 bounds10, null);
85 }
86
87 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
88 public void FillShortBounds() {
89 NativePiscesRasterizer.produceFillAlphas(coords6, move_arr, 1, true,
90 1, 0, 0, 0, 1, 0,
91 new int[3], mask1k);
92 }
93
94 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
95 public void FillShortCommands() {
96 NativePiscesRasterizer.produceFillAlphas(coords6, move_arr, 2, true,
97 1, 0, 0, 0, 1, 0,
98 bounds10, mask1k);
99 }
100
101 @Test
102 public void FillBadCommands() {
103 byte badcmd_arr[] = new byte[2];
104 badcmd_arr[0] = SEG_MOVETO;
105 for (int i = 0; i < 256; i++) {
106 switch (i) {
107 case SEG_MOVETO:
108 case SEG_LINETO:
109 case SEG_QUADTO:
110 case SEG_CUBICTO:
111 case SEG_CLOSE:
112 continue;
113 default:
114 badcmd_arr[1] = (byte) i;
115 try {
116 NativePiscesRasterizer.produceFillAlphas(coords6, badcmd_arr, 2, true,
117 1, 0, 0, 0, 1, 0,
118 bounds10, mask1k);
119 throw new RuntimeException("allowed bad command: "+i);
120 } catch (InternalError e) {
121 }
122 break;
123 }
124 }
125 }
126
127 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
128 public void FillShortMoveCoords() {
129 NativePiscesRasterizer.produceFillAlphas(coords1, move_arr, 1, true,
130 1, 0, 0, 0, 1, 0,
131 bounds10, mask1k);
132 }
133
134 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
135 public void FillShortLineCoords() {
136 NativePiscesRasterizer.produceFillAlphas(coords3, moveline_arr, 2, true,
137 1, 0, 0, 0, 1, 0,
138 bounds10, mask1k);
139 }
140
141 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
142 public void FillShortQuadCoords() {
143 NativePiscesRasterizer.produceFillAlphas(coords5, movequad_arr, 2, true,
144 1, 0, 0, 0, 1, 0,
145 bounds10, mask1k);
146 }
147
148 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
149 public void FillShortCubicCoords() {
150 NativePiscesRasterizer.produceFillAlphas(coords7, movecubic_arr, 2, true,
151 1, 0, 0, 0, 1, 0,
152 bounds10, mask1k);
153 }
154
155 @Test(expected=java.lang.NullPointerException.class)
156 public void StrokeNullCoords() {
157 NativePiscesRasterizer.produceStrokeAlphas(null, move_arr, 1,
158 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
159 1, 0, 0, 0, 1, 0,
160 bounds10, mask1k);
161 }
162
163 @Test(expected=java.lang.NullPointerException.class)
164 public void StrokeNullCommands() {
165 NativePiscesRasterizer.produceStrokeAlphas(coords6, null, 1,
166 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
167 1, 0, 0, 0, 1, 0,
168 bounds10, mask1k);
169 }
170
171 @Test(expected=java.lang.NullPointerException.class)
172 public void StrokeNullBounds() {
173 NativePiscesRasterizer.produceStrokeAlphas(coords6, move_arr, 1,
174 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
175 1, 0, 0, 0, 1, 0,
176 null, mask1k);
177 }
178
179 @Test(expected=java.lang.NullPointerException.class)
180 public void StrokeNullMask() {
181 NativePiscesRasterizer.produceStrokeAlphas(coords6, move_arr, 1,
182 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
183 1, 0, 0, 0, 1, 0,
184 bounds10, null);
185 }
186
187 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
188 public void StrokeShortBounds() {
189 NativePiscesRasterizer.produceStrokeAlphas(coords6, move_arr, 1,
190 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
191 1, 0, 0, 0, 1, 0,
192 new int[3], mask1k);
193 }
194
195 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
196 public void StrokeShortCommands() {
197 NativePiscesRasterizer.produceStrokeAlphas(coords6, move_arr, 2,
198 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
199 1, 0, 0, 0, 1, 0,
200 bounds10, mask1k);
201 }
202
203 @Test
204 public void StrokeBadCommands() {
205 byte badcmd_arr[] = new byte[2];
206 badcmd_arr[0] = SEG_MOVETO;
207 for (int i = 0; i < 256; i++) {
208 switch (i) {
209 case SEG_MOVETO:
210 case SEG_LINETO:
211 case SEG_QUADTO:
212 case SEG_CUBICTO:
213 case SEG_CLOSE:
214 continue;
215 default:
216 badcmd_arr[1] = (byte) i;
217 try {
218 NativePiscesRasterizer.produceStrokeAlphas(coords6, badcmd_arr, 2,
219 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
220 1, 0, 0, 0, 1, 0,
221 bounds10, mask1k);
222 throw new RuntimeException("allowed bad command: "+i);
223 } catch (InternalError e) {
224 }
225 break;
226 }
227 }
228 }
229
230 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
231 public void StrokeShortMoveCoords() {
232 NativePiscesRasterizer.produceStrokeAlphas(coords1, move_arr, 1,
233 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
234 1, 0, 0, 0, 1, 0,
235 bounds10, mask1k);
236 }
237
238 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
239 public void StrokeShortLineCoords() {
240 NativePiscesRasterizer.produceStrokeAlphas(coords3, moveline_arr, 2,
241 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
242 1, 0, 0, 0, 1, 0,
243 bounds10, mask1k);
244 }
245
246 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
247 public void StrokeShortQuadCoords() {
248 NativePiscesRasterizer.produceStrokeAlphas(coords5, movequad_arr, 2,
249 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
250 1, 0, 0, 0, 1, 0,
251 bounds10, mask1k);
252 }
253
254 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
255 public void StrokeShortCubicCoords() {
256 NativePiscesRasterizer.produceStrokeAlphas(coords7, movecubic_arr, 2,
257 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
258 1, 0, 0, 0, 1, 0,
259 bounds10, mask1k);
260 }
261 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.com.sun.prism.impl.shape;
27
28 import com.sun.javafx.geom.PathIterator;
29 import com.sun.prism.BasicStroke;
30 import com.sun.prism.impl.shape.NativePiscesRasterizerShim;
31 import org.junit.Test;
32
33 public class NativePiscesRasterizerTest {
34 static final int JOIN_BEVEL = BasicStroke.JOIN_BEVEL;
35 static final int JOIN_MITER = BasicStroke.JOIN_MITER;
36 static final int JOIN_ROUND = BasicStroke.JOIN_ROUND;
37
38 static final int CAP_SQUARE = BasicStroke.CAP_SQUARE;
39 static final int CAP_ROUND = BasicStroke.CAP_ROUND;
40 static final int CAP_BUTT = BasicStroke.CAP_BUTT;
41
42 static final byte SEG_MOVETO = PathIterator.SEG_MOVETO;
43 static final byte SEG_LINETO = PathIterator.SEG_LINETO;
44 static final byte SEG_QUADTO = PathIterator.SEG_QUADTO;
45 static final byte SEG_CUBICTO = PathIterator.SEG_CUBICTO;
46 static final byte SEG_CLOSE = PathIterator.SEG_CLOSE;
47
48 static final float coords6[] = new float[6];
49 static final float coords1[] = new float[1];
50 static final float coords3[] = new float[3];
51 static final float coords5[] = new float[5];
52 static final float coords7[] = new float[7];
53 static final byte move_arr[] = { SEG_MOVETO };
54 static final byte moveline_arr[] = { SEG_MOVETO, SEG_LINETO };
55 static final byte movequad_arr[] = { SEG_MOVETO, SEG_QUADTO };
56 static final byte movecubic_arr[] = { SEG_MOVETO, SEG_CUBICTO };
57 static final int bounds10[] = { 0, 0, 10, 10 };
58 static final byte mask1k[] = new byte[1024];
59
60 @Test(expected=java.lang.NullPointerException.class)
61 public void FillNullCoords() {
62 NativePiscesRasterizerShim.produceFillAlphas(null, move_arr, 1, true,
63 1, 0, 0, 0, 1, 0,
64 bounds10, mask1k);
65 }
66
67 @Test(expected=java.lang.NullPointerException.class)
68 public void FillNullCommands() {
69 NativePiscesRasterizerShim.produceFillAlphas(coords6, null, 1, true,
70 1, 0, 0, 0, 1, 0,
71 bounds10, mask1k);
72 }
73
74 @Test(expected=java.lang.NullPointerException.class)
75 public void FillNullBounds() {
76 NativePiscesRasterizerShim.produceFillAlphas(coords6, move_arr, 1, true,
77 1, 0, 0, 0, 1, 0,
78 null, mask1k);
79 }
80
81 @Test(expected=java.lang.NullPointerException.class)
82 public void FillNullMask() {
83 NativePiscesRasterizerShim.produceFillAlphas(coords6, move_arr, 1, true,
84 1, 0, 0, 0, 1, 0,
85 bounds10, null);
86 }
87
88 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
89 public void FillShortBounds() {
90 NativePiscesRasterizerShim.produceFillAlphas(coords6, move_arr, 1, true,
91 1, 0, 0, 0, 1, 0,
92 new int[3], mask1k);
93 }
94
95 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
96 public void FillShortCommands() {
97 NativePiscesRasterizerShim.produceFillAlphas(coords6, move_arr, 2, true,
98 1, 0, 0, 0, 1, 0,
99 bounds10, mask1k);
100 }
101
102 @Test
103 public void FillBadCommands() {
104 byte badcmd_arr[] = new byte[2];
105 badcmd_arr[0] = SEG_MOVETO;
106 for (int i = 0; i < 256; i++) {
107 switch (i) {
108 case SEG_MOVETO:
109 case SEG_LINETO:
110 case SEG_QUADTO:
111 case SEG_CUBICTO:
112 case SEG_CLOSE:
113 continue;
114 default:
115 badcmd_arr[1] = (byte) i;
116 try {
117 NativePiscesRasterizerShim.produceFillAlphas(coords6, badcmd_arr, 2, true,
118 1, 0, 0, 0, 1, 0,
119 bounds10, mask1k);
120 throw new RuntimeException("allowed bad command: "+i);
121 } catch (InternalError e) {
122 }
123 break;
124 }
125 }
126 }
127
128 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
129 public void FillShortMoveCoords() {
130 NativePiscesRasterizerShim.produceFillAlphas(coords1, move_arr, 1, true,
131 1, 0, 0, 0, 1, 0,
132 bounds10, mask1k);
133 }
134
135 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
136 public void FillShortLineCoords() {
137 NativePiscesRasterizerShim.produceFillAlphas(coords3, moveline_arr, 2, true,
138 1, 0, 0, 0, 1, 0,
139 bounds10, mask1k);
140 }
141
142 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
143 public void FillShortQuadCoords() {
144 NativePiscesRasterizerShim.produceFillAlphas(coords5, movequad_arr, 2, true,
145 1, 0, 0, 0, 1, 0,
146 bounds10, mask1k);
147 }
148
149 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
150 public void FillShortCubicCoords() {
151 NativePiscesRasterizerShim.produceFillAlphas(coords7, movecubic_arr, 2, true,
152 1, 0, 0, 0, 1, 0,
153 bounds10, mask1k);
154 }
155
156 @Test(expected=java.lang.NullPointerException.class)
157 public void StrokeNullCoords() {
158 NativePiscesRasterizerShim.produceStrokeAlphas(null, move_arr, 1,
159 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
160 1, 0, 0, 0, 1, 0,
161 bounds10, mask1k);
162 }
163
164 @Test(expected=java.lang.NullPointerException.class)
165 public void StrokeNullCommands() {
166 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, null, 1,
167 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
168 1, 0, 0, 0, 1, 0,
169 bounds10, mask1k);
170 }
171
172 @Test(expected=java.lang.NullPointerException.class)
173 public void StrokeNullBounds() {
174 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, move_arr, 1,
175 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
176 1, 0, 0, 0, 1, 0,
177 null, mask1k);
178 }
179
180 @Test(expected=java.lang.NullPointerException.class)
181 public void StrokeNullMask() {
182 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, move_arr, 1,
183 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
184 1, 0, 0, 0, 1, 0,
185 bounds10, null);
186 }
187
188 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
189 public void StrokeShortBounds() {
190 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, move_arr, 1,
191 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
192 1, 0, 0, 0, 1, 0,
193 new int[3], mask1k);
194 }
195
196 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
197 public void StrokeShortCommands() {
198 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, move_arr, 2,
199 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
200 1, 0, 0, 0, 1, 0,
201 bounds10, mask1k);
202 }
203
204 @Test
205 public void StrokeBadCommands() {
206 byte badcmd_arr[] = new byte[2];
207 badcmd_arr[0] = SEG_MOVETO;
208 for (int i = 0; i < 256; i++) {
209 switch (i) {
210 case SEG_MOVETO:
211 case SEG_LINETO:
212 case SEG_QUADTO:
213 case SEG_CUBICTO:
214 case SEG_CLOSE:
215 continue;
216 default:
217 badcmd_arr[1] = (byte) i;
218 try {
219 NativePiscesRasterizerShim.produceStrokeAlphas(coords6, badcmd_arr, 2,
220 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
221 1, 0, 0, 0, 1, 0,
222 bounds10, mask1k);
223 throw new RuntimeException("allowed bad command: "+i);
224 } catch (InternalError e) {
225 }
226 break;
227 }
228 }
229 }
230
231 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
232 public void StrokeShortMoveCoords() {
233 NativePiscesRasterizerShim.produceStrokeAlphas(coords1, move_arr, 1,
234 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
235 1, 0, 0, 0, 1, 0,
236 bounds10, mask1k);
237 }
238
239 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
240 public void StrokeShortLineCoords() {
241 NativePiscesRasterizerShim.produceStrokeAlphas(coords3, moveline_arr, 2,
242 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
243 1, 0, 0, 0, 1, 0,
244 bounds10, mask1k);
245 }
246
247 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
248 public void StrokeShortQuadCoords() {
249 NativePiscesRasterizerShim.produceStrokeAlphas(coords5, movequad_arr, 2,
250 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
251 1, 0, 0, 0, 1, 0,
252 bounds10, mask1k);
253 }
254
255 @Test(expected=java.lang.ArrayIndexOutOfBoundsException.class)
256 public void StrokeShortCubicCoords() {
257 NativePiscesRasterizerShim.produceStrokeAlphas(coords7, movecubic_arr, 2,
258 10, CAP_ROUND, JOIN_ROUND, 10, null, 0,
259 1, 0, 0, 0, 1, 0,
260 bounds10, mask1k);
261 }
262 }
|