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 Vadim L. Bogdanov
019: * @version $Revision$
020: */package javax.swing.plaf.basic;
021:
022: import java.awt.Dimension;
023: import javax.swing.DefaultDesktopManager;
024: import javax.swing.JComponent;
025: import javax.swing.JDesktopPane;
026: import javax.swing.SwingTestCase;
027: import javax.swing.SwingUtilities;
028: import javax.swing.plaf.ComponentUI;
029:
030: public class BasicDesktopPaneUITest extends SwingTestCase {
031: private JDesktopPane desktop;
032:
033: private BasicDesktopPaneUI ui;
034:
035: /*
036: * @see TestCase#setUp()
037: */
038: @Override
039: protected void setUp() throws Exception {
040: super .setUp();
041: desktop = new JDesktopPane();
042: ui = new BasicDesktopPaneUI();
043: desktop.setUI(ui);
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 BasicDesktopPaneUITest.
056: * @param name
057: */
058: public BasicDesktopPaneUITest(final String name) {
059: super (name);
060: }
061:
062: /*
063: * Class under test for ComponentUI createUI(JComponent)
064: */
065: public void testCreateUI() {
066: ComponentUI ui1 = BasicDesktopPaneUI.createUI(desktop);
067: ComponentUI ui2 = BasicDesktopPaneUI.createUI(desktop);
068: assertTrue("not null", ui1 != null);
069: assertTrue("stateful", ui1 != ui2);
070: }
071:
072: public void testBasicDesktopPaneUI() {
073: }
074:
075: public void testCreatePropertyChangeListener() {
076: assertNotNull(ui.createPropertyChangeListener());
077: }
078:
079: /*
080: * Class under test for Dimension getMaximumSize(JComponent)
081: */
082: public void testGetMaximumSize() {
083: assertEquals(
084: new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), ui
085: .getMaximumSize(desktop));
086: }
087:
088: /*
089: * Class under test for Dimension getMinimumSize(JComponent)
090: */
091: public void testGetMinimumSize() {
092: assertEquals(new Dimension(0, 0), ui.getMinimumSize(desktop));
093: }
094:
095: /*
096: * Class under test for Dimension getPreferredSize(JComponent)
097: */
098: public void testGetPreferredSize() {
099: assertNull(ui.getPreferredSize(desktop));
100: }
101:
102: public void testInstallDefaults() {
103: desktop.setBackground(null);
104: ui.installDefaults();
105: assertNotNull("background", desktop.getBackground());
106: }
107:
108: public void testUninstallDefaults() {
109: ui.uninstallDefaults();
110: if (isHarmony()) {
111: assertNull("background", desktop.getBackground());
112: }
113: }
114:
115: public void testInstallDesktopManager() {
116: desktop.setDesktopManager(null);
117: ui.installDesktopManager();
118: assertNotNull(desktop.getDesktopManager());
119: assertEquals("installed", ui.desktopManager, desktop
120: .getDesktopManager());
121: }
122:
123: public void testUninstallDesktopManager() {
124: ui.installDesktopManager();
125: ui.uninstallDesktopManager();
126: assertNotNull(desktop.getDesktopManager());
127: DefaultDesktopManager m = new DefaultDesktopManager();
128: desktop.setDesktopManager(m);
129: ui.uninstallDesktopManager();
130: assertSame(m, desktop.getDesktopManager());
131: desktop.setDesktopManager(null);
132: ui.uninstallDesktopManager();
133: assertNotNull(desktop.getDesktopManager());
134: }
135:
136: public void testInstallKeyboardActions() {
137: assertNotNull("action map", SwingUtilities
138: .getUIActionMap(desktop));
139: assertNotNull("input map", SwingUtilities.getUIInputMap(
140: desktop, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
141: }
142:
143: public void testUninstallKeyboardActions() {
144: ui.uninstallKeyboardActions();
145: assertNull("action map", SwingUtilities.getUIActionMap(desktop));
146: assertNull("input map", SwingUtilities.getUIInputMap(desktop,
147: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
148: }
149:
150: public void testInstallListeners() {
151: // nothing to test
152: }
153:
154: /*
155: * Class under test for void installUI(JComponent)
156: */
157: public void testInstallUI() {
158: assertEquals("desktop", desktop, ui.desktop);
159: }
160:
161: /*
162: * Class under test for void uninstallUI(JComponent)
163: */
164: public void testUninstallUI() {
165: ui.uninstallUI(desktop);
166: assertNull("action map", SwingUtilities.getUIActionMap(desktop));
167: assertNull(desktop.getDesktopManager());
168: }
169:
170: /*
171: * Class under test for void paint(Graphics, JComponent)
172: */
173: public void testPaint() {
174: // cannot test
175: }
176:
177: public void testRegisterKeyboardActions() {
178: // nothing to test
179: }
180:
181: public void testUninstallListeners() {
182: // nothing to test
183: }
184:
185: public void testUnregisterKeyboardActions() {
186: // nothing to test
187: }
188: }
|