1 19 20 package org.netbeans.modules.tasklist.usertasks.test; 21 22 import java.awt.Rectangle ; 23 import javax.swing.DefaultCellEditor ; 24 import javax.swing.JComboBox ; 25 import javax.swing.table.TableCellEditor ; 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 29 import org.netbeans.jellytools.FilesTabOperator; 30 import org.netbeans.jellytools.JellyTestCase; 31 import org.netbeans.jellytools.NbDialogOperator; 32 import org.netbeans.jellytools.TopComponentOperator; 33 import org.netbeans.jellytools.actions.Action; 34 import org.netbeans.jellytools.actions.OpenAction; 35 import org.netbeans.jellytools.nodes.Node; 36 import org.netbeans.jemmy.EventTool; 37 import org.netbeans.jemmy.operators.DialogOperator; 38 import org.netbeans.jemmy.operators.JButtonOperator; 39 import org.netbeans.jemmy.operators.JPopupMenuOperator; 40 import org.netbeans.jemmy.operators.JTableOperator; 41 import org.netbeans.junit.NbTestSuite; 42 43 46 public class TestTable extends JellyTestCase { 47 public TestTable(java.lang.String testName) { 48 super(testName); 49 } 50 51 public static Test suite() { 52 TestSuite suite = new NbTestSuite(TestTable.class); 53 return suite; 54 } 55 56 public static void main(java.lang.String [] args) { 57 junit.textui.TestRunner.run(suite()); 58 } 59 60 63 public void testShowTask() { 64 Node n = FilesTabOperator.invoke().getProjectNode("SampleApp"); 66 Node buildXml = new Node(n, "build.xml"); buildXml.select(); 68 new OpenAction().perform(buildXml); 69 70 TopComponentOperator tc = openIcsFile("test10.ics"); 72 JTableOperator t = new JTableOperator(tc, 0); 73 t.waitHasFocus(); 74 assertEquals(0, t.getSelectedRow()); 75 t.selectCell(1, 0); 76 77 Action ea = new Action(null, "Expand All"); ea.performPopup(t); 79 t.selectCell(1, 0); 80 81 t.clickForPopup(); 82 83 new EventTool().waitNoEvent(1500); 84 85 JPopupMenuOperator pm = new JPopupMenuOperator(); 86 pm.pushMenuNoBlock("Show Task"); 88 new NbDialogOperator("Show Task").close(); } 90 91 94 public void testStartTaskFillsOwner() { 95 121 } 122 123 126 public void testDelete() { 127 TopComponentOperator tc = openIcsFile("test15.ics"); 129 JTableOperator t = new JTableOperator(tc, 0); 130 t.waitHasFocus(); 131 132 Action ea = new Action(null, "Expand All"); ea.performPopup(t); 134 135 t.addRowSelectionInterval(5, 7); 136 t.addRowSelectionInterval(9, 9); 137 138 Rectangle r = t.getCellRect(5, 0, false); 139 t.clickForPopup(r.x, r.y); 140 141 new EventTool().waitNoEvent(1500); 142 143 JPopupMenuOperator pm = new JPopupMenuOperator(); 144 pm.pushMenuNoBlock("Delete"); 146 DialogOperator dop = new DialogOperator("Confirm Multiple Object Deletion"); JButtonOperator bo = new JButtonOperator(dop, "Yes"); bo.push(); 149 150 new EventTool().waitNoEvent(1500); 151 152 assertEquals(6, t.getSelectedRow()); 153 } 154 155 158 public void testCategoryInplace() { 159 TopComponentOperator tc = openIcsFile("test13.ics"); 161 JTableOperator t = new JTableOperator(tc, 0); 162 t.waitHasFocus(); 163 t.selectCell(1, 0); 164 165 Action ea = new Action(null, "Expand All"); ea.performPopup(t); 167 t.selectCell(3, 3); 168 t.editCellAt(3, 3); 169 TableCellEditor ed = t.getCellEditor(); 170 JComboBox cb = ((JComboBox ) ((DefaultCellEditor ) ed).getComponent()); 171 assertEquals(2, cb.getItemCount()); 172 assertEquals(cb.getItemAt(0), "CatA"); assertEquals(cb.getItemAt(1), "CatB"); } 175 176 182 private TopComponentOperator openIcsFile(String name) { 183 Node n = FilesTabOperator.invoke().getProjectNode("SampleApp"); 185 Node data = new Node(n, "ics|" + name); data.select(); 187 new OpenAction().perform(data); 188 189 TopComponentOperator op = new TopComponentOperator(name); 190 191 return op; 192 } 193 } 194 | Popular Tags |