Source Code Cross Referenced for BasicDesktopIconUITest.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.Insets;
024:        import java.beans.PropertyVetoException;
025:        import javax.swing.JInternalFrame;
026:        import javax.swing.SwingTestCase;
027:        import javax.swing.event.MouseInputListener;
028:        import javax.swing.plaf.ComponentUI;
029:
030:        public class BasicDesktopIconUITest extends SwingTestCase {
031:            private static boolean belongs(final Object o, final Object[] array) {
032:                for (int i = 0; i < array.length; i++) {
033:                    if (array[i] == o) {
034:                        return true;
035:                    }
036:                }
037:                return false;
038:            }
039:
040:            private static class MyBasicDesktopIconUI extends
041:                    BasicDesktopIconUI {
042:                public MouseInputListener mouseInputListener;
043:
044:                @Override
045:                protected MouseInputListener createMouseInputListener() {
046:                    mouseInputListener = super .createMouseInputListener();
047:                    return mouseInputListener;
048:                }
049:            }
050:
051:            private MyBasicDesktopIconUI ui;
052:
053:            private JInternalFrame.JDesktopIcon icon;
054:
055:            private JInternalFrame frame;
056:
057:            /*
058:             * @see TestCase#setUp()
059:             */
060:            @Override
061:            protected void setUp() throws Exception {
062:                super .setUp();
063:                frame = new JInternalFrame();
064:                icon = frame.getDesktopIcon();
065:                ui = new MyBasicDesktopIconUI();
066:                icon.setUI(ui);
067:            }
068:
069:            /*
070:             * @see TestCase#tearDown()
071:             */
072:            @Override
073:            protected void tearDown() throws Exception {
074:                super .tearDown();
075:            }
076:
077:            public BasicDesktopIconUITest(final String name) {
078:                super (name);
079:            }
080:
081:            /*
082:             * Class under test for ComponentUI createUI(JComponent)
083:             */
084:            public void testCreateUI() {
085:                ComponentUI ui1 = BasicDesktopIconUI.createUI(frame);
086:                ComponentUI ui2 = BasicDesktopIconUI.createUI(frame);
087:                assertTrue("not null", ui1 != null);
088:                assertTrue("stateful", ui1 != ui2);
089:            }
090:
091:            /*
092:             * Class under test for BasicDesktopIconUI()
093:             */
094:            public void testBasicDesktopIconUI() {
095:                // nothing to test
096:            }
097:
098:            /*
099:             * Class under test for MouseInputListener createMouseInputListener()
100:             */
101:            public void testCreateMouseInputListener() {
102:                MouseInputListener l1 = ui.createMouseInputListener();
103:                MouseInputListener l2 = ui.createMouseInputListener();
104:                assertTrue("not null", l1 != null);
105:                if (isHarmony()) {
106:                    assertSame("the same instance", l1, l2);
107:                }
108:            }
109:
110:            /*
111:             * Class under test for void deiconize()
112:             */
113:            public void testDeiconize() {
114:                try {
115:                    frame.setIcon(true);
116:                } catch (PropertyVetoException e) {
117:                }
118:                assertTrue("is icon", frame.isIcon());
119:                ui.deiconize();
120:                assertFalse("deiconized", frame.isIcon());
121:            }
122:
123:            /*
124:             * Class under test for Insets getInsets(JComponent)
125:             */
126:            public void testGetInsets() {
127:                final Insets validInsets = new Insets(5, 5, 5, 5);
128:                Insets insets = ui.getInsets(icon);
129:                assertTrue("not null", insets != null);
130:                assertEquals("ok", validInsets, insets);
131:                try { //Regression test for HARMONY-2664
132:                    ui.getInsets(null);
133:                    fail("NullPointerException should have been thrown");
134:                } catch (NullPointerException e) {
135:                    // Expected
136:                }
137:            }
138:
139:            /*
140:             * Class under test for Dimension getMaximumSize(JComponent)
141:             */
142:            public void testGetMaximumSize() {
143:                if (isHarmony()) {
144:                    assertEquals("== minimumSize", ui.getMinimumSize(icon), ui
145:                            .getMaximumSize(icon));
146:                }
147:            }
148:
149:            /*
150:             * Class under test for Dimension getMinimumSize(JComponent)
151:             */
152:            public void testGetMinimumSize() {
153:                if (isHarmony()) {
154:                    assertEquals("== preferredSize", ui.getPreferredSize(icon),
155:                            ui.getMinimumSize(icon));
156:                }
157:            }
158:
159:            /*
160:             * Class under test for Dimension getPreferredSize(JComponent)
161:             */
162:            public void testGetPreferredSize() {
163:                icon.setSize(ui.getPreferredSize(icon));
164:                icon.doLayout();
165:                assertEquals(ui.iconPane.getPreferredSize(), ui.iconPane
166:                        .getSize());
167:            }
168:
169:            /*
170:             * Class under test for void installComponents()
171:             */
172:            public void testInstallComponents() {
173:                int count = icon.getComponentCount();
174:                ui.uninstallComponents();
175:                assertEquals("uninstalled", count - 1, icon.getComponentCount());
176:                ui.installComponents();
177:                assertEquals("added 1 component", count, icon
178:                        .getComponentCount());
179:                assertTrue("added iconPane", icon.isAncestorOf(ui.iconPane));
180:            }
181:
182:            /*
183:             * Class under test for void uninstallComponents()
184:             */
185:            public void testUninstallComponents() {
186:                int count = icon.getComponentCount();
187:                assertTrue("added iconPane", icon.isAncestorOf(ui.iconPane));
188:                ui.uninstallComponents();
189:                assertEquals("uninstalled", count - 1, icon.getComponentCount());
190:                assertFalse("removed iconPane", icon.isAncestorOf(ui.iconPane));
191:            }
192:
193:            /*
194:             * Class under test for void installDefaults()
195:             */
196:            public void testInstallDefaults() {
197:                icon.setBorder(null);
198:                icon.setLayout(null);
199:                ui.installDefaults();
200:                assertTrue("opaque", icon.isOpaque());
201:                assertTrue("border", icon.getBorder() != null);
202:                assertNull("layout", icon.getLayout());
203:            }
204:
205:            /*
206:             * Class under test for void uninstallDefaults()
207:             */
208:            public void testUninstallDefaults() {
209:                ui.uninstallDefaults();
210:                assertNull("border", icon.getBorder());
211:                assertTrue("layout", icon.getLayout() instanceof  BorderLayout);
212:            }
213:
214:            /*
215:             * Class under test for void installListeners()
216:             */
217:            public void testInstallListeners() {
218:                ui.uninstallListeners();
219:                ui.installListeners();
220:                MouseInputListener listener = ui.mouseInputListener;
221:                assertTrue("installed mouseListener", belongs(listener, icon
222:                        .getMouseListeners()));
223:                assertTrue("installed mouseMotionListener", belongs(listener,
224:                        icon.getMouseMotionListeners()));
225:            }
226:
227:            /*
228:             * Class under test for void uninstallListeners()
229:             */
230:            public void testUninstallListeners() {
231:                MouseInputListener listener = ui.createMouseInputListener();
232:                ui.uninstallListeners();
233:                assertFalse("uninstalled mouseListener", belongs(listener, icon
234:                        .getMouseListeners()));
235:                assertFalse("uninstalled mouseMotionListener", belongs(
236:                        listener, icon.getMouseMotionListeners()));
237:            }
238:
239:            /*
240:             * Class under test for void installUI(JComponent)
241:             */
242:            public void testInstallUI() {
243:                assertTrue("desktopIcon", ui.desktopIcon == icon);
244:                assertTrue("frame", ui.frame == frame);
245:                assertTrue("iconPane", ui.iconPane != null);
246:                assertTrue("width != 0", icon.getWidth() != 0);
247:                assertTrue("height != 0", icon.getHeight() != 0);
248:            }
249:
250:            /*
251:             * Class under test for void uninstallUI(JComponent)
252:             */
253:            public void testUninstallUI() {
254:                // test that no crash occur
255:                ui.uninstallUI(icon);
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.