Source Code Cross Referenced for AbstractLayoutCacheTest.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) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:        /**
0018:         * @author Alexander T. Simbirtsev
0019:         * @version $Revision$
0020:         */package javax.swing.tree;
0021:
0022:        import java.awt.Rectangle;
0023:        import java.util.Enumeration;
0024:        import javax.swing.JTree;
0025:        import javax.swing.SwingTestCase;
0026:        import javax.swing.event.TreeModelEvent;
0027:        import javax.swing.event.TreeModelListener;
0028:
0029:        public class AbstractLayoutCacheTest extends SwingTestCase {
0030:            protected class UndefaultTreeModel implements  TreeModel {
0031:                private Object root;
0032:
0033:                public UndefaultTreeModel(Object root) {
0034:                    this .root = root;
0035:                }
0036:
0037:                public Object getChild(Object parent, int i) {
0038:                    return ((TreeNode) parent).getChildAt(i);
0039:                }
0040:
0041:                public int getChildCount(Object node) {
0042:                    return ((TreeNode) node).getChildCount();
0043:                }
0044:
0045:                public int getIndexOfChild(Object parent, Object child) {
0046:                    if (parent == null || child == null) {
0047:                        return -1;
0048:                    }
0049:                    TreeNode parentNode = (TreeNode) parent;
0050:                    int numChildren = parentNode.getChildCount();
0051:                    for (int i = 0; i < numChildren; i++) {
0052:                        if (child.equals(parentNode.getChildAt(i))) {
0053:                            return i;
0054:                        }
0055:                    }
0056:                    return -1;
0057:                }
0058:
0059:                public Object getRoot() {
0060:                    return root;
0061:                }
0062:
0063:                public boolean isLeaf(Object node) {
0064:                    return false;
0065:                }
0066:
0067:                public void valueForPathChanged(TreePath path, Object value) {
0068:                }
0069:
0070:                public void addTreeModelListener(TreeModelListener l) {
0071:                }
0072:
0073:                public void removeTreeModelListener(TreeModelListener l) {
0074:                }
0075:            };
0076:
0077:            protected class ConcreteLayoutCache extends AbstractLayoutCache {
0078:                public class FakeNodeDimensions extends
0079:                        AbstractLayoutCache.NodeDimensions {
0080:                    @Override
0081:                    public Rectangle getNodeDimensions(final Object value,
0082:                            final int row, final int depth,
0083:                            final boolean expanded, final Rectangle placeIn) {
0084:                        return new Rectangle(value.hashCode(), row, depth,
0085:                                expanded ? 1 : 0);
0086:                    }
0087:                };
0088:
0089:                public class NearlyFakeNodeDimensions extends
0090:                        AbstractLayoutCache.NodeDimensions {
0091:                    @Override
0092:                    public Rectangle getNodeDimensions(final Object value,
0093:                            final int row, final int depth,
0094:                            final boolean expanded, final Rectangle placeIn) {
0095:                        return new Rectangle(10000 * depth, 100 * row,
0096:                                10 * (Math.abs(row) + 1),
0097:                                1000 * (Math.abs(row) + 1));
0098:                    }
0099:                };
0100:
0101:                public class RealisticNodeDimensions extends
0102:                        AbstractLayoutCache.NodeDimensions {
0103:                    @Override
0104:                    public Rectangle getNodeDimensions(final Object value,
0105:                            final int row, final int depth,
0106:                            final boolean expanded, final Rectangle placeIn) {
0107:                        return new Rectangle(depth * 10, row * 10, 100, 10);
0108:                    }
0109:                };
0110:
0111:                public NodeDimensions createNodeDimensions(final int type) {
0112:                    if (type == 0) {
0113:                        return new FakeNodeDimensions();
0114:                    } else if (type == 1) {
0115:                        return new NearlyFakeNodeDimensions();
0116:                    }
0117:                    return new RealisticNodeDimensions();
0118:                }
0119:
0120:                @Override
0121:                public Rectangle getBounds(TreePath path, Rectangle palceIn) {
0122:                    return null;
0123:                }
0124:
0125:                @Override
0126:                public boolean getExpandedState(TreePath path) {
0127:                    return false;
0128:                }
0129:
0130:                @Override
0131:                public TreePath getPathClosestTo(int x, int y) {
0132:                    return null;
0133:                }
0134:
0135:                @Override
0136:                public TreePath getPathForRow(int row) {
0137:                    return null;
0138:                }
0139:
0140:                @Override
0141:                public int getRowCount() {
0142:                    return 0;
0143:                }
0144:
0145:                @Override
0146:                public int getRowForPath(TreePath path) {
0147:                    return 111;
0148:                }
0149:
0150:                @Override
0151:                public int getVisibleChildCount(TreePath path) {
0152:                    return 0;
0153:                }
0154:
0155:                @SuppressWarnings("unchecked")
0156:                @Override
0157:                public Enumeration getVisiblePathsFrom(TreePath path) {
0158:                    return null;
0159:                }
0160:
0161:                @Override
0162:                public void invalidatePathBounds(TreePath path) {
0163:                }
0164:
0165:                @Override
0166:                public void invalidateSizes() {
0167:                }
0168:
0169:                @Override
0170:                public boolean isExpanded(TreePath path) {
0171:                    return false;
0172:                }
0173:
0174:                @Override
0175:                public void setExpandedState(TreePath path, boolean expanded) {
0176:                }
0177:
0178:                @Override
0179:                public void treeNodesChanged(TreeModelEvent e) {
0180:                }
0181:
0182:                @Override
0183:                public void treeNodesInserted(TreeModelEvent e) {
0184:                }
0185:
0186:                @Override
0187:                public void treeNodesRemoved(TreeModelEvent e) {
0188:                }
0189:
0190:                @Override
0191:                public void treeStructureChanged(TreeModelEvent e) {
0192:                }
0193:            };
0194:
0195:            protected final DefaultMutableTreeNode root = new DefaultMutableTreeNode(
0196:                    "root");
0197:
0198:            protected final DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(
0199:                    "node1");
0200:
0201:            protected final DefaultMutableTreeNode node2 = new DefaultMutableTreeNode(
0202:                    "node2");
0203:
0204:            protected final DefaultMutableTreeNode node3 = new DefaultMutableTreeNode(
0205:                    "node3");
0206:
0207:            protected final DefaultMutableTreeNode node4 = new DefaultMutableTreeNode(
0208:                    "node4");
0209:
0210:            protected final DefaultMutableTreeNode node5 = new DefaultMutableTreeNode(
0211:                    "node5");
0212:
0213:            protected final DefaultMutableTreeNode node6 = new DefaultMutableTreeNode(
0214:                    "node6");
0215:
0216:            protected final TreePath rootPath = new TreePath(root);
0217:
0218:            protected final TreePath path1 = new TreePath(new Object[] { root,
0219:                    node1 });
0220:
0221:            protected final TreePath path2 = new TreePath(new Object[] { root,
0222:                    node2 });
0223:
0224:            protected final TreePath path3 = new TreePath(new Object[] { root,
0225:                    node3 });
0226:
0227:            protected final TreePath path4 = new TreePath(new Object[] { root,
0228:                    node4 });
0229:
0230:            protected final TreePath path23 = new TreePath(new Object[] { root,
0231:                    node2, node3 });
0232:
0233:            protected final TreePath path24 = new TreePath(new Object[] { root,
0234:                    node2, node4 });
0235:
0236:            protected final TreePath path234 = new TreePath(new Object[] {
0237:                    root, node2, node3, node4 });
0238:
0239:            protected final TreePath path13 = new TreePath(new Object[] { root,
0240:                    node1, node3 });
0241:
0242:            protected final TreePath path14 = new TreePath(new Object[] { root,
0243:                    node1, node4 });
0244:
0245:            protected final TreePath path25 = new TreePath(new Object[] { root,
0246:                    node2, node5 });
0247:
0248:            protected final TreePath path26 = new TreePath(new Object[] { root,
0249:                    node2, node6 });
0250:
0251:            protected AbstractLayoutCache.NodeDimensions dimensions1;
0252:
0253:            protected AbstractLayoutCache.NodeDimensions dimensions2;
0254:
0255:            protected AbstractLayoutCache.NodeDimensions dimensions3;
0256:
0257:            protected int defaultRowValue;
0258:
0259:            protected AbstractLayoutCache cache;
0260:
0261:            @Override
0262:            protected void setUp() throws Exception {
0263:                super .setUp();
0264:                cache = new ConcreteLayoutCache();
0265:                dimensions1 = ((ConcreteLayoutCache) cache)
0266:                        .createNodeDimensions(0);
0267:                dimensions2 = ((ConcreteLayoutCache) cache)
0268:                        .createNodeDimensions(2);
0269:                dimensions3 = ((ConcreteLayoutCache) cache)
0270:                        .createNodeDimensions(1);
0271:                defaultRowValue = cache.getRowForPath(null);
0272:            }
0273:
0274:            @Override
0275:            protected void tearDown() throws Exception {
0276:                cache = null;
0277:                root.removeAllChildren();
0278:                node1.removeAllChildren();
0279:                node2.removeAllChildren();
0280:                node3.removeAllChildren();
0281:                node4.removeAllChildren();
0282:                node5.removeAllChildren();
0283:                node6.removeAllChildren();
0284:                super .tearDown();
0285:            }
0286:
0287:            /*
0288:             * Test method for 'javax.swing.tree.AbstractLayoutCache.AbstractLayoutCache()'
0289:             */
0290:            public void testLayoutCache() {
0291:                assertFalse(cache.rootVisible);
0292:                assertNull(cache.nodeDimensions);
0293:                assertEquals(0, cache.rowHeight);
0294:                assertNull(cache.treeModel);
0295:                assertNull(cache.treeSelectionModel);
0296:            }
0297:
0298:            /*
0299:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getModel()'
0300:             */
0301:            public void testGetModel() {
0302:                TreeModel model = new DefaultTreeModel(null);
0303:                assertNull(cache.getModel());
0304:                cache.treeModel = model;
0305:                assertEquals(model, cache.getModel());
0306:            }
0307:
0308:            /*
0309:             * Test method for 'javax.swing.tree.AbstractLayoutCache.setModel(TreeModel)'
0310:             */
0311:            public void testSetModel() {
0312:                TreeModel model1 = new DefaultTreeModel(null);
0313:                TreeModel model2 = new DefaultTreeModel(root);
0314:                assertNull(cache.getModel());
0315:                cache.setModel(model1);
0316:                assertSame(model1, cache.treeModel);
0317:                assertSame(model1, cache.getModel());
0318:                cache.setModel(model2);
0319:                assertSame(model2, cache.treeModel);
0320:                assertSame(model2, cache.getModel());
0321:                if (getClass() == AbstractLayoutCacheTest.class) {
0322:                    return;
0323:                }
0324:                root.add(node1);
0325:                root.add(node2);
0326:                node1.add(node3);
0327:                node1.add(node4);
0328:                node2.add(node5);
0329:                node2.add(node6);
0330:                cache.setRootVisible(true);
0331:                cache.setExpandedState(path1, true);
0332:                assertEquals(0, cache.getRowForPath(rootPath));
0333:                assertEquals(1, cache.getRowForPath(path1));
0334:                assertEquals(2, cache.getRowForPath(path13));
0335:                assertEquals(3, cache.getRowForPath(path14));
0336:                assertEquals(4, cache.getRowForPath(path2));
0337:                assertEquals(-1, cache.getRowForPath(path25));
0338:                assertEquals(-1, cache.getRowForPath(path26));
0339:                cache.setModel(model1);
0340:                assertEquals(-1, cache.getRowForPath(rootPath));
0341:                assertEquals(-1, cache.getRowForPath(path1));
0342:                assertEquals(-1, cache.getRowForPath(path13));
0343:                assertEquals(-1, cache.getRowForPath(path14));
0344:                assertEquals(-1, cache.getRowForPath(path2));
0345:                assertEquals(-1, cache.getRowForPath(path25));
0346:                assertEquals(-1, cache.getRowForPath(path26));
0347:            }
0348:
0349:            /*
0350:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getSelectionModel()'
0351:             */
0352:            public void testGetSelectionModel() {
0353:                TreeSelectionModel model = new DefaultTreeSelectionModel();
0354:                assertNull(cache.getSelectionModel());
0355:                cache.treeSelectionModel = model;
0356:                assertEquals(model, cache.getSelectionModel());
0357:            }
0358:
0359:            /*
0360:             * Test method for 'javax.swing.tree.AbstractLayoutCache.setSelectionModel(TreeSelectionModel)'
0361:             */
0362:            public void testSetSelectionModel() {
0363:                TreeSelectionModel model1 = new DefaultTreeSelectionModel();
0364:                TreeSelectionModel model2 = new DefaultTreeSelectionModel();
0365:                assertNull(cache.getSelectionModel());
0366:                cache.setSelectionModel(model1);
0367:                assertSame(cache, model1.getRowMapper());
0368:                assertEquals(model1, cache.treeSelectionModel);
0369:                assertEquals(model1, cache.getSelectionModel());
0370:                cache.setSelectionModel(model2);
0371:                assertSame(cache, model2.getRowMapper());
0372:                assertNull(model1.getRowMapper());
0373:                assertEquals(model2, cache.treeSelectionModel);
0374:                assertEquals(model2, cache.getSelectionModel());
0375:                cache.setSelectionModel(null);
0376:                assertNull(cache.getSelectionModel());
0377:            }
0378:
0379:            /*
0380:             * Test method for 'javax.swing.tree.AbstractLayoutCache.setRootVisible(boolean)'
0381:             */
0382:            public void testSetRootVisible() {
0383:                cache.setRootVisible(true);
0384:                assertTrue(cache.rootVisible);
0385:                assertTrue(cache.isRootVisible());
0386:                cache.setRootVisible(false);
0387:                assertFalse(cache.rootVisible);
0388:                assertFalse(cache.isRootVisible());
0389:            }
0390:
0391:            /*
0392:             * Test method for 'javax.swing.tree.AbstractLayoutCache.isRootVisible()'
0393:             */
0394:            public void testIsRootVisible() {
0395:                cache.rootVisible = true;
0396:                assertTrue(cache.isRootVisible());
0397:                cache.rootVisible = false;
0398:                assertFalse(cache.isRootVisible());
0399:            }
0400:
0401:            /*
0402:             * Test method for 'javax.swing.tree.AbstractLayoutCache.setRowHeight(int)'
0403:             */
0404:            public void testSetRowHeight() {
0405:                cache.setRowHeight(100);
0406:                assertEquals(100, cache.rowHeight);
0407:                assertEquals(100, cache.getRowHeight());
0408:                cache.setRowHeight(200);
0409:                assertEquals(200, cache.rowHeight);
0410:                assertEquals(200, cache.getRowHeight());
0411:            }
0412:
0413:            /*
0414:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getRowHeight()'
0415:             */
0416:            public void testGetRowHeight() {
0417:                cache.rowHeight = 100;
0418:                assertEquals(100, cache.getRowHeight());
0419:                cache.rowHeight = 200;
0420:                assertEquals(200, cache.getRowHeight());
0421:            }
0422:
0423:            /*
0424:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getNodeDimensions(Object, int, int, boolean, Rectangle)'
0425:             */
0426:            public void testGetNodeDimensionsObjectIntIntBooleanRectangle() {
0427:                AbstractLayoutCache.NodeDimensions renderer1 = dimensions1;
0428:                assertNull(cache.getNodeDimensions(null, 1, 1, true, null));
0429:                cache.setNodeDimensions(renderer1);
0430:                assertEquals(new Rectangle("a".hashCode(), 10, 20, 1), cache
0431:                        .getNodeDimensions("a", 10, 20, true, null));
0432:            }
0433:
0434:            /*
0435:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getNodeDimensions()'
0436:             */
0437:            public void testGetNodeDimensions() {
0438:                AbstractLayoutCache.NodeDimensions renderer1 = dimensions1;
0439:                AbstractLayoutCache.NodeDimensions renderer2 = dimensions2;
0440:                cache.nodeDimensions = renderer1;
0441:                assertEquals(renderer1, cache.getNodeDimensions());
0442:                cache.nodeDimensions = renderer2;
0443:                assertEquals(renderer2, cache.getNodeDimensions());
0444:            }
0445:
0446:            /*
0447:             * Test method for 'javax.swing.tree.AbstractLayoutCache.setNodeDimensions(NodeDimensions)'
0448:             */
0449:            public void testSetNodeDimensions() {
0450:                AbstractLayoutCache.NodeDimensions renderer1 = dimensions1;
0451:                AbstractLayoutCache.NodeDimensions renderer2 = dimensions2;
0452:                cache.setNodeDimensions(renderer1);
0453:                assertSame(renderer1, cache.nodeDimensions);
0454:                assertSame(renderer1, cache.getNodeDimensions());
0455:                cache.setNodeDimensions(renderer2);
0456:                assertSame(renderer2, cache.nodeDimensions);
0457:                assertSame(renderer2, cache.getNodeDimensions());
0458:            }
0459:
0460:            /*
0461:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getPreferredHeight()'
0462:             */
0463:            public void testGetPreferredHeight() {
0464:                assertEquals(0, cache.getPreferredHeight());
0465:            }
0466:
0467:            /*
0468:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getPreferredWidth(Rectangle)'
0469:             */
0470:            public void testGetPreferredWidth() {
0471:                assertEquals(0, cache.getPreferredWidth(null));
0472:                assertEquals(0, cache.getPreferredWidth(new Rectangle(0, 0, 20,
0473:                        20)));
0474:                JTree tree = new JTree();
0475:                cache.setModel(tree.getModel());
0476:                cache.setRootVisible(true);
0477:                cache.setRowHeight(10);
0478:                cache.setNodeDimensions(dimensions1);
0479:                assertEquals(0, cache.getPreferredWidth(null));
0480:                assertEquals(0, cache.getPreferredWidth(new Rectangle(0, 0, 20,
0481:                        20)));
0482:            }
0483:
0484:            /*
0485:             * Test method for 'javax.swing.tree.AbstractLayoutCache.getRowsForPaths(TreePath[])'
0486:             */
0487:            public void testGetRowsForPaths() {
0488:                if (!isHarmony()) {
0489:                    assertNull(cache.getRowsForPaths(null));
0490:                } else {
0491:                    assertEquals(0, cache.getRowsForPaths(null).length);
0492:                }
0493:                assertEquals(0, cache.getRowsForPaths(new TreePath[0]).length);
0494:                TreePath[] paths = new TreePath[] { new TreePath("1"),
0495:                        new TreePath("2"),
0496:                        new TreePath(new Object[] { "1", "2" }) };
0497:                assertEquals(3, cache.getRowsForPaths(paths).length);
0498:                assertEquals(defaultRowValue, cache.getRowsForPaths(paths)[0]);
0499:                assertEquals(defaultRowValue, cache.getRowsForPaths(paths)[1]);
0500:                assertEquals(defaultRowValue, cache.getRowsForPaths(paths)[2]);
0501:            }
0502:
0503:            /*
0504:             * Test method for 'javax.swing.tree.AbstractLayoutCache.isFixedRowHeight()'
0505:             */
0506:            public void testIsFixedRowHeight() {
0507:                assertFalse(cache.isFixedRowHeight());
0508:                cache.setRowHeight(1);
0509:                assertTrue(cache.isFixedRowHeight());
0510:                cache.setRowHeight(0);
0511:                assertFalse(cache.isFixedRowHeight());
0512:                cache.setRowHeight(-10);
0513:                assertFalse(cache.isFixedRowHeight());
0514:            }
0515:
0516:            @SuppressWarnings("unchecked")
0517:            protected boolean checkEnumeration(final Enumeration e,
0518:                    final Object[] array) {
0519:                int size = (array != null) ? array.length : 0;
0520:                boolean enumEmpty = (e == null) || (!e.hasMoreElements());
0521:                boolean arrayEmpty = (size == 0);
0522:                if (enumEmpty || arrayEmpty) {
0523:                    //            if (enumEmpty != arrayEmpty) {
0524:                    //                System.out.println("sizes: " + array.length);
0525:                    //            }
0526:                    return (enumEmpty == arrayEmpty);
0527:                }
0528:                int i = 0;
0529:                while (e.hasMoreElements()) {
0530:                    Object element = e.nextElement();
0531:                    if (i >= size || !element.equals(array[i++])) {
0532:                        return false;
0533:                    }
0534:                }
0535:                return (i == size);
0536:            }
0537:
0538:            /*
0539:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.setExpandedState(TreePath, boolean)'
0540:             */
0541:            public void testSetExpandedState() {
0542:                if (cache instanceof  ConcreteLayoutCache) {
0543:                    return;
0544:                }
0545:                root.add(node1);
0546:                root.add(node2);
0547:                node2.add(node3);
0548:                node3.add(node4);
0549:                TreeModel model = new DefaultTreeModel(root);
0550:                cache.setModel(model);
0551:                cache.setExpandedState(rootPath, false);
0552:                assertFalse(cache.getExpandedState(rootPath));
0553:                assertFalse(cache.getExpandedState(path1));
0554:                assertFalse(cache.getExpandedState(path2));
0555:                assertFalse(cache.getExpandedState(path23));
0556:                cache.setExpandedState(path1, true);
0557:                assertTrue(cache.getExpandedState(rootPath));
0558:                assertFalse(cache.getExpandedState(path1));
0559:                assertFalse(cache.getExpandedState(path2));
0560:                assertFalse(cache.getExpandedState(path23));
0561:                cache.setExpandedState(rootPath, false);
0562:                cache.setExpandedState(path2, true);
0563:                assertTrue(cache.getExpandedState(rootPath));
0564:                assertFalse(cache.getExpandedState(path1));
0565:                assertTrue(cache.getExpandedState(path2));
0566:                assertFalse(cache.getExpandedState(path23));
0567:                cache.setExpandedState(rootPath, false);
0568:                assertFalse(cache.getExpandedState(rootPath));
0569:                assertFalse(cache.getExpandedState(path1));
0570:                assertFalse(cache.getExpandedState(path2));
0571:                assertFalse(cache.getExpandedState(path23));
0572:                cache.setExpandedState(rootPath, true);
0573:                assertTrue(cache.getExpandedState(rootPath));
0574:                assertFalse(cache.getExpandedState(path1));
0575:                assertTrue(cache.getExpandedState(path2));
0576:                assertFalse(cache.getExpandedState(path23));
0577:                cache.setExpandedState(rootPath, false);
0578:                cache.setExpandedState(path2, false);
0579:                cache.setExpandedState(path234, true);
0580:                assertTrue(cache.getExpandedState(rootPath));
0581:                assertFalse(cache.getExpandedState(path1));
0582:                assertTrue(cache.getExpandedState(path2));
0583:                assertTrue(cache.getExpandedState(path23));
0584:                assertFalse(cache.getExpandedState(path234));
0585:            }
0586:
0587:            /*
0588:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getExpandedState(TreePath)'
0589:             */
0590:            public void testGetExpandedState() {
0591:                if (cache instanceof  ConcreteLayoutCache) {
0592:                    return;
0593:                }
0594:                root.add(node1);
0595:                root.add(node2);
0596:                node2.add(node3);
0597:                assertFalse(cache.getExpandedState(rootPath));
0598:                TreeModel model = new DefaultTreeModel(root);
0599:                cache.setModel(model);
0600:                assertTrue(cache.getExpandedState(rootPath));
0601:                assertFalse(cache.getExpandedState(path1));
0602:                assertFalse(cache.getExpandedState(path2));
0603:                cache.setExpandedState(path1, true);
0604:                assertTrue(cache.getExpandedState(rootPath));
0605:                assertFalse(cache.getExpandedState(path1));
0606:                assertFalse(cache.getExpandedState(path2));
0607:                cache.setExpandedState(path2, true);
0608:                assertTrue(cache.getExpandedState(rootPath));
0609:                assertFalse(cache.getExpandedState(path1));
0610:                assertTrue(cache.getExpandedState(path2));
0611:                cache.setRootVisible(false);
0612:                assertTrue(cache.getExpandedState(rootPath));
0613:                assertFalse(cache.getExpandedState(path1));
0614:                assertTrue(cache.getExpandedState(path2));
0615:            }
0616:
0617:            /*
0618:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.isExpanded(TreePath)'
0619:             */
0620:            public void testIsExpanded() {
0621:                if (cache instanceof  ConcreteLayoutCache) {
0622:                    return;
0623:                }
0624:                root.add(node1);
0625:                root.add(node2);
0626:                node2.add(node3);
0627:                assertFalse(cache.isExpanded(rootPath));
0628:                TreeModel model = new DefaultTreeModel(root);
0629:                cache.setModel(model);
0630:                assertTrue(cache.isExpanded(rootPath));
0631:                assertFalse(cache.isExpanded(path1));
0632:                assertFalse(cache.isExpanded(path2));
0633:                cache.setExpandedState(path1, true);
0634:                assertTrue(cache.isExpanded(rootPath));
0635:                assertFalse(cache.isExpanded(path1));
0636:                assertFalse(cache.isExpanded(path2));
0637:                cache.setExpandedState(path2, true);
0638:                assertTrue(cache.isExpanded(rootPath));
0639:                assertFalse(cache.isExpanded(path1));
0640:                assertTrue(cache.isExpanded(path2));
0641:                cache.setExpandedState(rootPath, false);
0642:                assertFalse(cache.isExpanded(rootPath));
0643:                assertFalse(cache.isExpanded(path1));
0644:                assertFalse(cache.isExpanded(path2));
0645:                cache.setExpandedState(path1, true);
0646:                assertTrue(cache.isExpanded(rootPath));
0647:                assertFalse(cache.isExpanded(path1));
0648:                assertTrue(cache.isExpanded(path2));
0649:            }
0650:
0651:            /*
0652:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getPathForRow(int)'
0653:             */
0654:            public void testGetPathForRow() {
0655:                if (cache instanceof  ConcreteLayoutCache) {
0656:                    return;
0657:                }
0658:                root.add(node1);
0659:                root.add(node2);
0660:                node1.add(node3);
0661:                node1.add(node4);
0662:                node2.add(node5);
0663:                node2.add(node6);
0664:                assertNull(cache.getPathForRow(0));
0665:                cache.setRootVisible(true);
0666:                assertNull(cache.getPathForRow(0));
0667:                TreeModel model = new UndefaultTreeModel(root);
0668:                cache.setModel(model);
0669:                cache.setRootVisible(false);
0670:                assertEquals(path1, cache.getPathForRow(0));
0671:                assertEquals(path2, cache.getPathForRow(1));
0672:                assertNull(cache.getPathForRow(2));
0673:                cache.setRootVisible(true);
0674:                assertEquals(rootPath, cache.getPathForRow(0));
0675:                assertEquals(path1, cache.getPathForRow(1));
0676:                assertEquals(path2, cache.getPathForRow(2));
0677:                assertNull(cache.getPathForRow(3));
0678:                cache.setExpandedState(path1, true);
0679:                assertEquals(rootPath, cache.getPathForRow(0));
0680:                assertEquals(path1, cache.getPathForRow(1));
0681:                assertEquals(path13, cache.getPathForRow(2));
0682:                assertEquals(path14, cache.getPathForRow(3));
0683:                assertEquals(path2, cache.getPathForRow(4));
0684:                assertNull(cache.getPathForRow(5));
0685:                cache.setExpandedState(path1, false);
0686:                cache.setExpandedState(path2, true);
0687:                assertEquals(rootPath, cache.getPathForRow(0));
0688:                assertEquals(path1, cache.getPathForRow(1));
0689:                assertEquals(path2, cache.getPathForRow(2));
0690:                assertEquals(path25, cache.getPathForRow(3));
0691:                assertEquals(path26, cache.getPathForRow(4));
0692:                assertNull(cache.getPathForRow(5));
0693:            }
0694:
0695:            /*
0696:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getRowCount()'
0697:             */
0698:            public void testGetRowCount() {
0699:                if (cache instanceof  ConcreteLayoutCache) {
0700:                    return;
0701:                }
0702:                root.add(node1);
0703:                root.add(node2);
0704:                TreeModel model = new DefaultTreeModel(root);
0705:                assertEquals(0, cache.getRowCount());
0706:                cache.setModel(model);
0707:                assertEquals(2, cache.getRowCount());
0708:                cache.setRootVisible(true);
0709:                assertEquals(3, cache.getRowCount());
0710:                cache.setExpandedState(rootPath, false);
0711:                assertEquals(1, cache.getRowCount());
0712:                cache.setRootVisible(false);
0713:                assertEquals(0, cache.getRowCount());
0714:            }
0715:
0716:            /*
0717:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getRowForPath(TreePath)'
0718:             */
0719:            public void testGetRowForPath() {
0720:                if (cache instanceof  ConcreteLayoutCache) {
0721:                    return;
0722:                }
0723:                root.add(node1);
0724:                root.add(node2);
0725:                node1.add(node3);
0726:                node1.add(node4);
0727:                node2.add(node5);
0728:                node2.add(node6);
0729:                assertEquals(-1, cache.getRowForPath(null));
0730:                assertEquals(-1, cache.getRowForPath(rootPath));
0731:                cache.setRootVisible(true);
0732:                assertEquals(-1, cache.getRowForPath(rootPath));
0733:                TreeModel model = new UndefaultTreeModel(root);
0734:                cache.setModel(model);
0735:                cache.setRootVisible(false);
0736:                assertEquals(-1, cache.getRowForPath(rootPath));
0737:                assertEquals(0, cache.getRowForPath(path1));
0738:                assertEquals(1, cache.getRowForPath(path2));
0739:                assertEquals(-1, cache.getRowForPath(path13));
0740:                assertEquals(-1, cache.getRowForPath(path14));
0741:                assertEquals(-1, cache.getRowForPath(path25));
0742:                assertEquals(-1, cache.getRowForPath(path26));
0743:                cache.setRootVisible(true);
0744:                assertEquals(0, cache.getRowForPath(rootPath));
0745:                assertEquals(1, cache.getRowForPath(path1));
0746:                assertEquals(2, cache.getRowForPath(path2));
0747:                assertEquals(-1, cache.getRowForPath(path13));
0748:                assertEquals(-1, cache.getRowForPath(path14));
0749:                assertEquals(-1, cache.getRowForPath(path25));
0750:                assertEquals(-1, cache.getRowForPath(path26));
0751:                cache.setExpandedState(path1, true);
0752:                assertEquals(0, cache.getRowForPath(rootPath));
0753:                assertEquals(1, cache.getRowForPath(path1));
0754:                assertEquals(2, cache.getRowForPath(path13));
0755:                assertEquals(3, cache.getRowForPath(path14));
0756:                assertEquals(4, cache.getRowForPath(path2));
0757:                assertEquals(-1, cache.getRowForPath(path25));
0758:                assertEquals(-1, cache.getRowForPath(path26));
0759:                cache.setExpandedState(path1, false);
0760:                cache.setExpandedState(path2, true);
0761:                assertEquals(0, cache.getRowForPath(rootPath));
0762:                assertEquals(1, cache.getRowForPath(path1));
0763:                assertEquals(-1, cache.getRowForPath(path13));
0764:                assertEquals(-1, cache.getRowForPath(path14));
0765:                assertEquals(2, cache.getRowForPath(path2));
0766:                assertEquals(3, cache.getRowForPath(path25));
0767:                assertEquals(4, cache.getRowForPath(path26));
0768:            }
0769:
0770:            /*
0771:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getVisibleChildCount(TreePath)'
0772:             */
0773:            public void testGetVisibleChildCount() {
0774:                if (cache instanceof  ConcreteLayoutCache) {
0775:                    return;
0776:                }
0777:                root.add(node1);
0778:                root.add(node2);
0779:                node2.add(node3);
0780:                node2.add(node4);
0781:                TreeModel model = new DefaultTreeModel(root);
0782:                assertEquals(0, cache.getVisibleChildCount(rootPath));
0783:                cache.setModel(model);
0784:                assertEquals(2, cache.getVisibleChildCount(rootPath));
0785:                assertEquals(0, cache.getVisibleChildCount(path1));
0786:                assertEquals(0, cache.getVisibleChildCount(path2));
0787:                cache.setExpandedState(rootPath, false);
0788:                assertEquals(0, cache.getVisibleChildCount(rootPath));
0789:                assertEquals(0, cache.getVisibleChildCount(path1));
0790:                assertEquals(0, cache.getVisibleChildCount(path2));
0791:                cache.setExpandedState(path2, true);
0792:                assertEquals(4, cache.getVisibleChildCount(rootPath));
0793:                assertEquals(0, cache.getVisibleChildCount(path1));
0794:                assertEquals(2, cache.getVisibleChildCount(path2));
0795:                cache.setExpandedState(rootPath, false);
0796:                assertEquals(0, cache.getVisibleChildCount(rootPath));
0797:                assertEquals(0, cache.getVisibleChildCount(path1));
0798:                assertEquals(0, cache.getVisibleChildCount(path2));
0799:            }
0800:
0801:            /*
0802:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.getVisiblePathsFrom(TreePath)'
0803:             */
0804:            public void testGetVisiblePathsFrom() {
0805:                if (cache instanceof  ConcreteLayoutCache) {
0806:                    return;
0807:                }
0808:                final TreePath path5 = new TreePath(
0809:                        new Object[] { root, node5 });
0810:                root.add(node1);
0811:                root.add(node2);
0812:                node2.add(node3);
0813:                node2.add(node4);
0814:                root.add(node5);
0815:                assertTrue(checkEnumeration(
0816:                        cache.getVisiblePathsFrom(rootPath), new Object[] {}));
0817:                TreeModel model = new DefaultTreeModel(root);
0818:                cache.setModel(model);
0819:                assertTrue(checkEnumeration(
0820:                        cache.getVisiblePathsFrom(rootPath), new Object[] {
0821:                                rootPath, path1, path2, path5 }));
0822:                assertTrue(checkEnumeration(cache.getVisiblePathsFrom(path1),
0823:                        new Object[] { path1, path2, path5 }));
0824:                assertTrue(checkEnumeration(cache.getVisiblePathsFrom(path2),
0825:                        new Object[] { path2, path5 }));
0826:                cache.setExpandedState(rootPath, false);
0827:                assertTrue(checkEnumeration(
0828:                        cache.getVisiblePathsFrom(rootPath),
0829:                        new Object[] { rootPath }));
0830:                assertNull(cache.getVisiblePathsFrom(path1));
0831:                assertNull(cache.getVisiblePathsFrom(path2));
0832:                cache.setRootVisible(false);
0833:                assertTrue(checkEnumeration(
0834:                        cache.getVisiblePathsFrom(rootPath),
0835:                        new Object[] { rootPath }));
0836:                assertNull(cache.getVisiblePathsFrom(path1));
0837:                assertNull(cache.getVisiblePathsFrom(path2));
0838:                cache.setRootVisible(true);
0839:                cache.setExpandedState(path2, true);
0840:                assertTrue(checkEnumeration(
0841:                        cache.getVisiblePathsFrom(rootPath), new Object[] {
0842:                                rootPath, path1, path2, path23, path24, path5 }));
0843:                assertTrue(checkEnumeration(cache.getVisiblePathsFrom(path1),
0844:                        new Object[] { path1, path2, path23, path24, path5 }));
0845:                assertTrue(checkEnumeration(cache.getVisiblePathsFrom(path2),
0846:                        new Object[] { path2, path23, path24, path5 }));
0847:                assertTrue(checkEnumeration(cache.getVisiblePathsFrom(path23),
0848:                        new Object[] { path23, path24, path5 }));
0849:                cache.setExpandedState(rootPath, false);
0850:                assertTrue(checkEnumeration(
0851:                        cache.getVisiblePathsFrom(rootPath),
0852:                        new Object[] { rootPath }));
0853:                assertNull(cache.getVisiblePathsFrom(path1));
0854:                assertNull(cache.getVisiblePathsFrom(path2));
0855:            }
0856:
0857:            /*
0858:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.treeNodesChanged(TreeModelEvent)'
0859:             */
0860:            public void testTreeNodesChanged() {
0861:            }
0862:
0863:            /*
0864:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.treeNodesInserted(TreeModelEvent)'
0865:             */
0866:            public void testTreeNodesInserted() {
0867:                if (cache instanceof  ConcreteLayoutCache) {
0868:                    return;
0869:                }
0870:                root.add(node1);
0871:                TreeModel model = new UndefaultTreeModel(root);
0872:                cache.setModel(model);
0873:                assertEquals(0, cache.getRowForPath(path1));
0874:                assertEquals(-1, cache.getRowForPath(path2));
0875:                root.insert(node2, 0);
0876:                cache.treeNodesInserted(new TreeModelEvent(model, rootPath,
0877:                        new int[] { 0 }, new Object[] { node2 }));
0878:                assertEquals(0, cache.getRowForPath(path2));
0879:                assertEquals(-1, cache.getRowForPath(path25));
0880:                assertEquals(-1, cache.getRowForPath(path26));
0881:                assertEquals(1, cache.getRowForPath(path1));
0882:                assertEquals(-1, cache.getRowForPath(path13));
0883:                assertEquals(-1, cache.getRowForPath(path14));
0884:                node2.add(node6);
0885:                cache.treeNodesInserted(new TreeModelEvent(model, path2,
0886:                        new int[] { 0 }, null));
0887:                assertEquals(0, cache.getRowForPath(path2));
0888:                assertEquals(-1, cache.getRowForPath(path25));
0889:                assertEquals(-1, cache.getRowForPath(path26));
0890:                assertEquals(1, cache.getRowForPath(path1));
0891:                assertEquals(-1, cache.getRowForPath(path13));
0892:                assertEquals(-1, cache.getRowForPath(path14));
0893:                cache.setExpandedState(path2, true);
0894:                node2.insert(node5, 0);
0895:                cache.treeNodesInserted(new TreeModelEvent(model, path2,
0896:                        new int[] { 0 }, null));
0897:                assertEquals(0, cache.getRowForPath(path2));
0898:                assertEquals(1, cache.getRowForPath(path25));
0899:                assertEquals(2, cache.getRowForPath(path26));
0900:                assertEquals(3, cache.getRowForPath(path1));
0901:                assertEquals(-1, cache.getRowForPath(path13));
0902:                assertEquals(-1, cache.getRowForPath(path14));
0903:                node1.add(node3);
0904:                cache.treeNodesInserted(new TreeModelEvent(model, path1,
0905:                        new int[] { 0 }, new Object[] { node3 }));
0906:                assertEquals(0, cache.getRowForPath(path2));
0907:                assertEquals(1, cache.getRowForPath(path25));
0908:                assertEquals(2, cache.getRowForPath(path26));
0909:                assertEquals(3, cache.getRowForPath(path1));
0910:                assertEquals(-1, cache.getRowForPath(path13));
0911:                assertEquals(-1, cache.getRowForPath(path14));
0912:                cache.setExpandedState(path1, true);
0913:                node1.add(node4);
0914:                cache.treeNodesInserted(new TreeModelEvent(model, path1,
0915:                        new int[] { 1 }, new Object[] { node4 }));
0916:                assertEquals(0, cache.getRowForPath(path2));
0917:                assertEquals(1, cache.getRowForPath(path25));
0918:                assertEquals(2, cache.getRowForPath(path26));
0919:                assertEquals(3, cache.getRowForPath(path1));
0920:                assertEquals(4, cache.getRowForPath(path13));
0921:                assertEquals(5, cache.getRowForPath(path14));
0922:            }
0923:
0924:            /*
0925:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.treeNodesRemoved(TreeModelEvent)'
0926:             */
0927:            public void testTreeNodesRemoved() {
0928:                if (cache instanceof  ConcreteLayoutCache) {
0929:                    return;
0930:                }
0931:                TreeModel model = new UndefaultTreeModel(root);
0932:                root.add(node1);
0933:                root.add(node2);
0934:                node1.add(node3);
0935:                node1.add(node4);
0936:                node2.add(node5);
0937:                node2.add(node6);
0938:                cache.setModel(model);
0939:                cache.setExpandedState(path1, true);
0940:                cache.setExpandedState(path2, true);
0941:                assertEquals(0, cache.getRowForPath(path1));
0942:                assertEquals(1, cache.getRowForPath(path13));
0943:                assertEquals(2, cache.getRowForPath(path14));
0944:                assertEquals(3, cache.getRowForPath(path2));
0945:                assertEquals(4, cache.getRowForPath(path25));
0946:                assertEquals(5, cache.getRowForPath(path26));
0947:                node1.remove(0);
0948:                cache.treeNodesRemoved(new TreeModelEvent(model, path1,
0949:                        new int[] { 0 }, new Object[] { node1 }));
0950:                assertEquals(0, cache.getRowForPath(path1));
0951:                //        assertEquals(-1, cache.getRowForPath(path13));
0952:                assertEquals(1, cache.getRowForPath(path14));
0953:                assertEquals(2, cache.getRowForPath(path2));
0954:                assertEquals(3, cache.getRowForPath(path25));
0955:                assertEquals(4, cache.getRowForPath(path26));
0956:                assertTrue(cache.getExpandedState(path1));
0957:                node1.remove(0);
0958:                cache.treeNodesRemoved(new TreeModelEvent(model, path1,
0959:                        new int[] { 0 }, new Object[] { node4 }));
0960:                assertEquals(0, cache.getRowForPath(path1));
0961:                //        assertEquals(-1, cache.getRowForPath(path13));
0962:                //        assertEquals(-1, cache.getRowForPath(path14));
0963:                assertEquals(1, cache.getRowForPath(path2));
0964:                assertEquals(2, cache.getRowForPath(path25));
0965:                assertEquals(3, cache.getRowForPath(path26));
0966:                assertTrue(cache.getExpandedState(path1));
0967:                root.remove(0);
0968:                cache.treeNodesRemoved(new TreeModelEvent(model, rootPath,
0969:                        new int[] { 0 }, new Object[] { node1 }));
0970:                assertEquals(-1, cache.getRowForPath(path1));
0971:                assertEquals(-1, cache.getRowForPath(path13));
0972:                assertEquals(-1, cache.getRowForPath(path14));
0973:                assertEquals(0, cache.getRowForPath(path2));
0974:                assertEquals(1, cache.getRowForPath(path25));
0975:                assertEquals(2, cache.getRowForPath(path26));
0976:                if (isHarmony()) {
0977:                    assertFalse(cache.getExpandedState(path1));
0978:                }
0979:                root.remove(0);
0980:                cache.treeNodesRemoved(new TreeModelEvent(model, rootPath,
0981:                        new int[] { 0 }, new Object[] { node2 }));
0982:                if (isHarmony()) {
0983:                    assertEquals(-1, cache.getRowForPath(path1));
0984:                }
0985:                assertEquals(-1, cache.getRowForPath(path13));
0986:                assertEquals(-1, cache.getRowForPath(path14));
0987:                if (isHarmony()) {
0988:                    assertEquals(-1, cache.getRowForPath(path2));
0989:                }
0990:                assertEquals(-1, cache.getRowForPath(path25));
0991:                assertEquals(-1, cache.getRowForPath(path26));
0992:                if (isHarmony()) {
0993:                    assertFalse(cache.getExpandedState(path2));
0994:                }
0995:            }
0996:
0997:            /*
0998:             * Test method for 'javax.swing.tree.FixedHeightLayoutCache.treeStructureChanged(TreeModelEvent)'
0999:             */
1000:            public void testTreeStructureChanged() {
1001:                if (cache instanceof  ConcreteLayoutCache) {
1002:                    return;
1003:                }
1004:                TreeModel model = new UndefaultTreeModel(root);
1005:                root.add(node1);
1006:                root.add(node2);
1007:                node2.add(node5);
1008:                cache.setModel(model);
1009:                assertEquals(0, cache.getRowForPath(path1));
1010:                assertEquals(1, cache.getRowForPath(path2));
1011:                assertEquals(-1, cache.getRowForPath(path25));
1012:                assertEquals(-1, cache.getRowForPath(path26));
1013:                root.add(node3);
1014:                root.add(node4);
1015:                cache.treeStructureChanged(new TreeModelEvent(model, path1));
1016:                assertEquals(0, cache.getRowForPath(path1));
1017:                assertEquals(1, cache.getRowForPath(path2));
1018:                assertEquals(-1, cache.getRowForPath(path25));
1019:                assertEquals(-1, cache.getRowForPath(path26));
1020:                cache.treeStructureChanged(new TreeModelEvent(model, rootPath));
1021:                assertEquals(0, cache.getRowForPath(path1));
1022:                assertEquals(1, cache.getRowForPath(path2));
1023:                assertEquals(2, cache.getRowForPath(path3));
1024:                assertEquals(3, cache.getRowForPath(path4));
1025:                assertEquals(-1, cache.getRowForPath(path25));
1026:                assertEquals(-1, cache.getRowForPath(path26));
1027:                cache.setExpandedState(path2, true);
1028:                node2.add(node6);
1029:                assertEquals(0, cache.getRowForPath(path1));
1030:                assertEquals(1, cache.getRowForPath(path2));
1031:                assertEquals(2, cache.getRowForPath(path25));
1032:                if (!isHarmony()) {
1033:                    assertEquals(3, cache.getRowForPath(path3));
1034:                    assertEquals(4, cache.getRowForPath(path4));
1035:                }
1036:                cache.treeStructureChanged(new TreeModelEvent(model, path2));
1037:                assertEquals(0, cache.getRowForPath(path1));
1038:                assertEquals(1, cache.getRowForPath(path2));
1039:                assertEquals(2, cache.getRowForPath(path25));
1040:                assertEquals(3, cache.getRowForPath(path26));
1041:                assertEquals(4, cache.getRowForPath(path3));
1042:                assertEquals(5, cache.getRowForPath(path4));
1043:                cache.treeStructureChanged(new TreeModelEvent(model, rootPath));
1044:                assertEquals(0, cache.getRowForPath(path1));
1045:                assertEquals(1, cache.getRowForPath(path2));
1046:                assertEquals(-1, cache.getRowForPath(path25));
1047:                assertEquals(-1, cache.getRowForPath(path26));
1048:                assertEquals(2, cache.getRowForPath(path3));
1049:                assertEquals(3, cache.getRowForPath(path4));
1050:            }
1051:
1052:            public void testInvalidateSizes() {
1053:                if (cache instanceof  ConcreteLayoutCache) {
1054:                    return;
1055:                }
1056:                root.add(node1);
1057:                root.add(node2);
1058:                node2.add(node3);
1059:                node2.add(node4);
1060:                TreeModel model = new DefaultTreeModel(root);
1061:                cache.setModel(model);
1062:                cache.setExpandedState(path2, true);
1063:                cache.invalidateSizes();
1064:            }
1065:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.