Source Code Cross Referenced for VariableHeightLayoutCacheTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » tree » 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.tree 
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 Alexander T. Simbirtsev
019:         * @version $Revision$
020:         */package javax.swing.tree;
021:
022:        import java.awt.Rectangle;
023:
024:        public class VariableHeightLayoutCacheTest extends
025:                AbstractLayoutCacheTest {
026:            @Override
027:            protected void setUp() throws Exception {
028:                super .setUp();
029:                cache = new VariableHeightLayoutCache();
030:                defaultRowValue = cache.getRowForPath(null);
031:            }
032:
033:            @Override
034:            protected void tearDown() throws Exception {
035:                super .tearDown();
036:            }
037:
038:            /*
039:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.VariableHeightLayoutCache()'
040:             */
041:            @Override
042:            public void testLayoutCache() {
043:                assertFalse(cache.rootVisible);
044:                assertNull(cache.nodeDimensions);
045:                assertEquals(0, cache.rowHeight);
046:                assertNull(cache.treeModel);
047:                assertNull(cache.treeSelectionModel);
048:            }
049:
050:            /*
051:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.setRootVisible(boolean)'
052:             */
053:            @Override
054:            public void testSetRootVisible() {
055:                super .testSetRootVisible();
056:                int height = 1111;
057:                cache.setRowHeight(height);
058:                TreeModel model = new UndefaultTreeModel(root);
059:                root.add(node1);
060:                root.add(node2);
061:                cache.setModel(model);
062:                cache.setNodeDimensions(dimensions2);
063:                if (isHarmony()) {
064:                    assertEquals(new Rectangle(0, -1111, 100, 1111), cache
065:                            .getBounds(rootPath, null));
066:                } else {
067:                    assertEquals(new Rectangle(0, -1, 100, 1111), cache
068:                            .getBounds(rootPath, null));
069:                }
070:                assertEquals(new Rectangle(10, 0 * height, 100, height), cache
071:                        .getBounds(path1, null));
072:                assertEquals(new Rectangle(10, 1 * height, 100, height), cache
073:                        .getBounds(path2, null));
074:                cache.setRootVisible(true);
075:                assertEquals(new Rectangle(0, 0, 100, 1111), cache.getBounds(
076:                        rootPath, null));
077:                assertEquals(new Rectangle(10, 1 * height, 100, height), cache
078:                        .getBounds(path1, null));
079:                assertEquals(new Rectangle(10, 2 * height, 100, height), cache
080:                        .getBounds(path2, null));
081:            }
082:
083:            /*
084:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.setRowHeight(int)'
085:             */
086:            @Override
087:            public void testSetRowHeight() {
088:                cache.setRowHeight(100);
089:                assertEquals(100, cache.getRowHeight());
090:                cache.setRowHeight(200);
091:                assertEquals(200, cache.getRowHeight());
092:                cache.setRowHeight(-1);
093:                assertEquals(-1, cache.getRowHeight());
094:            }
095:
096:            /*
097:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.getPreferredHeight()'
098:             */
099:            @Override
100:            public void testGetPreferredHeight() {
101:                int height = 1111;
102:                TreeModel model = new UndefaultTreeModel(root);
103:                root.add(node1);
104:                root.add(node2);
105:                cache.setRowHeight(height);
106:                assertEquals(0, cache.getPreferredHeight());
107:                cache.setModel(model);
108:                assertEquals(2222, cache.getPreferredHeight());
109:                cache.setRowHeight(-100);
110:                assertEquals(0, cache.getPreferredHeight());
111:                cache.setRowHeight(height);
112:                cache.setNodeDimensions(dimensions3);
113:                assertEquals(2222, cache.getPreferredHeight());
114:                cache.setRootVisible(true);
115:                assertEquals(3333, cache.getPreferredHeight());
116:                cache.setRowHeight(-100);
117:                assertEquals(6000, cache.getPreferredHeight());
118:                cache.setRootVisible(false);
119:                if (isHarmony()) {
120:                    assertEquals(3000, cache.getPreferredHeight());
121:                } else {
122:                    assertEquals(5000, cache.getPreferredHeight());
123:                }
124:            }
125:
126:            /*
127:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.getPreferredWidth(Rectangle)'
128:             */
129:            @Override
130:            public void testGetPreferredWidth() {
131:                int height = 1111;
132:                TreeModel model = new DefaultTreeModel(root);
133:                root.add(node1);
134:                root.add(node2);
135:                node1.add(node3);
136:                node1.add(node4);
137:                node2.add(node5);
138:                node2.add(node6);
139:                cache.setRowHeight(height);
140:                assertEquals(0, cache.getPreferredWidth(null));
141:                cache.setModel(model);
142:                assertEquals(0, cache.getPreferredWidth(null));
143:                cache.setRowHeight(-100);
144:                assertEquals(0, cache.getPreferredWidth(null));
145:                cache.setNodeDimensions(dimensions2);
146:                assertEquals(110, cache.getPreferredWidth(new Rectangle(0, 0,
147:                        0, 0)));
148:                assertEquals(20, cache.getPreferredHeight());
149:                assertEquals(110, cache.getPreferredWidth(new Rectangle(0,
150:                        3010, 10, 10)));
151:                cache.setRootVisible(true);
152:                assertEquals(110, cache.getPreferredWidth(new Rectangle(0, 0,
153:                        50, 100)));
154:                cache.setExpandedState(path1, true);
155:                if (!isHarmony()) {
156:                    assertEquals(120, cache.getPreferredWidth(new Rectangle(0,
157:                            0, 0, 0)));
158:                } else {
159:                    assertEquals(100, cache.getPreferredWidth(new Rectangle(0,
160:                            0, 0, 0)));
161:                }
162:                assertEquals(120, cache.getPreferredWidth(null));
163:                cache.setExpandedState(path1, false);
164:                cache.setExpandedState(path2, true);
165:                if (!isHarmony()) {
166:                    assertEquals(120, cache.getPreferredWidth(new Rectangle(0,
167:                            0, 0, 0)));
168:                } else {
169:                    assertEquals(100, cache.getPreferredWidth(new Rectangle(0,
170:                            0, 0, 0)));
171:                }
172:                assertEquals(120, cache.getPreferredWidth(null));
173:            }
174:
175:            /*
176:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.getBounds(TreePath, Rectangle)'
177:             */
178:            public void testGetBounds() {
179:                int height = 1111;
180:                cache.setRowHeight(height);
181:                TreeModel model = new UndefaultTreeModel(root);
182:                root.add(node1);
183:                root.add(node2);
184:                node1.add(node3);
185:                node1.add(node4);
186:                node2.add(node5);
187:                node2.add(node6);
188:                cache.setModel(model);
189:                cache.setExpandedState(rootPath, false);
190:                assertNull(cache.getBounds(path1, new Rectangle()));
191:                cache.setExpandedState(path1, true);
192:                cache.setExpandedState(path2, true);
193:                cache.setRowHeight(10);
194:                if (isHarmony()) {
195:                    assertEquals(new Rectangle(0, -10, 0, 10), cache.getBounds(
196:                            rootPath, null));
197:                } else {
198:                    assertEquals(new Rectangle(0, -1, 0, 10), cache.getBounds(
199:                            rootPath, null));
200:                }
201:                assertEquals(new Rectangle(0, 0, 0, 10), cache.getBounds(path1,
202:                        null));
203:                assertEquals(new Rectangle(0, 30, 0, 10), cache.getBounds(
204:                        path2, null));
205:                assertEquals(new Rectangle(0, 50, 0, 10), cache.getBounds(
206:                        path26, null));
207:                cache.setRowHeight(-10);
208:                assertEquals(new Rectangle(0, 0, 0, 0), cache.getBounds(path1,
209:                        null));
210:                assertEquals(new Rectangle(0, 0, 0, 0), cache.getBounds(path2,
211:                        null));
212:                assertEquals(new Rectangle(0, 0, 0, 0), cache.getBounds(path26,
213:                        null));
214:                cache.setNodeDimensions(dimensions1);
215:                assertEquals(new Rectangle(root.hashCode(), 0, 0, 1), cache
216:                        .getBounds(rootPath, null));
217:                assertEquals(new Rectangle(node1.hashCode(), 0, 1, 1), cache
218:                        .getBounds(path1, null));
219:                assertEquals(new Rectangle(node2.hashCode(), 1, 1, 1), cache
220:                        .getBounds(path2, null));
221:                //        assertEquals(new Rectangle(0, 1, 0, 0), cache.getBounds(path13, null));
222:                //        assertEquals(new Rectangle(0, 1, 0, 0), cache.getBounds(path14, null));
223:                //        assertEquals(new Rectangle(0, 2, 0, 0), cache.getBounds(path25, null));
224:                //        assertEquals(new Rectangle(0, 2, 0, 0), cache.getBounds(path26, null));
225:                cache.setRowHeight(-110);
226:                cache.setNodeDimensions(dimensions3);
227:                assertEquals(new Rectangle(0, 0, 20, 2000), cache.getBounds(
228:                        rootPath, null));
229:                assertEquals(new Rectangle(10000, 0, 10, 1000), cache
230:                        .getBounds(path1, null));
231:                assertEquals(new Rectangle(10000, 6000, 40, 4000), cache
232:                        .getBounds(path2, null));
233:                assertEquals(new Rectangle(20000, 1000, 20, 2000), cache
234:                        .getBounds(path13, null));
235:                assertEquals(new Rectangle(20000, 3000, 30, 3000), cache
236:                        .getBounds(path14, null));
237:                assertEquals(new Rectangle(20000, 10000, 50, 5000), cache
238:                        .getBounds(path25, null));
239:                assertEquals(new Rectangle(20000, 15000, 60, 6000), cache
240:                        .getBounds(path26, null));
241:                cache.setModel(null);
242:                assertNull(cache.getBounds(path1, null));
243:            }
244:
245:            /*
246:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.getPathClosestTo(int, int)'
247:             */
248:            public void testGetPathClosestTo() {
249:                int height = 10;
250:                cache.setRowHeight(height);
251:                TreeModel model = new UndefaultTreeModel(root);
252:                root.add(node1);
253:                root.add(node2);
254:                node1.add(node3);
255:                node1.add(node4);
256:                node2.add(node5);
257:                node2.add(node6);
258:                assertNull(cache.getPathClosestTo(-100, -100));
259:                assertNull(cache.getPathClosestTo(0, 0));
260:                assertNull(cache.getPathClosestTo(100, 100));
261:                cache.setModel(model);
262:                cache.setExpandedState(rootPath, false);
263:                assertNull(cache.getPathClosestTo(-100, -100));
264:                assertNull(cache.getPathClosestTo(0, 0));
265:                assertNull(cache.getPathClosestTo(100, 100));
266:                cache.setRootVisible(true);
267:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
268:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
269:                assertEquals(rootPath, cache.getPathClosestTo(100, 100));
270:                cache.setExpandedState(rootPath, true);
271:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
272:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
273:                assertEquals(path2, cache.getPathClosestTo(100, 100));
274:                cache.setExpandedState(path1, true);
275:                cache.setExpandedState(path2, true);
276:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
277:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
278:                assertEquals(path13, cache.getPathClosestTo(0, 20));
279:                assertEquals(path2, cache.getPathClosestTo(0, 40));
280:                assertEquals(path26, cache.getPathClosestTo(0, 60));
281:                assertEquals(path26, cache.getPathClosestTo(0, 80));
282:                assertEquals(rootPath, cache.getPathClosestTo(120, 0));
283:                assertEquals(path13, cache.getPathClosestTo(120, 20));
284:                assertEquals(path2, cache.getPathClosestTo(120, 40));
285:                assertEquals(path26, cache.getPathClosestTo(120, 60));
286:                assertEquals(path26, cache.getPathClosestTo(120, 80));
287:                cache.setRowHeight(-100);
288:                cache.setNodeDimensions(dimensions2);
289:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
290:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
291:                assertEquals(path26, cache.getPathClosestTo(100, 100));
292:                cache.setModel(model);
293:                cache.setRootVisible(false);
294:                cache.setExpandedState(rootPath, false);
295:                assertNull(cache.getPathClosestTo(-100, -100));
296:                assertNull(cache.getPathClosestTo(0, 0));
297:                assertNull(cache.getPathClosestTo(100, 100));
298:                cache.setRootVisible(true);
299:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
300:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
301:                assertEquals(rootPath, cache.getPathClosestTo(100, 100));
302:                cache.setExpandedState(rootPath, true);
303:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
304:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
305:                assertEquals(path2, cache.getPathClosestTo(100, 100));
306:                cache.setExpandedState(path1, true);
307:                cache.setExpandedState(path2, true);
308:                assertEquals(rootPath, cache.getPathClosestTo(-100, -100));
309:                assertEquals(rootPath, cache.getPathClosestTo(0, 0));
310:                assertEquals(path13, cache.getPathClosestTo(0, 20));
311:                assertEquals(path2, cache.getPathClosestTo(0, 40));
312:                assertEquals(path26, cache.getPathClosestTo(0, 60));
313:                assertEquals(path26, cache.getPathClosestTo(0, 80));
314:                assertEquals(rootPath, cache.getPathClosestTo(120, 0));
315:                assertEquals(path13, cache.getPathClosestTo(120, 20));
316:                assertEquals(path2, cache.getPathClosestTo(120, 40));
317:                assertEquals(path26, cache.getPathClosestTo(120, 60));
318:                assertEquals(path26, cache.getPathClosestTo(120, 80));
319:                cache.setModel(null);
320:                assertNull(cache.getPathClosestTo(0, 0));
321:            }
322:
323:            /*
324:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.invalidatePathBounds(TreePath)'
325:             */
326:            public void testInvalidatePathBounds() {
327:            }
328:
329:            /*
330:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.invalidateSizes()'
331:             */
332:            @Override
333:            public void testInvalidateSizes() {
334:                //        super.testInvalidateSizes();
335:            }
336:
337:            /*
338:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.treeNodesChanged(TreeModelEvent)'
339:             */
340:            @Override
341:            public void testTreeNodesChanged() {
342:                super .testTreeNodesChanged();
343:            }
344:
345:            /*
346:             * Test method for 'javax.swing.tree.VariableHeightLayoutCache.setNodeDimensions(NodeDimensions)'
347:             */
348:            public void testSetNodeDimensionsNodeDimensions() {
349:            }
350:
351:            @Override
352:            public void testIsFixedRowHeight() {
353:                assertFalse(cache.isFixedRowHeight());
354:            }
355:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.