Source Code Cross Referenced for MetalRootPaneUITest.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 javax.swing.BorderFactory;
024:        import javax.swing.JFrame;
025:        import javax.swing.JRootPane;
026:        import javax.swing.SwingTestCase;
027:        import javax.swing.border.Border;
028:        import javax.swing.plaf.ComponentUI;
029:
030:        public class MetalRootPaneUITest extends SwingTestCase {
031:            private JRootPane rootPane;
032:
033:            private MetalRootPaneUI ui;
034:
035:            private JFrame frame;
036:
037:            /*
038:             * @see TestCase#setUp()
039:             */
040:            @Override
041:            protected void setUp() throws Exception {
042:                super .setUp();
043:                frame = new JFrame();
044:                rootPane = frame.getRootPane();
045:                ui = new MetalRootPaneUI();
046:            }
047:
048:            /*
049:             * @see TestCase#tearDown()
050:             */
051:            @Override
052:            protected void tearDown() throws Exception {
053:                super .tearDown();
054:            }
055:
056:            /*
057:             * Constructor for MetalRootPaneUITest.
058:             */
059:            public MetalRootPaneUITest(final String name) {
060:                super (name);
061:            }
062:
063:            /*
064:             * Class under test for void installUI(JComponent)
065:             */
066:            public void testInstallUI() {
067:                // test install with windowDecorationStyle = JRootPane.NONE
068:                Border saveBorder = rootPane.getBorder();
069:                LayoutManager saveLayout = rootPane.getLayout();
070:                int saveComponentCount = rootPane.getLayeredPane()
071:                        .getComponentCount();
072:                ui.installUI(rootPane);
073:                assertTrue("didn't install border",
074:                        rootPane.getBorder() == saveBorder);
075:                assertTrue("didn't install layout",
076:                        rootPane.getLayout() == saveLayout);
077:                assertTrue(
078:                        "didn't install titlePane",
079:                        rootPane.getLayeredPane().getComponentCount() == saveComponentCount);
080:                // test install with windowDecorationStyle = JRootPane.FRAME
081:                rootPane.setWindowDecorationStyle(JRootPane.FRAME);
082:                ui.uninstallUI(rootPane);
083:                saveBorder = rootPane.getBorder();
084:                saveLayout = rootPane.getLayout();
085:                saveComponentCount = rootPane.getLayeredPane()
086:                        .getComponentCount();
087:                ui.installUI(rootPane);
088:                assertTrue("border != null", rootPane.getBorder() != null);
089:                assertTrue("installed border",
090:                        rootPane.getBorder() != saveBorder);
091:                assertTrue("layout != null", rootPane.getBorder() != null);
092:                assertTrue("installed layout",
093:                        rootPane.getLayout() != saveLayout);
094:                assertTrue("installed titlePane", rootPane.getLayeredPane()
095:                        .getComponentCount() == saveComponentCount + 1);
096:            }
097:
098:            /*
099:             * Class under test for void uninstallUI(JComponent)
100:             */
101:            public void testUninstallUI() {
102:                // test uninstall with windowDecorationStyle = JRootPane.NONE
103:                ui.installUI(rootPane);
104:                Border saveBorder = rootPane.getBorder();
105:                LayoutManager saveLayout = rootPane.getLayout();
106:                int saveComponentCount = rootPane.getLayeredPane()
107:                        .getComponentCount();
108:                ui.uninstallUI(rootPane);
109:                assertTrue("didn't uninstall border",
110:                        rootPane.getBorder() == saveBorder);
111:                assertTrue("didn't uninstall layout",
112:                        rootPane.getLayout() == saveLayout);
113:                assertTrue(
114:                        "didn't uninstall titlePane",
115:                        rootPane.getLayeredPane().getComponentCount() == saveComponentCount);
116:                // test uninstall with windowDecorationStyle = JRootPane.FRAME
117:                ui.installUI(rootPane);
118:                rootPane.setWindowDecorationStyle(JRootPane.FRAME);
119:                saveBorder = rootPane.getBorder();
120:                saveLayout = rootPane.getLayout();
121:                saveComponentCount = rootPane.getLayeredPane()
122:                        .getComponentCount();
123:                ui.uninstallUI(rootPane);
124:                assertTrue("uninstalled border",
125:                        rootPane.getBorder() != saveBorder);
126:                assertTrue("uninstalled layout",
127:                        rootPane.getLayout() != saveLayout);
128:                assertTrue("uninstalled titlePane", rootPane.getLayeredPane()
129:                        .getComponentCount() == saveComponentCount - 1);
130:            }
131:
132:            /*
133:             * Class under test for void propertyChange(PropertyChangeEvent)
134:             */
135:            public void testPropertyChange() {
136:                rootPane.setUI(ui);
137:                Border saveBorder = rootPane.getBorder();
138:                LayoutManager saveLayout = rootPane.getLayout();
139:                int saveComponentCount = rootPane.getLayeredPane()
140:                        .getComponentCount();
141:                // test windowDecorationStyle = JRootPane.FRAME
142:                rootPane.setWindowDecorationStyle(JRootPane.FRAME);
143:                assertTrue("border != null", rootPane.getBorder() != null);
144:                assertTrue("installed border",
145:                        rootPane.getBorder() != saveBorder);
146:                assertTrue("layout != null", rootPane.getBorder() != null);
147:                assertTrue("installed layout",
148:                        rootPane.getLayout() != saveLayout);
149:                assertTrue("installed titlePane", rootPane.getLayeredPane()
150:                        .getComponentCount() == saveComponentCount + 1);
151:                // test windowDecorationStyle = JRootPane.NONE
152:                rootPane.setWindowDecorationStyle(JRootPane.NONE);
153:                assertTrue("uninstalled border",
154:                        rootPane.getBorder() == saveBorder);
155:                assertTrue("uninstalled layout",
156:                        rootPane.getLayout() == saveLayout);
157:                assertTrue("uninstalled titlePane", rootPane.getLayeredPane()
158:                        .getComponentCount() == saveComponentCount);
159:                // the border is not instanceof UIResource, must not be changed
160:                saveBorder = BorderFactory.createEmptyBorder();
161:                rootPane.setBorder(saveBorder);
162:                assertTrue("didn't install border",
163:                        rootPane.getBorder() == saveBorder);
164:            }
165:
166:            /*
167:             * Class under test for ComponentUI createUI(JComponent)
168:             */
169:            public void testCreateUI() {
170:                ComponentUI ui = MetalRootPaneUI.createUI(rootPane);
171:                assertTrue("not null", ui != null);
172:                assertTrue("instanceof MetalRootPaneUI",
173:                        ui instanceof  MetalRootPaneUI);
174:                ComponentUI ui2 = MetalRootPaneUI.createUI(rootPane);
175:                assertTrue("stateful", ui != ui2);
176:            }
177:
178:            /*
179:             * Class under test for MetalRootPaneUI()
180:             */
181:            public void testMetalRootPaneUI() {
182:                // test that it doesn't crash
183:                ui = new MetalRootPaneUI();
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.