Source Code Cross Referenced for MetalInternalFrameTitlePaneTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » metal » 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.metal 
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.metal;
021:
022:        import java.awt.LayoutManager;
023:        import java.awt.Rectangle;
024:        import java.beans.PropertyChangeListener;
025:        import javax.swing.Icon;
026:        import javax.swing.JButton;
027:        import javax.swing.JInternalFrame;
028:        import javax.swing.JMenu;
029:        import javax.swing.JMenuBar;
030:        import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
031:        import javax.swing.SwingTestCase;
032:
033:        public class MetalInternalFrameTitlePaneTest extends SwingTestCase {
034:            /*
035:             * This class is used to access protected members
036:             */
037:            private class TestMetalInternalFrameTitlePane extends
038:                    MetalInternalFrameTitlePane {
039:                private static final long serialVersionUID = 1L;
040:
041:                public TestMetalInternalFrameTitlePane(
042:                        final JInternalFrame frame) {
043:                    super (frame);
044:                }
045:
046:                public JMenu getWindowMenu() {
047:                    return windowMenu;
048:                }
049:
050:                public JMenuBar getMenuBar() {
051:                    return menuBar;
052:                }
053:
054:                public JButton getCloseButton() {
055:                    return closeButton;
056:                }
057:
058:                public Icon getCloseIcon() {
059:                    return closeIcon;
060:                }
061:
062:                public JButton getIconButton() {
063:                    return iconButton;
064:                }
065:
066:                public JButton getMaxButton() {
067:                    return maxButton;
068:                }
069:            }
070:
071:            private MetalInternalFrameTitlePane pane;
072:
073:            private JInternalFrame frame;
074:
075:            /*
076:             * Constructor for MetalInternalFrameTitlePaneTest.
077:             */
078:            public MetalInternalFrameTitlePaneTest(final String name) {
079:                super (name);
080:            }
081:
082:            /*
083:             * @see TestCase#setUp()
084:             */
085:            @Override
086:            protected void setUp() throws Exception {
087:                super .setUp();
088:                frame = new JInternalFrame();
089:                pane = new MetalInternalFrameTitlePane(frame);
090:            }
091:
092:            /*
093:             * @see TestCase#tearDown()
094:             */
095:            @Override
096:            protected void tearDown() throws Exception {
097:                super .tearDown();
098:            }
099:
100:            /*
101:             * Class under test for void addNotify()
102:             */
103:            public void testAddNotify() {
104:                // Note: it's unclear what to test here
105:            }
106:
107:            /*
108:             * Class under test for void addSubComponents()
109:             */
110:            public void testAddSubComponents() {
111:                frame = new JInternalFrame("", true, true, true, true);
112:                pane = new MetalInternalFrameTitlePane(frame);
113:                assertEquals(3, pane.getComponentCount());
114:                frame = new JInternalFrame("", true, true, true, false);
115:                pane = new MetalInternalFrameTitlePane(frame);
116:                if (isHarmony()) {
117:                    assertEquals(2, pane.getComponentCount());
118:                }
119:            }
120:
121:            /*
122:             * Class under test for void installDefaults()
123:             */
124:            public void testInstallDefaults() {
125:                pane.uninstallDefaults();
126:                pane.paletteTitleHeight = 0;
127:                pane.paletteCloseIcon = null;
128:                pane.installDefaults();
129:                assertTrue("paletteTitleHeight != 0",
130:                        pane.paletteTitleHeight != 0);
131:                assertTrue("installed paletteCloseIcon",
132:                        pane.paletteCloseIcon != null);
133:            }
134:
135:            /*
136:             * Class under test for void uninstallDefaults()
137:             */
138:            public void testUninstallDefaults() {
139:                pane.uninstallDefaults();
140:                assertTrue("paletteTitleHeight != 0",
141:                        pane.paletteTitleHeight != 0);
142:                assertTrue("didn't uninstall paletteCloseIcon",
143:                        pane.paletteCloseIcon != null);
144:            }
145:
146:            /*
147:             * Class under test for void createButtons()
148:             */
149:            public void testCreateButtons() {
150:                TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(
151:                        frame);
152:                assertEquals("maxButton accessible name", "Maximize", pane
153:                        .getMaxButton().getAccessibleContext()
154:                        .getAccessibleName());
155:                if (isHarmony()) {
156:                    assertFalse("maxButton's border is not painted", pane
157:                            .getMaxButton().isBorderPainted());
158:                }
159:                assertEquals("iconButton accessible name", "Iconify", pane
160:                        .getIconButton().getAccessibleContext()
161:                        .getAccessibleName());
162:                if (isHarmony()) {
163:                    assertFalse("iconButton's border is not painted", pane
164:                            .getIconButton().isBorderPainted());
165:                }
166:                assertEquals("closeButton accessible name", "Close", pane
167:                        .getCloseButton().getAccessibleContext()
168:                        .getAccessibleName());
169:                if (isHarmony()) {
170:                    assertFalse("closeButton's border is not painted", pane
171:                            .getCloseButton().isBorderPainted());
172:                }
173:            }
174:
175:            /*
176:             * Class under test for void assembleSystemMenu()
177:             */
178:            public void testAssembleSystemMenu() {
179:                TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(
180:                        frame);
181:                pane.assembleSystemMenu();
182:                assertNull("windowMenu == null", pane.getWindowMenu());
183:                assertNull("menuBar == null", pane.getMenuBar());
184:            }
185:
186:            /*
187:             * Class under test for void showSystemMenu()
188:             */
189:            public void testShowSystemMenu() {
190:                // does nothing
191:            }
192:
193:            /*
194:             * Class under test for MetalInternalFrameTitlePane(JInternalFrame)
195:             */
196:            public void testMetalInternalFrameTitlePane() {
197:                pane = new MetalInternalFrameTitlePane(frame);
198:                assertFalse("isPalette == false", pane.isPalette);
199:            }
200:
201:            /*
202:             * Class under test for void addSystemMenuItems(JMenu)
203:             */
204:            public void testAddSystemMenuItems() {
205:                // the tested function does nothing
206:                JMenu menu = new JMenu();
207:                pane.addSystemMenuItems(menu);
208:                assertEquals(0, menu.getItemCount());
209:            }
210:
211:            /*
212:             * Class under test for PropertyChangeListener createPropertyChangeListener()
213:             */
214:            public void testCreatePropertyChangeListener() {
215:                PropertyChangeListener listener = pane
216:                        .createPropertyChangeListener();
217:                assertTrue("!= null", listener != null);
218:                assertTrue(
219:                        "instanceof TitlePaneLayout",
220:                        listener instanceof  BasicInternalFrameTitlePane.PropertyChangeHandler);
221:            }
222:
223:            /*
224:             * Class under test for LayoutManager createLayout()
225:             */
226:            public void testCreateLayout() {
227:                LayoutManager layout = pane.createLayout();
228:                assertTrue("!= null", layout != null);
229:                assertTrue(
230:                        "instanceof TitlePaneLayout",
231:                        layout instanceof  BasicInternalFrameTitlePane.TitlePaneLayout);
232:            }
233:
234:            /*
235:             * Class under test for void void setPalette(boolean)
236:             */
237:            public void testSetPalette() {
238:                TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(
239:                        frame);
240:                frame.setClosable(true);
241:                frame.setIconifiable(true);
242:                frame.setMaximizable(true);
243:                // test set to true
244:                pane.setPalette(true);
245:                assertTrue("isPalette is true", pane.isPalette);
246:                assertTrue("changed close icon", pane.getCloseButton()
247:                        .getIcon() == pane.paletteCloseIcon);
248:                assertTrue("1 child", pane.getComponentCount() == 1);
249:                // is layoutContainer called?
250:                // test set to false
251:                pane.setPalette(false);
252:                assertFalse("isPalette is false", pane.isPalette);
253:                assertTrue("changed close icon", pane.getCloseButton()
254:                        .getIcon() == pane.getCloseIcon());
255:                assertTrue("3 children", pane.getComponentCount() == 3);
256:            }
257:
258:            public void testPaintPalette() {
259:                // Note: painting code, cannot test
260:            }
261:
262:            /*
263:             * Class under test for void paintComponent(Graphics)
264:             */
265:            public void testPaintComponent() {
266:                // Note: painting code, cannot test
267:            }
268:
269:            /*
270:             * Test MetalInternalFrameTitlePane.MetalTitlePaneLayout class
271:             */
272:            public void testMetalTitlePaneLayout() {
273:                TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(
274:                        frame);
275:                pane.setSize(200, 31);
276:                LayoutManager layout = pane.getLayout();
277:                final Rectangle iconButtonBounds = new Rectangle(134, 7, 16, 16);
278:                final Rectangle maximizeButtonBounds = new Rectangle(156, 7,
279:                        16, 16);
280:                final Rectangle closeButtonBounds = new Rectangle(178, 7, 16,
281:                        16);
282:                // test layoutContainer(): non-iconifiable, non-maximizable, non-closable
283:                layout.layoutContainer(null);
284:                //        assertEquals("iconButton", zeroBounds,
285:                //                     pane.getComponent(0).getBounds());
286:                //        assertTrue("maximizeButton", pane.getComponent(1).getBounds().
287:                //                equals(zeroBounds));
288:                //        assertTrue("closeButton", pane.getComponent(2).getBounds().
289:                //                equals(zeroBounds));
290:                // test layoutContainer(): iconifiable, maximizable, closable
291:                frame.setIconifiable(true);
292:                frame.setMaximizable(true);
293:                frame.setClosable(true);
294:                layout.layoutContainer(pane);
295:                if (isHarmony()) {
296:                    assertEquals("iconButton", iconButtonBounds, pane
297:                            .getComponent(0).getBounds());
298:                    assertEquals("maximizeButton", maximizeButtonBounds, pane
299:                            .getComponent(1).getBounds());
300:                    assertEquals("closeButton", closeButtonBounds, pane
301:                            .getComponent(2).getBounds());
302:                }
303:                // test layoutContainer(): isPalette == true
304:                pane.setPalette(true);
305:                layout.layoutContainer(null);
306:                // these bounds can be changed in the future
307:                if (isHarmony()) {
308:                    assertEquals("palette: closeButton", new Rectangle(189, 11,
309:                            8, 8), pane.getComponent(0).getBounds());
310:                }
311:                // minimumLayoutSize(), preferredLayoutSize() implementations
312:                assertTrue("", layout.minimumLayoutSize(pane) != null);
313:                assertTrue("", layout.preferredLayoutSize(pane) != null);
314:            }
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.