1 19 20 package org.openide.explorer.view; 21 22 import java.awt.Image ; 23 import javax.swing.Icon ; 24 import javax.swing.tree.TreeNode ; 25 import org.netbeans.junit.NbTestCase; 26 import org.openide.nodes.AbstractNode; 27 import org.openide.nodes.Children; 28 import org.openide.nodes.Node; 29 30 32 public class VisualizerNodeTest extends NbTestCase { 33 34 public VisualizerNodeTest(String name) { 35 super(name); 36 } 37 38 protected boolean runInEQ() { 39 return true; 40 } 41 42 public void testIconIsProvidedEvenTheNodeIsBrokenIssue46727() { 43 final boolean[] arr = new boolean[1]; 44 45 AbstractNode a = new AbstractNode(Children.LEAF) { 46 public Image getIcon(int type) { 47 arr[0] = true; 48 return null; 49 } 50 }; 51 52 VisualizerNode v = VisualizerNode.getVisualizer(null, a); 53 assertNotNull("Visualizer node", v); 54 55 Icon icon = v.getIcon(false, false); 56 assertNotNull("Cannot be null even the node's icon is null", icon); 57 assertTrue("getIcon called", arr[0]); 58 } 59 60 public void testIndexOfProvidesResultsEvenIfTheVisualizerIsComputedViaDifferentMeans() throws Exception { 61 AbstractNode a = new AbstractNode(new Children.Array()); 62 AbstractNode m = new AbstractNode(Children.LEAF); 63 a.getChildren().add(new Node [] { Node.EMPTY.cloneNode(), m, Node.EMPTY.cloneNode() }); 64 65 TreeNode ta = Visualizer.findVisualizer(a); 66 TreeNode tm = Visualizer.findVisualizer(m); 67 68 assertEquals("Index is 1", 1, ta.getIndex(tm)); 69 } 70 } 71 | Popular Tags |