Source Code Cross Referenced for BasicTableHeaderUITest.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 Anton Avtamonov
019:         * @version $Revision$
020:         */package javax.swing.plaf.basic;
021:
022:        import java.awt.Color;
023:        import java.awt.Component;
024:        import java.awt.Dimension;
025:        import java.awt.Font;
026:        import java.awt.Graphics;
027:        import java.awt.Label;
028:        import java.awt.event.MouseWheelEvent;
029:        import javax.swing.BasicSwingTestCase;
030:        import javax.swing.JTable;
031:        import javax.swing.UIManager;
032:        import javax.swing.plaf.ColorUIResource;
033:        import javax.swing.plaf.FontUIResource;
034:        import javax.swing.table.JTableHeader;
035:        import javax.swing.table.TableColumn;
036:        import org.apache.harmony.x.swing.Utilities;
037:
038:        public class BasicTableHeaderUITest extends BasicSwingTestCase {
039:
040:            private BasicTableHeaderUI ui;
041:
042:            private MouseWheelEvent mouseWheelEvent = new MouseWheelEvent(
043:                    new Label(), 0, 0, 0, 0, 0, 0, false, 0,
044:                    MouseWheelEvent.WHEEL_UNIT_SCROLL, 0);
045:
046:            public BasicTableHeaderUITest(final String name) {
047:                super (name);
048:            }
049:
050:            @Override
051:            protected void setUp() throws Exception {
052:                ui = new BasicTableHeaderUI();
053:            }
054:
055:            @Override
056:            protected void tearDown() throws Exception {
057:                ui = null;
058:            }
059:
060:            public void testCreateMouseInputListener() throws Exception {
061:                assertSame(BasicTableHeaderUI.MouseInputHandler.class, ui
062:                        .createMouseInputListener().getClass());
063:                assertNotSame(ui.createMouseInputListener(), ui
064:                        .createMouseInputListener());
065:            }
066:
067:            public void testCreate() throws Exception {
068:                assertSame(BasicTableHeaderUI.class, BasicTableHeaderUI
069:                        .createUI(null).getClass());
070:                assertNotSame(BasicTableHeaderUI.createUI(null),
071:                        BasicTableHeaderUI.createUI(null));
072:                assertNull(((BasicTableHeaderUI) BasicTableHeaderUI
073:                        .createUI(new JTableHeader())).header);
074:            }
075:
076:            public void testInstallUninstallUI() throws Exception {
077:                testExceptionalCase(new NullPointerCase() {
078:                    // Regression test for HARMONY-2613
079:                    @Override
080:                    public void exceptionalAction() throws Exception {
081:                        ui.uninstallUI(new JTable());
082:                    }
083:                });
084:                assertNull(ui.header);
085:                assertNull(ui.rendererPane);
086:                JTableHeader header = new JTableHeader();
087:                ui.installUI(header);
088:                assertSame(header, ui.header);
089:                assertNotNull(ui.rendererPane);
090:                assertTrue(ui.header.isOpaque());
091:                ui.uninstallUI(null);
092:                assertNull(ui.header);
093:                assertNull(ui.rendererPane);
094:            }
095:
096:            public void testInstallUninstallDefaults() throws Exception {
097:                testExceptionalCase(new NullPointerCase() {
098:                    // Regression test for HARMONY-2613
099:                    @Override
100:                    public void exceptionalAction() throws Exception {
101:                        ui.installDefaults();
102:                    }
103:                });
104:
105:                // Regression test for HARMONY-2613
106:                // Make sure it throws no exceptions
107:                ui.uninstallDefaults();
108:
109:                ui.header = new JTableHeader();
110:                ui.header.setForeground(new ColorUIResource(Color.RED));
111:                ui.header.setBackground(new ColorUIResource(Color.BLUE));
112:                ui.header.setFont(new FontUIResource(new Font("any", Font.BOLD,
113:                        20)));
114:                ui.installDefaults();
115:                assertEquals(UIManager.getColor("TableHeader.background"),
116:                        ui.header.getBackground());
117:                assertEquals(UIManager.getColor("TableHeader.foreground"),
118:                        ui.header.getForeground());
119:                assertEquals(UIManager.getFont("TableHeader.font"), ui.header
120:                        .getFont());
121:                ui.uninstallDefaults();
122:                if (isHarmony()) {
123:                    assertNull(ui.header.getForeground());
124:                    assertNull(ui.header.getBackground());
125:                    assertNull(ui.header.getFont());
126:                }
127:            }
128:
129:            public void testInstallUninstallListeners() throws Exception {
130:                assertNull(ui.mouseInputListener);
131:
132:                testExceptionalCase(new NullPointerCase() {
133:                    // Regression test for HARMONY-2613
134:                    @Override
135:                    public void exceptionalAction() throws Exception {
136:                        ui.installListeners();
137:                    }
138:                });
139:                testExceptionalCase(new NullPointerCase() {
140:                    // Regression test for HARMONY-2613
141:                    @Override
142:                    public void exceptionalAction() throws Exception {
143:                        ui.uninstallListeners();
144:                    }
145:                });
146:                ui.header = new JTableHeader();
147:                int mouseListenersCount = ui.header.getMouseListeners().length;
148:                int mouseMotionListenersCount = ui.header
149:                        .getMouseMotionListeners().length;
150:                ui.installListeners();
151:                assertEquals(mouseListenersCount + 1, ui.header
152:                        .getMouseListeners().length);
153:                assertEquals(mouseMotionListenersCount + 1, ui.header
154:                        .getMouseMotionListeners().length);
155:                assertNotNull(ui.mouseInputListener);
156:                ui.uninstallListeners();
157:                assertEquals(mouseListenersCount,
158:                        ui.header.getMouseListeners().length);
159:                assertEquals(mouseMotionListenersCount, ui.header
160:                        .getMouseMotionListeners().length);
161:                assertNull(ui.mouseInputListener);
162:            }
163:
164:            public void testInstallUninstallKeyboardActions() throws Exception {
165:                ui.header = new JTableHeader();
166:                ui.installKeyboardActions();
167:                assertTrue(Utilities.isEmptyArray(ui.header.getActionMap()
168:                        .allKeys()));
169:            }
170:
171:            public void testInstallKeyboardActions() throws Exception {
172:                // Regression test for HARMONY-2613
173:                // Make sure it throws no exceptions
174:                ui.installKeyboardActions();
175:            }
176:
177:            public void testUninstallKeyboardActions() throws Exception {
178:                // Regression test for HARMONY-2613
179:                // Make sure it throws no exceptions
180:                ui.uninstallKeyboardActions();
181:            }
182:
183:            public void testPaint() throws Exception {
184:                final Graphics g = createTestGraphics();
185:
186:                testExceptionalCase(new NullPointerCase() {
187:                    // Regression test for HARMONY-2613
188:                    @Override
189:                    public void exceptionalAction() throws Exception {
190:                        ui.paint(g, new JTable());
191:                    }
192:                });
193:                ui.installUI(new JTableHeader());
194:                ui.header.getColumnModel().addColumn(new TableColumn());
195:                g.setClip(0, 0, 100, 100);
196:                ui.paint(g, null);
197:            }
198:
199:            public void testGetMinimumMaximumPreferredSize() throws Exception {
200:                testExceptionalCase(new NullPointerCase() {
201:                    // Regression test for HARMONY-2613
202:                    @Override
203:                    public void exceptionalAction() throws Exception {
204:                        ui.getMinimumSize(new JTable());
205:                    }
206:                });
207:                testExceptionalCase(new NullPointerCase() {
208:                    // Regression test for HARMONY-2613
209:                    @Override
210:                    public void exceptionalAction() throws Exception {
211:                        ui.getMaximumSize(new JTable());
212:                    }
213:                });
214:                testExceptionalCase(new NullPointerCase() {
215:                    // Regression test for HARMONY-2613
216:                    @Override
217:                    public void exceptionalAction() throws Exception {
218:                        ui.getPreferredSize(new JTable());
219:                    }
220:                });
221:                ui.header = new JTableHeader();
222:                assertEquals(new Dimension(), ui.getMinimumSize(null));
223:                assertEquals(new Dimension(), ui.getMaximumSize(null));
224:                assertEquals(new Dimension(), ui.getPreferredSize(null));
225:                TableColumn column1 = new TableColumn(0, 30);
226:                column1.setMinWidth(20);
227:                column1.setMaxWidth(60);
228:                ui.header.getColumnModel().addColumn(column1);
229:                assertEquals(new Dimension(20, 0), ui.getMinimumSize(null));
230:                assertEquals(new Dimension(60, 0), ui.getMaximumSize(null));
231:                assertEquals(new Dimension(30, 0), ui.getPreferredSize(null));
232:                TableColumn column2 = new TableColumn(0, 40);
233:                column2.setMinWidth(30);
234:                column2.setMaxWidth(100);
235:                ui.header.getColumnModel().addColumn(column2);
236:                assertEquals(new Dimension(50, 0), ui.getMinimumSize(null));
237:                assertEquals(new Dimension(160, 0), ui.getMaximumSize(null));
238:                assertEquals(new Dimension(70, 0), ui.getPreferredSize(null));
239:                column1.setHeaderValue("any");
240:                Component renderingComponent = ui.header.getDefaultRenderer()
241:                        .getTableCellRendererComponent(null, "any", false,
242:                                false, 0, 0);
243:                assertEquals(new Dimension(50, renderingComponent
244:                        .getMinimumSize().height), ui.getMinimumSize(null));
245:                assertEquals(new Dimension(160, renderingComponent
246:                        .getMaximumSize().height), ui.getMaximumSize(null));
247:                assertEquals(new Dimension(70, renderingComponent
248:                        .getPreferredSize().height), ui.getPreferredSize(null));
249:            }
250:
251:            public void testMouseInputHandlerMouseEnteredNull()
252:                    throws Exception {
253:                // Regression test for HARMONY-1777
254:                new BasicTableHeaderUI().new MouseInputHandler()
255:                        .mouseEntered(null);
256:            }
257:
258:            public void testMouseInputHandlerMouseClicked() throws Exception {
259:                // Regression test for HARMONY-2613
260:                // Make sure it throws no exceptions
261:                ui.new MouseInputHandler().mouseClicked(mouseWheelEvent);
262:            }
263:
264:            public void testMouseInputHandlerMouseEntered() throws Exception {
265:                // Regression test for HARMONY-2613
266:                // Make sure it throws no exceptions
267:                ui.new MouseInputHandler().mouseEntered(mouseWheelEvent);
268:            }
269:
270:            public void testMouseInputHandlerMouseExited() throws Exception {
271:                // Regression test for HARMONY-2613
272:                // Make sure it throws no exceptions
273:                ui.new MouseInputHandler().mouseExited(mouseWheelEvent);
274:            }
275:
276:            public void testMouseInputHandlerMousePressed() throws Exception {
277:                testExceptionalCase(new NullPointerCase() {
278:                    // Regression test for HARMONY-2613
279:                    @Override
280:                    public void exceptionalAction() throws Exception {
281:                        ui.new MouseInputHandler()
282:                                .mousePressed(mouseWheelEvent);
283:                    }
284:                });
285:            }
286:
287:            public void testMouseInputHandlerMouseReleased() throws Exception {
288:                testExceptionalCase(new NullPointerCase() {
289:                    // Regression test for HARMONY-2613
290:                    @Override
291:                    public void exceptionalAction() throws Exception {
292:                        ui.new MouseInputHandler()
293:                                .mouseReleased(mouseWheelEvent);
294:                    }
295:                });
296:            }
297:
298:            public void testMouseInputHandlerMouseDragged() throws Exception {
299:                testExceptionalCase(new NullPointerCase() {
300:                    // Regression test for HARMONY-2613
301:                    @Override
302:                    public void exceptionalAction() throws Exception {
303:                        ui.new MouseInputHandler()
304:                                .mouseDragged(mouseWheelEvent);
305:                    }
306:                });
307:            }
308:
309:            public void testMouseInputHandlerMouseMoved() throws Exception {
310:                testExceptionalCase(new NullPointerCase() {
311:                    // Regression test for HARMONY-2613
312:                    @Override
313:                    public void exceptionalAction() throws Exception {
314:                        ui.new MouseInputHandler().mouseMoved(mouseWheelEvent);
315:                    }
316:                });
317:            }
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.