1 19 20 package org.netbeans.test.junit.testcreation; 21 22 import org.netbeans.jellytools.Bundle; 23 import org.netbeans.jellytools.EditorOperator; 24 import org.netbeans.jellytools.MainWindowOperator; 25 import org.netbeans.jellytools.ProjectsTabOperator; 26 import org.netbeans.jellytools.nodes.Node; 27 import org.netbeans.jemmy.operators.JMenuBarOperator; 28 import org.netbeans.jemmy.operators.JMenuItemOperator; 29 import org.netbeans.jemmy.operators.JMenuOperator; 30 import org.netbeans.junit.NbTestCase; 31 import org.netbeans.junit.NbTestSuite; 32 import org.netbeans.test.junit.utils.Utilities; 33 34 38 public class GotoTest extends NbTestCase { 39 private static final String TEST_PACKAGE_NAME = 40 "org.netbeans.test.junit.testresults.test"; 41 42 private static final String TEST_PACKAGE_PACKAGEGOTO_NAME = 43 "org.netbeans.test.junit.go.test"; 44 45 46 public GotoTest(String testName) { 47 super(testName); 48 } 49 50 54 public static NbTestSuite suite() { 55 NbTestSuite suite = new NbTestSuite(GotoTest.class); 56 return suite; 57 } 58 59 62 public void testSelectTestFromMainMenu() { 63 Node n = Utilities.openFile(Utilities.SRC_PACKAGES_PATH + 65 "|" + TEST_PACKAGE_NAME+ "|" + Utilities.TEST_CLASS_NAME); 66 67 EditorOperator eos = new EditorOperator(Utilities.TEST_CLASS_NAME); 68 69 JMenuBarOperator jbo = new JMenuBarOperator( 70 MainWindowOperator.getDefault().getJMenuBar()); 71 String [] sf = {Bundle.getStringTrimmed("org.netbeans.core.Bundle", 72 "Menu/GoTo"), 73 Bundle.getStringTrimmed("org.netbeans.modules.junit.Bundle", 74 "LBL_Action_GoToTest")}; 75 jbo.pushMenu(sf[0]); 76 JMenuItemOperator jmio = new JMenuItemOperator(new JMenuOperator(jbo, sf[0]).getItem(0)); 77 assertTrue("Goto Test disabled when invoked from Editor!", jmio.isEnabled()); 79 jbo.pushMenu(sf); 80 EditorOperator eo = new EditorOperator(Utilities.TEST_CLASS_NAME + "Test"); 82 assertTrue("Test for \"" + TEST_PACKAGE_NAME + 83 Utilities.TEST_CLASS_NAME + "\" not opened!", eo.isVisible()); 84 eo.close(false); 85 eos.close(false); 86 } 87 88 91 public void testSelectTestFromExplorer() { 92 Node pn = new ProjectsTabOperator().getProjectRootNode( 94 Utilities.TEST_PROJECT_NAME); 95 pn.select(); 96 Node n = new Node(pn, Utilities.SRC_PACKAGES_PATH + 97 "|" + TEST_PACKAGE_NAME+ "|" + Utilities.TEST_CLASS_NAME); 98 n.select(); 99 100 JMenuBarOperator jbo = new JMenuBarOperator( 101 MainWindowOperator.getDefault().getJMenuBar()); 102 103 String [] sf = {Bundle.getStringTrimmed("org.netbeans.core.Bundle", 104 "Menu/GoTo"), 105 Bundle.getStringTrimmed("org.netbeans.modules.junit.Bundle", 106 "LBL_Action_GoToTest")}; 107 jbo.pushMenu(sf[0]); 108 JMenuItemOperator jmio = new JMenuItemOperator(new JMenuOperator(jbo, sf[0]).getItem(0)); 109 assertTrue("Goto Test disabled when invoked from Explorer, over a class node!" + 111 "see: http://www.netbeans.org/issues/show_bug.cgi?id=88599", 112 jmio.isEnabled()); 113 jbo.pushMenu(sf); 114 EditorOperator eot = new EditorOperator(Utilities.TEST_CLASS_NAME); 115 assertTrue("Test for \"" + TEST_PACKAGE_NAME + 116 Utilities.TEST_CLASS_NAME + "\" not opened!", eot.isVisible()); 117 eot.close(false); 118 } 119 120 123 public void testSelectTestFromExplorerPackage() { 124 Node pn = new ProjectsTabOperator().getProjectRootNode( 126 Utilities.TEST_PROJECT_NAME); 127 pn.select(); 128 Node n = new Node(pn, Utilities.SRC_PACKAGES_PATH + 129 "|" + TEST_PACKAGE_PACKAGEGOTO_NAME); 130 n.select(); 132 JMenuBarOperator jbo = new JMenuBarOperator( 133 MainWindowOperator.getDefault().getJMenuBar()); 134 135 String [] sf = {Bundle.getStringTrimmed("org.netbeans.core.Bundle", 136 "Menu/GoTo"), 137 Bundle.getStringTrimmed("org.netbeans.modules.junit.Bundle", 138 "LBL_Action_GoToTest")}; 139 jbo.pushMenu(sf[0]); 140 JMenuItemOperator jmio = new JMenuItemOperator(new JMenuOperator(jbo, sf[0]).getItem(0)); 141 assertTrue("Goto Test disabled when invoked from Explorer, over a package node!" + 143 "see: http://www.netbeans.org/issues/show_bug.cgi?id=88599", 144 jmio.isEnabled()); 145 jbo.pushMenu(sf); 146 EditorOperator eot = new EditorOperator("TestSuite"); assertTrue("Test suite for \"" + TEST_PACKAGE_PACKAGEGOTO_NAME + 148 "\" (TestSuite.java) not opened!", eot.isVisible()); 149 eot.close(false); 150 } 151 152 153 154 } 155 | Popular Tags |