01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package java.awt.image;
18:
19: import junit.framework.TestCase;
20:
21: public class ColorModelTest extends TestCase {
22:
23: /**
24: * Test method for
25: * {@link java.awt.image.ColorModel#getNormalizedComponents(int[], int, float[], int)}.
26: * Regression for HARMONY-2793
27: */
28: public void testGetNormalizedComponentsIntArrayIntFloatArrayInt() {
29: try {
30: new IndexColorModel(1, 1, new byte[] { 1, 1, 1 }, 0, false)
31: .getNormalizedComponents(new int[] { 1, -23, 5, 67,
32: 89, 0 }, 1, new float[] { 1, -23, 5, 67,
33: 89, 0 }, 200);
34: fail("ArrayIndexOutOfBoundsException should be thrown"); //$NON-NLS-1$
35: } catch (ArrayIndexOutOfBoundsException ex) {
36: // expected
37: }
38: }
39:
40: // Regression test for JIRA HARMONY-2794
41: public void testNormOffset() {
42: IndexColorModel obj = new IndexColorModel(1, 1, new byte[] { 1,
43: 1, 1 }, 0, false);
44: obj.getNormalizedComponents(new int[] { 1, -23, 5, 67, 89, 0 },
45: 1, null, 1002);
46: }
47:
48: // Regression test for JIRA HARMONY-2796
49: public void testGetNormalizedComponentsNullPixel() {
50: IndexColorModel cm = new IndexColorModel(4, 2, new byte[2],
51: new byte[2], new byte[2]);
52:
53: try {
54: cm
55: .getNormalizedComponents((Object) null,
56: new float[] {}, 5);
57: fail("NullPointerException expected");
58: } catch (NullPointerException npe) {
59: // valid
60: }
61: }
62: }
|