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; 2380a6f5c5SLiu Zhe 2480a6f5c5SLiu Zhe import static org.junit.Assert.*; 2580a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*; 2680a6f5c5SLiu Zhe import static testlib.gui.AppTool.*; 2780a6f5c5SLiu Zhe import static testlib.gui.UIMap.*; 2880a6f5c5SLiu Zhe 2980a6f5c5SLiu Zhe import org.junit.After; 3080a6f5c5SLiu Zhe import org.junit.Before; 3180a6f5c5SLiu Zhe import org.junit.Ignore; 32fd348426SLi Feng Wang import org.junit.Rule; 3380a6f5c5SLiu Zhe import org.junit.Test; 34fd348426SLi Feng Wang import org.openoffice.test.common.Logger; 3580a6f5c5SLiu Zhe import org.openoffice.test.common.SystemUtil; 3680a6f5c5SLiu Zhe 37b74bac87SLi Feng Wang import testlib.gui.AppTool; 3880a6f5c5SLiu Zhe 3980a6f5c5SLiu Zhe public class TableGeneral { 4080a6f5c5SLiu Zhe 41fd348426SLi Feng Wang @Rule 42fd348426SLi Feng Wang public Logger log = Logger.getLogger(this); 43fd348426SLi Feng Wang 4480a6f5c5SLiu Zhe @Before setUp()4580a6f5c5SLiu Zhe public void setUp() throws Exception { 4680a6f5c5SLiu Zhe // Start OpenOffice 4780a6f5c5SLiu Zhe app.start(); 4880a6f5c5SLiu Zhe 49b74bac87SLi Feng Wang AppTool.newTextDocument(); 5080a6f5c5SLiu Zhe // Insert a table 5180a6f5c5SLiu Zhe app.dispatch(".uno:InsertTable"); 5280a6f5c5SLiu Zhe } 5380a6f5c5SLiu Zhe 5480a6f5c5SLiu Zhe @After tearDown()5580a6f5c5SLiu Zhe public void tearDown() throws Exception { 5696ee427fSLi Feng Wang app.stop(); 5780a6f5c5SLiu Zhe } 5880a6f5c5SLiu 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 */ 6480a6f5c5SLiu Zhe @Test testTableSize()6580a6f5c5SLiu Zhe public void testTableSize() throws Exception { 6680a6f5c5SLiu Zhe 6780a6f5c5SLiu Zhe swTableSizeColBox.focus(); 6880a6f5c5SLiu Zhe typeKeys("<delete>"); 6980a6f5c5SLiu Zhe typeKeys("3"); 7080a6f5c5SLiu Zhe swTableSizeRowBox.focus(); 7180a6f5c5SLiu Zhe typeKeys("<delete>"); 7280a6f5c5SLiu Zhe typeKeys("4"); 7380a6f5c5SLiu Zhe writerInsertTable.ok(); 7480a6f5c5SLiu Zhe 75b74bac87SLi Feng Wang writer.focus(); 76b74bac87SLi Feng Wang // verify the rows in the table 7780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 7880a6f5c5SLiu Zhe for (int i = 0; i < 3; i++) { 7980a6f5c5SLiu Zhe typeKeys("<down>"); 8080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 8180a6f5c5SLiu Zhe } 8280a6f5c5SLiu Zhe typeKeys("<down>"); 8380a6f5c5SLiu Zhe sleep(1); 8480a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 8580a6f5c5SLiu Zhe } 8680a6f5c5SLiu 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 */ 9280a6f5c5SLiu Zhe @Test 93b74bac87SLi Feng Wang @Ignore("Bug #120378- the table cell fill color change when copy one table cell in word processor to presentation") testTableBackground()9480a6f5c5SLiu Zhe public void testTableBackground() throws Exception { 9580a6f5c5SLiu Zhe writerInsertTable.ok(); 9680a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 9780a6f5c5SLiu Zhe writer.focus(); 9880a6f5c5SLiu Zhe // set table cell background 9980a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 10080a6f5c5SLiu Zhe swTableBackground.select(); 10180a6f5c5SLiu Zhe assertTrue("Table background property dialog pop up", 10280a6f5c5SLiu Zhe swTableBackground.exists()); 10380a6f5c5SLiu Zhe swTableBackgroundColor.focus(); 10480a6f5c5SLiu Zhe swTableBackgroundColor.click(50, 50); 10580a6f5c5SLiu Zhe swTableBackground.ok(); 10680a6f5c5SLiu Zhe // verify table cell background color 10780a6f5c5SLiu Zhe writer.focus(); 10880a6f5c5SLiu Zhe // select the cell which is filled with color 10980a6f5c5SLiu Zhe app.dispatch(".uno:EntireCell"); 11080a6f5c5SLiu Zhe 11180a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 112b74bac87SLi Feng Wang AppTool.newPresentation(); 11380a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 11480a6f5c5SLiu Zhe // enable table cell area format dialog 11580a6f5c5SLiu Zhe app.dispatch(".uno:FormatArea"); 11680a6f5c5SLiu Zhe sleep(1); 11780a6f5c5SLiu Zhe assertEquals("Light red", sdTableBACGColorListbox.getSelText()); 11880a6f5c5SLiu Zhe // close table cell area format dialog 11980a6f5c5SLiu Zhe sdTableBACGColorArea.cancel(); 12080a6f5c5SLiu Zhe } 12180a6f5c5SLiu 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 */ 12780a6f5c5SLiu Zhe @Test testTableBorder()12880a6f5c5SLiu Zhe public void testTableBorder() throws Exception { 12980a6f5c5SLiu Zhe writerInsertTable.ok(); 13080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 13180a6f5c5SLiu Zhe // set table border as none 13280a6f5c5SLiu Zhe writer.focus(); 13380a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 13480a6f5c5SLiu Zhe swTableBorder.select(); 13580a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 13680a6f5c5SLiu Zhe swTableBorder.exists()); 13780a6f5c5SLiu Zhe swTableBorderLineArrange.click(10, 10); 13880a6f5c5SLiu Zhe swTableBorder.ok(); 13980a6f5c5SLiu Zhe } 14080a6f5c5SLiu 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 */ 14780a6f5c5SLiu Zhe @Test testTableBorderLineStyle()14880a6f5c5SLiu Zhe public void testTableBorderLineStyle() throws Exception { 14980a6f5c5SLiu Zhe writerInsertTable.ok(); 15080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 15180a6f5c5SLiu Zhe writer.focus(); 15280a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 15380a6f5c5SLiu Zhe swTableBorder.select(); 15480a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 15580a6f5c5SLiu Zhe swTableBorder.exists()); 156b74bac87SLi Feng Wang // set line style 157b74bac87SLi Feng Wang swTableBorderLineStyle.select(8); 158b74bac87SLi Feng Wang // set line color 159*772b8e0bSHerbert Dürr final int nMagentaIndex = 16; // for AOO's colorpicker as of #i118828# 160*772b8e0bSHerbert Dürr swTableBorderLineColor.select( nMagentaIndex); 161b74bac87SLi Feng Wang // set spacing to content 162b74bac87SLi Feng Wang swTableSTCLeft.focus(); 16380a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 16480a6f5c5SLiu Zhe typeKeys("<delete>"); 165b74bac87SLi Feng Wang // set spacing to content 166b74bac87SLi Feng Wang typeKeys("0.5"); 167b74bac87SLi Feng Wang // set table shadow 168b74bac87SLi Feng Wang swTableShadow.click(40, 10); 16980a6f5c5SLiu Zhe swTableShadowSize.focus(); 17080a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 17180a6f5c5SLiu Zhe typeKeys("<delete>"); 17280a6f5c5SLiu Zhe typeKeys("2"); 173*772b8e0bSHerbert Dürr swTableShadowColor.select( nMagentaIndex); 17480a6f5c5SLiu Zhe swTableBorder.ok(); 175b74bac87SLi Feng Wang // verify the setting property of table 176b74bac87SLi Feng Wang writer.focus(); 17780a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 17880a6f5c5SLiu Zhe swTableBorder.select(); 17980a6f5c5SLiu Zhe assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8)); 180*772b8e0bSHerbert Dürr assertEquals("Magenta", swTableBorderLineColor.getItemText( nMagentaIndex)); 18180a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSTCLeft.getText()); 18280a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSTCRight.getText()); 18380a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSTCTop.getText()); 18480a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSTCBottom.getText()); 18580a6f5c5SLiu Zhe assertEquals("1.97 \"", swTableShadowSize.getText()); 186*772b8e0bSHerbert Dürr assertEquals("Magenta", swTableShadowColor.getItemText( nMagentaIndex)); 18780a6f5c5SLiu Zhe assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 18880a6f5c5SLiu Zhe swTableBorder.close(); 18980a6f5c5SLiu Zhe 19080a6f5c5SLiu Zhe // uncheck Synchronize box and set spacing to content 19180a6f5c5SLiu Zhe writer.focus(); 19280a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 19380a6f5c5SLiu Zhe swTableBorder.select(); 19480a6f5c5SLiu Zhe swTableSTCSYNC.uncheck(); 195b74bac87SLi Feng Wang // set left spacing to content 196b74bac87SLi Feng Wang swTableSTCLeft.focus(); 19780a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 19880a6f5c5SLiu Zhe typeKeys("<delete>"); 19980a6f5c5SLiu Zhe typeKeys("0.5"); 200b74bac87SLi Feng Wang // set right spacing to content 201b74bac87SLi Feng Wang swTableSTCRight.focus(); 20280a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 20380a6f5c5SLiu Zhe typeKeys("<delete>"); 20480a6f5c5SLiu Zhe typeKeys("0.8"); 205b74bac87SLi Feng Wang // set top spacing to content 206b74bac87SLi Feng Wang swTableSTCTop.focus(); 20780a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 20880a6f5c5SLiu Zhe typeKeys("<delete>"); 20980a6f5c5SLiu Zhe typeKeys("1.0"); 210b74bac87SLi Feng Wang // set bottom spacing to content 211b74bac87SLi Feng Wang swTableSTCBottom.focus(); 21280a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 21380a6f5c5SLiu Zhe typeKeys("<delete>"); 21480a6f5c5SLiu Zhe typeKeys("2"); 21580a6f5c5SLiu Zhe swTableBorder.ok(); 21680a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 21780a6f5c5SLiu Zhe 218b74bac87SLi Feng Wang writer.focus(); 219b74bac87SLi Feng Wang // verify the setting value of spacing to content for table 22080a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 22180a6f5c5SLiu Zhe swTableBorder.select(); 22280a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSTCLeft.getText()); 22380a6f5c5SLiu Zhe assertEquals("0.80 \"", swTableSTCRight.getText()); 22480a6f5c5SLiu Zhe assertEquals("1.00 \"", swTableSTCTop.getText()); 22580a6f5c5SLiu Zhe assertEquals("1.97 \"", swTableSTCBottom.getText()); 22680a6f5c5SLiu Zhe assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 22780a6f5c5SLiu Zhe swTableBorder.close(); 22880a6f5c5SLiu Zhe } 22980a6f5c5SLiu Zhe 230b74bac87SLi Feng Wang /** 231b74bac87SLi Feng Wang * create table with auto format 232b74bac87SLi Feng Wang * 233b74bac87SLi Feng Wang * @throws Exception 234b74bac87SLi Feng Wang */ 23580a6f5c5SLiu Zhe @Test testTableAutoFormat()23680a6f5c5SLiu Zhe public void testTableAutoFormat() throws Exception { 23780a6f5c5SLiu Zhe // create table with auto format 23880a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 23980a6f5c5SLiu Zhe assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists()); 24080a6f5c5SLiu Zhe swTableAutoFormatListbox.select(3); 24180a6f5c5SLiu Zhe swTableAutoFMT.ok(); 24280a6f5c5SLiu Zhe // verify the auto format is that just selected 24380a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 24480a6f5c5SLiu Zhe assertEquals("Blue", swTableAutoFormatListbox.getSelText()); 24580a6f5c5SLiu Zhe swTableAutoFMT.close(); 24680a6f5c5SLiu Zhe writerInsertTable.ok(); 24780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 24880a6f5c5SLiu Zhe 24980a6f5c5SLiu Zhe } 25080a6f5c5SLiu Zhe 251b74bac87SLi Feng Wang /** 252b74bac87SLi Feng Wang * set row height and select row,insert/delete row 253b74bac87SLi Feng Wang * 254b74bac87SLi Feng Wang * @throws Exception 255b74bac87SLi Feng Wang */ 25680a6f5c5SLiu Zhe @Test testTableRowHeight()25780a6f5c5SLiu Zhe public void testTableRowHeight() throws Exception { 25880a6f5c5SLiu Zhe writerInsertTable.ok(); 25980a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 26080a6f5c5SLiu Zhe 26180a6f5c5SLiu Zhe // set row height 26280a6f5c5SLiu Zhe writer.focus(); 26380a6f5c5SLiu Zhe writer.openContextMenu(); 26480a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 26580a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 26680a6f5c5SLiu Zhe swTableSetRowHeight.focus(); 26780a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 26880a6f5c5SLiu Zhe typeKeys("<delete>"); 26980a6f5c5SLiu Zhe typeKeys("0.5"); 27080a6f5c5SLiu Zhe swTableSetRowHeightDialog.ok(); 27180a6f5c5SLiu Zhe 27280a6f5c5SLiu Zhe // verify row height 27380a6f5c5SLiu Zhe writer.focus(); 27480a6f5c5SLiu Zhe writer.openContextMenu(); 27580a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 27680a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 27780a6f5c5SLiu Zhe assertEquals("0.50 \"", swTableSetRowHeight.getText()); 27880a6f5c5SLiu Zhe swTableSetRowHeightDialog.close(); 27980a6f5c5SLiu Zhe } 28080a6f5c5SLiu Zhe 281b74bac87SLi Feng Wang /** 282b74bac87SLi Feng Wang * test select row 283b74bac87SLi Feng Wang * 284b74bac87SLi Feng Wang * @throws Exception 285b74bac87SLi Feng Wang */ 28680a6f5c5SLiu Zhe @Test testTableSelectRow()28780a6f5c5SLiu Zhe public void testTableSelectRow() throws Exception { 28880a6f5c5SLiu Zhe writerInsertTable.ok(); 28980a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 29080a6f5c5SLiu Zhe // select row 29180a6f5c5SLiu Zhe writer.focus(); 29280a6f5c5SLiu Zhe writer.openContextMenu(); 29380a6f5c5SLiu Zhe swTableSelectRowMenu.select(); 29480a6f5c5SLiu Zhe 29580a6f5c5SLiu Zhe // verify select one row successfully 29680a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 29780a6f5c5SLiu Zhe typeKeys("<down>"); 29880a6f5c5SLiu Zhe typeKeys("<down>"); 29980a6f5c5SLiu Zhe typeKeys("<enter>"); 30080a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 30180a6f5c5SLiu Zhe typeKeys("<up>"); 30280a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 30380a6f5c5SLiu Zhe 30480a6f5c5SLiu Zhe } 30580a6f5c5SLiu Zhe 306b74bac87SLi Feng Wang /** 307b74bac87SLi Feng Wang * insert row and verify how many row inserted 308b74bac87SLi Feng Wang * 309b74bac87SLi Feng Wang * @throws Exception 310b74bac87SLi Feng Wang */ 31180a6f5c5SLiu Zhe @Test testTableInsertRow()31280a6f5c5SLiu Zhe public void testTableInsertRow() throws Exception { 31380a6f5c5SLiu Zhe writerInsertTable.ok(); 31480a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 31580a6f5c5SLiu Zhe writer.focus(); 31680a6f5c5SLiu Zhe writer.openContextMenu(); 31780a6f5c5SLiu Zhe swTableInsertRowMenu.select(); 318b74bac87SLi Feng Wang assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists()); 31980a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 32080a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 32180a6f5c5SLiu Zhe typeKeys("<delete>"); 32280a6f5c5SLiu Zhe typeKeys("3"); 32380a6f5c5SLiu Zhe swTableInsertRow.ok(); 32480a6f5c5SLiu Zhe 325b74bac87SLi Feng Wang writer.focus(); 326b74bac87SLi Feng Wang // verify how many rows in the table 32780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 32880a6f5c5SLiu Zhe for (int i = 0; i < 4; i++) { 32980a6f5c5SLiu Zhe typeKeys("<down>"); 33080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 33180a6f5c5SLiu Zhe } 33280a6f5c5SLiu Zhe typeKeys("<down>"); 33380a6f5c5SLiu Zhe sleep(1); 33480a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 33580a6f5c5SLiu Zhe } 33680a6f5c5SLiu Zhe 337b74bac87SLi Feng Wang /** 338b74bac87SLi Feng Wang * delete row and verify row 339b74bac87SLi Feng Wang * 340b74bac87SLi Feng Wang * @throws Exception 341b74bac87SLi Feng Wang */ 34280a6f5c5SLiu Zhe @Test testTableRowDelete()34380a6f5c5SLiu Zhe public void testTableRowDelete() throws Exception { 34480a6f5c5SLiu Zhe writerInsertTable.ok(); 34580a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 34680a6f5c5SLiu Zhe // delete row 34780a6f5c5SLiu Zhe writer.focus(); 34880a6f5c5SLiu Zhe writer.openContextMenu(); 34980a6f5c5SLiu Zhe swTableRowDleteMenu.select(); 35080a6f5c5SLiu Zhe // verify whether delete row 35180a6f5c5SLiu Zhe writer.focus(); 35280a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 35380a6f5c5SLiu Zhe typeKeys("<down>"); 35480a6f5c5SLiu Zhe sleep(1); 35580a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 35680a6f5c5SLiu Zhe 35780a6f5c5SLiu Zhe } 35880a6f5c5SLiu Zhe 359b74bac87SLi Feng Wang /** 360b74bac87SLi Feng Wang * set column width and verify 361b74bac87SLi Feng Wang * 362b74bac87SLi Feng Wang * @throws Exception 363b74bac87SLi Feng Wang */ 36480a6f5c5SLiu Zhe @Test testTableColumnWidth()36580a6f5c5SLiu Zhe public void testTableColumnWidth() throws Exception { 36680a6f5c5SLiu Zhe writerInsertTable.ok(); 36780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 36880a6f5c5SLiu Zhe // set column width 36980a6f5c5SLiu Zhe writer.focus(); 37080a6f5c5SLiu Zhe writer.openContextMenu(); 37180a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 37280a6f5c5SLiu Zhe swTableSetColumnWidth.focus(); 37380a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 37480a6f5c5SLiu Zhe typeKeys("<delete>"); 37580a6f5c5SLiu Zhe typeKeys("2"); 37680a6f5c5SLiu Zhe swTableSetColumnDialog.ok(); 37780a6f5c5SLiu Zhe // verify column width 37880a6f5c5SLiu Zhe writer.focus(); 37980a6f5c5SLiu Zhe writer.openContextMenu(); 38080a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 38180a6f5c5SLiu Zhe assertEquals("2.00 \"", swTableSetColumnWidth.getText()); 38280a6f5c5SLiu Zhe 38380a6f5c5SLiu Zhe } 38480a6f5c5SLiu Zhe 385b74bac87SLi Feng Wang /** 386b74bac87SLi Feng Wang * select column and verify 387b74bac87SLi Feng Wang * 388b74bac87SLi Feng Wang * @throws Exception 389b74bac87SLi Feng Wang */ 39080a6f5c5SLiu Zhe @Test testTableColumnSelect()39180a6f5c5SLiu Zhe public void testTableColumnSelect() throws Exception { 39280a6f5c5SLiu Zhe writerInsertTable.ok(); 39380a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 39480a6f5c5SLiu Zhe writer.focus(); 39580a6f5c5SLiu Zhe writer.openContextMenu(); 39680a6f5c5SLiu Zhe swTableColumnSelectMenu.select(); 39780a6f5c5SLiu Zhe 39880a6f5c5SLiu Zhe // verify select one column 39980a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 40080a6f5c5SLiu Zhe typeKeys("<down>"); 40180a6f5c5SLiu Zhe typeKeys("<down>"); 40280a6f5c5SLiu Zhe typeKeys("<enter>"); 40380a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 40480a6f5c5SLiu Zhe typeKeys("<up>"); 40580a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 40680a6f5c5SLiu Zhe 40780a6f5c5SLiu Zhe } 40880a6f5c5SLiu Zhe 409b74bac87SLi Feng Wang /** 410b74bac87SLi Feng Wang * insert column and verify 411b74bac87SLi Feng Wang * 412b74bac87SLi Feng Wang * @throws Exception 413b74bac87SLi Feng Wang */ 41480a6f5c5SLiu Zhe @Test testTableColumnInsert()41580a6f5c5SLiu Zhe public void testTableColumnInsert() throws Exception { 41680a6f5c5SLiu Zhe writerInsertTable.ok(); 41780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 41880a6f5c5SLiu Zhe // insert column 41980a6f5c5SLiu Zhe writer.focus(); 42080a6f5c5SLiu Zhe writer.openContextMenu(); 42180a6f5c5SLiu Zhe swTableColumnInsertMenu.select(); 42280a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 42380a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 42480a6f5c5SLiu Zhe typeKeys("<delete>"); 42580a6f5c5SLiu Zhe typeKeys("3"); 42680a6f5c5SLiu Zhe swTableInsertColumn.ok(); 42780a6f5c5SLiu Zhe // verify insert column successfully 42880a6f5c5SLiu Zhe writer.focus(); 42980a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 43080a6f5c5SLiu Zhe for (int i = 0; i < 9; i++) { 43180a6f5c5SLiu Zhe typeKeys("<right>"); 43280a6f5c5SLiu Zhe sleep(1); 43380a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 43480a6f5c5SLiu Zhe } 43580a6f5c5SLiu Zhe typeKeys("<right>"); 43680a6f5c5SLiu Zhe sleep(1); 43780a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 43880a6f5c5SLiu Zhe } 43980a6f5c5SLiu Zhe 440b74bac87SLi Feng Wang /** 441b74bac87SLi Feng Wang * delete column and verify whether delete or not 442b74bac87SLi Feng Wang * 443b74bac87SLi Feng Wang * @throws Exception 444b74bac87SLi Feng Wang */ testTableColumnDelete()44580a6f5c5SLiu Zhe public void testTableColumnDelete() throws Exception { 44680a6f5c5SLiu Zhe writerInsertTable.ok(); 44780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 44880a6f5c5SLiu Zhe // delete column 44980a6f5c5SLiu Zhe writer.focus(); 45080a6f5c5SLiu Zhe writer.openContextMenu(); 45180a6f5c5SLiu Zhe swTableColumnDeleteMenu.select(); 45280a6f5c5SLiu Zhe // verify delete column 45380a6f5c5SLiu Zhe writer.focus(); 45480a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 45580a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 45680a6f5c5SLiu Zhe typeKeys("<right>"); 45780a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 45880a6f5c5SLiu Zhe } 45980a6f5c5SLiu Zhe sleep(1); 46080a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 46180a6f5c5SLiu Zhe } 46280a6f5c5SLiu Zhe 463b74bac87SLi Feng Wang /** 464b74bac87SLi Feng Wang * split cell 465b74bac87SLi Feng Wang * 466b74bac87SLi Feng Wang * @throws Exception 467b74bac87SLi Feng Wang */ 46880a6f5c5SLiu Zhe @Test testTableCellSplit()46980a6f5c5SLiu Zhe public void testTableCellSplit() throws Exception { 47080a6f5c5SLiu Zhe writerInsertTable.ok(); 47180a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 47280a6f5c5SLiu Zhe for (int k = 0; k < 2; k++) { 47380a6f5c5SLiu Zhe writer.focus(); 47480a6f5c5SLiu Zhe writer.openContextMenu(); 47580a6f5c5SLiu Zhe swTableCellSplitMenu.select(); 47680a6f5c5SLiu Zhe swTableCellSplitNumber.focus(); 47780a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 47880a6f5c5SLiu Zhe typeKeys("<delete>"); 47980a6f5c5SLiu Zhe typeKeys("2"); 48080a6f5c5SLiu Zhe if (k == 0) { 481b74bac87SLi Feng Wang // split table cell horizontally 482b74bac87SLi Feng Wang swTableCellSplitDialog.ok(); 48380a6f5c5SLiu Zhe } else { 484b74bac87SLi Feng Wang // split table cell 485b74bac87SLi Feng Wang swTableCellSplitVERTButton.check(); 48680a6f5c5SLiu Zhe // vertically 48780a6f5c5SLiu Zhe swTableCellSplitDialog.ok(); 48880a6f5c5SLiu Zhe } 48980a6f5c5SLiu Zhe } 49080a6f5c5SLiu Zhe // verify cell split successfully 49180a6f5c5SLiu Zhe writer.focus(); 49280a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 49380a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 49480a6f5c5SLiu Zhe typeKeys("<right>"); 49580a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 49680a6f5c5SLiu Zhe } 49780a6f5c5SLiu Zhe sleep(1); 49880a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 49980a6f5c5SLiu Zhe } 50080a6f5c5SLiu Zhe 50180a6f5c5SLiu Zhe /** 50280a6f5c5SLiu Zhe * Test convert table to text in text document 50380a6f5c5SLiu Zhe * 50480a6f5c5SLiu Zhe * @throws Exception 50580a6f5c5SLiu Zhe */ 50680a6f5c5SLiu Zhe @Test testConvertTableToText()50780a6f5c5SLiu Zhe public void testConvertTableToText() throws Exception { 50880a6f5c5SLiu Zhe writerInsertTable.ok(); 50980a6f5c5SLiu Zhe writer.focus(); 51080a6f5c5SLiu Zhe typeKeys("1<right>2<right>3<right>4"); 51180a6f5c5SLiu Zhe sleep(1); 51280a6f5c5SLiu Zhe 51380a6f5c5SLiu Zhe // Convert table to text 51480a6f5c5SLiu Zhe app.dispatch(".uno:ConvertTableToText"); 515b74bac87SLi Feng Wang assertTrue("Convert Table to Text dialog pop up", 516b74bac87SLi Feng Wang writerConvertTableToTextDlg.exists()); 51780a6f5c5SLiu Zhe // typeKeys("<enter>"); 518b74bac87SLi Feng Wang writerConvertTableToTextDlg.ok(); 51980a6f5c5SLiu Zhe 52080a6f5c5SLiu Zhe // Verify if text is converted successfully 52180a6f5c5SLiu Zhe app.dispatch(".uno:SelectAll"); 52280a6f5c5SLiu Zhe app.dispatch(".uno:Copy"); 52380a6f5c5SLiu Zhe if (SystemUtil.isWindows()) 524b74bac87SLi Feng Wang assertEquals("Converted text", "1\t2\r\n3\t4\r\n", 525b74bac87SLi Feng Wang app.getClipboard()); 52680a6f5c5SLiu Zhe else 52780a6f5c5SLiu Zhe assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard()); 52880a6f5c5SLiu Zhe } 52980a6f5c5SLiu Zhe } 530