1 24 25 package org.netbeans.test.utilities.search; 26 27 import java.util.Hashtable ; 28 import java.util.Iterator ; 29 import org.netbeans.jellytools.NbDialogOperator; 30 import org.netbeans.jemmy.ComponentChooser; 31 import org.netbeans.jemmy.ComponentChooser; 32 import org.netbeans.jemmy.operators.JComboBoxOperator; 33 import org.netbeans.jemmy.operators.JTabbedPaneOperator; 34 import org.netbeans.junit.NbTestCase; 35 import org.netbeans.junit.NbTestSuite; 36 import org.netbeans.test.utilities.operators.SearchResultsOperator; 37 import org.netbeans.test.utilities.testcase.Utilities; 38 39 43 public class BasicSearchTest extends NbTestCase { 44 45 46 private static final String TEST_PACKAGE_PATH = 47 "org.netbeans.test.utilities.basicsearch"; 48 49 50 public BasicSearchTest(String testName) { 51 super(testName); 52 } 53 54 58 public static NbTestSuite suite() { 59 NbTestSuite suite = new NbTestSuite(BasicSearchTest.class); 60 return suite; 61 } 62 63 public void testSearchForClass() { 64 NbDialogOperator ndo = Utilities.getFindDialog(); 65 JTabbedPaneOperator jtpo = new JTabbedPaneOperator(ndo, 0); 66 jtpo.selectPage(0); 67 68 JComboBoxOperator jcbo = new JComboBoxOperator(ndo, 69 new JComboBoxOperator.JComboBoxFinder()); 70 jcbo.enterText("class"); 72 SearchResultsOperator sro = new SearchResultsOperator(); 73 assertTrue("Junit Output window should be visible", sro.isVisible()); 74 System.out.println("## Search output opened"); 75 Utilities.takeANap(1000); 76 sro.close(); 77 assertFalse("Search window is visible," + 78 "should be closed", sro.isShowing()); 79 } 80 81 84 public void testRememberSearchesInsideComboBox() { 85 for (int i = 0; i < 10; i++) { 87 NbDialogOperator ndo = Utilities.getFindDialog(); 88 JTabbedPaneOperator jtpo = new JTabbedPaneOperator(ndo, 0); 89 jtpo.selectPage(0); 90 91 JComboBoxOperator jcbo = new JComboBoxOperator(ndo, 92 new JComboBoxOperator.JComboBoxFinder()); 93 jcbo.enterText("a" + i); 94 Utilities.takeANap(500); 95 } 96 NbDialogOperator ndo = Utilities.getFindDialog(); 98 JTabbedPaneOperator jtpo = new JTabbedPaneOperator(ndo, 0); 99 jtpo.selectPage(0); 100 101 JComboBoxOperator jcbo = new JComboBoxOperator(ndo, 102 new JComboBoxOperator.JComboBoxFinder()); 103 104 for (int i = 0; i < jcbo.getItemCount() - 1; i++) { 105 assertEquals("Found " + jcbo.getItemAt(i).toString() +" in search combo" + 106 "expected" + new Integer (9-i).toString() + ".", 107 jcbo.getItemAt(i).toString(), "a" + new Integer (9-i).toString()); 108 } 109 assertEquals("Expected 'class', found: " + 110 jcbo.getItemAt(jcbo.getItemCount()-1), 111 jcbo.getItemAt(jcbo.getItemCount()-1), "class"); 112 113 } 114 115 116 private String soutHashTable(Hashtable ht) { 117 StringBuffer sb = new StringBuffer (); 118 Iterator itv = ht.values().iterator(); 119 for (Iterator it = ht.keySet().iterator(); it.hasNext();) { 120 sb.append("KEY: " + it.next() + " Value: " + itv.next() + "\n"); 121 122 } 123 return sb.toString(); 124 } 125 126 127 } 128 | Popular Tags |