xref: /AOO41X/test/testgui/source/fvt/gui/sw/table/TableGeneral.java (revision b74bac8742d0d5bfaf1470fb9389497e8888fb2d)
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;
3280a6f5c5SLiu Zhe import org.junit.Test;
3380a6f5c5SLiu Zhe import org.openoffice.test.common.SystemUtil;
3480a6f5c5SLiu Zhe 
35*b74bac87SLi Feng Wang import testlib.gui.AppTool;
3680a6f5c5SLiu Zhe 
3780a6f5c5SLiu Zhe public class TableGeneral {
3880a6f5c5SLiu Zhe 
3980a6f5c5SLiu Zhe     @Before
4080a6f5c5SLiu Zhe     public void setUp() throws Exception {
4180a6f5c5SLiu Zhe         // Start OpenOffice
4280a6f5c5SLiu Zhe         app.start();
4380a6f5c5SLiu Zhe 
44*b74bac87SLi Feng Wang         AppTool.newTextDocument();
4580a6f5c5SLiu Zhe         // Insert a table
4680a6f5c5SLiu Zhe         app.dispatch(".uno:InsertTable");
4780a6f5c5SLiu Zhe     }
4880a6f5c5SLiu Zhe 
4980a6f5c5SLiu Zhe     @After
5080a6f5c5SLiu Zhe     public void tearDown() throws Exception {
5196ee427fSLi Feng Wang         app.stop();
5280a6f5c5SLiu Zhe     }
5380a6f5c5SLiu 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      */
5980a6f5c5SLiu Zhe     @Test
6080a6f5c5SLiu Zhe     public void testTableSize() throws Exception {
6180a6f5c5SLiu Zhe 
6280a6f5c5SLiu Zhe         swTableSizeColBox.focus();
6380a6f5c5SLiu Zhe         typeKeys("<delete>");
6480a6f5c5SLiu Zhe         typeKeys("3");
6580a6f5c5SLiu Zhe         swTableSizeRowBox.focus();
6680a6f5c5SLiu Zhe         typeKeys("<delete>");
6780a6f5c5SLiu Zhe         typeKeys("4");
6880a6f5c5SLiu Zhe         writerInsertTable.ok();
6980a6f5c5SLiu Zhe 
70*b74bac87SLi Feng Wang         writer.focus();
71*b74bac87SLi Feng Wang         // verify the rows in the table
7280a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
7380a6f5c5SLiu Zhe         for (int i = 0; i < 3; i++) {
7480a6f5c5SLiu Zhe             typeKeys("<down>");
7580a6f5c5SLiu Zhe             assertNotNull(statusBar.getItemTextById(8));
7680a6f5c5SLiu Zhe         }
7780a6f5c5SLiu Zhe         typeKeys("<down>");
7880a6f5c5SLiu Zhe         sleep(1);
7980a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
8080a6f5c5SLiu Zhe     }
8180a6f5c5SLiu 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      */
8780a6f5c5SLiu 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")
8980a6f5c5SLiu Zhe     public void testTableBackground() throws Exception {
9080a6f5c5SLiu Zhe         writerInsertTable.ok();
9180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
9280a6f5c5SLiu Zhe         writer.focus();
9380a6f5c5SLiu Zhe         // set table cell background
9480a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
9580a6f5c5SLiu Zhe         swTableBackground.select();
9680a6f5c5SLiu Zhe         assertTrue("Table background property dialog pop up",
9780a6f5c5SLiu Zhe                 swTableBackground.exists());
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>");
107*b74bac87SLi Feng Wang         AppTool.newPresentation();
10880a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
10980a6f5c5SLiu Zhe         // enable table cell area format dialog
11080a6f5c5SLiu Zhe         app.dispatch(".uno:FormatArea");
11180a6f5c5SLiu Zhe         sleep(1);
11280a6f5c5SLiu Zhe         assertEquals("Light red", sdTableBACGColorListbox.getSelText());
11380a6f5c5SLiu Zhe         // close table cell area format dialog
11480a6f5c5SLiu Zhe         sdTableBACGColorArea.cancel();
11580a6f5c5SLiu Zhe     }
11680a6f5c5SLiu 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      */
12280a6f5c5SLiu Zhe     @Test
12380a6f5c5SLiu Zhe     public void testTableBorder() throws Exception {
12480a6f5c5SLiu Zhe         writerInsertTable.ok();
12580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
12680a6f5c5SLiu Zhe         // set table border as none
12780a6f5c5SLiu Zhe         writer.focus();
12880a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
12980a6f5c5SLiu Zhe         swTableBorder.select();
13080a6f5c5SLiu Zhe         assertTrue("Table border property dialog pop up",
13180a6f5c5SLiu Zhe                 swTableBorder.exists());
13280a6f5c5SLiu Zhe         swTableBorderLineArrange.click(10, 10);
13380a6f5c5SLiu Zhe         swTableBorder.ok();
13480a6f5c5SLiu Zhe     }
13580a6f5c5SLiu 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      */
14280a6f5c5SLiu Zhe     @Test
14380a6f5c5SLiu Zhe     public void testTableBorderLineStyle() throws Exception {
14480a6f5c5SLiu Zhe         writerInsertTable.ok();
14580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
14680a6f5c5SLiu Zhe         writer.focus();
14780a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
14880a6f5c5SLiu Zhe         swTableBorder.select();
14980a6f5c5SLiu Zhe         assertTrue("Table border property dialog pop up",
15080a6f5c5SLiu 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();
15780a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
15880a6f5c5SLiu 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);
16380a6f5c5SLiu Zhe         swTableShadowSize.focus();
16480a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
16580a6f5c5SLiu Zhe         typeKeys("<delete>");
16680a6f5c5SLiu Zhe         typeKeys("2");
16780a6f5c5SLiu Zhe         swTableShadowColor.select(5);
16880a6f5c5SLiu Zhe         swTableBorder.ok();
169*b74bac87SLi Feng Wang         // verify the setting property of table
170*b74bac87SLi Feng Wang         writer.focus();
17180a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
17280a6f5c5SLiu Zhe         swTableBorder.select();
17380a6f5c5SLiu Zhe         assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
17480a6f5c5SLiu Zhe         assertEquals("Magenta", swTableBorderLineColor.getItemText(5));
17580a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCLeft.getText());
17680a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCRight.getText());
17780a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCTop.getText());
17880a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCBottom.getText());
17980a6f5c5SLiu Zhe         assertEquals("1.97\"", swTableShadowSize.getText());
18080a6f5c5SLiu Zhe         assertEquals("Magenta", swTableShadowColor.getItemText(5));
18180a6f5c5SLiu Zhe         assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
18280a6f5c5SLiu Zhe         swTableBorder.close();
18380a6f5c5SLiu Zhe 
18480a6f5c5SLiu Zhe         // uncheck Synchronize box and set spacing to content
18580a6f5c5SLiu Zhe         writer.focus();
18680a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
18780a6f5c5SLiu Zhe         swTableBorder.select();
18880a6f5c5SLiu Zhe         swTableSTCSYNC.uncheck();
189*b74bac87SLi Feng Wang         // set left spacing to content
190*b74bac87SLi Feng Wang         swTableSTCLeft.focus();
19180a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
19280a6f5c5SLiu Zhe         typeKeys("<delete>");
19380a6f5c5SLiu Zhe         typeKeys("0.5");
194*b74bac87SLi Feng Wang         // set right spacing to content
195*b74bac87SLi Feng Wang         swTableSTCRight.focus();
19680a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
19780a6f5c5SLiu Zhe         typeKeys("<delete>");
19880a6f5c5SLiu Zhe         typeKeys("0.8");
199*b74bac87SLi Feng Wang         // set top spacing to content
200*b74bac87SLi Feng Wang         swTableSTCTop.focus();
20180a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
20280a6f5c5SLiu Zhe         typeKeys("<delete>");
20380a6f5c5SLiu Zhe         typeKeys("1.0");
204*b74bac87SLi Feng Wang         // set bottom spacing to content
205*b74bac87SLi Feng Wang         swTableSTCBottom.focus();
20680a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
20780a6f5c5SLiu Zhe         typeKeys("<delete>");
20880a6f5c5SLiu Zhe         typeKeys("2");
20980a6f5c5SLiu Zhe         swTableBorder.ok();
21080a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
21180a6f5c5SLiu Zhe 
212*b74bac87SLi Feng Wang         writer.focus();
213*b74bac87SLi Feng Wang         // verify the setting value of spacing to content for table
21480a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
21580a6f5c5SLiu Zhe         swTableBorder.select();
21680a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCLeft.getText());
21780a6f5c5SLiu Zhe         assertEquals("0.80\"", swTableSTCRight.getText());
21880a6f5c5SLiu Zhe         assertEquals("1.00\"", swTableSTCTop.getText());
21980a6f5c5SLiu Zhe         assertEquals("1.97\"", swTableSTCBottom.getText());
22080a6f5c5SLiu Zhe         assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
22180a6f5c5SLiu Zhe         swTableBorder.close();
22280a6f5c5SLiu Zhe     }
22380a6f5c5SLiu 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      */
22980a6f5c5SLiu Zhe     @Test
23080a6f5c5SLiu Zhe     public void testTableAutoFormat() throws Exception {
23180a6f5c5SLiu Zhe         // create table with auto format
23280a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
23380a6f5c5SLiu Zhe         assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
23480a6f5c5SLiu Zhe         swTableAutoFormatListbox.select(3);
23580a6f5c5SLiu Zhe         swTableAutoFMT.ok();
23680a6f5c5SLiu Zhe         // verify the auto format is that just selected
23780a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
23880a6f5c5SLiu Zhe         assertEquals("Blue", swTableAutoFormatListbox.getSelText());
23980a6f5c5SLiu Zhe         swTableAutoFMT.close();
24080a6f5c5SLiu Zhe         writerInsertTable.ok();
24180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
24280a6f5c5SLiu Zhe 
24380a6f5c5SLiu Zhe     }
24480a6f5c5SLiu 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      */
25080a6f5c5SLiu Zhe     @Test
25180a6f5c5SLiu Zhe     public void testTableRowHeight() throws Exception {
25280a6f5c5SLiu Zhe         writerInsertTable.ok();
25380a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
25480a6f5c5SLiu Zhe 
25580a6f5c5SLiu Zhe         // set row height
25680a6f5c5SLiu Zhe         writer.focus();
25780a6f5c5SLiu Zhe         writer.openContextMenu();
25880a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
25980a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
26080a6f5c5SLiu Zhe         swTableSetRowHeight.focus();
26180a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
26280a6f5c5SLiu Zhe         typeKeys("<delete>");
26380a6f5c5SLiu Zhe         typeKeys("0.5");
26480a6f5c5SLiu Zhe         swTableSetRowHeightDialog.ok();
26580a6f5c5SLiu Zhe 
26680a6f5c5SLiu Zhe         // verify row height
26780a6f5c5SLiu Zhe         writer.focus();
26880a6f5c5SLiu Zhe         writer.openContextMenu();
26980a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
27080a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
27180a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSetRowHeight.getText());
27280a6f5c5SLiu Zhe         swTableSetRowHeightDialog.close();
27380a6f5c5SLiu Zhe     }
27480a6f5c5SLiu 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      */
28080a6f5c5SLiu Zhe     @Test
28180a6f5c5SLiu Zhe     public void testTableSelectRow() throws Exception {
28280a6f5c5SLiu Zhe         writerInsertTable.ok();
28380a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
28480a6f5c5SLiu Zhe         // select row
28580a6f5c5SLiu Zhe         writer.focus();
28680a6f5c5SLiu Zhe         writer.openContextMenu();
28780a6f5c5SLiu Zhe         swTableSelectRowMenu.select();
28880a6f5c5SLiu Zhe 
28980a6f5c5SLiu Zhe         // verify select one row successfully
29080a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
29180a6f5c5SLiu Zhe         typeKeys("<down>");
29280a6f5c5SLiu Zhe         typeKeys("<down>");
29380a6f5c5SLiu Zhe         typeKeys("<enter>");
29480a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
29580a6f5c5SLiu Zhe         typeKeys("<up>");
29680a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
29780a6f5c5SLiu Zhe 
29880a6f5c5SLiu Zhe     }
29980a6f5c5SLiu 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      */
30580a6f5c5SLiu Zhe     @Test
30680a6f5c5SLiu Zhe     public void testTableInsertRow() throws Exception {
30780a6f5c5SLiu Zhe         writerInsertTable.ok();
30880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
30980a6f5c5SLiu Zhe         writer.focus();
31080a6f5c5SLiu Zhe         writer.openContextMenu();
31180a6f5c5SLiu Zhe         swTableInsertRowMenu.select();
312*b74bac87SLi Feng Wang         assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists());
31380a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
31480a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
31580a6f5c5SLiu Zhe         typeKeys("<delete>");
31680a6f5c5SLiu Zhe         typeKeys("3");
31780a6f5c5SLiu Zhe         swTableInsertRow.ok();
31880a6f5c5SLiu Zhe 
319*b74bac87SLi Feng Wang         writer.focus();
320*b74bac87SLi Feng Wang         // verify how many rows in the table
32180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
32280a6f5c5SLiu Zhe         for (int i = 0; i < 4; i++) {
32380a6f5c5SLiu Zhe             typeKeys("<down>");
32480a6f5c5SLiu Zhe             assertNotNull(statusBar.getItemTextById(8));
32580a6f5c5SLiu Zhe         }
32680a6f5c5SLiu Zhe         typeKeys("<down>");
32780a6f5c5SLiu Zhe         sleep(1);
32880a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
32980a6f5c5SLiu Zhe     }
33080a6f5c5SLiu 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      */
33680a6f5c5SLiu Zhe     @Test
33780a6f5c5SLiu Zhe     public void testTableRowDelete() throws Exception {
33880a6f5c5SLiu Zhe         writerInsertTable.ok();
33980a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
34080a6f5c5SLiu Zhe         // delete row
34180a6f5c5SLiu Zhe         writer.focus();
34280a6f5c5SLiu Zhe         writer.openContextMenu();
34380a6f5c5SLiu Zhe         swTableRowDleteMenu.select();
34480a6f5c5SLiu Zhe         // verify whether delete row
34580a6f5c5SLiu Zhe         writer.focus();
34680a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
34780a6f5c5SLiu Zhe         typeKeys("<down>");
34880a6f5c5SLiu Zhe         sleep(1);
34980a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
35080a6f5c5SLiu Zhe 
35180a6f5c5SLiu Zhe     }
35280a6f5c5SLiu 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      */
35880a6f5c5SLiu Zhe     @Test
35980a6f5c5SLiu Zhe     public void testTableColumnWidth() throws Exception {
36080a6f5c5SLiu Zhe         writerInsertTable.ok();
36180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
36280a6f5c5SLiu Zhe         // set column width
36380a6f5c5SLiu Zhe         writer.focus();
36480a6f5c5SLiu Zhe         writer.openContextMenu();
36580a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
36680a6f5c5SLiu Zhe         swTableSetColumnWidth.focus();
36780a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
36880a6f5c5SLiu Zhe         typeKeys("<delete>");
36980a6f5c5SLiu Zhe         typeKeys("2");
37080a6f5c5SLiu Zhe         swTableSetColumnDialog.ok();
37180a6f5c5SLiu Zhe         // verify column width
37280a6f5c5SLiu Zhe         writer.focus();
37380a6f5c5SLiu Zhe         writer.openContextMenu();
37480a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
37580a6f5c5SLiu Zhe         assertEquals("2.00\"", swTableSetColumnWidth.getText());
37680a6f5c5SLiu Zhe 
37780a6f5c5SLiu Zhe     }
37880a6f5c5SLiu 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      */
38480a6f5c5SLiu Zhe     @Test
38580a6f5c5SLiu Zhe     public void testTableColumnSelect() throws Exception {
38680a6f5c5SLiu Zhe         writerInsertTable.ok();
38780a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
38880a6f5c5SLiu Zhe         writer.focus();
38980a6f5c5SLiu Zhe         writer.openContextMenu();
39080a6f5c5SLiu Zhe         swTableColumnSelectMenu.select();
39180a6f5c5SLiu Zhe 
39280a6f5c5SLiu Zhe         // verify select one column
39380a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
39480a6f5c5SLiu Zhe         typeKeys("<down>");
39580a6f5c5SLiu Zhe         typeKeys("<down>");
39680a6f5c5SLiu Zhe         typeKeys("<enter>");
39780a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
39880a6f5c5SLiu Zhe         typeKeys("<up>");
39980a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
40080a6f5c5SLiu Zhe 
40180a6f5c5SLiu Zhe     }
40280a6f5c5SLiu 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      */
40880a6f5c5SLiu Zhe     @Test
40980a6f5c5SLiu Zhe     public void testTableColumnInsert() throws Exception {
41080a6f5c5SLiu Zhe         writerInsertTable.ok();
41180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
41280a6f5c5SLiu Zhe         // insert column
41380a6f5c5SLiu Zhe         writer.focus();
41480a6f5c5SLiu Zhe         writer.openContextMenu();
41580a6f5c5SLiu Zhe         swTableColumnInsertMenu.select();
41680a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
41780a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
41880a6f5c5SLiu Zhe         typeKeys("<delete>");
41980a6f5c5SLiu Zhe         typeKeys("3");
42080a6f5c5SLiu Zhe         swTableInsertColumn.ok();
42180a6f5c5SLiu Zhe         // verify insert column successfully
42280a6f5c5SLiu Zhe         writer.focus();
42380a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
42480a6f5c5SLiu Zhe         for (int i = 0; i < 9; i++) {
42580a6f5c5SLiu Zhe             typeKeys("<right>");
42680a6f5c5SLiu Zhe             sleep(1);
42780a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
42880a6f5c5SLiu Zhe         }
42980a6f5c5SLiu Zhe         typeKeys("<right>");
43080a6f5c5SLiu Zhe         sleep(1);
43180a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
43280a6f5c5SLiu Zhe     }
43380a6f5c5SLiu 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      */
43980a6f5c5SLiu Zhe     public void testTableColumnDelete() throws Exception {
44080a6f5c5SLiu Zhe         writerInsertTable.ok();
44180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
44280a6f5c5SLiu Zhe         // delete column
44380a6f5c5SLiu Zhe         writer.focus();
44480a6f5c5SLiu Zhe         writer.openContextMenu();
44580a6f5c5SLiu Zhe         swTableColumnDeleteMenu.select();
44680a6f5c5SLiu Zhe         // verify delete column
44780a6f5c5SLiu Zhe         writer.focus();
44880a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
44980a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
45080a6f5c5SLiu Zhe             typeKeys("<right>");
45180a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
45280a6f5c5SLiu Zhe         }
45380a6f5c5SLiu Zhe         sleep(1);
45480a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
45580a6f5c5SLiu Zhe     }
45680a6f5c5SLiu 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      */
46280a6f5c5SLiu Zhe     @Test
46380a6f5c5SLiu Zhe     public void testTableCellSplit() throws Exception {
46480a6f5c5SLiu Zhe         writerInsertTable.ok();
46580a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
46680a6f5c5SLiu Zhe         for (int k = 0; k < 2; k++) {
46780a6f5c5SLiu Zhe             writer.focus();
46880a6f5c5SLiu Zhe             writer.openContextMenu();
46980a6f5c5SLiu Zhe             swTableCellSplitMenu.select();
47080a6f5c5SLiu Zhe             swTableCellSplitNumber.focus();
47180a6f5c5SLiu Zhe             typeKeys("<ctrl a>");
47280a6f5c5SLiu Zhe             typeKeys("<delete>");
47380a6f5c5SLiu Zhe             typeKeys("2");
47480a6f5c5SLiu Zhe             if (k == 0) {
475*b74bac87SLi Feng Wang                 // split table cell horizontally
476*b74bac87SLi Feng Wang                 swTableCellSplitDialog.ok();
47780a6f5c5SLiu Zhe             } else {
478*b74bac87SLi Feng Wang                 // split table cell
479*b74bac87SLi Feng Wang                 swTableCellSplitVERTButton.check();
48080a6f5c5SLiu Zhe                 // vertically
48180a6f5c5SLiu Zhe                 swTableCellSplitDialog.ok();
48280a6f5c5SLiu Zhe             }
48380a6f5c5SLiu Zhe         }
48480a6f5c5SLiu Zhe         // verify cell split successfully
48580a6f5c5SLiu Zhe         writer.focus();
48680a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
48780a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
48880a6f5c5SLiu Zhe             typeKeys("<right>");
48980a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
49080a6f5c5SLiu Zhe         }
49180a6f5c5SLiu Zhe         sleep(1);
49280a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
49380a6f5c5SLiu Zhe     }
49480a6f5c5SLiu Zhe 
49580a6f5c5SLiu Zhe     /**
49680a6f5c5SLiu Zhe      * Test convert table to text in text document
49780a6f5c5SLiu Zhe      *
49880a6f5c5SLiu Zhe      * @throws Exception
49980a6f5c5SLiu Zhe      */
50080a6f5c5SLiu Zhe     @Test
50180a6f5c5SLiu Zhe     public void testConvertTableToText() throws Exception {
50280a6f5c5SLiu Zhe         writerInsertTable.ok();
50380a6f5c5SLiu Zhe         writer.focus();
50480a6f5c5SLiu Zhe         typeKeys("1<right>2<right>3<right>4");
50580a6f5c5SLiu Zhe         sleep(1);
50680a6f5c5SLiu Zhe 
50780a6f5c5SLiu Zhe         // Convert table to text
50880a6f5c5SLiu Zhe         app.dispatch(".uno:ConvertTableToText");
509*b74bac87SLi Feng Wang         assertTrue("Convert Table to Text dialog pop up",
510*b74bac87SLi Feng Wang                 writerConvertTableToTextDlg.exists());
51180a6f5c5SLiu Zhe         // typeKeys("<enter>");
512*b74bac87SLi Feng Wang         writerConvertTableToTextDlg.ok();
51380a6f5c5SLiu Zhe 
51480a6f5c5SLiu Zhe         // Verify if text is converted successfully
51580a6f5c5SLiu Zhe         app.dispatch(".uno:SelectAll");
51680a6f5c5SLiu Zhe         app.dispatch(".uno:Copy");
51780a6f5c5SLiu Zhe         if (SystemUtil.isWindows())
518*b74bac87SLi Feng Wang             assertEquals("Converted text", "1\t2\r\n3\t4\r\n",
519*b74bac87SLi Feng Wang                     app.getClipboard());
52080a6f5c5SLiu Zhe         else
52180a6f5c5SLiu Zhe             assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
52280a6f5c5SLiu Zhe     }
52380a6f5c5SLiu Zhe }
524