Source Code Cross Referenced for BasicTableUITest.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.Dimension;
023:        import java.awt.Graphics;
024:        import java.awt.Label;
025:        import java.awt.event.FocusEvent;
026:        import java.awt.event.KeyEvent;
027:        import java.awt.event.MouseWheelEvent;
028:        import javax.swing.BasicSwingTestCase;
029:        import javax.swing.CellRendererPane;
030:        import javax.swing.JTable;
031:        import javax.swing.UIManager;
032:        import javax.swing.table.DefaultTableModel;
033:        import javax.swing.table.TableColumn;
034:
035:        public class BasicTableUITest extends BasicSwingTestCase {
036:            private BasicTableUI ui;
037:
038:            private FocusEvent focusEvent = new FocusEvent(new JTable(), 0);
039:
040:            private KeyEvent keyEvent = new KeyEvent(new JTable(), 0, 0, 0, 0);
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 BasicTableUITest(final String name) {
047:                super (name);
048:            }
049:
050:            @Override
051:            protected void setUp() throws Exception {
052:                ui = new BasicTableUI();
053:            }
054:
055:            @Override
056:            protected void tearDown() throws Exception {
057:                ui = null;
058:            }
059:
060:            public void testBasicTableUI() throws Exception {
061:                assertNull(ui.table);
062:                assertNull(ui.rendererPane);
063:                assertNull(ui.focusListener);
064:                assertNull(ui.keyListener);
065:                assertNull(ui.mouseInputListener);
066:            }
067:
068:            public void testCreateKeyListener() throws Exception {
069:                assertNull(ui.createKeyListener());
070:            }
071:
072:            public void testCreateFocusListener() throws Exception {
073:                assertTrue(ui.createFocusListener() instanceof  BasicTableUI.FocusHandler);
074:                assertNotSame(ui.createFocusListener(), ui
075:                        .createFocusListener());
076:                assertNull(ui.focusListener);
077:            }
078:
079:            public void testCreateMouseInputListener() throws Exception {
080:                assertTrue(ui.createMouseInputListener() instanceof  BasicTableUI.MouseInputHandler);
081:                assertNotSame(ui.createMouseInputListener(), ui
082:                        .createMouseInputListener());
083:                assertNull(ui.mouseInputListener);
084:            }
085:
086:            public void testCreateUI() throws Exception {
087:                assertSame(BasicTableUI.createUI(null).getClass(),
088:                        BasicTableUI.class);
089:                assertNotSame(BasicTableUI.createUI(null), BasicTableUI
090:                        .createUI(null));
091:            }
092:
093:            public void testInstallUI() throws Exception {
094:                JTable table = new JTable();
095:                ui.installUI(table);
096:                assertSame(table, ui.table);
097:                assertNotNull(ui.rendererPane);
098:            }
099:
100:            public void testUninstallUI() throws Exception {
101:                testExceptionalCase(new NullPointerCase() {
102:                    // Regression test for HARMONY-2613
103:                    @Override
104:                    public void exceptionalAction() throws Exception {
105:                        ui.uninstallUI(new JTable());
106:                    }
107:                });
108:                JTable table = new JTable();
109:                ui.installUI(table);
110:                ui.uninstallUI(null);
111:                assertNull(ui.table);
112:                assertNull(ui.rendererPane);
113:            }
114:
115:            public void testGetMinimumMaximumPreferredSize() throws Exception {
116:                JTable table = new JTable();
117:                testExceptionalCase(new NullPointerCase() {
118:                    // Regression test for HARMONY-2613
119:                    @Override
120:                    public void exceptionalAction() throws Exception {
121:                        ui.getMinimumSize(new JTable());
122:                    }
123:                });
124:                testExceptionalCase(new NullPointerCase() {
125:                    // Regression test for HARMONY-2613
126:                    @Override
127:                    public void exceptionalAction() throws Exception {
128:                        ui.getMaximumSize(new JTable());
129:                    }
130:                });
131:                testExceptionalCase(new NullPointerCase() {
132:                    // Regression test for HARMONY-2613
133:                    @Override
134:                    public void exceptionalAction() throws Exception {
135:                        ui.getPreferredSize(new JTable());
136:                    }
137:                });
138:                ui.table = table;
139:                assertEquals(new Dimension(), ui.getMinimumSize(null));
140:                TableColumn column1 = new TableColumn();
141:                column1.setMinWidth(20);
142:                column1.setPreferredWidth(50);
143:                column1.setMaxWidth(100);
144:                table.addColumn(column1);
145:                assertEquals(new Dimension(20, 0), ui.getMinimumSize(null));
146:                assertEquals(new Dimension(100, 0), ui.getMaximumSize(null));
147:                assertEquals(new Dimension(50, 0), ui.getPreferredSize(null));
148:                TableColumn column2 = new TableColumn();
149:                column2.setMinWidth(10);
150:                column2.setPreferredWidth(20);
151:                column2.setMaxWidth(40);
152:                table.addColumn(column2);
153:                assertEquals(new Dimension(30, 0), ui.getMinimumSize(null));
154:                assertEquals(new Dimension(140, 0), ui.getMaximumSize(null));
155:                assertEquals(new Dimension(70, 0), ui.getPreferredSize(null));
156:                table.setRowHeight(30);
157:                ((DefaultTableModel) table.getModel())
158:                        .addRow(new Object[] { "1" });
159:                assertEquals(new Dimension(30, 30), ui.getMinimumSize(null));
160:                assertEquals(new Dimension(140, 30), ui.getMaximumSize(null));
161:                assertEquals(new Dimension(70, 30), ui.getPreferredSize(null));
162:                ((DefaultTableModel) table.getModel()).addRow(new Object[] {
163:                        "2", "2" });
164:                table.setRowHeight(1, 20);
165:                assertEquals(new Dimension(30, 50), ui.getMinimumSize(null));
166:                assertEquals(new Dimension(140, 50), ui.getMaximumSize(null));
167:                assertEquals(new Dimension(70, 50), ui.getPreferredSize(null));
168:            }
169:
170:            public void testPaint() throws Exception {
171:                ui.table = new JTable();
172:                DefaultTableModel model = (DefaultTableModel) ui.table
173:                        .getModel();
174:                model.addColumn("column1");
175:                model.addRow(new Object[] { "1" });
176:                ui.rendererPane = new CellRendererPane();
177:                Graphics g = createTestGraphics();
178:                g.setClip(0, 0, 100, 100);
179:                ui.paint(g, null);
180:            }
181:
182:            public void testPaint_Null() throws Exception {
183:                try {
184:                    // Regression test for HARMONY-1776
185:                    ui.paint(null, null);
186:                    fail("NullPointerException should have been thrown");
187:                } catch (NullPointerException e) {
188:                    // Expected
189:                }
190:
191:                testExceptionalCase(new NullPointerCase() {
192:                    // Regression test for HARMONY-2613
193:                    @Override
194:                    public void exceptionalAction() throws Exception {
195:                        ui.paint(createTestGraphics(), new JTable());
196:                    }
197:                });
198:            }
199:
200:            public void testInstallDefaults() throws Exception {
201:                testExceptionalCase(new NullPointerCase() {
202:                    // Regression test for HARMONY-2613
203:                    @Override
204:                    public void exceptionalAction() throws Exception {
205:                        ui.installDefaults();
206:                    }
207:                });
208:                ui.table = new JTable();
209:                ui.installDefaults();
210:                assertSame(UIManager.getFont("Table.font"), ui.table.getFont());
211:                assertSame(UIManager.getColor("Table.gridColor"), ui.table
212:                        .getGridColor());
213:                assertSame(UIManager.getColor("Table.foreground"), ui.table
214:                        .getForeground());
215:                assertSame(UIManager.getColor("Table.background"), ui.table
216:                        .getBackground());
217:                assertSame(UIManager.getColor("Table.selectionForeground"),
218:                        ui.table.getSelectionForeground());
219:                assertSame(UIManager.getColor("Table.selectionBackground"),
220:                        ui.table.getSelectionBackground());
221:            }
222:
223:            public void testInstallKeyboardActions() throws Exception {
224:                testExceptionalCase(new NullPointerCase() {
225:                    // Regression test for HARMONY-2613
226:                    @Override
227:                    public void exceptionalAction() throws Exception {
228:                        ui.installKeyboardActions();
229:                    }
230:                });
231:            }
232:
233:            public void testUninstallDefaults() throws Exception {
234:                testExceptionalCase(new NullPointerCase() {
235:                    // Regression test for HARMONY-2613
236:                    @Override
237:                    public void exceptionalAction() throws Exception {
238:                        ui.uninstallDefaults();
239:                    }
240:                });
241:            }
242:
243:            public void testUninstallKeyboardActions() throws Exception {
244:                testExceptionalCase(new NullPointerCase() {
245:                    // Regression test for HARMONY-2613
246:                    @Override
247:                    public void exceptionalAction() throws Exception {
248:                        ui.uninstallKeyboardActions();
249:                    }
250:                });
251:            }
252:
253:            public void testInstallListeners() throws Exception {
254:                testExceptionalCase(new NullPointerCase() {
255:                    // Regression test for HARMONY-2613
256:                    @Override
257:                    public void exceptionalAction() throws Exception {
258:                        ui.installListeners();
259:                    }
260:                });
261:            }
262:
263:            public void testUninstallListeners() throws Exception {
264:                testExceptionalCase(new NullPointerCase() {
265:                    // Regression test for HARMONY-2613
266:                    @Override
267:                    public void exceptionalAction() throws Exception {
268:                        ui.uninstallListeners();
269:                    }
270:                });
271:            }
272:
273:            public void testFocusHandlerFocusGained() throws Exception {
274:                testExceptionalCase(new NullPointerCase() {
275:                    // Regression test for HARMONY-2613
276:                    @Override
277:                    public void exceptionalAction() throws Exception {
278:                        ui.new FocusHandler().focusGained(focusEvent);
279:                    }
280:                });
281:            }
282:
283:            public void testFocusHandlerFocusLost() throws Exception {
284:                testExceptionalCase(new NullPointerCase() {
285:                    // Regression test for HARMONY-2613
286:                    @Override
287:                    public void exceptionalAction() throws Exception {
288:                        ui.new FocusHandler().focusLost(focusEvent);
289:                    }
290:                });
291:            }
292:
293:            public void testKeyHandlerKeyPressed() throws Exception {
294:                // Regression test for HARMONY-2613
295:                // Make sure it throws no exceptions
296:                ui.new KeyHandler().keyPressed(keyEvent);
297:            }
298:
299:            public void testKeyHandlerKeyReleased() throws Exception {
300:                // Regression test for HARMONY-2613
301:                // Make sure it throws no exceptions
302:                ui.new KeyHandler().keyReleased(keyEvent);
303:            }
304:
305:            public void testFocusHandlerKeyTyped() throws Exception {
306:                testExceptionalCase(new NullPointerCase() {
307:                    // Regression test for HARMONY-2613
308:                    @Override
309:                    public void exceptionalAction() throws Exception {
310:                        ui.new KeyHandler().keyTyped(keyEvent);
311:                    }
312:                });
313:            }
314:
315:            public void testMouseInputHandlerMouseClicked() throws Exception {
316:                // Regression test for HARMONY-2613
317:                // Make sure it throws no exceptions
318:                ui.new MouseInputHandler().mouseClicked(mouseWheelEvent);
319:            }
320:
321:            public void testMouseInputHandlerMouseEntered() throws Exception {
322:                // Regression test for HARMONY-2613
323:                // Make sure it throws no exceptions
324:                ui.new MouseInputHandler().mouseEntered(mouseWheelEvent);
325:            }
326:
327:            public void testMouseInputHandlerMouseExited() throws Exception {
328:                // Regression test for HARMONY-2613
329:                // Make sure it throws no exceptions
330:                ui.new MouseInputHandler().mouseExited(mouseWheelEvent);
331:            }
332:
333:            public void testMouseInputHandlerMousePressed() throws Exception {
334:                // Regression test for HARMONY-2613
335:                // Make sure it throws no exceptions
336:                ui.new MouseInputHandler().mousePressed(mouseWheelEvent);
337:            }
338:
339:            public void testMouseInputHandlerMouseReleased() throws Exception {
340:                // Regression test for HARMONY-2613
341:                // Make sure it throws no exceptions
342:                ui.new MouseInputHandler().mouseReleased(mouseWheelEvent);
343:            }
344:
345:            public void testMouseInputHandlerMouseDragged() throws Exception {
346:                // Regression test for HARMONY-2613
347:                // Make sure it throws no exceptions
348:                ui.new MouseInputHandler().mouseDragged(mouseWheelEvent);
349:            }
350:
351:            public void testMouseInputHandlerMouseMoved() throws Exception {
352:                // Regression test for HARMONY-2613
353:                // Make sure it throws no exceptions
354:                ui.new MouseInputHandler().mouseMoved(mouseWheelEvent);
355:            }
356:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.