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: /**
18: * @author Oleg V. Khaschansky
19: * @version $Revision$
20: */package org.apache.harmony.awt.gl.linux;
21:
22: import junit.framework.TestCase;
23:
24: import java.awt.*;
25: import java.awt.geom.AffineTransform;
26: import java.awt.image.VolatileImage;
27:
28: public class XGraphics2DRTest extends TestCase {
29: public void testNullClip() {
30: try {
31: GraphicsConfiguration gconf = GraphicsEnvironment
32: .getLocalGraphicsEnvironment()
33: .getDefaultScreenDevice().getDefaultConfiguration();
34: VolatileImage vim = gconf.createCompatibleVolatileImage(10,
35: 10);
36: Graphics2D g2 = (Graphics2D) vim.getGraphics();
37: g2.setClip(null);
38: } catch (Exception e) {
39: e.printStackTrace();
40: fail("Cannot set null clip");
41: }
42: }
43:
44: public void testCopyArea() {
45: GraphicsConfiguration gconf = GraphicsEnvironment
46: .getLocalGraphicsEnvironment().getDefaultScreenDevice()
47: .getDefaultConfiguration();
48: VolatileImage vim = gconf.createCompatibleVolatileImage(20, 20);
49: Graphics2D g2 = (Graphics2D) vim.getGraphics();
50: g2.setColor(Color.WHITE);
51: g2.fillRect(0, 0, 20, 20);
52: g2.setColor(Color.RED);
53: g2.fillRect(2, 2, 1, 1);
54: g2.copyArea(2, 2, 1, 1, 2, 4);
55: int pix[] = vim.getSnapshot().getRaster().getPixel(4, 6,
56: (int[]) null);
57: assertEquals("copyArea failed for untranslated graphics",
58: pix[0], 255);
59: assertEquals("copyArea failed for untranslated graphics",
60: pix[1], 0);
61: assertEquals("copyArea failed for untranslated graphics",
62: pix[2], 0);
63: g2.setTransform(AffineTransform.getTranslateInstance(2, 2));
64: g2.copyArea(0, 0, 1, 1, 4, 8);
65: pix = vim.getSnapshot().getRaster().getPixel(6, 10,
66: (int[]) null);
67: assertEquals("copyArea failed for translated graphics", pix[0],
68: 255);
69: assertEquals("copyArea failed for translated graphics", pix[1],
70: 0);
71: assertEquals("copyArea failed for translated graphics", pix[2],
72: 0);
73: }
74:
75: public static void main(String[] args) {
76: junit.textui.TestRunner.run(XGraphics2DRTest.class);
77: }
78: }
|