1 19 20 package org.openide.explorer.view; 21 22 import javax.swing.JPanel ; 23 import javax.swing.tree.TreeNode ; 24 import org.netbeans.junit.NbTestCase; 25 import org.netbeans.junit.NbTestSuite; 26 import org.openide.explorer.ExplorerManager; 27 import org.openide.nodes.AbstractNode; 28 import org.openide.nodes.Children; 29 import org.openide.nodes.Node; 30 31 34 public class VisualizerSpeed95364Test extends NbTestCase { 35 private int size; 36 private TreeNode toCheck; 37 38 42 public VisualizerSpeed95364Test(String name) { 43 super(name); 44 } 45 46 50 public static NbTestSuite suite() { 51 return NbTestSuite.speedSuite( 52 VisualizerSpeed95364Test.class, 53 10 , 54 3 55 ); 56 } 57 58 61 protected void setUp() { 62 size = getTestNumber(); 63 final MyKeys chK = new MyKeys(); 64 final AbstractNode root = new AbstractNode(chK); 65 root.setName("test root"); 66 67 final String [] childrenNames = new String [size]; 68 for (int i = 0; i < size; i++) { 69 childrenNames[i] = "test"+i; 70 }; 71 chK.mySetKeys(childrenNames); 72 toCheck = Visualizer.findVisualizer(root); 73 } 74 75 private void doTest() { 76 TreeNode tn = null; 77 for (int i = 0; i < 100000; i++) { 78 tn = toCheck.getChildAt(size/2); 79 } 80 } 81 82 85 public void test10() { doTest(); } 86 89 public void test100() { doTest(); } 90 93 public void test1000() { doTest(); } 94 95 96 private static Node createLeaf(String name) { 97 AbstractNode n = new AbstractNode(Children.LEAF); 98 n.setName(name); 99 return n; 100 } 101 102 private static final class MyKeys extends Children.Keys { 103 protected Node [] createNodes(Object key) { 104 return new Node [] { createLeaf(key.toString())}; 105 } 106 107 public void mySetKeys(Object [] newKeys) { 108 super.setKeys(newKeys); 109 } 110 } 111 } 112 | Popular Tags |