1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert 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; 3280a6f5c5SLiu Zhe import org.junit.Rule; 3380a6f5c5SLiu Zhe import org.junit.Test; 3480a6f5c5SLiu Zhe import org.openoffice.test.common.Logger; 3580a6f5c5SLiu Zhe import org.openoffice.test.common.SystemUtil; 3680a6f5c5SLiu Zhe 3780a6f5c5SLiu Zhe 3880a6f5c5SLiu Zhe public class TableGeneral { 3980a6f5c5SLiu Zhe 4080a6f5c5SLiu Zhe @Rule 4180a6f5c5SLiu Zhe public Logger log = Logger.getLogger(this); 4280a6f5c5SLiu Zhe 4380a6f5c5SLiu Zhe @Before 4480a6f5c5SLiu Zhe public void setUp() throws Exception { 4580a6f5c5SLiu Zhe // Start OpenOffice 4680a6f5c5SLiu Zhe app.start(); 4780a6f5c5SLiu Zhe 4880a6f5c5SLiu Zhe // Create a new text document 4980a6f5c5SLiu Zhe app.dispatch("private:factory/swriter"); 5080a6f5c5SLiu Zhe 5180a6f5c5SLiu Zhe // Insert a table 5280a6f5c5SLiu Zhe app.dispatch(".uno:InsertTable"); 5380a6f5c5SLiu Zhe assertTrue("Insert Table dialog pop up", writerInsertTable.exists()); 5480a6f5c5SLiu Zhe } 5580a6f5c5SLiu Zhe 5680a6f5c5SLiu Zhe @After 5780a6f5c5SLiu Zhe public void tearDown() throws Exception { 5880a6f5c5SLiu Zhe app.close(); 5980a6f5c5SLiu Zhe } 6080a6f5c5SLiu Zhe 6180a6f5c5SLiu Zhe @Test 6280a6f5c5SLiu Zhe // Test setting table size in text document 6380a6f5c5SLiu Zhe public void testTableSize() throws Exception { 6480a6f5c5SLiu Zhe 6580a6f5c5SLiu Zhe swTableSizeColBox.focus(); 6680a6f5c5SLiu Zhe typeKeys("<delete>"); 6780a6f5c5SLiu Zhe typeKeys("3"); 6880a6f5c5SLiu Zhe swTableSizeRowBox.focus(); 6980a6f5c5SLiu Zhe typeKeys("<delete>"); 7080a6f5c5SLiu Zhe typeKeys("4"); 7180a6f5c5SLiu Zhe writerInsertTable.ok(); 7280a6f5c5SLiu Zhe 7380a6f5c5SLiu Zhe writer.focus(); // verify how many rows in the table 7480a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 7580a6f5c5SLiu Zhe for (int i = 0; i < 3; i++) { 7680a6f5c5SLiu Zhe typeKeys("<down>"); 7780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 7880a6f5c5SLiu Zhe } 7980a6f5c5SLiu Zhe typeKeys("<down>"); 8080a6f5c5SLiu Zhe sleep(1); 8180a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 8280a6f5c5SLiu Zhe } 8380a6f5c5SLiu Zhe 8480a6f5c5SLiu Zhe // Test setting table cell background in text document 8580a6f5c5SLiu Zhe 8680a6f5c5SLiu Zhe @Test 8783ae2205SHerbert Dürr @Ignore("Bug #120378") 8880a6f5c5SLiu Zhe public void testTableBackground() throws Exception { 8980a6f5c5SLiu Zhe writerInsertTable.ok(); 9080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 9180a6f5c5SLiu Zhe writer.focus(); 9280a6f5c5SLiu Zhe // set table cell background 9380a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 9480a6f5c5SLiu Zhe swTableBackground.select(); 9580a6f5c5SLiu Zhe assertTrue("Table background property dialog pop up", 9680a6f5c5SLiu Zhe swTableBackground.exists()); 9780a6f5c5SLiu Zhe ; 9880a6f5c5SLiu Zhe swTableBackgroundColor.focus(); 9980a6f5c5SLiu Zhe swTableBackgroundColor.click(50, 50); 10080a6f5c5SLiu Zhe swTableBackground.ok(); 10180a6f5c5SLiu Zhe // verify table cell background color 10280a6f5c5SLiu Zhe writer.focus(); 10380a6f5c5SLiu Zhe // select the cell which is filled with color 10480a6f5c5SLiu Zhe app.dispatch(".uno:EntireCell"); 10580a6f5c5SLiu Zhe 10680a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 10780a6f5c5SLiu Zhe app.dispatch("private:factory/simpress?slot=6686"); 10880a6f5c5SLiu Zhe presentationWizard.ok(); 10980a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 11080a6f5c5SLiu Zhe // enable table cell area format dialog 11180a6f5c5SLiu Zhe app.dispatch(".uno:FormatArea"); 11280a6f5c5SLiu Zhe sleep(1); 11380a6f5c5SLiu Zhe assertEquals("Light red", sdTableBACGColorListbox.getSelText()); 11480a6f5c5SLiu Zhe // close table cell area format dialog 11580a6f5c5SLiu Zhe sdTableBACGColorArea.cancel(); 11680a6f5c5SLiu Zhe } 11780a6f5c5SLiu Zhe 11880a6f5c5SLiu Zhe // Test setting table border in text document 11980a6f5c5SLiu Zhe 12080a6f5c5SLiu Zhe @Test 12180a6f5c5SLiu Zhe public void testTableBorder() throws Exception { 12280a6f5c5SLiu Zhe writerInsertTable.ok(); 12380a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 12480a6f5c5SLiu Zhe // set table border as none 12580a6f5c5SLiu Zhe writer.focus(); 12680a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 12780a6f5c5SLiu Zhe swTableBorder.select(); 12880a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 12980a6f5c5SLiu Zhe swTableBorder.exists()); 13080a6f5c5SLiu Zhe ; 13180a6f5c5SLiu Zhe swTableBorderLineArrange.click(10, 10); 13280a6f5c5SLiu Zhe swTableBorder.ok(); 13380a6f5c5SLiu Zhe } 13480a6f5c5SLiu Zhe 13580a6f5c5SLiu Zhe // Test setting table border line style,line color,spacing to content in 13680a6f5c5SLiu Zhe // text document 13780a6f5c5SLiu Zhe 13880a6f5c5SLiu Zhe @Test 13980a6f5c5SLiu Zhe public void testTableBorderLineStyle() throws Exception { 14080a6f5c5SLiu Zhe writerInsertTable.ok(); 14180a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 14280a6f5c5SLiu Zhe writer.focus(); 14380a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 14480a6f5c5SLiu Zhe swTableBorder.select(); 14580a6f5c5SLiu Zhe assertTrue("Table border property dialog pop up", 14680a6f5c5SLiu Zhe swTableBorder.exists()); 14780a6f5c5SLiu Zhe ; 14880a6f5c5SLiu Zhe swTableBorderLineStyle.select(8); // set line style 14980a6f5c5SLiu Zhe swTableBorderLineColor.select(5); // set line color 15080a6f5c5SLiu Zhe swTableSTCLeft.focus(); // set spacing to content 15180a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 15280a6f5c5SLiu Zhe typeKeys("<delete>"); 15380a6f5c5SLiu Zhe typeKeys("0.5"); // set spacing to content 15480a6f5c5SLiu Zhe swTableShadow.click(40, 10); // set table shadow 15580a6f5c5SLiu Zhe swTableShadowSize.focus(); 15680a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 15780a6f5c5SLiu Zhe typeKeys("<delete>"); 15880a6f5c5SLiu Zhe typeKeys("2"); 15980a6f5c5SLiu Zhe swTableShadowColor.select(5); 16080a6f5c5SLiu Zhe swTableBorder.ok(); 16180a6f5c5SLiu Zhe 16280a6f5c5SLiu Zhe writer.focus(); // verify the setting property of table 16380a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 16480a6f5c5SLiu Zhe swTableBorder.select(); 16580a6f5c5SLiu Zhe assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8)); 16680a6f5c5SLiu Zhe assertEquals("Magenta", swTableBorderLineColor.getItemText(5)); 16780a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 16880a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCRight.getText()); 16980a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCTop.getText()); 17080a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCBottom.getText()); 17180a6f5c5SLiu Zhe assertEquals("1.97\"", swTableShadowSize.getText()); 17280a6f5c5SLiu Zhe assertEquals("Magenta", swTableShadowColor.getItemText(5)); 17380a6f5c5SLiu Zhe assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 17480a6f5c5SLiu Zhe swTableBorder.close(); 17580a6f5c5SLiu Zhe 17680a6f5c5SLiu Zhe // uncheck Synchronize box and set spacing to content 17780a6f5c5SLiu Zhe 17880a6f5c5SLiu Zhe writer.focus(); 17980a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 18080a6f5c5SLiu Zhe swTableBorder.select(); 18180a6f5c5SLiu Zhe swTableSTCSYNC.uncheck(); 18280a6f5c5SLiu Zhe swTableSTCLeft.focus();// set left spacing to content 18380a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 18480a6f5c5SLiu Zhe typeKeys("<delete>"); 18580a6f5c5SLiu Zhe typeKeys("0.5"); 18680a6f5c5SLiu Zhe swTableSTCRight.focus();// set right spacing to content 18780a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 18880a6f5c5SLiu Zhe typeKeys("<delete>"); 18980a6f5c5SLiu Zhe typeKeys("0.8"); 19080a6f5c5SLiu Zhe swTableSTCTop.focus();// set top spacing to content 19180a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 19280a6f5c5SLiu Zhe typeKeys("<delete>"); 19380a6f5c5SLiu Zhe typeKeys("1.0"); 19480a6f5c5SLiu Zhe swTableSTCBottom.focus();// set bottom spacing to content 19580a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 19680a6f5c5SLiu Zhe typeKeys("<delete>"); 19780a6f5c5SLiu Zhe typeKeys("2"); 19880a6f5c5SLiu Zhe swTableBorder.ok(); 19980a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 20080a6f5c5SLiu Zhe 20180a6f5c5SLiu Zhe writer.focus(); // verify the setting value of spacing to content for 20280a6f5c5SLiu Zhe // tabel 20380a6f5c5SLiu Zhe app.dispatch(".uno:TableDialog"); 20480a6f5c5SLiu Zhe swTableBorder.select(); 20580a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSTCLeft.getText()); 20680a6f5c5SLiu Zhe assertEquals("0.80\"", swTableSTCRight.getText()); 20780a6f5c5SLiu Zhe assertEquals("1.00\"", swTableSTCTop.getText()); 20880a6f5c5SLiu Zhe assertEquals("1.97\"", swTableSTCBottom.getText()); 20980a6f5c5SLiu Zhe assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked()); 21080a6f5c5SLiu Zhe swTableBorder.close(); 21180a6f5c5SLiu Zhe } 21280a6f5c5SLiu Zhe 21380a6f5c5SLiu Zhe // create table with auto format 21480a6f5c5SLiu Zhe 21580a6f5c5SLiu Zhe @Test 21680a6f5c5SLiu Zhe public void testTableAutoFormat() throws Exception { 21780a6f5c5SLiu Zhe // create table with auto format 21880a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 21980a6f5c5SLiu Zhe assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists()); 22080a6f5c5SLiu Zhe swTableAutoFormatListbox.select(3); 22180a6f5c5SLiu Zhe swTableAutoFMT.ok(); 22280a6f5c5SLiu Zhe // verify the auto format is that just selected 22380a6f5c5SLiu Zhe button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click(); 22480a6f5c5SLiu Zhe assertEquals("Blue", swTableAutoFormatListbox.getSelText()); 22580a6f5c5SLiu Zhe swTableAutoFMT.close(); 22680a6f5c5SLiu Zhe writerInsertTable.ok(); 22780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 22880a6f5c5SLiu Zhe 22980a6f5c5SLiu Zhe } 23080a6f5c5SLiu Zhe 23180a6f5c5SLiu Zhe // set row height and select row,insert/delete row 23280a6f5c5SLiu Zhe 23380a6f5c5SLiu Zhe @Test 23480a6f5c5SLiu Zhe public void testTableRowHeight() throws Exception { 23580a6f5c5SLiu Zhe writerInsertTable.ok(); 23680a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 23780a6f5c5SLiu Zhe 23880a6f5c5SLiu Zhe // set row height 23980a6f5c5SLiu Zhe writer.focus(); 24080a6f5c5SLiu Zhe writer.openContextMenu(); 24180a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 24280a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 24380a6f5c5SLiu Zhe swTableSetRowHeight.focus(); 24480a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 24580a6f5c5SLiu Zhe typeKeys("<delete>"); 24680a6f5c5SLiu Zhe typeKeys("0.5"); 24780a6f5c5SLiu Zhe swTableSetRowHeightDialog.ok(); 24880a6f5c5SLiu Zhe 24980a6f5c5SLiu Zhe // verify row height 25080a6f5c5SLiu Zhe writer.focus(); 25180a6f5c5SLiu Zhe writer.openContextMenu(); 25280a6f5c5SLiu Zhe swTableRowHeightMenu.select(); 25380a6f5c5SLiu Zhe assertTrue(swTableSetRowHeightDialog.exists()); 25480a6f5c5SLiu Zhe assertEquals("0.50\"", swTableSetRowHeight.getText()); 25580a6f5c5SLiu Zhe swTableSetRowHeightDialog.close(); 25680a6f5c5SLiu Zhe } 25780a6f5c5SLiu Zhe 25880a6f5c5SLiu Zhe // select row 25980a6f5c5SLiu Zhe @Test 26080a6f5c5SLiu Zhe public void testTableSelectRow() throws Exception { 26180a6f5c5SLiu Zhe writerInsertTable.ok(); 26280a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 26380a6f5c5SLiu Zhe // select row 26480a6f5c5SLiu Zhe writer.focus(); 26580a6f5c5SLiu Zhe writer.openContextMenu(); 26680a6f5c5SLiu Zhe swTableSelectRowMenu.select(); 26780a6f5c5SLiu Zhe 26880a6f5c5SLiu Zhe // verify select one row successfully 26980a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 27080a6f5c5SLiu Zhe typeKeys("<down>"); 27180a6f5c5SLiu Zhe typeKeys("<down>"); 27280a6f5c5SLiu Zhe typeKeys("<enter>"); 27380a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 27480a6f5c5SLiu Zhe typeKeys("<up>"); 27580a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 27680a6f5c5SLiu Zhe 27780a6f5c5SLiu Zhe } 27880a6f5c5SLiu Zhe 27980a6f5c5SLiu Zhe // insert row and verify how many row inserted 28080a6f5c5SLiu Zhe @Test 28180a6f5c5SLiu Zhe public void testTableInsertRow() throws Exception { 28280a6f5c5SLiu Zhe writerInsertTable.ok(); 28380a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 28480a6f5c5SLiu Zhe writer.focus(); 28580a6f5c5SLiu Zhe writer.openContextMenu(); 28680a6f5c5SLiu Zhe swTableInsertRowMenu.select(); 28780a6f5c5SLiu Zhe assertTrue("SWTable_InsertRow Dialog pop up", 28880a6f5c5SLiu Zhe swTableInsertRow.exists()); 28980a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 29080a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 29180a6f5c5SLiu Zhe typeKeys("<delete>"); 29280a6f5c5SLiu Zhe typeKeys("3"); 29380a6f5c5SLiu Zhe swTableInsertRow.ok(); 29480a6f5c5SLiu Zhe 29580a6f5c5SLiu Zhe writer.focus(); // verify how many rows in the table 29680a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 29780a6f5c5SLiu Zhe for (int i = 0; i < 4; i++) { 29880a6f5c5SLiu Zhe typeKeys("<down>"); 29980a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 30080a6f5c5SLiu Zhe } 30180a6f5c5SLiu Zhe typeKeys("<down>"); 30280a6f5c5SLiu Zhe sleep(1); 30380a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 30480a6f5c5SLiu Zhe } 30580a6f5c5SLiu Zhe 30680a6f5c5SLiu Zhe // delete row and verify row 30780a6f5c5SLiu Zhe @Test 30880a6f5c5SLiu Zhe public void testTableRowDelete() throws Exception { 30980a6f5c5SLiu Zhe writerInsertTable.ok(); 31080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 31180a6f5c5SLiu Zhe // delete row 31280a6f5c5SLiu Zhe writer.focus(); 31380a6f5c5SLiu Zhe writer.openContextMenu(); 31480a6f5c5SLiu Zhe swTableRowDleteMenu.select(); 31580a6f5c5SLiu Zhe // verify whether delete row 31680a6f5c5SLiu Zhe writer.focus(); 31780a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 31880a6f5c5SLiu Zhe typeKeys("<down>"); 31980a6f5c5SLiu Zhe sleep(1); 32080a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 32180a6f5c5SLiu Zhe 32280a6f5c5SLiu Zhe } 32380a6f5c5SLiu Zhe 32480a6f5c5SLiu Zhe // set column width and verify 32580a6f5c5SLiu Zhe @Test 32680a6f5c5SLiu Zhe public void testTableColumnWidth() throws Exception { 32780a6f5c5SLiu Zhe writerInsertTable.ok(); 32880a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 32980a6f5c5SLiu Zhe // set column width 33080a6f5c5SLiu Zhe writer.focus(); 33180a6f5c5SLiu Zhe writer.openContextMenu(); 33280a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 33380a6f5c5SLiu Zhe swTableSetColumnWidth.focus(); 33480a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 33580a6f5c5SLiu Zhe typeKeys("<delete>"); 33680a6f5c5SLiu Zhe typeKeys("2"); 33780a6f5c5SLiu Zhe swTableSetColumnDialog.ok(); 33880a6f5c5SLiu Zhe // verify column width 33980a6f5c5SLiu Zhe writer.focus(); 34080a6f5c5SLiu Zhe writer.openContextMenu(); 34180a6f5c5SLiu Zhe swTableColumnWidthMenu.select(); 34280a6f5c5SLiu Zhe assertEquals("2.00\"", swTableSetColumnWidth.getText()); 34380a6f5c5SLiu Zhe 34480a6f5c5SLiu Zhe } 34580a6f5c5SLiu Zhe 34680a6f5c5SLiu Zhe // select column and verify 34780a6f5c5SLiu Zhe @Test 34880a6f5c5SLiu Zhe public void testTableColumnSelect() throws Exception { 34980a6f5c5SLiu Zhe writerInsertTable.ok(); 35080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 35180a6f5c5SLiu Zhe writer.focus(); 35280a6f5c5SLiu Zhe writer.openContextMenu(); 35380a6f5c5SLiu Zhe swTableColumnSelectMenu.select(); 35480a6f5c5SLiu Zhe 35580a6f5c5SLiu Zhe // verify select one column 35680a6f5c5SLiu Zhe typeKeys("<ctrl c>"); 35780a6f5c5SLiu Zhe typeKeys("<down>"); 35880a6f5c5SLiu Zhe typeKeys("<down>"); 35980a6f5c5SLiu Zhe typeKeys("<enter>"); 36080a6f5c5SLiu Zhe typeKeys("<ctrl v>"); 36180a6f5c5SLiu Zhe typeKeys("<up>"); 36280a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 36380a6f5c5SLiu Zhe 36480a6f5c5SLiu Zhe } 36580a6f5c5SLiu Zhe 36680a6f5c5SLiu Zhe // insert column and verify 36780a6f5c5SLiu Zhe @Test 36880a6f5c5SLiu Zhe public void testTableColumnInsert() throws Exception { 36980a6f5c5SLiu Zhe writerInsertTable.ok(); 37080a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 37180a6f5c5SLiu Zhe // insert column 37280a6f5c5SLiu Zhe writer.focus(); 37380a6f5c5SLiu Zhe writer.openContextMenu(); 37480a6f5c5SLiu Zhe swTableColumnInsertMenu.select(); 37580a6f5c5SLiu Zhe swTableInsertRowColumnSetNumber.focus(); 37680a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 37780a6f5c5SLiu Zhe typeKeys("<delete>"); 37880a6f5c5SLiu Zhe typeKeys("3"); 37980a6f5c5SLiu Zhe swTableInsertColumn.ok(); 38080a6f5c5SLiu Zhe // verify insert column successfully 38180a6f5c5SLiu Zhe writer.focus(); 38280a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 38380a6f5c5SLiu Zhe for (int i = 0; i < 9; i++) { 38480a6f5c5SLiu Zhe typeKeys("<right>"); 38580a6f5c5SLiu Zhe sleep(1); 38680a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 38780a6f5c5SLiu Zhe } 38880a6f5c5SLiu Zhe typeKeys("<right>"); 38980a6f5c5SLiu Zhe sleep(1); 39080a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 39180a6f5c5SLiu Zhe } 39280a6f5c5SLiu Zhe 39380a6f5c5SLiu Zhe // delete column and verify whether delete or not 39480a6f5c5SLiu Zhe public void testTableColumnDelete() throws Exception { 39580a6f5c5SLiu Zhe writerInsertTable.ok(); 39680a6f5c5SLiu Zhe assertNotNull(statusBar.getItemTextById(8)); 39780a6f5c5SLiu Zhe // delete column 39880a6f5c5SLiu Zhe writer.focus(); 39980a6f5c5SLiu Zhe writer.openContextMenu(); 40080a6f5c5SLiu Zhe swTableColumnDeleteMenu.select(); 40180a6f5c5SLiu Zhe // verify delete column 40280a6f5c5SLiu Zhe writer.focus(); 40380a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 40480a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 40580a6f5c5SLiu Zhe typeKeys("<right>"); 40680a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 40780a6f5c5SLiu Zhe } 40880a6f5c5SLiu Zhe sleep(1); 40980a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 41080a6f5c5SLiu Zhe } 41180a6f5c5SLiu Zhe 41280a6f5c5SLiu Zhe // split cell 41380a6f5c5SLiu Zhe @Test 41480a6f5c5SLiu Zhe public void testTableCellSplit() throws Exception { 41580a6f5c5SLiu Zhe writerInsertTable.ok(); 41680a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 41780a6f5c5SLiu Zhe for (int k = 0; k < 2; k++) { 41880a6f5c5SLiu Zhe writer.focus(); 41980a6f5c5SLiu Zhe writer.openContextMenu(); 42080a6f5c5SLiu Zhe swTableCellSplitMenu.select(); 42180a6f5c5SLiu Zhe swTableCellSplitNumber.focus(); 42280a6f5c5SLiu Zhe typeKeys("<ctrl a>"); 42380a6f5c5SLiu Zhe typeKeys("<delete>"); 42480a6f5c5SLiu Zhe typeKeys("2"); 42580a6f5c5SLiu Zhe if (k == 0) { 42680a6f5c5SLiu Zhe swTableCellSplitDialog.ok(); // split table cell horizontally 42780a6f5c5SLiu Zhe } else { 42880a6f5c5SLiu Zhe swTableCellSplitVERTButton.check(); // split table cell 42980a6f5c5SLiu Zhe // vertically 43080a6f5c5SLiu Zhe swTableCellSplitDialog.ok(); 43180a6f5c5SLiu Zhe } 43280a6f5c5SLiu Zhe } 43380a6f5c5SLiu Zhe // verify cell split successfully 43480a6f5c5SLiu Zhe writer.focus(); 43580a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 43680a6f5c5SLiu Zhe for (int i = 0; i < 7; i++) { 43780a6f5c5SLiu Zhe typeKeys("<right>"); 43880a6f5c5SLiu Zhe assertTrue(tableToolbar.exists()); 43980a6f5c5SLiu Zhe } 44080a6f5c5SLiu Zhe sleep(1); 44180a6f5c5SLiu Zhe assertFalse(tableToolbar.exists()); 44280a6f5c5SLiu Zhe } 44380a6f5c5SLiu Zhe 44480a6f5c5SLiu Zhe /** 44580a6f5c5SLiu Zhe * Test convert table to text in text document 44680a6f5c5SLiu Zhe * 44780a6f5c5SLiu Zhe * @throws Exception 44880a6f5c5SLiu Zhe */ 44980a6f5c5SLiu Zhe @Test 45080a6f5c5SLiu Zhe public void testConvertTableToText() throws Exception { 45180a6f5c5SLiu Zhe writerInsertTable.ok(); 45280a6f5c5SLiu Zhe writer.focus(); 45380a6f5c5SLiu Zhe typeKeys("1<right>2<right>3<right>4"); 45480a6f5c5SLiu Zhe sleep(1); 45580a6f5c5SLiu Zhe 45680a6f5c5SLiu Zhe // Convert table to text 45780a6f5c5SLiu Zhe app.dispatch(".uno:ConvertTableToText"); 45880a6f5c5SLiu Zhe assertTrue("Convert Table to Text dialog pop up", writerConvertTableToTextDlg.exists()); 45980a6f5c5SLiu Zhe // typeKeys("<enter>"); 46080a6f5c5SLiu Zhe writerConvertTableToTextDlg.ok(); // "Enter" does not work on linux 46180a6f5c5SLiu Zhe 46280a6f5c5SLiu Zhe // Verify if text is converted successfully 46380a6f5c5SLiu Zhe app.dispatch(".uno:SelectAll"); 46480a6f5c5SLiu Zhe app.dispatch(".uno:Copy"); 46580a6f5c5SLiu Zhe if (SystemUtil.isWindows()) 46680a6f5c5SLiu Zhe assertEquals("Converted text", "1\t2\r\n3\t4\r\n", app.getClipboard()); // in 46780a6f5c5SLiu Zhe // windows, 46880a6f5c5SLiu Zhe // \n 46980a6f5c5SLiu Zhe // is 47080a6f5c5SLiu Zhe // \r\n 47180a6f5c5SLiu Zhe else 47280a6f5c5SLiu Zhe assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard()); 47380a6f5c5SLiu Zhe } 47480a6f5c5SLiu Zhe } 475