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