xref: /trunk/test/testgui/source/fvt/gui/sw/table/TableGeneral.java (revision e83be9d674f628e794bfc4b1a4b3b603664fcbfd)
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
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
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
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")
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
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
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
159772b8e0bSHerbert Dürr         final int nMagentaIndex = 16; // for AOO's colorpicker as of #i118828#
160772b8e0bSHerbert 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");
173772b8e0bSHerbert 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));
180772b8e0bSHerbert 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());
186772b8e0bSHerbert 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();
197*e83be9d6Scbmarcum         sleep(0.2);
19880a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
19980a6f5c5SLiu Zhe         typeKeys("<delete>");
20080a6f5c5SLiu Zhe         typeKeys("0.5");
201b74bac87SLi Feng Wang         // set right spacing to content
202b74bac87SLi Feng Wang         swTableSTCRight.focus();
20380a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
20480a6f5c5SLiu Zhe         typeKeys("<delete>");
20580a6f5c5SLiu Zhe         typeKeys("0.8");
206b74bac87SLi Feng Wang         // set top spacing to content
207b74bac87SLi Feng Wang         swTableSTCTop.focus();
20880a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
20980a6f5c5SLiu Zhe         typeKeys("<delete>");
21080a6f5c5SLiu Zhe         typeKeys("1.0");
211b74bac87SLi Feng Wang         // set bottom spacing to content
212b74bac87SLi Feng Wang         swTableSTCBottom.focus();
21380a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
21480a6f5c5SLiu Zhe         typeKeys("<delete>");
21580a6f5c5SLiu Zhe         typeKeys("2");
21680a6f5c5SLiu Zhe         swTableBorder.ok();
21780a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
21880a6f5c5SLiu Zhe 
219b74bac87SLi Feng Wang         writer.focus();
220b74bac87SLi Feng Wang         // verify the setting value of spacing to content for table
22180a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
22280a6f5c5SLiu Zhe         swTableBorder.select();
22380a6f5c5SLiu Zhe         assertEquals("0.50 \"", swTableSTCLeft.getText());
22480a6f5c5SLiu Zhe         assertEquals("0.80 \"", swTableSTCRight.getText());
22580a6f5c5SLiu Zhe         assertEquals("1.00 \"", swTableSTCTop.getText());
22680a6f5c5SLiu Zhe         assertEquals("1.97 \"", swTableSTCBottom.getText());
22780a6f5c5SLiu Zhe         assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
22880a6f5c5SLiu Zhe         swTableBorder.close();
22980a6f5c5SLiu Zhe     }
23080a6f5c5SLiu Zhe 
231b74bac87SLi Feng Wang     /**
232b74bac87SLi Feng Wang      * create table with auto format
233b74bac87SLi Feng Wang      *
234b74bac87SLi Feng Wang      * @throws Exception
235b74bac87SLi Feng Wang      */
23680a6f5c5SLiu Zhe     @Test
23780a6f5c5SLiu Zhe     public void testTableAutoFormat() throws Exception {
23880a6f5c5SLiu Zhe         // create table with auto format
23980a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
24080a6f5c5SLiu Zhe         assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
24180a6f5c5SLiu Zhe         swTableAutoFormatListbox.select(3);
24280a6f5c5SLiu Zhe         swTableAutoFMT.ok();
24380a6f5c5SLiu Zhe         // verify the auto format is that just selected
24480a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
24580a6f5c5SLiu Zhe         assertEquals("Blue", swTableAutoFormatListbox.getSelText());
24680a6f5c5SLiu Zhe         swTableAutoFMT.close();
24780a6f5c5SLiu Zhe         writerInsertTable.ok();
24880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
24980a6f5c5SLiu Zhe 
25080a6f5c5SLiu Zhe     }
25180a6f5c5SLiu Zhe 
252b74bac87SLi Feng Wang     /**
253b74bac87SLi Feng Wang      * set row height and select row,insert/delete row
254b74bac87SLi Feng Wang      *
255b74bac87SLi Feng Wang      * @throws Exception
256b74bac87SLi Feng Wang      */
25780a6f5c5SLiu Zhe     @Test
25880a6f5c5SLiu Zhe     public void testTableRowHeight() throws Exception {
25980a6f5c5SLiu Zhe         writerInsertTable.ok();
26080a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
26180a6f5c5SLiu Zhe 
26280a6f5c5SLiu Zhe         // set row height
26380a6f5c5SLiu Zhe         writer.focus();
26480a6f5c5SLiu Zhe         writer.openContextMenu();
26580a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
26680a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
26780a6f5c5SLiu Zhe         swTableSetRowHeight.focus();
26880a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
26980a6f5c5SLiu Zhe         typeKeys("<delete>");
27080a6f5c5SLiu Zhe         typeKeys("0.5");
27180a6f5c5SLiu Zhe         swTableSetRowHeightDialog.ok();
27280a6f5c5SLiu Zhe 
27380a6f5c5SLiu Zhe         // verify row height
27480a6f5c5SLiu Zhe         writer.focus();
27580a6f5c5SLiu Zhe         writer.openContextMenu();
27680a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
27780a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
27880a6f5c5SLiu Zhe         assertEquals("0.50 \"", swTableSetRowHeight.getText());
27980a6f5c5SLiu Zhe         swTableSetRowHeightDialog.close();
28080a6f5c5SLiu Zhe     }
28180a6f5c5SLiu Zhe 
282b74bac87SLi Feng Wang     /**
283b74bac87SLi Feng Wang      * test select row
284b74bac87SLi Feng Wang      *
285b74bac87SLi Feng Wang      * @throws Exception
286b74bac87SLi Feng Wang      */
28780a6f5c5SLiu Zhe     @Test
28880a6f5c5SLiu Zhe     public void testTableSelectRow() throws Exception {
28980a6f5c5SLiu Zhe         writerInsertTable.ok();
29080a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
29180a6f5c5SLiu Zhe         // select row
29280a6f5c5SLiu Zhe         writer.focus();
29380a6f5c5SLiu Zhe         writer.openContextMenu();
29480a6f5c5SLiu Zhe         swTableSelectRowMenu.select();
29580a6f5c5SLiu Zhe 
29680a6f5c5SLiu Zhe         // verify select one row successfully
29780a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
29880a6f5c5SLiu Zhe         typeKeys("<down>");
29980a6f5c5SLiu Zhe         typeKeys("<down>");
30080a6f5c5SLiu Zhe         typeKeys("<enter>");
30180a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
30280a6f5c5SLiu Zhe         typeKeys("<up>");
30380a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
30480a6f5c5SLiu Zhe 
30580a6f5c5SLiu Zhe     }
30680a6f5c5SLiu Zhe 
307b74bac87SLi Feng Wang     /**
308b74bac87SLi Feng Wang      * insert row and verify how many row inserted
309b74bac87SLi Feng Wang      *
310b74bac87SLi Feng Wang      * @throws Exception
311b74bac87SLi Feng Wang      */
31280a6f5c5SLiu Zhe     @Test
31380a6f5c5SLiu Zhe     public void testTableInsertRow() throws Exception {
31480a6f5c5SLiu Zhe         writerInsertTable.ok();
31580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
31680a6f5c5SLiu Zhe         writer.focus();
31780a6f5c5SLiu Zhe         writer.openContextMenu();
31880a6f5c5SLiu Zhe         swTableInsertRowMenu.select();
319b74bac87SLi Feng Wang         assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists());
32080a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
32180a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
32280a6f5c5SLiu Zhe         typeKeys("<delete>");
32380a6f5c5SLiu Zhe         typeKeys("3");
32480a6f5c5SLiu Zhe         swTableInsertRow.ok();
32580a6f5c5SLiu Zhe 
326b74bac87SLi Feng Wang         writer.focus();
327b74bac87SLi Feng Wang         // verify how many rows in the table
32880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
32980a6f5c5SLiu Zhe         for (int i = 0; i < 4; i++) {
33080a6f5c5SLiu Zhe             typeKeys("<down>");
33180a6f5c5SLiu Zhe             assertNotNull(statusBar.getItemTextById(8));
33280a6f5c5SLiu Zhe         }
33380a6f5c5SLiu Zhe         typeKeys("<down>");
33480a6f5c5SLiu Zhe         sleep(1);
33580a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
33680a6f5c5SLiu Zhe     }
33780a6f5c5SLiu Zhe 
338b74bac87SLi Feng Wang     /**
339b74bac87SLi Feng Wang      * delete row and verify row
340b74bac87SLi Feng Wang      *
341b74bac87SLi Feng Wang      * @throws Exception
342b74bac87SLi Feng Wang      */
34380a6f5c5SLiu Zhe     @Test
34480a6f5c5SLiu Zhe     public void testTableRowDelete() throws Exception {
34580a6f5c5SLiu Zhe         writerInsertTable.ok();
34680a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
34780a6f5c5SLiu Zhe         // delete row
34880a6f5c5SLiu Zhe         writer.focus();
34980a6f5c5SLiu Zhe         writer.openContextMenu();
35080a6f5c5SLiu Zhe         swTableRowDleteMenu.select();
35180a6f5c5SLiu Zhe         // verify whether delete row
35280a6f5c5SLiu Zhe         writer.focus();
35380a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
35480a6f5c5SLiu Zhe         typeKeys("<down>");
35580a6f5c5SLiu Zhe         sleep(1);
35680a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
35780a6f5c5SLiu Zhe 
35880a6f5c5SLiu Zhe     }
35980a6f5c5SLiu Zhe 
360b74bac87SLi Feng Wang     /**
361b74bac87SLi Feng Wang      * set column width and verify
362b74bac87SLi Feng Wang      *
363b74bac87SLi Feng Wang      * @throws Exception
364b74bac87SLi Feng Wang      */
36580a6f5c5SLiu Zhe     @Test
36680a6f5c5SLiu Zhe     public void testTableColumnWidth() throws Exception {
36780a6f5c5SLiu Zhe         writerInsertTable.ok();
36880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
36980a6f5c5SLiu Zhe         // set column width
37080a6f5c5SLiu Zhe         writer.focus();
37180a6f5c5SLiu Zhe         writer.openContextMenu();
37280a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
37380a6f5c5SLiu Zhe         swTableSetColumnWidth.focus();
37480a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
37580a6f5c5SLiu Zhe         typeKeys("<delete>");
37680a6f5c5SLiu Zhe         typeKeys("2");
37780a6f5c5SLiu Zhe         swTableSetColumnDialog.ok();
37880a6f5c5SLiu Zhe         // verify column width
37980a6f5c5SLiu Zhe         writer.focus();
38080a6f5c5SLiu Zhe         writer.openContextMenu();
38180a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
38280a6f5c5SLiu Zhe         assertEquals("2.00 \"", swTableSetColumnWidth.getText());
38380a6f5c5SLiu Zhe 
38480a6f5c5SLiu Zhe     }
38580a6f5c5SLiu Zhe 
386b74bac87SLi Feng Wang     /**
387b74bac87SLi Feng Wang      * select column and verify
388b74bac87SLi Feng Wang      *
389b74bac87SLi Feng Wang      * @throws Exception
390b74bac87SLi Feng Wang      */
39180a6f5c5SLiu Zhe     @Test
39280a6f5c5SLiu Zhe     public void testTableColumnSelect() throws Exception {
39380a6f5c5SLiu Zhe         writerInsertTable.ok();
39480a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
39580a6f5c5SLiu Zhe         writer.focus();
39680a6f5c5SLiu Zhe         writer.openContextMenu();
39780a6f5c5SLiu Zhe         swTableColumnSelectMenu.select();
39880a6f5c5SLiu Zhe 
39980a6f5c5SLiu Zhe         // verify select one column
40080a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
40180a6f5c5SLiu Zhe         typeKeys("<down>");
40280a6f5c5SLiu Zhe         typeKeys("<down>");
40380a6f5c5SLiu Zhe         typeKeys("<enter>");
40480a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
40580a6f5c5SLiu Zhe         typeKeys("<up>");
40680a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
40780a6f5c5SLiu Zhe 
40880a6f5c5SLiu Zhe     }
40980a6f5c5SLiu Zhe 
410b74bac87SLi Feng Wang     /**
411b74bac87SLi Feng Wang      * insert column and verify
412b74bac87SLi Feng Wang      *
413b74bac87SLi Feng Wang      * @throws Exception
414b74bac87SLi Feng Wang      */
41580a6f5c5SLiu Zhe     @Test
41680a6f5c5SLiu Zhe     public void testTableColumnInsert() throws Exception {
41780a6f5c5SLiu Zhe         writerInsertTable.ok();
41880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
41980a6f5c5SLiu Zhe         // insert column
42080a6f5c5SLiu Zhe         writer.focus();
42180a6f5c5SLiu Zhe         writer.openContextMenu();
42280a6f5c5SLiu Zhe         swTableColumnInsertMenu.select();
42380a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
42480a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
42580a6f5c5SLiu Zhe         typeKeys("<delete>");
42680a6f5c5SLiu Zhe         typeKeys("3");
42780a6f5c5SLiu Zhe         swTableInsertColumn.ok();
42880a6f5c5SLiu Zhe         // verify insert column successfully
42980a6f5c5SLiu Zhe         writer.focus();
43080a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
43180a6f5c5SLiu Zhe         for (int i = 0; i < 9; i++) {
43280a6f5c5SLiu Zhe             typeKeys("<right>");
43380a6f5c5SLiu Zhe             sleep(1);
43480a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
43580a6f5c5SLiu Zhe         }
43680a6f5c5SLiu Zhe         typeKeys("<right>");
43780a6f5c5SLiu Zhe         sleep(1);
43880a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
43980a6f5c5SLiu Zhe     }
44080a6f5c5SLiu Zhe 
441b74bac87SLi Feng Wang     /**
442b74bac87SLi Feng Wang      * delete column and verify whether delete or not
443b74bac87SLi Feng Wang      *
444b74bac87SLi Feng Wang      * @throws Exception
445b74bac87SLi Feng Wang      */
44680a6f5c5SLiu Zhe     public void testTableColumnDelete() throws Exception {
44780a6f5c5SLiu Zhe         writerInsertTable.ok();
44880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
44980a6f5c5SLiu Zhe         // delete column
45080a6f5c5SLiu Zhe         writer.focus();
45180a6f5c5SLiu Zhe         writer.openContextMenu();
45280a6f5c5SLiu Zhe         swTableColumnDeleteMenu.select();
45380a6f5c5SLiu Zhe         // verify delete column
45480a6f5c5SLiu Zhe         writer.focus();
45580a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
45680a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
45780a6f5c5SLiu Zhe             typeKeys("<right>");
45880a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
45980a6f5c5SLiu Zhe         }
46080a6f5c5SLiu Zhe         sleep(1);
46180a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
46280a6f5c5SLiu Zhe     }
46380a6f5c5SLiu Zhe 
464b74bac87SLi Feng Wang     /**
465b74bac87SLi Feng Wang      * split cell
466b74bac87SLi Feng Wang      *
467b74bac87SLi Feng Wang      * @throws Exception
468b74bac87SLi Feng Wang      */
46980a6f5c5SLiu Zhe     @Test
47080a6f5c5SLiu Zhe     public void testTableCellSplit() throws Exception {
47180a6f5c5SLiu Zhe         writerInsertTable.ok();
47280a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
47380a6f5c5SLiu Zhe         for (int k = 0; k < 2; k++) {
47480a6f5c5SLiu Zhe             writer.focus();
47580a6f5c5SLiu Zhe             writer.openContextMenu();
47680a6f5c5SLiu Zhe             swTableCellSplitMenu.select();
47780a6f5c5SLiu Zhe             swTableCellSplitNumber.focus();
47880a6f5c5SLiu Zhe             typeKeys("<ctrl a>");
47980a6f5c5SLiu Zhe             typeKeys("<delete>");
48080a6f5c5SLiu Zhe             typeKeys("2");
48180a6f5c5SLiu Zhe             if (k == 0) {
482b74bac87SLi Feng Wang                 // split table cell horizontally
483b74bac87SLi Feng Wang                 swTableCellSplitDialog.ok();
48480a6f5c5SLiu Zhe             } else {
485b74bac87SLi Feng Wang                 // split table cell
486b74bac87SLi Feng Wang                 swTableCellSplitVERTButton.check();
48780a6f5c5SLiu Zhe                 // vertically
48880a6f5c5SLiu Zhe                 swTableCellSplitDialog.ok();
48980a6f5c5SLiu Zhe             }
49080a6f5c5SLiu Zhe         }
49180a6f5c5SLiu Zhe         // verify cell split successfully
49280a6f5c5SLiu Zhe         writer.focus();
49380a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
49480a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
49580a6f5c5SLiu Zhe             typeKeys("<right>");
49680a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
49780a6f5c5SLiu Zhe         }
49880a6f5c5SLiu Zhe         sleep(1);
49980a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
50080a6f5c5SLiu Zhe     }
50180a6f5c5SLiu Zhe 
50280a6f5c5SLiu Zhe     /**
50380a6f5c5SLiu Zhe      * Test convert table to text in text document
50480a6f5c5SLiu Zhe      *
50580a6f5c5SLiu Zhe      * @throws Exception
50680a6f5c5SLiu Zhe      */
50780a6f5c5SLiu Zhe     @Test
50880a6f5c5SLiu Zhe     public void testConvertTableToText() throws Exception {
50980a6f5c5SLiu Zhe         writerInsertTable.ok();
51080a6f5c5SLiu Zhe         writer.focus();
51180a6f5c5SLiu Zhe         typeKeys("1<right>2<right>3<right>4");
51280a6f5c5SLiu Zhe         sleep(1);
51380a6f5c5SLiu Zhe 
51480a6f5c5SLiu Zhe         // Convert table to text
51580a6f5c5SLiu Zhe         app.dispatch(".uno:ConvertTableToText");
516b74bac87SLi Feng Wang         assertTrue("Convert Table to Text dialog pop up",
517b74bac87SLi Feng Wang                 writerConvertTableToTextDlg.exists());
51880a6f5c5SLiu Zhe         // typeKeys("<enter>");
519b74bac87SLi Feng Wang         writerConvertTableToTextDlg.ok();
52080a6f5c5SLiu Zhe 
52180a6f5c5SLiu Zhe         // Verify if text is converted successfully
52280a6f5c5SLiu Zhe         app.dispatch(".uno:SelectAll");
52380a6f5c5SLiu Zhe         app.dispatch(".uno:Copy");
52480a6f5c5SLiu Zhe         if (SystemUtil.isWindows())
525b74bac87SLi Feng Wang             assertEquals("Converted text", "1\t2\r\n3\t4\r\n",
526b74bac87SLi Feng Wang                     app.getClipboard());
52780a6f5c5SLiu Zhe         else
52880a6f5c5SLiu Zhe             assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
52980a6f5c5SLiu Zhe     }
53080a6f5c5SLiu Zhe }
531