1 19 20 package org.netbeans.modules.apisupport.project.ui; 21 22 import org.netbeans.api.project.ProjectManager; 23 import org.netbeans.modules.apisupport.project.NbModuleProject; 24 import org.netbeans.modules.apisupport.project.TestBase; 25 import org.netbeans.modules.apisupport.project.Util; 26 import org.netbeans.spi.project.ui.LogicalViewProvider; 27 import org.openide.nodes.Node; 28 29 32 public class LibrariesNodeTest extends TestBase { 33 34 public LibrariesNodeTest(String testName) { 35 super(testName); 36 } 37 38 public void testLibrariesNodeListening() throws Exception { 39 NbModuleProject p = generateStandaloneModule("module"); 40 LogicalViewProvider lvp = (LogicalViewProvider) p.getLookup().lookup(LogicalViewProvider.class); 41 assertNotNull("have a LogicalViewProvider", lvp); 42 Node root = lvp.createLogicalView(); 43 Node libraries = root.getChildren().findChild(LibrariesNode.LIBRARIES_NAME); 44 assertNotNull("have the Libraries node", libraries); 45 libraries.getChildren().getNodes(); 47 waitForChildrenUpdate(); 48 assertEquals("just jdk node is present", 1, libraries.getChildren().getNodes(true).length); 49 50 Util.addDependency(p, "org.netbeans.modules.java.project"); 51 ProjectManager.getDefault().saveProject(p); 52 53 waitForChildrenUpdate(); 54 assertEquals("dependency noticed", 2, libraries.getChildren().getNodes(true).length); 55 } 56 57 public void testDependencyNodeActions() throws Exception { 58 NbModuleProject p = generateStandaloneModule("module"); 59 LogicalViewProvider lvp = (LogicalViewProvider) p.getLookup().lookup(LogicalViewProvider.class); 60 Node root = lvp.createLogicalView(); 61 Node libraries = root.getChildren().findChild(LibrariesNode.LIBRARIES_NAME); 62 63 Util.addDependency(p, "org.netbeans.modules.java.project"); 64 ProjectManager.getDefault().saveProject(p); 65 libraries.getChildren().getNodes(); waitForChildrenUpdate(); 67 Node[] nodes = libraries.getChildren().getNodes(true); 68 assertEquals("dependency noticed", 2, nodes.length); 69 assertEquals("dependency noticed", 4, nodes[1].getActions(false).length); 70 } 71 72 private void waitForChildrenUpdate() { 73 LibrariesNode.RP.post(new Runnable () { 74 public void run() { 75 } 77 }).waitFinished(); 78 } 79 80 82 } 83 | Popular Tags |