001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexander T. Simbirtsev
019: * @version $Revision$
020: * Created on 08.09.2004
021:
022: */package javax.swing.plaf;
023:
024: import javax.accessibility.Accessible;
025: import javax.swing.JComponent;
026: import javax.swing.JPanel;
027: import javax.swing.SwingTestCase;
028:
029: public class ComponentUITest extends SwingTestCase {
030: protected ComponentUI componentUI = null;
031:
032: public static void main(final String[] args) {
033: junit.textui.TestRunner.run(ComponentUITest.class);
034: }
035:
036: /*
037: * @see TestCase#setUp()
038: */
039: @Override
040: protected void setUp() throws Exception {
041: super .setUp();
042: componentUI = new ComponentUI() {
043: };
044: }
045:
046: /*
047: * @see TestCase#tearDown()
048: */
049: @Override
050: protected void tearDown() throws Exception {
051: super .tearDown();
052: }
053:
054: /**
055: * Constructor for ComponentUITest.
056: * @param name
057: */
058: public ComponentUITest(final String name) {
059: super (name);
060: }
061:
062: // "update" method should be tested by MyComponentTest.testUpdate()
063: public void testUpdate() {
064: }
065:
066: public void testGetPreferredSize() {
067: JPanel panel = new JPanel();
068: assertNull(componentUI.getPreferredSize(panel));
069: }
070:
071: public void testGetMinimumSize() {
072: JPanel panel = new JPanel();
073: assertNull(componentUI.getMinimumSize(panel));
074: }
075:
076: public void testGetMaximumSize() {
077: JPanel panel = new JPanel();
078: assertNull(componentUI.getMaximumSize(panel));
079: }
080:
081: // "contains" method is beeing tested by MyComponentTest.testContainsintint()
082: public void testContains() {
083: }
084:
085: public void testGetAccessibleChild() {
086: JPanel panel = new JPanel();
087: Accessible child = componentUI.getAccessibleChild(panel, 0);
088: assertNull(child);
089: JPanel panel1 = new JPanel();
090: JPanel panel2 = new JPanel();
091: panel.add(panel1);
092: panel.add(panel2);
093: child = componentUI.getAccessibleChild(panel, 0);
094: assertTrue(child == panel1);
095: child = componentUI.getAccessibleChild(panel, 1);
096: assertTrue(child == panel2);
097: }
098:
099: public void testGetAccessibleChildrenCount() {
100: JPanel panel = new JPanel();
101: assertTrue(componentUI.getAccessibleChildrenCount(panel) == 0);
102: JPanel panel1 = new JPanel();
103: JPanel panel2 = new JPanel();
104: panel.add(panel1);
105: panel.add(panel2);
106: assertTrue(componentUI.getAccessibleChildrenCount(panel) == 2);
107: }
108:
109: public void testCreateUI() {
110: JComponent component = new JPanel();
111: boolean isExceptionThrown = false;
112: try {
113: ComponentUI.createUI(component);
114: } catch (Error e) {
115: isExceptionThrown = true;
116: } finally {
117: assertTrue(isExceptionThrown);
118: }
119: }
120: }
|