xref: /AOO41X/test/testgui/source/fvt/gui/sw/table/TableGeneral.java (revision fd3484265709667881cfaec27d41da15d46b6832)
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;
32*fd348426SLi Feng Wang import org.junit.Rule;
3380a6f5c5SLiu Zhe import org.junit.Test;
34*fd348426SLi 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 
41*fd348426SLi Feng Wang 	@Rule
42*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
43*fd348426SLi 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
159b74bac87SLi Feng Wang 		swTableBorderLineColor.select(5);
160b74bac87SLi Feng Wang 		// set spacing to content
161b74bac87SLi Feng Wang 		swTableSTCLeft.focus();
16280a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
16380a6f5c5SLiu Zhe 		typeKeys("<delete>");
164b74bac87SLi Feng Wang 		// set spacing to content
165b74bac87SLi Feng Wang 		typeKeys("0.5");
166b74bac87SLi Feng Wang 		// set table shadow
167b74bac87SLi Feng Wang 		swTableShadow.click(40, 10);
16880a6f5c5SLiu Zhe 		swTableShadowSize.focus();
16980a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
17080a6f5c5SLiu Zhe 		typeKeys("<delete>");
17180a6f5c5SLiu Zhe 		typeKeys("2");
17280a6f5c5SLiu Zhe 		swTableShadowColor.select(5);
17380a6f5c5SLiu Zhe 		swTableBorder.ok();
174b74bac87SLi Feng Wang 		// verify the setting property of table
175b74bac87SLi Feng Wang 		writer.focus();
17680a6f5c5SLiu Zhe 		app.dispatch(".uno:TableDialog");
17780a6f5c5SLiu Zhe 		swTableBorder.select();
17880a6f5c5SLiu Zhe 		assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
17980a6f5c5SLiu Zhe 		assertEquals("Magenta", swTableBorderLineColor.getItemText(5));
18080a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSTCLeft.getText());
18180a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSTCRight.getText());
18280a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSTCTop.getText());
18380a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSTCBottom.getText());
18480a6f5c5SLiu Zhe 		assertEquals("1.97\"", swTableShadowSize.getText());
18580a6f5c5SLiu Zhe 		assertEquals("Magenta", swTableShadowColor.getItemText(5));
18680a6f5c5SLiu Zhe 		assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
18780a6f5c5SLiu Zhe 		swTableBorder.close();
18880a6f5c5SLiu Zhe 
18980a6f5c5SLiu Zhe 		// uncheck Synchronize box and set spacing to content
19080a6f5c5SLiu Zhe 		writer.focus();
19180a6f5c5SLiu Zhe 		app.dispatch(".uno:TableDialog");
19280a6f5c5SLiu Zhe 		swTableBorder.select();
19380a6f5c5SLiu Zhe 		swTableSTCSYNC.uncheck();
194b74bac87SLi Feng Wang 		// set left spacing to content
195b74bac87SLi Feng Wang 		swTableSTCLeft.focus();
19680a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
19780a6f5c5SLiu Zhe 		typeKeys("<delete>");
19880a6f5c5SLiu Zhe 		typeKeys("0.5");
199b74bac87SLi Feng Wang 		// set right spacing to content
200b74bac87SLi Feng Wang 		swTableSTCRight.focus();
20180a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
20280a6f5c5SLiu Zhe 		typeKeys("<delete>");
20380a6f5c5SLiu Zhe 		typeKeys("0.8");
204b74bac87SLi Feng Wang 		// set top spacing to content
205b74bac87SLi Feng Wang 		swTableSTCTop.focus();
20680a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
20780a6f5c5SLiu Zhe 		typeKeys("<delete>");
20880a6f5c5SLiu Zhe 		typeKeys("1.0");
209b74bac87SLi Feng Wang 		// set bottom spacing to content
210b74bac87SLi Feng Wang 		swTableSTCBottom.focus();
21180a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
21280a6f5c5SLiu Zhe 		typeKeys("<delete>");
21380a6f5c5SLiu Zhe 		typeKeys("2");
21480a6f5c5SLiu Zhe 		swTableBorder.ok();
21580a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
21680a6f5c5SLiu Zhe 
217b74bac87SLi Feng Wang 		writer.focus();
218b74bac87SLi Feng Wang 		// verify the setting value of spacing to content for table
21980a6f5c5SLiu Zhe 		app.dispatch(".uno:TableDialog");
22080a6f5c5SLiu Zhe 		swTableBorder.select();
22180a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSTCLeft.getText());
22280a6f5c5SLiu Zhe 		assertEquals("0.80\"", swTableSTCRight.getText());
22380a6f5c5SLiu Zhe 		assertEquals("1.00\"", swTableSTCTop.getText());
22480a6f5c5SLiu Zhe 		assertEquals("1.97\"", swTableSTCBottom.getText());
22580a6f5c5SLiu Zhe 		assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
22680a6f5c5SLiu Zhe 		swTableBorder.close();
22780a6f5c5SLiu Zhe 	}
22880a6f5c5SLiu Zhe 
229b74bac87SLi Feng Wang 	/**
230b74bac87SLi Feng Wang 	 * create table with auto format
231b74bac87SLi Feng Wang 	 *
232b74bac87SLi Feng Wang 	 * @throws Exception
233b74bac87SLi Feng Wang 	 */
23480a6f5c5SLiu Zhe 	@Test
23580a6f5c5SLiu Zhe 	public void testTableAutoFormat() throws Exception {
23680a6f5c5SLiu Zhe 		// create table with auto format
23780a6f5c5SLiu Zhe 		button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
23880a6f5c5SLiu Zhe 		assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
23980a6f5c5SLiu Zhe 		swTableAutoFormatListbox.select(3);
24080a6f5c5SLiu Zhe 		swTableAutoFMT.ok();
24180a6f5c5SLiu Zhe 		// verify the auto format is that just selected
24280a6f5c5SLiu Zhe 		button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
24380a6f5c5SLiu Zhe 		assertEquals("Blue", swTableAutoFormatListbox.getSelText());
24480a6f5c5SLiu Zhe 		swTableAutoFMT.close();
24580a6f5c5SLiu Zhe 		writerInsertTable.ok();
24680a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
24780a6f5c5SLiu Zhe 
24880a6f5c5SLiu Zhe 	}
24980a6f5c5SLiu Zhe 
250b74bac87SLi Feng Wang 	/**
251b74bac87SLi Feng Wang 	 * set row height and select row,insert/delete row
252b74bac87SLi Feng Wang 	 *
253b74bac87SLi Feng Wang 	 * @throws Exception
254b74bac87SLi Feng Wang 	 */
25580a6f5c5SLiu Zhe 	@Test
25680a6f5c5SLiu Zhe 	public void testTableRowHeight() throws Exception {
25780a6f5c5SLiu Zhe 		writerInsertTable.ok();
25880a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
25980a6f5c5SLiu Zhe 
26080a6f5c5SLiu Zhe 		// set row height
26180a6f5c5SLiu Zhe 		writer.focus();
26280a6f5c5SLiu Zhe 		writer.openContextMenu();
26380a6f5c5SLiu Zhe 		swTableRowHeightMenu.select();
26480a6f5c5SLiu Zhe 		assertTrue(swTableSetRowHeightDialog.exists());
26580a6f5c5SLiu Zhe 		swTableSetRowHeight.focus();
26680a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
26780a6f5c5SLiu Zhe 		typeKeys("<delete>");
26880a6f5c5SLiu Zhe 		typeKeys("0.5");
26980a6f5c5SLiu Zhe 		swTableSetRowHeightDialog.ok();
27080a6f5c5SLiu Zhe 
27180a6f5c5SLiu Zhe 		// verify row height
27280a6f5c5SLiu Zhe 		writer.focus();
27380a6f5c5SLiu Zhe 		writer.openContextMenu();
27480a6f5c5SLiu Zhe 		swTableRowHeightMenu.select();
27580a6f5c5SLiu Zhe 		assertTrue(swTableSetRowHeightDialog.exists());
27680a6f5c5SLiu Zhe 		assertEquals("0.50\"", swTableSetRowHeight.getText());
27780a6f5c5SLiu Zhe 		swTableSetRowHeightDialog.close();
27880a6f5c5SLiu Zhe 	}
27980a6f5c5SLiu Zhe 
280b74bac87SLi Feng Wang 	/**
281b74bac87SLi Feng Wang 	 * test select row
282b74bac87SLi Feng Wang 	 *
283b74bac87SLi Feng Wang 	 * @throws Exception
284b74bac87SLi Feng Wang 	 */
28580a6f5c5SLiu Zhe 	@Test
28680a6f5c5SLiu Zhe 	public void testTableSelectRow() throws Exception {
28780a6f5c5SLiu Zhe 		writerInsertTable.ok();
28880a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
28980a6f5c5SLiu Zhe 		// select row
29080a6f5c5SLiu Zhe 		writer.focus();
29180a6f5c5SLiu Zhe 		writer.openContextMenu();
29280a6f5c5SLiu Zhe 		swTableSelectRowMenu.select();
29380a6f5c5SLiu Zhe 
29480a6f5c5SLiu Zhe 		// verify select one row successfully
29580a6f5c5SLiu Zhe 		typeKeys("<ctrl c>");
29680a6f5c5SLiu Zhe 		typeKeys("<down>");
29780a6f5c5SLiu Zhe 		typeKeys("<down>");
29880a6f5c5SLiu Zhe 		typeKeys("<enter>");
29980a6f5c5SLiu Zhe 		typeKeys("<ctrl v>");
30080a6f5c5SLiu Zhe 		typeKeys("<up>");
30180a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
30280a6f5c5SLiu Zhe 
30380a6f5c5SLiu Zhe 	}
30480a6f5c5SLiu Zhe 
305b74bac87SLi Feng Wang 	/**
306b74bac87SLi Feng Wang 	 * insert row and verify how many row inserted
307b74bac87SLi Feng Wang 	 *
308b74bac87SLi Feng Wang 	 * @throws Exception
309b74bac87SLi Feng Wang 	 */
31080a6f5c5SLiu Zhe 	@Test
31180a6f5c5SLiu Zhe 	public void testTableInsertRow() throws Exception {
31280a6f5c5SLiu Zhe 		writerInsertTable.ok();
31380a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
31480a6f5c5SLiu Zhe 		writer.focus();
31580a6f5c5SLiu Zhe 		writer.openContextMenu();
31680a6f5c5SLiu Zhe 		swTableInsertRowMenu.select();
317b74bac87SLi Feng Wang 		assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists());
31880a6f5c5SLiu Zhe 		swTableInsertRowColumnSetNumber.focus();
31980a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
32080a6f5c5SLiu Zhe 		typeKeys("<delete>");
32180a6f5c5SLiu Zhe 		typeKeys("3");
32280a6f5c5SLiu Zhe 		swTableInsertRow.ok();
32380a6f5c5SLiu Zhe 
324b74bac87SLi Feng Wang 		writer.focus();
325b74bac87SLi Feng Wang 		// verify how many rows in the table
32680a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
32780a6f5c5SLiu Zhe 		for (int i = 0; i < 4; i++) {
32880a6f5c5SLiu Zhe 			typeKeys("<down>");
32980a6f5c5SLiu Zhe 			assertNotNull(statusBar.getItemTextById(8));
33080a6f5c5SLiu Zhe 		}
33180a6f5c5SLiu Zhe 		typeKeys("<down>");
33280a6f5c5SLiu Zhe 		sleep(1);
33380a6f5c5SLiu Zhe 		assertFalse(tableToolbar.exists());
33480a6f5c5SLiu Zhe 	}
33580a6f5c5SLiu Zhe 
336b74bac87SLi Feng Wang 	/**
337b74bac87SLi Feng Wang 	 * delete row and verify row
338b74bac87SLi Feng Wang 	 *
339b74bac87SLi Feng Wang 	 * @throws Exception
340b74bac87SLi Feng Wang 	 */
34180a6f5c5SLiu Zhe 	@Test
34280a6f5c5SLiu Zhe 	public void testTableRowDelete() throws Exception {
34380a6f5c5SLiu Zhe 		writerInsertTable.ok();
34480a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
34580a6f5c5SLiu Zhe 		// delete row
34680a6f5c5SLiu Zhe 		writer.focus();
34780a6f5c5SLiu Zhe 		writer.openContextMenu();
34880a6f5c5SLiu Zhe 		swTableRowDleteMenu.select();
34980a6f5c5SLiu Zhe 		// verify whether delete row
35080a6f5c5SLiu Zhe 		writer.focus();
35180a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
35280a6f5c5SLiu Zhe 		typeKeys("<down>");
35380a6f5c5SLiu Zhe 		sleep(1);
35480a6f5c5SLiu Zhe 		assertFalse(tableToolbar.exists());
35580a6f5c5SLiu Zhe 
35680a6f5c5SLiu Zhe 	}
35780a6f5c5SLiu Zhe 
358b74bac87SLi Feng Wang 	/**
359b74bac87SLi Feng Wang 	 * set column width and verify
360b74bac87SLi Feng Wang 	 *
361b74bac87SLi Feng Wang 	 * @throws Exception
362b74bac87SLi Feng Wang 	 */
36380a6f5c5SLiu Zhe 	@Test
36480a6f5c5SLiu Zhe 	public void testTableColumnWidth() throws Exception {
36580a6f5c5SLiu Zhe 		writerInsertTable.ok();
36680a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
36780a6f5c5SLiu Zhe 		// set column width
36880a6f5c5SLiu Zhe 		writer.focus();
36980a6f5c5SLiu Zhe 		writer.openContextMenu();
37080a6f5c5SLiu Zhe 		swTableColumnWidthMenu.select();
37180a6f5c5SLiu Zhe 		swTableSetColumnWidth.focus();
37280a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
37380a6f5c5SLiu Zhe 		typeKeys("<delete>");
37480a6f5c5SLiu Zhe 		typeKeys("2");
37580a6f5c5SLiu Zhe 		swTableSetColumnDialog.ok();
37680a6f5c5SLiu Zhe 		// verify column width
37780a6f5c5SLiu Zhe 		writer.focus();
37880a6f5c5SLiu Zhe 		writer.openContextMenu();
37980a6f5c5SLiu Zhe 		swTableColumnWidthMenu.select();
38080a6f5c5SLiu Zhe 		assertEquals("2.00\"", swTableSetColumnWidth.getText());
38180a6f5c5SLiu Zhe 
38280a6f5c5SLiu Zhe 	}
38380a6f5c5SLiu Zhe 
384b74bac87SLi Feng Wang 	/**
385b74bac87SLi Feng Wang 	 * select column and verify
386b74bac87SLi Feng Wang 	 *
387b74bac87SLi Feng Wang 	 * @throws Exception
388b74bac87SLi Feng Wang 	 */
38980a6f5c5SLiu Zhe 	@Test
39080a6f5c5SLiu Zhe 	public void testTableColumnSelect() throws Exception {
39180a6f5c5SLiu Zhe 		writerInsertTable.ok();
39280a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
39380a6f5c5SLiu Zhe 		writer.focus();
39480a6f5c5SLiu Zhe 		writer.openContextMenu();
39580a6f5c5SLiu Zhe 		swTableColumnSelectMenu.select();
39680a6f5c5SLiu Zhe 
39780a6f5c5SLiu Zhe 		// verify select one column
39880a6f5c5SLiu Zhe 		typeKeys("<ctrl c>");
39980a6f5c5SLiu Zhe 		typeKeys("<down>");
40080a6f5c5SLiu Zhe 		typeKeys("<down>");
40180a6f5c5SLiu Zhe 		typeKeys("<enter>");
40280a6f5c5SLiu Zhe 		typeKeys("<ctrl v>");
40380a6f5c5SLiu Zhe 		typeKeys("<up>");
40480a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
40580a6f5c5SLiu Zhe 
40680a6f5c5SLiu Zhe 	}
40780a6f5c5SLiu Zhe 
408b74bac87SLi Feng Wang 	/**
409b74bac87SLi Feng Wang 	 * insert column and verify
410b74bac87SLi Feng Wang 	 *
411b74bac87SLi Feng Wang 	 * @throws Exception
412b74bac87SLi Feng Wang 	 */
41380a6f5c5SLiu Zhe 	@Test
41480a6f5c5SLiu Zhe 	public void testTableColumnInsert() throws Exception {
41580a6f5c5SLiu Zhe 		writerInsertTable.ok();
41680a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
41780a6f5c5SLiu Zhe 		// insert column
41880a6f5c5SLiu Zhe 		writer.focus();
41980a6f5c5SLiu Zhe 		writer.openContextMenu();
42080a6f5c5SLiu Zhe 		swTableColumnInsertMenu.select();
42180a6f5c5SLiu Zhe 		swTableInsertRowColumnSetNumber.focus();
42280a6f5c5SLiu Zhe 		typeKeys("<ctrl a>");
42380a6f5c5SLiu Zhe 		typeKeys("<delete>");
42480a6f5c5SLiu Zhe 		typeKeys("3");
42580a6f5c5SLiu Zhe 		swTableInsertColumn.ok();
42680a6f5c5SLiu Zhe 		// verify insert column successfully
42780a6f5c5SLiu Zhe 		writer.focus();
42880a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
42980a6f5c5SLiu Zhe 		for (int i = 0; i < 9; i++) {
43080a6f5c5SLiu Zhe 			typeKeys("<right>");
43180a6f5c5SLiu Zhe 			sleep(1);
43280a6f5c5SLiu Zhe 			assertTrue(tableToolbar.exists());
43380a6f5c5SLiu Zhe 		}
43480a6f5c5SLiu Zhe 		typeKeys("<right>");
43580a6f5c5SLiu Zhe 		sleep(1);
43680a6f5c5SLiu Zhe 		assertFalse(tableToolbar.exists());
43780a6f5c5SLiu Zhe 	}
43880a6f5c5SLiu Zhe 
439b74bac87SLi Feng Wang 	/**
440b74bac87SLi Feng Wang 	 * delete column and verify whether delete or not
441b74bac87SLi Feng Wang 	 *
442b74bac87SLi Feng Wang 	 * @throws Exception
443b74bac87SLi Feng Wang 	 */
44480a6f5c5SLiu Zhe 	public void testTableColumnDelete() throws Exception {
44580a6f5c5SLiu Zhe 		writerInsertTable.ok();
44680a6f5c5SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
44780a6f5c5SLiu Zhe 		// delete column
44880a6f5c5SLiu Zhe 		writer.focus();
44980a6f5c5SLiu Zhe 		writer.openContextMenu();
45080a6f5c5SLiu Zhe 		swTableColumnDeleteMenu.select();
45180a6f5c5SLiu Zhe 		// verify delete column
45280a6f5c5SLiu Zhe 		writer.focus();
45380a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
45480a6f5c5SLiu Zhe 		for (int i = 0; i < 7; i++) {
45580a6f5c5SLiu Zhe 			typeKeys("<right>");
45680a6f5c5SLiu Zhe 			assertTrue(tableToolbar.exists());
45780a6f5c5SLiu Zhe 		}
45880a6f5c5SLiu Zhe 		sleep(1);
45980a6f5c5SLiu Zhe 		assertFalse(tableToolbar.exists());
46080a6f5c5SLiu Zhe 	}
46180a6f5c5SLiu Zhe 
462b74bac87SLi Feng Wang 	/**
463b74bac87SLi Feng Wang 	 * split cell
464b74bac87SLi Feng Wang 	 *
465b74bac87SLi Feng Wang 	 * @throws Exception
466b74bac87SLi Feng Wang 	 */
46780a6f5c5SLiu Zhe 	@Test
46880a6f5c5SLiu Zhe 	public void testTableCellSplit() throws Exception {
46980a6f5c5SLiu Zhe 		writerInsertTable.ok();
47080a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
47180a6f5c5SLiu Zhe 		for (int k = 0; k < 2; k++) {
47280a6f5c5SLiu Zhe 			writer.focus();
47380a6f5c5SLiu Zhe 			writer.openContextMenu();
47480a6f5c5SLiu Zhe 			swTableCellSplitMenu.select();
47580a6f5c5SLiu Zhe 			swTableCellSplitNumber.focus();
47680a6f5c5SLiu Zhe 			typeKeys("<ctrl a>");
47780a6f5c5SLiu Zhe 			typeKeys("<delete>");
47880a6f5c5SLiu Zhe 			typeKeys("2");
47980a6f5c5SLiu Zhe 			if (k == 0) {
480b74bac87SLi Feng Wang 				// split table cell horizontally
481b74bac87SLi Feng Wang 				swTableCellSplitDialog.ok();
48280a6f5c5SLiu Zhe 			} else {
483b74bac87SLi Feng Wang 				// split table cell
484b74bac87SLi Feng Wang 				swTableCellSplitVERTButton.check();
48580a6f5c5SLiu Zhe 				// vertically
48680a6f5c5SLiu Zhe 				swTableCellSplitDialog.ok();
48780a6f5c5SLiu Zhe 			}
48880a6f5c5SLiu Zhe 		}
48980a6f5c5SLiu Zhe 		// verify cell split successfully
49080a6f5c5SLiu Zhe 		writer.focus();
49180a6f5c5SLiu Zhe 		assertTrue(tableToolbar.exists());
49280a6f5c5SLiu Zhe 		for (int i = 0; i < 7; i++) {
49380a6f5c5SLiu Zhe 			typeKeys("<right>");
49480a6f5c5SLiu Zhe 			assertTrue(tableToolbar.exists());
49580a6f5c5SLiu Zhe 		}
49680a6f5c5SLiu Zhe 		sleep(1);
49780a6f5c5SLiu Zhe 		assertFalse(tableToolbar.exists());
49880a6f5c5SLiu Zhe 	}
49980a6f5c5SLiu Zhe 
50080a6f5c5SLiu Zhe 	/**
50180a6f5c5SLiu Zhe 	 * Test convert table to text in text document
50280a6f5c5SLiu Zhe 	 *
50380a6f5c5SLiu Zhe 	 * @throws Exception
50480a6f5c5SLiu Zhe 	 */
50580a6f5c5SLiu Zhe 	@Test
50680a6f5c5SLiu Zhe 	public void testConvertTableToText() throws Exception {
50780a6f5c5SLiu Zhe 		writerInsertTable.ok();
50880a6f5c5SLiu Zhe 		writer.focus();
50980a6f5c5SLiu Zhe 		typeKeys("1<right>2<right>3<right>4");
51080a6f5c5SLiu Zhe 		sleep(1);
51180a6f5c5SLiu Zhe 
51280a6f5c5SLiu Zhe 		// Convert table to text
51380a6f5c5SLiu Zhe 		app.dispatch(".uno:ConvertTableToText");
514b74bac87SLi Feng Wang 		assertTrue("Convert Table to Text dialog pop up",
515b74bac87SLi Feng Wang 				writerConvertTableToTextDlg.exists());
51680a6f5c5SLiu Zhe 		// typeKeys("<enter>");
517b74bac87SLi Feng Wang 		writerConvertTableToTextDlg.ok();
51880a6f5c5SLiu Zhe 
51980a6f5c5SLiu Zhe 		// Verify if text is converted successfully
52080a6f5c5SLiu Zhe 		app.dispatch(".uno:SelectAll");
52180a6f5c5SLiu Zhe 		app.dispatch(".uno:Copy");
52280a6f5c5SLiu Zhe 		if (SystemUtil.isWindows())
523b74bac87SLi Feng Wang 			assertEquals("Converted text", "1\t2\r\n3\t4\r\n",
524b74bac87SLi Feng Wang 					app.getClipboard());
52580a6f5c5SLiu Zhe 		else
52680a6f5c5SLiu Zhe 			assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
52780a6f5c5SLiu Zhe 	}
52880a6f5c5SLiu Zhe }
529