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 Sergey Burlak
19: * @version $Revision$
20: */package javax.swing.plaf.basic;
21:
22: import java.awt.Color;
23: import java.awt.Dimension;
24: import java.awt.Graphics2D;
25: import java.awt.image.BufferedImage;
26:
27: import javax.swing.SwingConstants;
28: import javax.swing.SwingTestCase;
29:
30: public class BasicArrowButtonTest extends SwingTestCase {
31: private BasicArrowButton button;
32:
33: @Override
34: protected void setUp() throws Exception {
35: button = new BasicArrowButton(SwingConstants.NORTH);
36: }
37:
38: @Override
39: protected void tearDown() throws Exception {
40: button = null;
41: }
42:
43: public void testGetPreferredSize() throws Exception {
44: assertEquals(new Dimension(16, 16), button.getPreferredSize());
45: assertFalse(button.getPreferredSize() == button
46: .getPreferredSize());
47: }
48:
49: public void testGetMaximumSize() throws Exception {
50: assertEquals(new Dimension(2147483647, 2147483647), button
51: .getMaximumSize());
52: }
53:
54: public void testGetMinimumSize() throws Exception {
55: assertEquals(new Dimension(5, 5), button.getMinimumSize());
56: assertFalse(button.getMinimumSize() == button.getMinimumSize());
57: }
58:
59: public void testFocusTraversable() throws Exception {
60: assertFalse(button.isFocusTraversable());
61: }
62:
63: /**
64: * Regression test for HARMONY-2707
65: * */
66: private static final int INCORRECT_DIRECTION = 10;
67:
68: public void testPaintTriangle() throws NullPointerException {
69: Graphics2D g2D = new BufferedImage(6, 6,
70: BufferedImage.TYPE_INT_RGB).createGraphics();
71: BasicArrowButton ab = new BasicArrowButton(0);
72: ab.paintTriangle(g2D, 0, 0, 0, INCORRECT_DIRECTION, true);
73: }
74:
75: /**
76: * Regression test for HARMONY-2629
77: * */
78: public void testGetBackground() {
79: final Color c = Color.red;
80: BasicArrowButton b = new BasicArrowButton(240, c, c, c, c);
81:
82: System.out.println("parameter background == " + c);
83: System.out.println("getBackground()==" + b.getBackground());
84: assertSame(c, b.getBackground());
85: }
86: }
|