1*80a6f5c5SLiu Zhe package fvt.gui.sw.table; 2*80a6f5c5SLiu Zhe 3*80a6f5c5SLiu Zhe import static org.junit.Assert.*; 4*80a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*; 5*80a6f5c5SLiu Zhe import static testlib.gui.AppTool.*; 6*80a6f5c5SLiu Zhe import static testlib.gui.UIMap.*; 7*80a6f5c5SLiu Zhe 8*80a6f5c5SLiu Zhe import org.junit.After; 9*80a6f5c5SLiu Zhe import org.junit.Before; 10*80a6f5c5SLiu Zhe import org.junit.Ignore; 11*80a6f5c5SLiu Zhe import org.junit.Rule; 12*80a6f5c5SLiu Zhe import org.junit.Test; 13*80a6f5c5SLiu Zhe import org.openoffice.test.common.Logger; 14*80a6f5c5SLiu Zhe import org.openoffice.test.common.SystemUtil; 15*80a6f5c5SLiu Zhe 16*80a6f5c5SLiu Zhe 17*80a6f5c5SLiu Zhe public class TableGeneral { 18*80a6f5c5SLiu Zhe 19*80a6f5c5SLiu Zhe @Rule 20*80a6f5c5SLiu Zhe public Logger log = Logger.getLogger(this); 21*80a6f5c5SLiu Zhe 22*80a6f5c5SLiu Zhe @Before 23*80a6f5c5SLiu Zhe public void setUp() throws Exception { 24*80a6f5c5SLiu Zhe // Start OpenOffice 25*80a6f5c5SLiu Zhe app.start(); 26*80a6f5c5SLiu Zhe 27*80a6f5c5SLiu Zhe // Create a new text document 28*80a6f5c5SLiu Zhe app.dispatch("private:factory/swriter"); 29*80a6f5c5SLiu Zhe 30*80a6f5c5SLiu Zhe // Insert a table 31*80a6f5c5SLiu Zhe app.dispatch(".uno:InsertTable"); 32*80a6f5c5SLiu Zhe assertTrue("Insert Table dialog pop up", writerInsertTable.exists()); 33*80a6f5c5SLiu Zhe } 34*80a6f5c5SLiu Zhe 35*80a6f5c5SLiu Zhe @After 36*80a6f5c5SLiu Zhe public void tearDown() throws Exception { 37*80a6f5c5SLiu Zhe app.close(); 38*80a6f5c5SLiu Zhe } 39*80a6f5c5SLiu Zhe 40*80a6f5c5SLiu Zhe @Test 41*80a6f5c5SLiu Zhe // Test setting table size in text document 42*80a6f5c5SLiu Zhe public void testTableSize() throws Exception { 43*80a6f5c5SLiu Zhe 44*80a6f5c5SLiu Zhe swTableSizeColBox.focus(); 45*80a6f5c5SLiu Zhe typeKeys("<delete>"); 46*80a6f5c5SLiu Zhe typeKeys("3"); 47*80a6f5c5SLiu Zhe swTableSizeRowBox.focus(); 48*80a6f5c5SLiu Zhe typeKeys("<delete>"); 49*80a6f5c5SLiu Zhe typeKeys("4"); 50*80a6f5c5SLiu Zhe writerInsertTable.ok(); 51*80a6f5c5SLiu Zhe 52*80a6f5c5SLiu Zhe writer.focus(); // verify how many rows in the table 53*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 54*80a6f5c5SLiu Zhe for (int i = 0; i < 3; i++) { 55*80a6f5c5SLiu Zhe typeKeys("<down>"); 56*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 57*80a6f5c5SLiu Zhe } 58*80a6f5c5SLiu Zhe typeKeys("<down>"); 59*80a6f5c5SLiu Zhe sleep(1); 60*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 61*80a6f5c5SLiu Zhe } 62*80a6f5c5SLiu Zhe 63*80a6f5c5SLiu Zhe // Test setting table cell background in text document 64*80a6f5c5SLiu Zhe 65*80a6f5c5SLiu Zhe @Test 66*80a6f5c5SLiu Zhe @Ignore 67*80a6f5c5SLiu Zhe // bug120378 68*80a6f5c5SLiu Zhe public void testTableBackground() throws Exception { 69*80a6f5c5SLiu Zhe writerInsertTable.ok(); 70*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 71*80a6f5c5SLiu Zhe writer.focus(); 72*80a6f5c5SLiu Zhe // set table cell background 73*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 74*80a6f5c5SLiu Zhe swTableBackground.select(); 75*80a6f5c5SLiu Zhe assertTrue("Table background property dialog pop up", 76*80a6f5c5SLiu Zhe swTableBackground.exists()); 77*80a6f5c5SLiu Zhe ; 78*80a6f5c5SLiu Zhe swTableBackgroundColor.focus(); 79*80a6f5c5SLiu Zhe swTableBackgroundColor.click(50, 50); 80*80a6f5c5SLiu Zhe swTableBackground.ok(); 81*80a6f5c5SLiu Zhe // verify table cell background color 82*80a6f5c5SLiu Zhe writer.focus(); 83*80a6f5c5SLiu Zhe // select the cell which is filled with color 84*80a6f5c5SLiu Zhe app.dispatch(".uno:EntireCell"); 85*80a6f5c5SLiu Zhe 86*80a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 87*80a6f5c5SLiu Zhe app.dispatch("private:factory/simpress?slot=6686"); 88*80a6f5c5SLiu Zhe presentationWizard.ok(); 89*80a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 90*80a6f5c5SLiu Zhe // enable table cell area format dialog 91*80a6f5c5SLiu Zhe app.dispatch(".uno:FormatArea"); 92*80a6f5c5SLiu Zhe sleep(1); 93*80a6f5c5SLiu Zhe assertEquals("Light red", sdTableBACGColorListbox.getSelText()); 94*80a6f5c5SLiu Zhe // close table cell area format dialog 95*80a6f5c5SLiu Zhe sdTableBACGColorArea.cancel(); 96*80a6f5c5SLiu Zhe } 97*80a6f5c5SLiu Zhe 98*80a6f5c5SLiu Zhe // Test setting table border in text document 99*80a6f5c5SLiu Zhe 100*80a6f5c5SLiu Zhe @Test 101*80a6f5c5SLiu Zhe public void testTableBorder() throws Exception { 102*80a6f5c5SLiu Zhe writerInsertTable.ok(); 103*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 104*80a6f5c5SLiu Zhe // set table border as none 105*80a6f5c5SLiu Zhe writer.focus(); 106*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 107*80a6f5c5SLiu Zhe swTableBorder.select(); 108*80a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 109*80a6f5c5SLiu Zhe swTableBorder.exists()); 110*80a6f5c5SLiu Zhe ; 111*80a6f5c5SLiu Zhe swTableBorderLineArrange.click(10, 10); 112*80a6f5c5SLiu Zhe swTableBorder.ok(); 113*80a6f5c5SLiu Zhe } 114*80a6f5c5SLiu Zhe 115*80a6f5c5SLiu Zhe // Test setting table border line style,line color,spacing to content in 116*80a6f5c5SLiu Zhe // text document 117*80a6f5c5SLiu Zhe 118*80a6f5c5SLiu Zhe @Test 119*80a6f5c5SLiu Zhe public void testTableBorderLineStyle() throws Exception { 120*80a6f5c5SLiu Zhe writerInsertTable.ok(); 121*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 122*80a6f5c5SLiu Zhe writer.focus(); 123*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 124*80a6f5c5SLiu Zhe swTableBorder.select(); 125*80a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 126*80a6f5c5SLiu Zhe swTableBorder.exists()); 127*80a6f5c5SLiu Zhe ; 128*80a6f5c5SLiu Zhe swTableBorderLineStyle.select(8); // set line style 129*80a6f5c5SLiu Zhe swTableBorderLineColor.select(5); // set line color 130*80a6f5c5SLiu Zhe swTableSTCLeft.focus(); // set spacing to content 131*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 132*80a6f5c5SLiu Zhe typeKeys("<delete>"); 133*80a6f5c5SLiu Zhe typeKeys("0.5"); // set spacing to content 134*80a6f5c5SLiu Zhe swTableShadow.click(40, 10); // set table shadow 135*80a6f5c5SLiu Zhe swTableShadowSize.focus(); 136*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 137*80a6f5c5SLiu Zhe typeKeys("<delete>"); 138*80a6f5c5SLiu Zhe typeKeys("2"); 139*80a6f5c5SLiu Zhe swTableShadowColor.select(5); 140*80a6f5c5SLiu Zhe swTableBorder.ok(); 141*80a6f5c5SLiu Zhe 142*80a6f5c5SLiu Zhe writer.focus(); // verify the setting property of table 143*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 144*80a6f5c5SLiu Zhe swTableBorder.select(); 145*80a6f5c5SLiu Zhe assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8)); 146*80a6f5c5SLiu Zhe assertEquals("Magenta", swTableBorderLineColor.getItemText(5)); 147*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 148*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCRight.getText()); 149*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCTop.getText()); 150*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCBottom.getText()); 151*80a6f5c5SLiu Zhe assertEquals("1.97\"", swTableShadowSize.getText()); 152*80a6f5c5SLiu Zhe assertEquals("Magenta", swTableShadowColor.getItemText(5)); 153*80a6f5c5SLiu Zhe assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 154*80a6f5c5SLiu Zhe swTableBorder.close(); 155*80a6f5c5SLiu Zhe 156*80a6f5c5SLiu Zhe // uncheck Synchronize box and set spacing to content 157*80a6f5c5SLiu Zhe 158*80a6f5c5SLiu Zhe writer.focus(); 159*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 160*80a6f5c5SLiu Zhe swTableBorder.select(); 161*80a6f5c5SLiu Zhe swTableSTCSYNC.uncheck(); 162*80a6f5c5SLiu Zhe swTableSTCLeft.focus();// set left spacing to content 163*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 164*80a6f5c5SLiu Zhe typeKeys("<delete>"); 165*80a6f5c5SLiu Zhe typeKeys("0.5"); 166*80a6f5c5SLiu Zhe swTableSTCRight.focus();// set right spacing to content 167*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 168*80a6f5c5SLiu Zhe typeKeys("<delete>"); 169*80a6f5c5SLiu Zhe typeKeys("0.8"); 170*80a6f5c5SLiu Zhe swTableSTCTop.focus();// set top spacing to content 171*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 172*80a6f5c5SLiu Zhe typeKeys("<delete>"); 173*80a6f5c5SLiu Zhe typeKeys("1.0"); 174*80a6f5c5SLiu Zhe swTableSTCBottom.focus();// set bottom spacing to content 175*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 176*80a6f5c5SLiu Zhe typeKeys("<delete>"); 177*80a6f5c5SLiu Zhe typeKeys("2"); 178*80a6f5c5SLiu Zhe swTableBorder.ok(); 179*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 180*80a6f5c5SLiu Zhe 181*80a6f5c5SLiu Zhe writer.focus(); // verify the setting value of spacing to content for 182*80a6f5c5SLiu Zhe // tabel 183*80a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 184*80a6f5c5SLiu Zhe swTableBorder.select(); 185*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 186*80a6f5c5SLiu Zhe assertEquals("0.80\"", swTableSTCRight.getText()); 187*80a6f5c5SLiu Zhe assertEquals("1.00\"", swTableSTCTop.getText()); 188*80a6f5c5SLiu Zhe assertEquals("1.97\"", swTableSTCBottom.getText()); 189*80a6f5c5SLiu Zhe assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 190*80a6f5c5SLiu Zhe swTableBorder.close(); 191*80a6f5c5SLiu Zhe } 192*80a6f5c5SLiu Zhe 193*80a6f5c5SLiu Zhe // create table with auto format 194*80a6f5c5SLiu Zhe 195*80a6f5c5SLiu Zhe @Test 196*80a6f5c5SLiu Zhe public void testTableAutoFormat() throws Exception { 197*80a6f5c5SLiu Zhe // create table with auto format 198*80a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 199*80a6f5c5SLiu Zhe assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists()); 200*80a6f5c5SLiu Zhe swTableAutoFormatListbox.select(3); 201*80a6f5c5SLiu Zhe swTableAutoFMT.ok(); 202*80a6f5c5SLiu Zhe // verify the auto format is that just selected 203*80a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 204*80a6f5c5SLiu Zhe assertEquals("Blue", swTableAutoFormatListbox.getSelText()); 205*80a6f5c5SLiu Zhe swTableAutoFMT.close(); 206*80a6f5c5SLiu Zhe writerInsertTable.ok(); 207*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 208*80a6f5c5SLiu Zhe 209*80a6f5c5SLiu Zhe } 210*80a6f5c5SLiu Zhe 211*80a6f5c5SLiu Zhe // set row height and select row,insert/delete row 212*80a6f5c5SLiu Zhe 213*80a6f5c5SLiu Zhe @Test 214*80a6f5c5SLiu Zhe public void testTableRowHeight() throws Exception { 215*80a6f5c5SLiu Zhe writerInsertTable.ok(); 216*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 217*80a6f5c5SLiu Zhe 218*80a6f5c5SLiu Zhe // set row height 219*80a6f5c5SLiu Zhe writer.focus(); 220*80a6f5c5SLiu Zhe writer.openContextMenu(); 221*80a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 222*80a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 223*80a6f5c5SLiu Zhe swTableSetRowHeight.focus(); 224*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 225*80a6f5c5SLiu Zhe typeKeys("<delete>"); 226*80a6f5c5SLiu Zhe typeKeys("0.5"); 227*80a6f5c5SLiu Zhe swTableSetRowHeightDialog.ok(); 228*80a6f5c5SLiu Zhe 229*80a6f5c5SLiu Zhe // verify row height 230*80a6f5c5SLiu Zhe writer.focus(); 231*80a6f5c5SLiu Zhe writer.openContextMenu(); 232*80a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 233*80a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 234*80a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSetRowHeight.getText()); 235*80a6f5c5SLiu Zhe swTableSetRowHeightDialog.close(); 236*80a6f5c5SLiu Zhe } 237*80a6f5c5SLiu Zhe 238*80a6f5c5SLiu Zhe // select row 239*80a6f5c5SLiu Zhe @Test 240*80a6f5c5SLiu Zhe public void testTableSelectRow() throws Exception { 241*80a6f5c5SLiu Zhe writerInsertTable.ok(); 242*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 243*80a6f5c5SLiu Zhe // select row 244*80a6f5c5SLiu Zhe writer.focus(); 245*80a6f5c5SLiu Zhe writer.openContextMenu(); 246*80a6f5c5SLiu Zhe swTableSelectRowMenu.select(); 247*80a6f5c5SLiu Zhe 248*80a6f5c5SLiu Zhe // verify select one row successfully 249*80a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 250*80a6f5c5SLiu Zhe typeKeys("<down>"); 251*80a6f5c5SLiu Zhe typeKeys("<down>"); 252*80a6f5c5SLiu Zhe typeKeys("<enter>"); 253*80a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 254*80a6f5c5SLiu Zhe typeKeys("<up>"); 255*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 256*80a6f5c5SLiu Zhe 257*80a6f5c5SLiu Zhe } 258*80a6f5c5SLiu Zhe 259*80a6f5c5SLiu Zhe // insert row and verify how many row inserted 260*80a6f5c5SLiu Zhe @Test 261*80a6f5c5SLiu Zhe public void testTableInsertRow() throws Exception { 262*80a6f5c5SLiu Zhe writerInsertTable.ok(); 263*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 264*80a6f5c5SLiu Zhe writer.focus(); 265*80a6f5c5SLiu Zhe writer.openContextMenu(); 266*80a6f5c5SLiu Zhe swTableInsertRowMenu.select(); 267*80a6f5c5SLiu Zhe assertTrue("SWTable_InsertRow Dialog pop up", 268*80a6f5c5SLiu Zhe swTableInsertRow.exists()); 269*80a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 270*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 271*80a6f5c5SLiu Zhe typeKeys("<delete>"); 272*80a6f5c5SLiu Zhe typeKeys("3"); 273*80a6f5c5SLiu Zhe swTableInsertRow.ok(); 274*80a6f5c5SLiu Zhe 275*80a6f5c5SLiu Zhe writer.focus(); // verify how many rows in the table 276*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 277*80a6f5c5SLiu Zhe for (int i = 0; i < 4; i++) { 278*80a6f5c5SLiu Zhe typeKeys("<down>"); 279*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 280*80a6f5c5SLiu Zhe } 281*80a6f5c5SLiu Zhe typeKeys("<down>"); 282*80a6f5c5SLiu Zhe sleep(1); 283*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 284*80a6f5c5SLiu Zhe } 285*80a6f5c5SLiu Zhe 286*80a6f5c5SLiu Zhe // delete row and verify row 287*80a6f5c5SLiu Zhe @Test 288*80a6f5c5SLiu Zhe public void testTableRowDelete() throws Exception { 289*80a6f5c5SLiu Zhe writerInsertTable.ok(); 290*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 291*80a6f5c5SLiu Zhe // delete row 292*80a6f5c5SLiu Zhe writer.focus(); 293*80a6f5c5SLiu Zhe writer.openContextMenu(); 294*80a6f5c5SLiu Zhe swTableRowDleteMenu.select(); 295*80a6f5c5SLiu Zhe // verify whether delete row 296*80a6f5c5SLiu Zhe writer.focus(); 297*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 298*80a6f5c5SLiu Zhe typeKeys("<down>"); 299*80a6f5c5SLiu Zhe sleep(1); 300*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 301*80a6f5c5SLiu Zhe 302*80a6f5c5SLiu Zhe } 303*80a6f5c5SLiu Zhe 304*80a6f5c5SLiu Zhe // set column width and verify 305*80a6f5c5SLiu Zhe @Test 306*80a6f5c5SLiu Zhe public void testTableColumnWidth() throws Exception { 307*80a6f5c5SLiu Zhe writerInsertTable.ok(); 308*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 309*80a6f5c5SLiu Zhe // set column width 310*80a6f5c5SLiu Zhe writer.focus(); 311*80a6f5c5SLiu Zhe writer.openContextMenu(); 312*80a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 313*80a6f5c5SLiu Zhe swTableSetColumnWidth.focus(); 314*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 315*80a6f5c5SLiu Zhe typeKeys("<delete>"); 316*80a6f5c5SLiu Zhe typeKeys("2"); 317*80a6f5c5SLiu Zhe swTableSetColumnDialog.ok(); 318*80a6f5c5SLiu Zhe // verify column width 319*80a6f5c5SLiu Zhe writer.focus(); 320*80a6f5c5SLiu Zhe writer.openContextMenu(); 321*80a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 322*80a6f5c5SLiu Zhe assertEquals("2.00\"", swTableSetColumnWidth.getText()); 323*80a6f5c5SLiu Zhe 324*80a6f5c5SLiu Zhe } 325*80a6f5c5SLiu Zhe 326*80a6f5c5SLiu Zhe // select column and verify 327*80a6f5c5SLiu Zhe @Test 328*80a6f5c5SLiu Zhe public void testTableColumnSelect() throws Exception { 329*80a6f5c5SLiu Zhe writerInsertTable.ok(); 330*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 331*80a6f5c5SLiu Zhe writer.focus(); 332*80a6f5c5SLiu Zhe writer.openContextMenu(); 333*80a6f5c5SLiu Zhe swTableColumnSelectMenu.select(); 334*80a6f5c5SLiu Zhe 335*80a6f5c5SLiu Zhe // verify select one column 336*80a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 337*80a6f5c5SLiu Zhe typeKeys("<down>"); 338*80a6f5c5SLiu Zhe typeKeys("<down>"); 339*80a6f5c5SLiu Zhe typeKeys("<enter>"); 340*80a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 341*80a6f5c5SLiu Zhe typeKeys("<up>"); 342*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 343*80a6f5c5SLiu Zhe 344*80a6f5c5SLiu Zhe } 345*80a6f5c5SLiu Zhe 346*80a6f5c5SLiu Zhe // insert column and verify 347*80a6f5c5SLiu Zhe @Test 348*80a6f5c5SLiu Zhe public void testTableColumnInsert() throws Exception { 349*80a6f5c5SLiu Zhe writerInsertTable.ok(); 350*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 351*80a6f5c5SLiu Zhe // insert column 352*80a6f5c5SLiu Zhe writer.focus(); 353*80a6f5c5SLiu Zhe writer.openContextMenu(); 354*80a6f5c5SLiu Zhe swTableColumnInsertMenu.select(); 355*80a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 356*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 357*80a6f5c5SLiu Zhe typeKeys("<delete>"); 358*80a6f5c5SLiu Zhe typeKeys("3"); 359*80a6f5c5SLiu Zhe swTableInsertColumn.ok(); 360*80a6f5c5SLiu Zhe // verify insert column successfully 361*80a6f5c5SLiu Zhe writer.focus(); 362*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 363*80a6f5c5SLiu Zhe for (int i = 0; i < 9; i++) { 364*80a6f5c5SLiu Zhe typeKeys("<right>"); 365*80a6f5c5SLiu Zhe sleep(1); 366*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 367*80a6f5c5SLiu Zhe } 368*80a6f5c5SLiu Zhe typeKeys("<right>"); 369*80a6f5c5SLiu Zhe sleep(1); 370*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 371*80a6f5c5SLiu Zhe } 372*80a6f5c5SLiu Zhe 373*80a6f5c5SLiu Zhe // delete column and verify whether delete or not 374*80a6f5c5SLiu Zhe public void testTableColumnDelete() throws Exception { 375*80a6f5c5SLiu Zhe writerInsertTable.ok(); 376*80a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 377*80a6f5c5SLiu Zhe // delete column 378*80a6f5c5SLiu Zhe writer.focus(); 379*80a6f5c5SLiu Zhe writer.openContextMenu(); 380*80a6f5c5SLiu Zhe swTableColumnDeleteMenu.select(); 381*80a6f5c5SLiu Zhe // verify delete column 382*80a6f5c5SLiu Zhe writer.focus(); 383*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 384*80a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 385*80a6f5c5SLiu Zhe typeKeys("<right>"); 386*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 387*80a6f5c5SLiu Zhe } 388*80a6f5c5SLiu Zhe sleep(1); 389*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 390*80a6f5c5SLiu Zhe } 391*80a6f5c5SLiu Zhe 392*80a6f5c5SLiu Zhe // split cell 393*80a6f5c5SLiu Zhe @Test 394*80a6f5c5SLiu Zhe public void testTableCellSplit() throws Exception { 395*80a6f5c5SLiu Zhe writerInsertTable.ok(); 396*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 397*80a6f5c5SLiu Zhe for (int k = 0; k < 2; k++) { 398*80a6f5c5SLiu Zhe writer.focus(); 399*80a6f5c5SLiu Zhe writer.openContextMenu(); 400*80a6f5c5SLiu Zhe swTableCellSplitMenu.select(); 401*80a6f5c5SLiu Zhe swTableCellSplitNumber.focus(); 402*80a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 403*80a6f5c5SLiu Zhe typeKeys("<delete>"); 404*80a6f5c5SLiu Zhe typeKeys("2"); 405*80a6f5c5SLiu Zhe if (k == 0) { 406*80a6f5c5SLiu Zhe swTableCellSplitDialog.ok(); // split table cell horizontally 407*80a6f5c5SLiu Zhe } else { 408*80a6f5c5SLiu Zhe swTableCellSplitVERTButton.check(); // split table cell 409*80a6f5c5SLiu Zhe // vertically 410*80a6f5c5SLiu Zhe swTableCellSplitDialog.ok(); 411*80a6f5c5SLiu Zhe } 412*80a6f5c5SLiu Zhe } 413*80a6f5c5SLiu Zhe // verify cell split successfully 414*80a6f5c5SLiu Zhe writer.focus(); 415*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 416*80a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 417*80a6f5c5SLiu Zhe typeKeys("<right>"); 418*80a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 419*80a6f5c5SLiu Zhe } 420*80a6f5c5SLiu Zhe sleep(1); 421*80a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 422*80a6f5c5SLiu Zhe } 423*80a6f5c5SLiu Zhe 424*80a6f5c5SLiu Zhe /** 425*80a6f5c5SLiu Zhe * Test convert table to text in text document 426*80a6f5c5SLiu Zhe * 427*80a6f5c5SLiu Zhe * @throws Exception 428*80a6f5c5SLiu Zhe */ 429*80a6f5c5SLiu Zhe @Test 430*80a6f5c5SLiu Zhe public void testConvertTableToText() throws Exception { 431*80a6f5c5SLiu Zhe writerInsertTable.ok(); 432*80a6f5c5SLiu Zhe writer.focus(); 433*80a6f5c5SLiu Zhe typeKeys("1<right>2<right>3<right>4"); 434*80a6f5c5SLiu Zhe sleep(1); 435*80a6f5c5SLiu Zhe 436*80a6f5c5SLiu Zhe // Convert table to text 437*80a6f5c5SLiu Zhe app.dispatch(".uno:ConvertTableToText"); 438*80a6f5c5SLiu Zhe assertTrue("Convert Table to Text dialog pop up", writerConvertTableToTextDlg.exists()); 439*80a6f5c5SLiu Zhe // typeKeys("<enter>"); 440*80a6f5c5SLiu Zhe writerConvertTableToTextDlg.ok(); // "Enter" does not work on linux 441*80a6f5c5SLiu Zhe 442*80a6f5c5SLiu Zhe // Verify if text is converted successfully 443*80a6f5c5SLiu Zhe app.dispatch(".uno:SelectAll"); 444*80a6f5c5SLiu Zhe app.dispatch(".uno:Copy"); 445*80a6f5c5SLiu Zhe if (SystemUtil.isWindows()) 446*80a6f5c5SLiu Zhe assertEquals("Converted text", "1\t2\r\n3\t4\r\n", app.getClipboard()); // in 447*80a6f5c5SLiu Zhe // windows, 448*80a6f5c5SLiu Zhe // \n 449*80a6f5c5SLiu Zhe // is 450*80a6f5c5SLiu Zhe // \r\n 451*80a6f5c5SLiu Zhe else 452*80a6f5c5SLiu Zhe assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard()); 453*80a6f5c5SLiu Zhe } 454*80a6f5c5SLiu Zhe }