Source Code Cross Referenced for BasicInternalFrameTitlePaneTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » basic » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.swing.plaf.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.BorderLayout;
023:        import java.awt.Font;
024:        import java.awt.FontMetrics;
025:        import java.awt.LayoutManager;
026:        import java.awt.Rectangle;
027:        import java.beans.PropertyChangeListener;
028:        import java.beans.PropertyVetoException;
029:
030:        import javax.swing.Action;
031:        import javax.swing.JDesktopPane;
032:        import javax.swing.JFrame;
033:        import javax.swing.JInternalFrame;
034:        import javax.swing.JMenu;
035:        import javax.swing.JMenuBar;
036:        import javax.swing.JMenuItem;
037:        import javax.swing.SwingTestCase;
038:        import javax.swing.UIManager;
039:        import javax.swing.event.InternalFrameAdapter;
040:        import javax.swing.event.InternalFrameEvent;
041:        import javax.swing.plaf.metal.MetalInternalFrameTitlePane;
042:
043:        public class BasicInternalFrameTitlePaneTest extends SwingTestCase {
044:            private BasicInternalFrameTitlePane pane;
045:
046:            private JInternalFrame frame;
047:
048:            private JDesktopPane desktop;
049:
050:            private JFrame rootFrame;
051:
052:            public BasicInternalFrameTitlePaneTest(final String name) {
053:                super (name);
054:            }
055:
056:            @Override
057:            protected void setUp() throws Exception {
058:                super .setUp();
059:                frame = new JInternalFrame();
060:                pane = new BasicInternalFrameTitlePane(frame);
061:                desktop = new JDesktopPane();
062:                desktop.add(frame);
063:                frame.addNotify(); // leads to enabling of move/size actions
064:                rootFrame = null;
065:            }
066:
067:            @Override
068:            protected void tearDown() throws Exception {
069:                super .tearDown();
070:                if (rootFrame != null) {
071:                    rootFrame.dispose();
072:                }
073:            }
074:
075:            private void checkButtonIcons() {
076:                assertTrue("closeButton ok",
077:                        pane.closeButton.getIcon() == pane.closeIcon);
078:                if (frame.isIcon()) {
079:                    assertTrue("iconButton ok",
080:                            pane.iconButton.getIcon() == pane.minIcon);
081:                } else {
082:                    assertTrue("iconButton ok",
083:                            pane.iconButton.getIcon() == pane.iconIcon);
084:                }
085:                if (frame.isMaximum() && !frame.isIcon()) {
086:                    assertTrue("maxButton ok",
087:                            pane.maxButton.getIcon() == pane.minIcon);
088:                } else {
089:                    assertTrue("maxButton ok",
090:                            pane.maxButton.getIcon() == pane.maxIcon);
091:                }
092:                assertTrue("closeButton tooltip ok", pane.closeButton
093:                        .getToolTipText() != null);
094:                assertTrue("iconButton tooltip ok", pane.iconButton
095:                        .getToolTipText() != null);
096:                assertTrue("maxButton tooltip ok", pane.maxButton
097:                        .getToolTipText() != null);
098:            }
099:
100:            private void checkEnabledActions() {
101:                assertEquals("iconifyAction", !frame.isIcon()
102:                        && frame.isIconifiable(), pane.iconifyAction
103:                        .isEnabled());
104:                assertEquals("closeAction", frame.isClosable(),
105:                        pane.closeAction.isEnabled());
106:                assertEquals("maximizeAction", frame.isMaximizable()
107:                        && (!frame.isMaximum() || frame.isIcon()
108:                                && frame.isIconifiable()), pane.maximizeAction
109:                        .isEnabled());
110:                assertEquals("moveAction",
111:                        isHarmony() && frame.getDesktopPane() != null
112:                                && !frame.isMaximum(), pane.moveAction
113:                                .isEnabled());
114:                assertEquals("sizeAction", !frame.isMaximum()
115:                        && frame.isResizable() && !frame.isIcon(),
116:                        pane.sizeAction.isEnabled());
117:                assertEquals("restoreAction", frame.isMaximum()
118:                        && frame.isMaximizable() || frame.isIcon()
119:                        && frame.isIconifiable(), pane.restoreAction
120:                        .isEnabled());
121:            }
122:
123:            private boolean belongs(final Object o, final Object[] array) {
124:                for (int i = 0; i < array.length; i++) {
125:                    if (array[i] == o) {
126:                        return true;
127:                    }
128:                }
129:                return false;
130:            }
131:
132:            public void testAddSubComponents() {
133:                frame = new JInternalFrame("", true, true, true, true);
134:                pane = new BasicInternalFrameTitlePane(frame);
135:                assertEquals(4, pane.getComponentCount());
136:                frame = new JInternalFrame("", true, true, true, false);
137:                pane = new BasicInternalFrameTitlePane(frame);
138:                if (isHarmony()) {
139:                    assertEquals(3, pane.getComponentCount());
140:                }
141:            }
142:
143:            public void testCreateActions() {
144:                pane.createActions();
145:                // test created actions
146:                assertTrue("closeAction != null", pane.closeAction != null);
147:                assertTrue(
148:                        "closeAction instanceof ok",
149:                        pane.closeAction instanceof  BasicInternalFrameTitlePane.CloseAction);
150:                assertTrue("iconifyAction != null", pane.iconifyAction != null);
151:                assertTrue(
152:                        "iconifyAction instanceof ok",
153:                        pane.iconifyAction instanceof  BasicInternalFrameTitlePane.IconifyAction);
154:                assertTrue("maximizeAction != null",
155:                        pane.maximizeAction != null);
156:                assertTrue(
157:                        "maximizeAction instanceof ok",
158:                        pane.maximizeAction instanceof  BasicInternalFrameTitlePane.MaximizeAction);
159:                assertTrue("moveAction != null", pane.moveAction != null);
160:                assertTrue(
161:                        "moveAction instanceof ok",
162:                        pane.moveAction instanceof  BasicInternalFrameTitlePane.MoveAction);
163:                assertTrue("restoreAction != null", pane.restoreAction != null);
164:                assertTrue(
165:                        "restoreAction instanceof ok",
166:                        pane.restoreAction instanceof  BasicInternalFrameTitlePane.RestoreAction);
167:                assertTrue("sizeAction != null", pane.sizeAction != null);
168:                assertTrue(
169:                        "sizeAction instanceof ok",
170:                        pane.sizeAction instanceof  BasicInternalFrameTitlePane.SizeAction);
171:            }
172:
173:            public void testCreateButtons() {
174:                pane.createButtons();
175:                // test created buttons
176:                assertTrue("maxButton != null", pane.maxButton != null);
177:                assertTrue("maxButton tooltip",
178:                        pane.maxButton.getToolTipText() != null);
179:                assertTrue("closeButton != null", pane.closeButton != null);
180:                assertTrue("closeButton tooltip", pane.closeButton
181:                        .getToolTipText() != null);
182:                assertTrue("iconButton != null", pane.iconButton != null);
183:                assertTrue("iconButton tooltip", pane.iconButton
184:                        .getToolTipText() != null);
185:            }
186:
187:            public void testEnableActions() {
188:                // iconifyAction test
189:                frame.setIconifiable(false);
190:                checkEnabledActions();
191:                frame.setIconifiable(true);
192:                checkEnabledActions();
193:                // closeAction test
194:                frame.setClosable(false);
195:                checkEnabledActions();
196:                frame.setClosable(true);
197:                checkEnabledActions();
198:                // maximizeAction test
199:                frame.setMaximizable(false);
200:                checkEnabledActions();
201:                frame.setMaximizable(true);
202:                checkEnabledActions();
203:                // restoreAction test
204:                checkEnabledActions(); // normal bounds - disabled
205:                frame.setMaximizable(true);
206:                try {
207:                    frame.setMaximum(true);
208:                } catch (PropertyVetoException e) {
209:                    assertTrue("exception", false);
210:                }
211:                checkEnabledActions(); // enabled
212:                frame.setMaximizable(false);
213:                if (isHarmony()) {
214:                    checkEnabledActions(); // disabled
215:                }
216:                frame.setMaximizable(true);
217:                frame.setIconifiable(true);
218:                try {
219:                    frame.setIcon(true);
220:                } catch (PropertyVetoException e) {
221:                    assertTrue("exception", false);
222:                }
223:                checkEnabledActions(); // enabled
224:                frame.setIconifiable(false);
225:                if (isHarmony()) {
226:                    checkEnabledActions(); // disabled
227:                }
228:            }
229:
230:            public void testInstallDefaults() {
231:                assertSame(UIManager.getIcon("InternalFrame.closeIcon"),
232:                        pane.closeIcon);
233:                assertSame(UIManager.getIcon("InternalFrame.maximizeIcon"),
234:                        pane.maxIcon);
235:                assertSame(UIManager.getIcon("InternalFrame.minimizeIcon"),
236:                        pane.minIcon);
237:                assertSame(UIManager.getIcon("InternalFrame.iconifyIcon"),
238:                        pane.iconIcon);
239:                assertSame(UIManager
240:                        .getColor("InternalFrame.activeTitleBackground"),
241:                        pane.selectedTitleColor);
242:                assertSame(UIManager
243:                        .getColor("InternalFrame.activeTitleForeground"),
244:                        pane.selectedTextColor);
245:                assertSame(UIManager
246:                        .getColor("InternalFrame.inactiveTitleBackground"),
247:                        pane.notSelectedTitleColor);
248:                assertSame(UIManager
249:                        .getColor("InternalFrame.inactiveTitleForeground"),
250:                        pane.notSelectedTextColor);
251:                assertSame(UIManager.getFont("InternalFrame.titleFont"), pane
252:                        .getFont());
253:            }
254:
255:            public void testInstallUninstallListeners() {
256:                pane.uninstallListeners();
257:                assertFalse("listener was uninstalled", belongs(
258:                        pane.propertyChangeListener, frame
259:                                .getPropertyChangeListeners()));
260:                pane.installListeners();
261:                assertTrue("listener != null",
262:                        pane.propertyChangeListener != null);
263:                assertTrue("listener was installed", belongs(
264:                        pane.propertyChangeListener, frame
265:                                .getPropertyChangeListeners()));
266:                pane.uninstallListeners();
267:                assertFalse("listener was uninstalled", belongs(
268:                        pane.propertyChangeListener, frame
269:                                .getPropertyChangeListeners()));
270:            }
271:
272:            public void testInstallTitlePane() {
273:                pane.installTitlePane();
274:                assertSame(UIManager.getIcon("InternalFrame.closeIcon"),
275:                        pane.closeIcon);
276:                assertTrue("listener != null",
277:                        pane.propertyChangeListener != null);
278:                assertTrue("listener was installed", belongs(
279:                        pane.propertyChangeListener, frame
280:                                .getPropertyChangeListeners()));
281:                assertTrue("closeAction != null", pane.closeAction != null);
282:                assertNotNull(pane.getLayout());
283:                assertTrue("maxButton != null", pane.maxButton != null);
284:                assertTrue("windowMenu != null", pane.windowMenu != null);
285:                assertTrue(pane.getComponentCount() > 1);
286:                checkEnabledActions();
287:            }
288:
289:            public void testSetButtonIcons() {
290:                checkButtonIcons();
291:                // test icons in Maximum state
292:                frame.setMaximizable(true);
293:                try {
294:                    frame.setMaximum(true);
295:                } catch (PropertyVetoException e) {
296:                    assertTrue("exception", false);
297:                }
298:                checkButtonIcons();
299:                // test icons in Icon state
300:                frame.setIconifiable(true);
301:                try {
302:                    frame.setIcon(true);
303:                } catch (PropertyVetoException e) {
304:                    assertTrue("exception", false);
305:                }
306:                checkButtonIcons();
307:            }
308:
309:            protected void createAndShowRootFrame() {
310:                rootFrame = new JFrame();
311:                rootFrame.setSize(90, 90);
312:                rootFrame.setContentPane(desktop);
313:                frame.setSize(80, 50);
314:                frame.setVisible(true);
315:                desktop.add(pane, BorderLayout.NORTH);
316:                rootFrame.setVisible(true);
317:            }
318:
319:            public void testShowSystemMenu() {
320:                createAndShowRootFrame();
321:                pane.showSystemMenu();
322:                assertTrue("", pane.windowMenu.isPopupMenuVisible());
323:                pane.windowMenu = null;
324:                testExceptionalCase(new NullPointerCase() {
325:                    @Override
326:                    public void exceptionalAction() throws Exception {
327:                        pane.showSystemMenu();
328:                    }
329:                });
330:            }
331:
332:            public void testUninstallDefaults() {
333:                // nothing to test
334:            }
335:
336:            public void testBasicInternalFrameTitlePane() {
337:                pane = new BasicInternalFrameTitlePane(frame);
338:                assertTrue("frame is set", pane.frame == frame);
339:                assertTrue("layout", pane.getLayout() != null);
340:            }
341:
342:            public void testGetTitle() {
343:                createAndShowRootFrame();
344:                final String title = "Document #1";
345:                Font font = new Font("Fixed", Font.PLAIN, 10);
346:                FontMetrics fm = getFontMetrics(font);
347:                assertEquals(title, pane.getTitle(title, fm, 110));
348:                assertEquals("Documen...", pane.getTitle(title, fm, 109));
349:                assertEquals("Do...", pane.getTitle(title, fm, 50));
350:                assertEquals("...", pane.getTitle(title, fm, 4));
351:            }
352:
353:            public void testCreateSystemMenuBar() {
354:                JMenuBar menuBar = pane.createSystemMenuBar();
355:                assertEquals(0, menuBar.getMenuCount());
356:            }
357:
358:            public void testAddSystemMenuItems() {
359:                JMenu menu = new JMenu();
360:                pane.addSystemMenuItems(menu);
361:                assertEquals(7, menu.getItemCount());
362:            }
363:
364:            public void testCreateSystemMenu() {
365:                JMenu menu = pane.createSystemMenu();
366:                assertEquals(0, menu.getItemCount());
367:            }
368:
369:            public void testAssembleSystemMenu() {
370:                pane.assembleSystemMenu();
371:                assertTrue("windowMenu != null", pane.windowMenu != null);
372:                assertEquals("7 items", 7, pane.windowMenu.getItemCount());
373:                JMenuBar menuBar = pane.menuBar;
374:                assertTrue("menuBar contains windowMenu",
375:                        menuBar.getMenu(0) == pane.windowMenu);
376:            }
377:
378:            public void testPostClosingEvent() {
379:                class MyInternalFrameAdapter extends InternalFrameAdapter {
380:                    boolean ok = false;
381:
382:                    @Override
383:                    public void internalFrameClosing(final InternalFrameEvent e) {
384:                        ok = true;
385:                    }
386:                }
387:                MyInternalFrameAdapter listener = new MyInternalFrameAdapter();
388:                frame.addInternalFrameListener(listener);
389:                pane.postClosingEvent(frame);
390:                if (isHarmony()) {
391:                    assertTrue("event ok", listener.ok);
392:                }
393:            }
394:
395:            public void testCreatePropertyChangeListener() {
396:                PropertyChangeListener listener = pane
397:                        .createPropertyChangeListener();
398:                assertTrue("!= null", listener != null);
399:                if (isHarmony()) {
400:                    assertTrue(
401:                            "instanceof TitlePaneLayout",
402:                            listener instanceof  BasicInternalFrameTitlePane.PropertyChangeHandler);
403:                }
404:            }
405:
406:            public void testCreateLayout() {
407:                LayoutManager layout = pane.createLayout();
408:                assertTrue("!= null", layout != null);
409:                if (isHarmony()) {
410:                    assertTrue(
411:                            "instanceof TitlePaneLayout",
412:                            layout instanceof  BasicInternalFrameTitlePane.TitlePaneLayout);
413:                }
414:            }
415:
416:            public void testCloseButton() {
417:                // test with isClosable == false
418:                pane.closeButton.doClick(0);
419:                assertFalse("not closed", frame.isClosed());
420:                // test with isClosable == true
421:                frame.setClosable(true);
422:                pane.closeButton.doClick(0);
423:                assertTrue("closed", frame.isClosed());
424:            }
425:
426:            public void testIconifyButton() {
427:                // test with isIconifiable == false
428:                pane.iconButton.doClick(0);
429:                assertFalse("not iconified", frame.isIcon());
430:                // test with isIconifiable == true
431:                frame.setIconifiable(true);
432:                pane.iconButton.doClick(0);
433:                assertTrue("iconified", frame.isIcon());
434:                // test iconify again
435:                pane.iconButton.doClick(0);
436:                assertFalse("deiconified", frame.isIcon());
437:                // test iconify from maximized state
438:                frame.setMaximizable(true);
439:                pane.maxButton.doClick(0);
440:                assertTrue("maximized", frame.isMaximum());
441:                pane.iconButton.doClick(0);
442:                assertTrue("iconified", frame.isIcon());
443:                assertTrue("maximized", frame.isMaximum());
444:                // test deiconify after iconify from maximized state
445:                pane.iconButton.doClick(0);
446:                assertFalse("deiconified", frame.isIcon());
447:                assertTrue("maximized", frame.isMaximum());
448:            }
449:
450:            public void testMaximizeButton() {
451:                // test with isMaximizable == false
452:                pane.maxButton.doClick(0);
453:                assertFalse("not maximized", frame.isMaximum());
454:                // test with isMaximizable == true
455:                frame.setMaximizable(true);
456:                pane.maxButton.doClick(0);
457:                assertTrue("maximized", frame.isMaximum());
458:                // test maximize again
459:                pane.maxButton.doClick(0);
460:                assertFalse("restored", frame.isMaximum());
461:                // test maximize from icon
462:                frame.setIconifiable(true);
463:                pane.iconButton.doClick(0);
464:                assertTrue("iconified", frame.isIcon());
465:                frame.setIconifiable(false);
466:                pane.maxButton.doClick(0);
467:                assertFalse("deiconified", frame.isIcon());
468:                assertTrue("maximized", frame.isMaximum());
469:                // test maximize again
470:                frame.setIconifiable(true);
471:                pane.iconButton.doClick(0);
472:                assertTrue("iconified", frame.isIcon());
473:                pane.maxButton.doClick(0);
474:                assertFalse("deiconified", frame.isIcon());
475:                assertTrue("maximized", frame.isMaximum());
476:            }
477:
478:            public void testRestoreAction() {
479:                frame.setMaximizable(true);
480:                pane.maxButton.doClick(0);
481:                assertTrue("maximized", frame.isMaximum());
482:                // test with isMaximizable == false
483:                frame.setMaximizable(false);
484:                JMenuItem menuItem = pane.menuBar.getMenu(0).getItem(0);
485:                assertEquals("name == Restore", "Restore", menuItem.getText());
486:                menuItem.doClick(0);
487:                assertTrue("restored", frame.isMaximum());
488:                // test with isMaximizable == true
489:                frame.setMaximizable(true);
490:                menuItem.doClick(0);
491:                assertFalse("restored", frame.isMaximum());
492:                // test restore again
493:                menuItem.doClick(0);
494:                assertFalse("no change", frame.isMaximum());
495:                // iconify the frame
496:                frame.setIconifiable(true);
497:                pane.iconButton.doClick(0);
498:                assertTrue("iconified", frame.isIcon());
499:                // test restore of the iconified frame with isIconifiable == false
500:                frame.setIconifiable(false);
501:                menuItem.doClick(0);
502:                assertTrue("not restored", frame.isIcon());
503:                // test restore of the iconified frame with isIconifiable == true
504:                frame.setIconifiable(true);
505:                menuItem.doClick(0);
506:                assertFalse("restored", frame.isIcon());
507:            }
508:
509:            public void testSizeAction() {
510:                // cannot test
511:            }
512:
513:            public void testMoveAction() {
514:                // cannot test
515:            }
516:
517:            public void testTitlePaneLayout() {
518:                LayoutManager layout = pane.new TitlePaneLayout();
519:                pane.setSize(200, 31);
520:                final Rectangle menuBarBounds = new Rectangle(2, 7, 16, 16);
521:                final Rectangle zeroBounds = new Rectangle();
522:                final Rectangle closeButtonBounds = new Rectangle(182, 7, 16,
523:                        16);
524:                final Rectangle iconButtonBounds = new Rectangle(146, 7, 16, 16);
525:                final Rectangle maximizeButtonBounds = new Rectangle(164, 7,
526:                        16, 16);
527:                // non-iconifiable, non-maximizable, non-closable
528:                layout.layoutContainer(null);
529:                assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds());
530:                assertEquals("iconButton", zeroBounds, pane.iconButton
531:                        .getBounds());
532:                assertEquals("maximizeButton", zeroBounds, pane.maxButton
533:                        .getBounds());
534:                assertEquals("closeButton", zeroBounds, pane.closeButton
535:                        .getBounds());
536:                if (!isHarmony()) {
537:                    return;
538:                }
539:                // iconifiable, non-maximizable, non-closable
540:                frame.setIconifiable(true);
541:                layout.layoutContainer(null);
542:                assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds());
543:                assertEquals("iconButton", closeButtonBounds, pane.iconButton
544:                        .getBounds());
545:                assertEquals("maximizeButton", zeroBounds, pane.maxButton
546:                        .getBounds());
547:                assertEquals("closeButton", zeroBounds, pane.closeButton
548:                        .getBounds());
549:                // iconifiable, maximizable, closable
550:                frame.setMaximizable(true);
551:                frame.setClosable(true);
552:                layout.layoutContainer(null);
553:                assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds());
554:                assertEquals("iconButton", iconButtonBounds, pane.iconButton
555:                        .getBounds());
556:                assertEquals("maximizeButton", maximizeButtonBounds,
557:                        pane.maxButton.getBounds());
558:                assertEquals("closeButton", closeButtonBounds, pane.closeButton
559:                        .getBounds());
560:                // minimumLayoutSize(), preferredLayoutSize() implementations
561:                assertTrue("", layout.minimumLayoutSize(pane) != null);
562:                assertTrue("", layout.preferredLayoutSize(pane) != null);
563:            }
564:
565:            @SuppressWarnings("deprecation")
566:            public void testSystemMenuBar() {
567:                JMenuBar menuBar = pane.new SystemMenuBar();
568:                assertTrue("opaque", menuBar.isOpaque());
569:                assertFalse("isFocusTraversable", menuBar.isFocusTraversable());
570:                assertFalse(menuBar.isFocusable());
571:            }
572:
573:            public void testPropertyChangeHandler() {
574:                // test "iconable" property change
575:                frame.setIconifiable(false);
576:                frame.setIconifiable(true);
577:                assertTrue("icon button added", belongs(pane.iconButton, pane
578:                        .getComponents()));
579:                frame.setIconifiable(false);
580:                assertFalse("icon button removed", belongs(pane.iconButton,
581:                        pane.getComponents()));
582:                // test "closable" property change
583:                frame.setClosable(false);
584:                frame.setClosable(true);
585:                assertTrue("close button added", belongs(pane.closeButton, pane
586:                        .getComponents()));
587:                frame.setClosable(false);
588:                assertFalse("close button removed", belongs(pane.closeButton,
589:                        pane.getComponents()));
590:                // test "maximizable" property change
591:                frame.setMaximizable(false);
592:                frame.setMaximizable(true);
593:                assertTrue("max button added", belongs(pane.maxButton, pane
594:                        .getComponents()));
595:                frame.setMaximizable(false);
596:                assertFalse("max button removed", belongs(pane.maxButton, pane
597:                        .getComponents()));
598:            }
599:
600:            public void testPaintTitleBackground() {
601:                // Note: painting code, cannot test
602:            }
603:
604:            public void testConstructor() {
605:                try {
606:                    new BasicInternalFrameTitlePane((JInternalFrame) null);
607:                    fail("NPE should be thrown");
608:                } catch (NullPointerException npe) {
609:                    // PASSED          
610:                }
611:            }
612:
613:            public void testPaintComponent() {
614:                // Note: painting code, cannot test
615:            }
616:
617:            /**
618:             * Regression test for HARMONY-2608
619:             * */
620:            public void testMoveActionKey() {
621:                BasicInternalFrameTitlePane.MoveAction m = pane.new MoveAction();
622:                assertEquals(1, m.getKeys().length);
623:                String key = (String) m.getKeys()[0];
624:                assertEquals(Action.NAME, key);
625:                assertEquals("Move", m.getValue(key));
626:            }
627:
628:            /**
629:             * Regression test for HARMONY-2608
630:             * */
631:            public void testMoveActionPerformed() {
632:                BasicInternalFrameTitlePane.MoveAction m = pane.new MoveAction();
633:                try {
634:                    m.actionPerformed(null);
635:                } catch (NullPointerException e) {
636:                    fail("NPE shouldn't be thrown");
637:                }
638:            }
639:
640:            /**
641:             * Regression test for HARMONY-2604
642:             * */
643:            public void testSizeActionPerformed() {
644:                String str = "test string";
645:                JInternalFrame jf = new JInternalFrame(str);
646:                MetalInternalFrameTitlePane jp = new MetalInternalFrameTitlePane(
647:                        jf);
648:                BasicInternalFrameTitlePane.SizeAction m = jp.new SizeAction();
649:                try {
650:                    m.actionPerformed(null);
651:                } catch (NullPointerException e) {
652:                    fail("NPE shouldn't be thrown");
653:                }
654:            }
655:
656:            /**
657:             * Regression test for HARMONY-2588
658:             * */
659:            public void testSizeActionKey() {
660:                String str = "test string";
661:                JInternalFrame jf = new JInternalFrame(str);
662:                MetalInternalFrameTitlePane jp = new MetalInternalFrameTitlePane(
663:                        jf);
664:                BasicInternalFrameTitlePane.SizeAction m = jp.new SizeAction();
665:                assertEquals(1, m.getKeys().length);
666:                String key = (String) m.getKeys()[0];
667:                assertEquals(Action.NAME, key);
668:                assertEquals("Size", m.getValue(key));
669:            }
670:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.