1 19 20 package org.netbeans.modules.java.freeform.ui; 21 22 import org.netbeans.modules.ant.freeform.TestBase; 23 import org.netbeans.modules.java.freeform.JavaProjectNature; 24 import org.netbeans.spi.project.ui.LogicalViewProvider; 25 import org.openide.loaders.DataObject; 26 import org.openide.nodes.Children; 27 import org.openide.nodes.Node; 28 29 33 public class ViewTest extends TestBase { 34 35 public ViewTest(String name) { 36 super(name); 37 } 38 39 private LogicalViewProvider lvp; 40 41 protected void setUp() throws Exception { 42 super.setUp(); 43 lvp = extsrcroot.getLookup().lookup(LogicalViewProvider.class); 44 assertNotNull("found a LogicalViewProvider", lvp); 45 } 46 47 public void testViewItemBasic() throws Exception { 48 Node root = lvp.createLogicalView(); 49 Children ch = root.getChildren(); 50 Node[] kids = ch.getNodes(true); 51 assertEquals("two child nodes", 2, kids.length); 52 assertEquals("correct code name #1", "../src", kids[0].getName()); 53 assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName()); 54 assertEquals("correct cookie #1", 55 DataObject.find(egdirFO.getFileObject("extsrcroot/src")), 56 kids[0].getLookup().lookup(DataObject.class)); 57 Node[] kids2 = kids[0].getChildren().getNodes(true); 58 assertEquals("one child of ../src", 1, kids2.length); 59 assertEquals("correct name of #1's kid", "org.foo", kids2[0].getName()); 60 } 62 63 public void testFindPath() throws Exception { 64 LogicalViewProvider lvp2 = simple.getLookup().lookup(LogicalViewProvider.class); 65 assertNotNull(lvp2); 66 Node root = lvp2.createLogicalView(); 67 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src/org/foo/myapp/MyApp.java"); 68 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src/org/foo/myapp"); 69 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathNegative(lvp2, root, simple, "src/org/foo"); 70 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathNegative(lvp2, root, simple, "src/org"); 71 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src"); 72 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "antsrc/org/foo/ant/SpecialTask.java"); 73 } 74 75 public void testIncludesExcludes() throws Exception { 76 org.netbeans.modules.ant.freeform.ui.ViewTest.doTestIncludesExcludes(this, JavaProjectNature.STYLE_PACKAGES, 77 "prj{s{ignored{file} relevant.excluded{file} relevant.included{file}}}", 78 "prj{s{relevant.included{file}}}", 79 "prj{s{ignored{file} relevant.included{file}}}", 80 "prj{s{relevant.included{file}}}"); 81 } 82 83 } 84 | Popular Tags |