107d7dbdcSHerbert Dürr /************************************************************** 207d7dbdcSHerbert Dürr * 307d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 407d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 507d7dbdcSHerbert Dürr * distributed with this work for additional information 607d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 707d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 807d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 907d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 1007d7dbdcSHerbert Dürr * 1107d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 1207d7dbdcSHerbert Dürr * 1307d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 1407d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 1507d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1607d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 1707d7dbdcSHerbert Dürr * specific language governing permissions and limitations 1807d7dbdcSHerbert Dürr * under the License. 1907d7dbdcSHerbert Dürr * 2007d7dbdcSHerbert Dürr *************************************************************/ 2107d7dbdcSHerbert Dürr 2280a6f5c5SLiu Zhe package fvt.gui.sw.table; 23ca72bc94SLiu Zhe 24ca72bc94SLiu Zhe import static org.junit.Assert.*; 25ca72bc94SLiu Zhe import static org.openoffice.test.vcl.Tester.*; 26b4d2d410SLiu Zhe import static testlib.gui.AppTool.*; 27ca72bc94SLiu Zhe import static testlib.gui.UIMap.*; 28ca72bc94SLiu Zhe 29ca72bc94SLiu Zhe import org.junit.After; 30ca72bc94SLiu Zhe import org.junit.Before; 31ca72bc94SLiu Zhe import org.junit.Ignore; 32ca72bc94SLiu Zhe import org.junit.Test; 33ca72bc94SLiu Zhe import org.openoffice.test.common.SystemUtil; 34ca72bc94SLiu Zhe 35*b74bac87SLi Feng Wang import testlib.gui.AppTool; 36ca72bc94SLiu Zhe 37ca72bc94SLiu Zhe public class TableGeneral { 38ca72bc94SLiu Zhe 39ca72bc94SLiu Zhe @Before 40ca72bc94SLiu Zhe public void setUp() throws Exception { 41ca72bc94SLiu Zhe // Start OpenOffice 42ca72bc94SLiu Zhe app.start(); 43ca72bc94SLiu Zhe 44*b74bac87SLi Feng Wang AppTool.newTextDocument(); 45ca72bc94SLiu Zhe // Insert a table 46ca72bc94SLiu Zhe app.dispatch(".uno:InsertTable"); 47ca72bc94SLiu Zhe } 48ca72bc94SLiu Zhe 49ca72bc94SLiu Zhe @After 50ca72bc94SLiu Zhe public void tearDown() throws Exception { 5196ee427fSLi Feng Wang app.stop(); 52ca72bc94SLiu Zhe } 53ca72bc94SLiu Zhe 54*b74bac87SLi Feng Wang /** 55*b74bac87SLi Feng Wang * Test setting table size in text document 56*b74bac87SLi Feng Wang * 57*b74bac87SLi Feng Wang * @throws Exception 58*b74bac87SLi Feng Wang */ 59ca72bc94SLiu Zhe @Test 60ca72bc94SLiu Zhe public void testTableSize() throws Exception { 61ca72bc94SLiu Zhe 62b4d2d410SLiu Zhe swTableSizeColBox.focus(); 63ca72bc94SLiu Zhe typeKeys("<delete>"); 64ca72bc94SLiu Zhe typeKeys("3"); 65b4d2d410SLiu Zhe swTableSizeRowBox.focus(); 66ca72bc94SLiu Zhe typeKeys("<delete>"); 67ca72bc94SLiu Zhe typeKeys("4"); 68b4d2d410SLiu Zhe writerInsertTable.ok(); 69ca72bc94SLiu Zhe 70*b74bac87SLi Feng Wang writer.focus(); 71*b74bac87SLi Feng Wang // verify the rows in the table 72b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 73ca72bc94SLiu Zhe for (int i = 0; i < 3; i++) { 74ca72bc94SLiu Zhe typeKeys("<down>"); 75b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 76ca72bc94SLiu Zhe } 77ca72bc94SLiu Zhe typeKeys("<down>"); 78ca72bc94SLiu Zhe sleep(1); 79b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 80ca72bc94SLiu Zhe } 81ca72bc94SLiu Zhe 82*b74bac87SLi Feng Wang /** 83*b74bac87SLi Feng Wang * Test setting table cell background in text document 84*b74bac87SLi Feng Wang * 85*b74bac87SLi Feng Wang * @throws Exception 86*b74bac87SLi Feng Wang */ 87ca72bc94SLiu Zhe @Test 88*b74bac87SLi Feng Wang @Ignore("Bug #120378- the table cell fill color change when copy one table cell in word processor to presentation") 89ca72bc94SLiu Zhe public void testTableBackground() throws Exception { 90b4d2d410SLiu Zhe writerInsertTable.ok(); 91b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 92ca72bc94SLiu Zhe writer.focus(); 93ca72bc94SLiu Zhe // set table cell background 94ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 95b4d2d410SLiu Zhe swTableBackground.select(); 96ca72bc94SLiu Zhe assertTrue("Table background property dialog pop up", 97b4d2d410SLiu Zhe swTableBackground.exists()); 98b4d2d410SLiu Zhe swTableBackgroundColor.focus(); 99b4d2d410SLiu Zhe swTableBackgroundColor.click(50, 50); 100b4d2d410SLiu Zhe swTableBackground.ok(); 101ca72bc94SLiu Zhe // verify table cell background color 102ca72bc94SLiu Zhe writer.focus(); 103ca72bc94SLiu Zhe // select the cell which is filled with color 104ca72bc94SLiu Zhe app.dispatch(".uno:EntireCell"); 105ca72bc94SLiu Zhe 106ca72bc94SLiu Zhe typeKeys("<ctrl c>"); 107*b74bac87SLi Feng Wang AppTool.newPresentation(); 108ca72bc94SLiu Zhe typeKeys("<ctrl v>"); 109ca72bc94SLiu Zhe // enable table cell area format dialog 110ca72bc94SLiu Zhe app.dispatch(".uno:FormatArea"); 111ca72bc94SLiu Zhe sleep(1); 112b4d2d410SLiu Zhe assertEquals("Light red", sdTableBACGColorListbox.getSelText()); 113ca72bc94SLiu Zhe // close table cell area format dialog 114b4d2d410SLiu Zhe sdTableBACGColorArea.cancel(); 115ca72bc94SLiu Zhe } 116ca72bc94SLiu Zhe 117*b74bac87SLi Feng Wang /** 118*b74bac87SLi Feng Wang * Test setting table border in text document 119*b74bac87SLi Feng Wang * 120*b74bac87SLi Feng Wang * @throws Exception 121*b74bac87SLi Feng Wang */ 122ca72bc94SLiu Zhe @Test 123ca72bc94SLiu Zhe public void testTableBorder() throws Exception { 124b4d2d410SLiu Zhe writerInsertTable.ok(); 125b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 126ca72bc94SLiu Zhe // set table border as none 127ca72bc94SLiu Zhe writer.focus(); 128ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 129b4d2d410SLiu Zhe swTableBorder.select(); 130ca72bc94SLiu Zhe assertTrue("Table border property dialog pop up", 131b4d2d410SLiu Zhe swTableBorder.exists()); 132b4d2d410SLiu Zhe swTableBorderLineArrange.click(10, 10); 133b4d2d410SLiu Zhe swTableBorder.ok(); 134ca72bc94SLiu Zhe } 135ca72bc94SLiu Zhe 136*b74bac87SLi Feng Wang /** 137*b74bac87SLi Feng Wang * Test setting table border line style,line color,spacing to content in 138*b74bac87SLi Feng Wang * text document 139*b74bac87SLi Feng Wang * 140*b74bac87SLi Feng Wang * @throws Exception 141*b74bac87SLi Feng Wang */ 142ca72bc94SLiu Zhe @Test 143ca72bc94SLiu Zhe public void testTableBorderLineStyle() throws Exception { 144b4d2d410SLiu Zhe writerInsertTable.ok(); 145b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 146ca72bc94SLiu Zhe writer.focus(); 147ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 148b4d2d410SLiu Zhe swTableBorder.select(); 149ca72bc94SLiu Zhe assertTrue("Table border property dialog pop up", 150b4d2d410SLiu Zhe swTableBorder.exists()); 151*b74bac87SLi Feng Wang // set line style 152*b74bac87SLi Feng Wang swTableBorderLineStyle.select(8); 153*b74bac87SLi Feng Wang // set line color 154*b74bac87SLi Feng Wang swTableBorderLineColor.select(5); 155*b74bac87SLi Feng Wang // set spacing to content 156*b74bac87SLi Feng Wang swTableSTCLeft.focus(); 157ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 158ca72bc94SLiu Zhe typeKeys("<delete>"); 159*b74bac87SLi Feng Wang // set spacing to content 160*b74bac87SLi Feng Wang typeKeys("0.5"); 161*b74bac87SLi Feng Wang // set table shadow 162*b74bac87SLi Feng Wang swTableShadow.click(40, 10); 163b4d2d410SLiu Zhe swTableShadowSize.focus(); 164ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 165ca72bc94SLiu Zhe typeKeys("<delete>"); 166ca72bc94SLiu Zhe typeKeys("2"); 167b4d2d410SLiu Zhe swTableShadowColor.select(5); 168b4d2d410SLiu Zhe swTableBorder.ok(); 169*b74bac87SLi Feng Wang // verify the setting property of table 170*b74bac87SLi Feng Wang writer.focus(); 171ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 172b4d2d410SLiu Zhe swTableBorder.select(); 173b4d2d410SLiu Zhe assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8)); 174b4d2d410SLiu Zhe assertEquals("Magenta", swTableBorderLineColor.getItemText(5)); 175b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 176b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSTCRight.getText()); 177b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSTCTop.getText()); 178b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSTCBottom.getText()); 179b4d2d410SLiu Zhe assertEquals("1.97\"", swTableShadowSize.getText()); 180b4d2d410SLiu Zhe assertEquals("Magenta", swTableShadowColor.getItemText(5)); 181b4d2d410SLiu Zhe assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 182b4d2d410SLiu Zhe swTableBorder.close(); 183ca72bc94SLiu Zhe 184ca72bc94SLiu Zhe // uncheck Synchronize box and set spacing to content 185ca72bc94SLiu Zhe writer.focus(); 186ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 187b4d2d410SLiu Zhe swTableBorder.select(); 188b4d2d410SLiu Zhe swTableSTCSYNC.uncheck(); 189*b74bac87SLi Feng Wang // set left spacing to content 190*b74bac87SLi Feng Wang swTableSTCLeft.focus(); 191ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 192ca72bc94SLiu Zhe typeKeys("<delete>"); 193ca72bc94SLiu Zhe typeKeys("0.5"); 194*b74bac87SLi Feng Wang // set right spacing to content 195*b74bac87SLi Feng Wang swTableSTCRight.focus(); 196ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 197ca72bc94SLiu Zhe typeKeys("<delete>"); 198ca72bc94SLiu Zhe typeKeys("0.8"); 199*b74bac87SLi Feng Wang // set top spacing to content 200*b74bac87SLi Feng Wang swTableSTCTop.focus(); 201ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 202ca72bc94SLiu Zhe typeKeys("<delete>"); 203ca72bc94SLiu Zhe typeKeys("1.0"); 204*b74bac87SLi Feng Wang // set bottom spacing to content 205*b74bac87SLi Feng Wang swTableSTCBottom.focus(); 206ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 207ca72bc94SLiu Zhe typeKeys("<delete>"); 208ca72bc94SLiu Zhe typeKeys("2"); 209b4d2d410SLiu Zhe swTableBorder.ok(); 210b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 211ca72bc94SLiu Zhe 212*b74bac87SLi Feng Wang writer.focus(); 213*b74bac87SLi Feng Wang // verify the setting value of spacing to content for table 214ca72bc94SLiu Zhe app.dispatch(".uno:TableDialog"); 215b4d2d410SLiu Zhe swTableBorder.select(); 216b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 217b4d2d410SLiu Zhe assertEquals("0.80\"", swTableSTCRight.getText()); 218b4d2d410SLiu Zhe assertEquals("1.00\"", swTableSTCTop.getText()); 219b4d2d410SLiu Zhe assertEquals("1.97\"", swTableSTCBottom.getText()); 220b4d2d410SLiu Zhe assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 221b4d2d410SLiu Zhe swTableBorder.close(); 222ca72bc94SLiu Zhe } 223ca72bc94SLiu Zhe 224*b74bac87SLi Feng Wang /** 225*b74bac87SLi Feng Wang * create table with auto format 226*b74bac87SLi Feng Wang * 227*b74bac87SLi Feng Wang * @throws Exception 228*b74bac87SLi Feng Wang */ 229ca72bc94SLiu Zhe @Test 230ca72bc94SLiu Zhe public void testTableAutoFormat() throws Exception { 231ca72bc94SLiu Zhe // create table with auto format 232ca72bc94SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 233b4d2d410SLiu Zhe assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists()); 234b4d2d410SLiu Zhe swTableAutoFormatListbox.select(3); 235b4d2d410SLiu Zhe swTableAutoFMT.ok(); 236ca72bc94SLiu Zhe // verify the auto format is that just selected 237ca72bc94SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 238b4d2d410SLiu Zhe assertEquals("Blue", swTableAutoFormatListbox.getSelText()); 239b4d2d410SLiu Zhe swTableAutoFMT.close(); 240b4d2d410SLiu Zhe writerInsertTable.ok(); 241b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 242ca72bc94SLiu Zhe 243ca72bc94SLiu Zhe } 244ca72bc94SLiu Zhe 245*b74bac87SLi Feng Wang /** 246*b74bac87SLi Feng Wang * set row height and select row,insert/delete row 247*b74bac87SLi Feng Wang * 248*b74bac87SLi Feng Wang * @throws Exception 249*b74bac87SLi Feng Wang */ 250ca72bc94SLiu Zhe @Test 251ca72bc94SLiu Zhe public void testTableRowHeight() throws Exception { 252b4d2d410SLiu Zhe writerInsertTable.ok(); 253b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 254ca72bc94SLiu Zhe 255ca72bc94SLiu Zhe // set row height 256ca72bc94SLiu Zhe writer.focus(); 257ca72bc94SLiu Zhe writer.openContextMenu(); 258b4d2d410SLiu Zhe swTableRowHeightMenu.select(); 259b4d2d410SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 260b4d2d410SLiu Zhe swTableSetRowHeight.focus(); 261ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 262ca72bc94SLiu Zhe typeKeys("<delete>"); 263ca72bc94SLiu Zhe typeKeys("0.5"); 264b4d2d410SLiu Zhe swTableSetRowHeightDialog.ok(); 265ca72bc94SLiu Zhe 266ca72bc94SLiu Zhe // verify row height 267ca72bc94SLiu Zhe writer.focus(); 268ca72bc94SLiu Zhe writer.openContextMenu(); 269b4d2d410SLiu Zhe swTableRowHeightMenu.select(); 270b4d2d410SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 271b4d2d410SLiu Zhe assertEquals("0.50\"", swTableSetRowHeight.getText()); 272b4d2d410SLiu Zhe swTableSetRowHeightDialog.close(); 273ca72bc94SLiu Zhe } 274ca72bc94SLiu Zhe 275*b74bac87SLi Feng Wang /** 276*b74bac87SLi Feng Wang * test select row 277*b74bac87SLi Feng Wang * 278*b74bac87SLi Feng Wang * @throws Exception 279*b74bac87SLi Feng Wang */ 280ca72bc94SLiu Zhe @Test 281ca72bc94SLiu Zhe public void testTableSelectRow() throws Exception { 282b4d2d410SLiu Zhe writerInsertTable.ok(); 283b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 284ca72bc94SLiu Zhe // select row 285ca72bc94SLiu Zhe writer.focus(); 286ca72bc94SLiu Zhe writer.openContextMenu(); 287b4d2d410SLiu Zhe swTableSelectRowMenu.select(); 288ca72bc94SLiu Zhe 289ca72bc94SLiu Zhe // verify select one row successfully 290ca72bc94SLiu Zhe typeKeys("<ctrl c>"); 291ca72bc94SLiu Zhe typeKeys("<down>"); 292ca72bc94SLiu Zhe typeKeys("<down>"); 293ca72bc94SLiu Zhe typeKeys("<enter>"); 294ca72bc94SLiu Zhe typeKeys("<ctrl v>"); 295ca72bc94SLiu Zhe typeKeys("<up>"); 296b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 297ca72bc94SLiu Zhe 298ca72bc94SLiu Zhe } 299ca72bc94SLiu Zhe 300*b74bac87SLi Feng Wang /** 301*b74bac87SLi Feng Wang * insert row and verify how many row inserted 302*b74bac87SLi Feng Wang * 303*b74bac87SLi Feng Wang * @throws Exception 304*b74bac87SLi Feng Wang */ 305ca72bc94SLiu Zhe @Test 306ca72bc94SLiu Zhe public void testTableInsertRow() throws Exception { 307b4d2d410SLiu Zhe writerInsertTable.ok(); 308b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 309ca72bc94SLiu Zhe writer.focus(); 310ca72bc94SLiu Zhe writer.openContextMenu(); 311b4d2d410SLiu Zhe swTableInsertRowMenu.select(); 312*b74bac87SLi Feng Wang assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists()); 313b4d2d410SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 314ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 315ca72bc94SLiu Zhe typeKeys("<delete>"); 316ca72bc94SLiu Zhe typeKeys("3"); 317b4d2d410SLiu Zhe swTableInsertRow.ok(); 318ca72bc94SLiu Zhe 319*b74bac87SLi Feng Wang writer.focus(); 320*b74bac87SLi Feng Wang // verify how many rows in the table 321b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 322ca72bc94SLiu Zhe for (int i = 0; i < 4; i++) { 323ca72bc94SLiu Zhe typeKeys("<down>"); 324b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 325ca72bc94SLiu Zhe } 326ca72bc94SLiu Zhe typeKeys("<down>"); 327ca72bc94SLiu Zhe sleep(1); 328b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 329ca72bc94SLiu Zhe } 330ca72bc94SLiu Zhe 331*b74bac87SLi Feng Wang /** 332*b74bac87SLi Feng Wang * delete row and verify row 333*b74bac87SLi Feng Wang * 334*b74bac87SLi Feng Wang * @throws Exception 335*b74bac87SLi Feng Wang */ 336ca72bc94SLiu Zhe @Test 337ca72bc94SLiu Zhe public void testTableRowDelete() throws Exception { 338b4d2d410SLiu Zhe writerInsertTable.ok(); 339b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 340ca72bc94SLiu Zhe // delete row 341ca72bc94SLiu Zhe writer.focus(); 342ca72bc94SLiu Zhe writer.openContextMenu(); 343b4d2d410SLiu Zhe swTableRowDleteMenu.select(); 344ca72bc94SLiu Zhe // verify whether delete row 345ca72bc94SLiu Zhe writer.focus(); 346b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 347ca72bc94SLiu Zhe typeKeys("<down>"); 348ca72bc94SLiu Zhe sleep(1); 349b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 350ca72bc94SLiu Zhe 351ca72bc94SLiu Zhe } 352ca72bc94SLiu Zhe 353*b74bac87SLi Feng Wang /** 354*b74bac87SLi Feng Wang * set column width and verify 355*b74bac87SLi Feng Wang * 356*b74bac87SLi Feng Wang * @throws Exception 357*b74bac87SLi Feng Wang */ 358ca72bc94SLiu Zhe @Test 359ca72bc94SLiu Zhe public void testTableColumnWidth() throws Exception { 360b4d2d410SLiu Zhe writerInsertTable.ok(); 361b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 362ca72bc94SLiu Zhe // set column width 363ca72bc94SLiu Zhe writer.focus(); 364ca72bc94SLiu Zhe writer.openContextMenu(); 365b4d2d410SLiu Zhe swTableColumnWidthMenu.select(); 366b4d2d410SLiu Zhe swTableSetColumnWidth.focus(); 367ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 368ca72bc94SLiu Zhe typeKeys("<delete>"); 369ca72bc94SLiu Zhe typeKeys("2"); 370b4d2d410SLiu Zhe swTableSetColumnDialog.ok(); 371ca72bc94SLiu Zhe // verify column width 372ca72bc94SLiu Zhe writer.focus(); 373ca72bc94SLiu Zhe writer.openContextMenu(); 374b4d2d410SLiu Zhe swTableColumnWidthMenu.select(); 375b4d2d410SLiu Zhe assertEquals("2.00\"", swTableSetColumnWidth.getText()); 376ca72bc94SLiu Zhe 377ca72bc94SLiu Zhe } 378ca72bc94SLiu Zhe 379*b74bac87SLi Feng Wang /** 380*b74bac87SLi Feng Wang * select column and verify 381*b74bac87SLi Feng Wang * 382*b74bac87SLi Feng Wang * @throws Exception 383*b74bac87SLi Feng Wang */ 384ca72bc94SLiu Zhe @Test 385ca72bc94SLiu Zhe public void testTableColumnSelect() throws Exception { 386b4d2d410SLiu Zhe writerInsertTable.ok(); 387b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 388ca72bc94SLiu Zhe writer.focus(); 389ca72bc94SLiu Zhe writer.openContextMenu(); 390b4d2d410SLiu Zhe swTableColumnSelectMenu.select(); 391ca72bc94SLiu Zhe 392ca72bc94SLiu Zhe // verify select one column 393ca72bc94SLiu Zhe typeKeys("<ctrl c>"); 394ca72bc94SLiu Zhe typeKeys("<down>"); 395ca72bc94SLiu Zhe typeKeys("<down>"); 396ca72bc94SLiu Zhe typeKeys("<enter>"); 397ca72bc94SLiu Zhe typeKeys("<ctrl v>"); 398ca72bc94SLiu Zhe typeKeys("<up>"); 399b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 400ca72bc94SLiu Zhe 401ca72bc94SLiu Zhe } 402ca72bc94SLiu Zhe 403*b74bac87SLi Feng Wang /** 404*b74bac87SLi Feng Wang * insert column and verify 405*b74bac87SLi Feng Wang * 406*b74bac87SLi Feng Wang * @throws Exception 407*b74bac87SLi Feng Wang */ 408ca72bc94SLiu Zhe @Test 409ca72bc94SLiu Zhe public void testTableColumnInsert() throws Exception { 410b4d2d410SLiu Zhe writerInsertTable.ok(); 411b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 412ca72bc94SLiu Zhe // insert column 413ca72bc94SLiu Zhe writer.focus(); 414ca72bc94SLiu Zhe writer.openContextMenu(); 415b4d2d410SLiu Zhe swTableColumnInsertMenu.select(); 416b4d2d410SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 417ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 418ca72bc94SLiu Zhe typeKeys("<delete>"); 419ca72bc94SLiu Zhe typeKeys("3"); 420b4d2d410SLiu Zhe swTableInsertColumn.ok(); 421ca72bc94SLiu Zhe // verify insert column successfully 422ca72bc94SLiu Zhe writer.focus(); 423b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 424ca72bc94SLiu Zhe for (int i = 0; i < 9; i++) { 425ca72bc94SLiu Zhe typeKeys("<right>"); 426ca72bc94SLiu Zhe sleep(1); 427b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 428ca72bc94SLiu Zhe } 429ca72bc94SLiu Zhe typeKeys("<right>"); 430ca72bc94SLiu Zhe sleep(1); 431b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 432ca72bc94SLiu Zhe } 433ca72bc94SLiu Zhe 434*b74bac87SLi Feng Wang /** 435*b74bac87SLi Feng Wang * delete column and verify whether delete or not 436*b74bac87SLi Feng Wang * 437*b74bac87SLi Feng Wang * @throws Exception 438*b74bac87SLi Feng Wang */ 439ca72bc94SLiu Zhe public void testTableColumnDelete() throws Exception { 440b4d2d410SLiu Zhe writerInsertTable.ok(); 441b4d2d410SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 442ca72bc94SLiu Zhe // delete column 443ca72bc94SLiu Zhe writer.focus(); 444ca72bc94SLiu Zhe writer.openContextMenu(); 445b4d2d410SLiu Zhe swTableColumnDeleteMenu.select(); 446ca72bc94SLiu Zhe // verify delete column 447ca72bc94SLiu Zhe writer.focus(); 448b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 449ca72bc94SLiu Zhe for (int i = 0; i < 7; i++) { 450ca72bc94SLiu Zhe typeKeys("<right>"); 451b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 452ca72bc94SLiu Zhe } 453ca72bc94SLiu Zhe sleep(1); 454b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 455ca72bc94SLiu Zhe } 456ca72bc94SLiu Zhe 457*b74bac87SLi Feng Wang /** 458*b74bac87SLi Feng Wang * split cell 459*b74bac87SLi Feng Wang * 460*b74bac87SLi Feng Wang * @throws Exception 461*b74bac87SLi Feng Wang */ 462ca72bc94SLiu Zhe @Test 463ca72bc94SLiu Zhe public void testTableCellSplit() throws Exception { 464b4d2d410SLiu Zhe writerInsertTable.ok(); 465b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 466ca72bc94SLiu Zhe for (int k = 0; k < 2; k++) { 467ca72bc94SLiu Zhe writer.focus(); 468ca72bc94SLiu Zhe writer.openContextMenu(); 469b4d2d410SLiu Zhe swTableCellSplitMenu.select(); 470b4d2d410SLiu Zhe swTableCellSplitNumber.focus(); 471ca72bc94SLiu Zhe typeKeys("<ctrl a>"); 472ca72bc94SLiu Zhe typeKeys("<delete>"); 473ca72bc94SLiu Zhe typeKeys("2"); 474ca72bc94SLiu Zhe if (k == 0) { 475*b74bac87SLi Feng Wang // split table cell horizontally 476*b74bac87SLi Feng Wang swTableCellSplitDialog.ok(); 477ca72bc94SLiu Zhe } else { 478*b74bac87SLi Feng Wang // split table cell 479*b74bac87SLi Feng Wang swTableCellSplitVERTButton.check(); 480ca72bc94SLiu Zhe // vertically 481b4d2d410SLiu Zhe swTableCellSplitDialog.ok(); 482ca72bc94SLiu Zhe } 483ca72bc94SLiu Zhe } 484ca72bc94SLiu Zhe // verify cell split successfully 485ca72bc94SLiu Zhe writer.focus(); 486b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 487ca72bc94SLiu Zhe for (int i = 0; i < 7; i++) { 488ca72bc94SLiu Zhe typeKeys("<right>"); 489b4d2d410SLiu Zhe assertTrue(tableToolbar.exists()); 490ca72bc94SLiu Zhe } 491ca72bc94SLiu Zhe sleep(1); 492b4d2d410SLiu Zhe assertFalse(tableToolbar.exists()); 493ca72bc94SLiu Zhe } 494*b74bac87SLi Feng Wang 495ca72bc94SLiu Zhe /** 496ca72bc94SLiu Zhe * Test convert table to text in text document 497ca72bc94SLiu Zhe * 498ca72bc94SLiu Zhe * @throws Exception 499ca72bc94SLiu Zhe */ 500ca72bc94SLiu Zhe @Test 501ca72bc94SLiu Zhe public void testConvertTableToText() throws Exception { 502b4d2d410SLiu Zhe writerInsertTable.ok(); 503ca72bc94SLiu Zhe writer.focus(); 504ca72bc94SLiu Zhe typeKeys("1<right>2<right>3<right>4"); 505ca72bc94SLiu Zhe sleep(1); 506ca72bc94SLiu Zhe 507ca72bc94SLiu Zhe // Convert table to text 508ca72bc94SLiu Zhe app.dispatch(".uno:ConvertTableToText"); 509*b74bac87SLi Feng Wang assertTrue("Convert Table to Text dialog pop up", 510*b74bac87SLi Feng Wang writerConvertTableToTextDlg.exists()); 511ca72bc94SLiu Zhe // typeKeys("<enter>"); 512*b74bac87SLi Feng Wang writerConvertTableToTextDlg.ok(); 513ca72bc94SLiu Zhe 514ca72bc94SLiu Zhe // Verify if text is converted successfully 515ca72bc94SLiu Zhe app.dispatch(".uno:SelectAll"); 516ca72bc94SLiu Zhe app.dispatch(".uno:Copy"); 517ca72bc94SLiu Zhe if (SystemUtil.isWindows()) 518*b74bac87SLi Feng Wang assertEquals("Converted text", "1\t2\r\n3\t4\r\n", 519*b74bac87SLi Feng Wang app.getClipboard()); 520ca72bc94SLiu Zhe else 521ca72bc94SLiu Zhe assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard()); 522ca72bc94SLiu Zhe } 52383ae2205SHerbert Dürr } 524