Source Code Cross Referenced for JDesktopPaneTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » 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 
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;
021:
022:        import java.beans.PropertyChangeEvent;
023:        import java.beans.PropertyChangeListener;
024:        import java.beans.PropertyVetoException;
025:        import javax.accessibility.AccessibleContext;
026:        import javax.accessibility.AccessibleRole;
027:        import javax.swing.plaf.ComponentUI;
028:        import javax.swing.plaf.basic.BasicDesktopPaneUI;
029:
030:        public class JDesktopPaneTest extends SwingTestCase {
031:            /*
032:             * This class is used to test protected methods.
033:             */
034:            private class TestJDesktopPane extends JDesktopPane {
035:                private static final long serialVersionUID = 1L;
036:
037:                @Override
038:                public String paramString() {
039:                    return super .paramString();
040:                }
041:            }
042:
043:            /*
044:             * This class is used to test that some property is (or is not) a bound property
045:             */
046:            private class MyPropertyChangeListener implements 
047:                    PropertyChangeListener {
048:                public boolean ok;
049:
050:                MyPropertyChangeListener() {
051:                    ok = false;
052:                }
053:
054:                public void propertyChange(final PropertyChangeEvent e) {
055:                    ok = true;
056:                }
057:            }
058:
059:            private JDesktopPane desktop;
060:
061:            public JDesktopPaneTest(final String name) {
062:                super (name);
063:            }
064:
065:            /*
066:             * @see TestCase#setUp()
067:             */
068:            @Override
069:            protected void setUp() throws Exception {
070:                super .setUp();
071:                desktop = new JDesktopPane();
072:            }
073:
074:            /*
075:             * @see TestCase#tearDown()
076:             */
077:            @Override
078:            protected void tearDown() throws Exception {
079:                super .tearDown();
080:            }
081:
082:            /*
083:             * Class under test for boolean isOpaque()
084:             */
085:            public void testIsOpaque() {
086:                assertTrue("always returns true", desktop.isOpaque());
087:                desktop.setOpaque(false);
088:                assertTrue("always returns true", desktop.isOpaque());
089:            }
090:
091:            /*
092:             * Class under test for void updateUI()
093:             */
094:            public void testUpdateUI() {
095:                desktop.updateUI();
096:                ComponentUI ui1 = desktop.getUI();
097:                ComponentUI ui2 = UIManager.getUI(desktop);
098:                // at least names of classes must be the same
099:                assertEquals(ui2.getClass().getName(), ui1.getClass().getName());
100:            }
101:
102:            /*
103:             * Class under test for AccessibleContext getAccessibleContext()
104:             */
105:            public void testGetAccessibleContext() {
106:                AccessibleContext c = desktop.getAccessibleContext();
107:                assertTrue("instanceof AccessibleJDesktopPane",
108:                        c instanceof  JDesktopPane.AccessibleJDesktopPane);
109:                assertTrue("AccessibleRole is ok",
110:                        c.getAccessibleRole() == AccessibleRole.DESKTOP_PANE);
111:            }
112:
113:            /*
114:             * Class under test for String paramString()
115:             */
116:            public void testParamString() {
117:                TestJDesktopPane desktop = new TestJDesktopPane();
118:                assertTrue(desktop.paramString() != null);
119:            }
120:
121:            public void testJDesktopPane() {
122:                desktop = new JDesktopPane();
123:                assertTrue(desktop.isFocusCycleRoot());
124:                assertFalse(desktop.isFocusTraversalPolicyProvider());
125:                assertTrue("ui != null", desktop.getUI() != null);
126:            }
127:
128:            /*
129:             * Class under test for
130:             *     void setUI(DesktopPaneUI)
131:             *     DesktopPaneUI getUI()
132:             */
133:            public void testSetGetUI() {
134:                BasicDesktopPaneUI ui = new BasicDesktopPaneUI();
135:                desktop.setUI(ui);
136:                assertTrue("UI is set", desktop.getUI() == ui);
137:            }
138:
139:            /*
140:             * Class under test for
141:             *     void setSelectedFrame(JInternalFrame)
142:             *     JInternalFrame getSelectedFrame()
143:             */
144:            public void testSetGetSelectedFrame() {
145:                JInternalFrame f = new JInternalFrame();
146:                assertNull("null by default", desktop.getSelectedFrame());
147:                desktop.setSelectedFrame(f);
148:                assertTrue("is set", desktop.getSelectedFrame() == f);
149:                desktop.setSelectedFrame(null);
150:                assertNull("is set to null", desktop.getSelectedFrame());
151:            }
152:
153:            /*
154:             * Adds some components to the desktop.
155:             */
156:            private void addComponents() {
157:                // add one frame, layer 0
158:                JInternalFrame frame1 = new JInternalFrame("frame1");
159:                frame1.setVisible(true);
160:                desktop.add(frame1);
161:                // add iconified frame, layer 1
162:                JInternalFrame frame2 = new JInternalFrame("frame2");
163:                frame2.setVisible(true);
164:                frame2.setLayer(1);
165:                desktop.add(frame2);
166:                try {
167:                    frame2.setIcon(true);
168:                } catch (PropertyVetoException e) {
169:                    assertFalse("exception", true);
170:                }
171:                // add some non JInternalFrame component
172:                JComponent comp = new JPanel();
173:                desktop.add(comp);
174:            }
175:
176:            /*
177:             * Class under test for JInternalFrame[] getAllFrames()
178:             */
179:            public void testGetAllFrames() {
180:                JInternalFrame[] frames = desktop.getAllFrames();
181:                assertTrue("empty array", frames.length == 0);
182:                addComponents();
183:                frames = desktop.getAllFrames();
184:                assertTrue("2 frames", frames.length == 2);
185:            }
186:
187:            /*
188:             * Class under test for JInternalFrame[] getAllFramesInLayer(int)
189:             */
190:            public void testGetAllFramesInLayer() {
191:                JInternalFrame[] frames; // = desktop.getAllFramesInLayer(1);
192:                //assertTrue("empty array", frames.length == 0);
193:                addComponents();
194:                frames = desktop.getAllFramesInLayer(0);
195:                assertTrue("1 frame", frames.length == 1);
196:                assertTrue("frame1", frames[0].getTitle() == "frame1");
197:                // invisible frames are counted
198:                frames[0].setVisible(false);
199:                frames = desktop.getAllFramesInLayer(0);
200:                assertTrue("1 frame", frames.length == 1);
201:                // iconified frames are counted
202:                frames = desktop.getAllFramesInLayer(1);
203:                assertTrue("1 frame", frames.length == 1);
204:                assertTrue("frame2", frames[0].getTitle() == "frame2");
205:                // no frames in this layer
206:                frames = desktop.getAllFramesInLayer(2);
207:                assertTrue("empty array", frames.length == 0);
208:            }
209:
210:            /*
211:             * Class under test for
212:             *     void setDesktopManager(DesktopManager)
213:             *     DesktopManager getDesktopManager()
214:             */
215:            public void testSetGetDesktopManager() {
216:                MyPropertyChangeListener l = new MyPropertyChangeListener();
217:                DesktopManager m = new DefaultDesktopManager();
218:                assertTrue("not null by default",
219:                        desktop.getDesktopManager() != null);
220:                desktop.addPropertyChangeListener("desktopManager", l);
221:                desktop.setDesktopManager(m);
222:                assertTrue("is set", desktop.getDesktopManager() == m);
223:                assertTrue("bound property", l.ok);
224:                desktop.setDesktopManager(null);
225:                assertTrue("is not set to null",
226:                        desktop.getDesktopManager() != null);
227:            }
228:
229:            /*
230:             * Class under test for String getUIClassID()
231:             */
232:            public void testGetUIClassID() {
233:                assertTrue("", desktop.getUIClassID() == "DesktopPaneUI");
234:            }
235:
236:            /*
237:             * Class under test for
238:             *     void setDragMode(int)
239:             *     int getDragMode()
240:             */
241:            public void testSetGetDragMode() {
242:                assertTrue("initial ok",
243:                        desktop.getDragMode() == JDesktopPane.LIVE_DRAG_MODE);
244:                desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
245:                assertTrue("set",
246:                        desktop.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE);
247:                desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
248:                assertTrue("set",
249:                        desktop.getDragMode() == JDesktopPane.LIVE_DRAG_MODE);
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.