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;
23ca72bc94SLiu Zhe 
24ca72bc94SLiu Zhe import static org.junit.Assert.*;
25ca72bc94SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
26b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
27ca72bc94SLiu Zhe import static testlib.gui.UIMap.*;
28ca72bc94SLiu Zhe 
29ca72bc94SLiu Zhe import org.junit.After;
30ca72bc94SLiu Zhe import org.junit.Before;
31ca72bc94SLiu Zhe import org.junit.Ignore;
32ca72bc94SLiu Zhe import org.junit.Rule;
33ca72bc94SLiu Zhe import org.junit.Test;
34ca72bc94SLiu Zhe import org.openoffice.test.common.Logger;
35ca72bc94SLiu Zhe import org.openoffice.test.common.SystemUtil;
36ca72bc94SLiu Zhe 
37ca72bc94SLiu Zhe 
38ca72bc94SLiu Zhe public class TableGeneral {
39ca72bc94SLiu Zhe 
40ca72bc94SLiu Zhe 	@Rule
41ca72bc94SLiu Zhe 	public Logger log = Logger.getLogger(this);
42ca72bc94SLiu Zhe 
43ca72bc94SLiu Zhe 	@Before
44ca72bc94SLiu Zhe 	public void setUp() throws Exception {
45ca72bc94SLiu Zhe 		// Start OpenOffice
46ca72bc94SLiu Zhe 		app.start();
47ca72bc94SLiu Zhe 
48ca72bc94SLiu Zhe 		// Create a new text document
49ca72bc94SLiu Zhe 		app.dispatch("private:factory/swriter");
50ca72bc94SLiu Zhe 
51ca72bc94SLiu Zhe 		// Insert a table
52ca72bc94SLiu Zhe 		app.dispatch(".uno:InsertTable");
53b4d2d410SLiu Zhe 		assertTrue("Insert Table dialog pop up", writerInsertTable.exists());
54ca72bc94SLiu Zhe 	}
55ca72bc94SLiu Zhe 
56ca72bc94SLiu Zhe 	@After
57ca72bc94SLiu Zhe 	public void tearDown() throws Exception {
58ca72bc94SLiu Zhe 		app.close();
59ca72bc94SLiu Zhe 	}
60ca72bc94SLiu Zhe 
61ca72bc94SLiu Zhe 	@Test
62ca72bc94SLiu Zhe 	// Test setting table size in text document
63ca72bc94SLiu Zhe 	public void testTableSize() throws Exception {
64ca72bc94SLiu Zhe 
65b4d2d410SLiu Zhe 		swTableSizeColBox.focus();
66ca72bc94SLiu Zhe 		typeKeys("<delete>");
67ca72bc94SLiu Zhe 		typeKeys("3");
68b4d2d410SLiu Zhe 		swTableSizeRowBox.focus();
69ca72bc94SLiu Zhe 		typeKeys("<delete>");
70ca72bc94SLiu Zhe 		typeKeys("4");
71b4d2d410SLiu Zhe 		writerInsertTable.ok();
72ca72bc94SLiu Zhe 
73ca72bc94SLiu Zhe 		writer.focus(); // verify how many rows in the table
74b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
75ca72bc94SLiu Zhe 		for (int i = 0; i < 3; i++) {
76ca72bc94SLiu Zhe 			typeKeys("<down>");
77b4d2d410SLiu Zhe 			assertNotNull(statusBar.getItemTextById(8));
78ca72bc94SLiu Zhe 		}
79ca72bc94SLiu Zhe 		typeKeys("<down>");
80ca72bc94SLiu Zhe 		sleep(1);
81b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
82ca72bc94SLiu Zhe 	}
83ca72bc94SLiu Zhe 
84ca72bc94SLiu Zhe 	// Test setting table cell background in text document
85ca72bc94SLiu Zhe 
86ca72bc94SLiu Zhe 	@Test
8783ae2205SHerbert Dürr 	@Ignore("Bug #120378")
88ca72bc94SLiu Zhe 	public void testTableBackground() throws Exception {
89b4d2d410SLiu Zhe 		writerInsertTable.ok();
90b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
91ca72bc94SLiu Zhe 		writer.focus();
92ca72bc94SLiu Zhe 		// set table cell background
93ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
94b4d2d410SLiu Zhe 		swTableBackground.select();
95ca72bc94SLiu Zhe 		assertTrue("Table background property dialog pop up",
96b4d2d410SLiu Zhe 				swTableBackground.exists());
97ca72bc94SLiu Zhe 		;
98b4d2d410SLiu Zhe 		swTableBackgroundColor.focus();
99b4d2d410SLiu Zhe 		swTableBackgroundColor.click(50, 50);
100b4d2d410SLiu Zhe 		swTableBackground.ok();
101ca72bc94SLiu Zhe 		// verify table cell background color
102ca72bc94SLiu Zhe 		writer.focus();
103ca72bc94SLiu Zhe 		// select the cell which is filled with color
104ca72bc94SLiu Zhe 		app.dispatch(".uno:EntireCell");
105ca72bc94SLiu Zhe 
106ca72bc94SLiu Zhe 		typeKeys("<ctrl c>");
107ca72bc94SLiu Zhe 		app.dispatch("private:factory/simpress?slot=6686");
108b4d2d410SLiu Zhe 		presentationWizard.ok();
109ca72bc94SLiu Zhe 		typeKeys("<ctrl v>");
110ca72bc94SLiu Zhe 		// enable table cell area format dialog
111ca72bc94SLiu Zhe 		app.dispatch(".uno:FormatArea");
112ca72bc94SLiu Zhe 		sleep(1);
113b4d2d410SLiu Zhe 		assertEquals("Light red", sdTableBACGColorListbox.getSelText());
114ca72bc94SLiu Zhe 		// close table cell area format dialog
115b4d2d410SLiu Zhe 		sdTableBACGColorArea.cancel();
116ca72bc94SLiu Zhe 	}
117ca72bc94SLiu Zhe 
118ca72bc94SLiu Zhe 	// Test setting table border in text document
119ca72bc94SLiu Zhe 
120ca72bc94SLiu Zhe 	@Test
121ca72bc94SLiu Zhe 	public void testTableBorder() throws Exception {
122b4d2d410SLiu Zhe 		writerInsertTable.ok();
123b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
124ca72bc94SLiu Zhe 		// set table border as none
125ca72bc94SLiu Zhe 		writer.focus();
126ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
127b4d2d410SLiu Zhe 		swTableBorder.select();
128ca72bc94SLiu Zhe 		assertTrue("Table border property dialog pop up",
129b4d2d410SLiu Zhe 				swTableBorder.exists());
130ca72bc94SLiu Zhe 		;
131b4d2d410SLiu Zhe 		swTableBorderLineArrange.click(10, 10);
132b4d2d410SLiu Zhe 		swTableBorder.ok();
133ca72bc94SLiu Zhe 	}
134ca72bc94SLiu Zhe 
135ca72bc94SLiu Zhe 	// Test setting table border line style,line color,spacing to content in
136ca72bc94SLiu Zhe 	// text document
137ca72bc94SLiu Zhe 
138ca72bc94SLiu Zhe 	@Test
139ca72bc94SLiu Zhe 	public void testTableBorderLineStyle() throws Exception {
140b4d2d410SLiu Zhe 		writerInsertTable.ok();
141b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
142ca72bc94SLiu Zhe 		writer.focus();
143ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
144b4d2d410SLiu Zhe 		swTableBorder.select();
145ca72bc94SLiu Zhe 		assertTrue("Table border property dialog pop up",
146b4d2d410SLiu Zhe 				swTableBorder.exists());
147ca72bc94SLiu Zhe 		;
148b4d2d410SLiu Zhe 		swTableBorderLineStyle.select(8); // set line style
149b4d2d410SLiu Zhe 		swTableBorderLineColor.select(5); // set line color
150b4d2d410SLiu Zhe 		swTableSTCLeft.focus(); // set spacing to content
151ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
152ca72bc94SLiu Zhe 		typeKeys("<delete>");
153ca72bc94SLiu Zhe 		typeKeys("0.5"); // set spacing to content
154b4d2d410SLiu Zhe 		swTableShadow.click(40, 10); // set table shadow
155b4d2d410SLiu Zhe 		swTableShadowSize.focus();
156ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
157ca72bc94SLiu Zhe 		typeKeys("<delete>");
158ca72bc94SLiu Zhe 		typeKeys("2");
159b4d2d410SLiu Zhe 		swTableShadowColor.select(5);
160b4d2d410SLiu Zhe 		swTableBorder.ok();
161ca72bc94SLiu Zhe 
162ca72bc94SLiu Zhe 		writer.focus(); // verify the setting property of table
163ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
164b4d2d410SLiu Zhe 		swTableBorder.select();
165b4d2d410SLiu Zhe 		assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
166b4d2d410SLiu Zhe 		assertEquals("Magenta", swTableBorderLineColor.getItemText(5));
167b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSTCLeft.getText());
168b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSTCRight.getText());
169b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSTCTop.getText());
170b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSTCBottom.getText());
171b4d2d410SLiu Zhe 		assertEquals("1.97\"", swTableShadowSize.getText());
172b4d2d410SLiu Zhe 		assertEquals("Magenta", swTableShadowColor.getItemText(5));
173b4d2d410SLiu Zhe 		assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
174b4d2d410SLiu Zhe 		swTableBorder.close();
175ca72bc94SLiu Zhe 
176ca72bc94SLiu Zhe 		// uncheck Synchronize box and set spacing to content
177ca72bc94SLiu Zhe 
178ca72bc94SLiu Zhe 		writer.focus();
179ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
180b4d2d410SLiu Zhe 		swTableBorder.select();
181b4d2d410SLiu Zhe 		swTableSTCSYNC.uncheck();
182b4d2d410SLiu Zhe 		swTableSTCLeft.focus();// set left spacing to content
183ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
184ca72bc94SLiu Zhe 		typeKeys("<delete>");
185ca72bc94SLiu Zhe 		typeKeys("0.5");
186b4d2d410SLiu Zhe 		swTableSTCRight.focus();// set right spacing to content
187ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
188ca72bc94SLiu Zhe 		typeKeys("<delete>");
189ca72bc94SLiu Zhe 		typeKeys("0.8");
190b4d2d410SLiu Zhe 		swTableSTCTop.focus();// set top spacing to content
191ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
192ca72bc94SLiu Zhe 		typeKeys("<delete>");
193ca72bc94SLiu Zhe 		typeKeys("1.0");
194b4d2d410SLiu Zhe 		swTableSTCBottom.focus();// set bottom spacing to content
195ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
196ca72bc94SLiu Zhe 		typeKeys("<delete>");
197ca72bc94SLiu Zhe 		typeKeys("2");
198b4d2d410SLiu Zhe 		swTableBorder.ok();
199b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
200ca72bc94SLiu Zhe 
201ca72bc94SLiu Zhe 		writer.focus(); // verify the setting value of spacing to content for
202ca72bc94SLiu Zhe 						// tabel
203ca72bc94SLiu Zhe 		app.dispatch(".uno:TableDialog");
204b4d2d410SLiu Zhe 		swTableBorder.select();
205b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSTCLeft.getText());
206b4d2d410SLiu Zhe 		assertEquals("0.80\"", swTableSTCRight.getText());
207b4d2d410SLiu Zhe 		assertEquals("1.00\"", swTableSTCTop.getText());
208b4d2d410SLiu Zhe 		assertEquals("1.97\"", swTableSTCBottom.getText());
209b4d2d410SLiu Zhe 		assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
210b4d2d410SLiu Zhe 		swTableBorder.close();
211ca72bc94SLiu Zhe 	}
212ca72bc94SLiu Zhe 
213ca72bc94SLiu Zhe 	// create table with auto format
214ca72bc94SLiu Zhe 
215ca72bc94SLiu Zhe 	@Test
216ca72bc94SLiu Zhe 	public void testTableAutoFormat() throws Exception {
217ca72bc94SLiu Zhe 		// create table with auto format
218ca72bc94SLiu Zhe 		button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
219b4d2d410SLiu Zhe 		assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
220b4d2d410SLiu Zhe 		swTableAutoFormatListbox.select(3);
221b4d2d410SLiu Zhe 		swTableAutoFMT.ok();
222ca72bc94SLiu Zhe 		// verify the auto format is that just selected
223ca72bc94SLiu Zhe 		button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
224b4d2d410SLiu Zhe 		assertEquals("Blue", swTableAutoFormatListbox.getSelText());
225b4d2d410SLiu Zhe 		swTableAutoFMT.close();
226b4d2d410SLiu Zhe 		writerInsertTable.ok();
227b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
228ca72bc94SLiu Zhe 
229ca72bc94SLiu Zhe 	}
230ca72bc94SLiu Zhe 
231ca72bc94SLiu Zhe 	// set row height and select row,insert/delete row
232ca72bc94SLiu Zhe 
233ca72bc94SLiu Zhe 	@Test
234ca72bc94SLiu Zhe 	public void testTableRowHeight() throws Exception {
235b4d2d410SLiu Zhe 		writerInsertTable.ok();
236b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
237ca72bc94SLiu Zhe 
238ca72bc94SLiu Zhe 		// set row height
239ca72bc94SLiu Zhe 		writer.focus();
240ca72bc94SLiu Zhe 		writer.openContextMenu();
241b4d2d410SLiu Zhe 		swTableRowHeightMenu.select();
242b4d2d410SLiu Zhe 		assertTrue(swTableSetRowHeightDialog.exists());
243b4d2d410SLiu Zhe 		swTableSetRowHeight.focus();
244ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
245ca72bc94SLiu Zhe 		typeKeys("<delete>");
246ca72bc94SLiu Zhe 		typeKeys("0.5");
247b4d2d410SLiu Zhe 		swTableSetRowHeightDialog.ok();
248ca72bc94SLiu Zhe 
249ca72bc94SLiu Zhe 		// verify row height
250ca72bc94SLiu Zhe 		writer.focus();
251ca72bc94SLiu Zhe 		writer.openContextMenu();
252b4d2d410SLiu Zhe 		swTableRowHeightMenu.select();
253b4d2d410SLiu Zhe 		assertTrue(swTableSetRowHeightDialog.exists());
254b4d2d410SLiu Zhe 		assertEquals("0.50\"", swTableSetRowHeight.getText());
255b4d2d410SLiu Zhe 		swTableSetRowHeightDialog.close();
256ca72bc94SLiu Zhe 	}
257ca72bc94SLiu Zhe 
258ca72bc94SLiu Zhe 	// select row
259ca72bc94SLiu Zhe 	@Test
260ca72bc94SLiu Zhe 	public void testTableSelectRow() throws Exception {
261b4d2d410SLiu Zhe 		writerInsertTable.ok();
262b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
263ca72bc94SLiu Zhe 		// select row
264ca72bc94SLiu Zhe 		writer.focus();
265ca72bc94SLiu Zhe 		writer.openContextMenu();
266b4d2d410SLiu Zhe 		swTableSelectRowMenu.select();
267ca72bc94SLiu Zhe 
268ca72bc94SLiu Zhe 		// verify select one row successfully
269ca72bc94SLiu Zhe 		typeKeys("<ctrl c>");
270ca72bc94SLiu Zhe 		typeKeys("<down>");
271ca72bc94SLiu Zhe 		typeKeys("<down>");
272ca72bc94SLiu Zhe 		typeKeys("<enter>");
273ca72bc94SLiu Zhe 		typeKeys("<ctrl v>");
274ca72bc94SLiu Zhe 		typeKeys("<up>");
275b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
276ca72bc94SLiu Zhe 
277ca72bc94SLiu Zhe 	}
278ca72bc94SLiu Zhe 
279ca72bc94SLiu Zhe 	// insert row and verify how many row inserted
280ca72bc94SLiu Zhe 	@Test
281ca72bc94SLiu Zhe 	public void testTableInsertRow() throws Exception {
282b4d2d410SLiu Zhe 		writerInsertTable.ok();
283b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
284ca72bc94SLiu Zhe 		writer.focus();
285ca72bc94SLiu Zhe 		writer.openContextMenu();
286b4d2d410SLiu Zhe 		swTableInsertRowMenu.select();
287ca72bc94SLiu Zhe 		assertTrue("SWTable_InsertRow Dialog pop up",
288b4d2d410SLiu Zhe 				swTableInsertRow.exists());
289b4d2d410SLiu Zhe 		swTableInsertRowColumnSetNumber.focus();
290ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
291ca72bc94SLiu Zhe 		typeKeys("<delete>");
292ca72bc94SLiu Zhe 		typeKeys("3");
293b4d2d410SLiu Zhe 		swTableInsertRow.ok();
294ca72bc94SLiu Zhe 
295ca72bc94SLiu Zhe 		writer.focus(); // verify how many rows in the table
296b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
297ca72bc94SLiu Zhe 		for (int i = 0; i < 4; i++) {
298ca72bc94SLiu Zhe 			typeKeys("<down>");
299b4d2d410SLiu Zhe 			assertNotNull(statusBar.getItemTextById(8));
300ca72bc94SLiu Zhe 		}
301ca72bc94SLiu Zhe 		typeKeys("<down>");
302ca72bc94SLiu Zhe 		sleep(1);
303b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
304ca72bc94SLiu Zhe 	}
305ca72bc94SLiu Zhe 
306ca72bc94SLiu Zhe 	// delete row and verify row
307ca72bc94SLiu Zhe 	@Test
308ca72bc94SLiu Zhe 	public void testTableRowDelete() throws Exception {
309b4d2d410SLiu Zhe 		writerInsertTable.ok();
310b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
311ca72bc94SLiu Zhe 		// delete row
312ca72bc94SLiu Zhe 		writer.focus();
313ca72bc94SLiu Zhe 		writer.openContextMenu();
314b4d2d410SLiu Zhe 		swTableRowDleteMenu.select();
315ca72bc94SLiu Zhe 		// verify whether delete row
316ca72bc94SLiu Zhe 		writer.focus();
317b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
318ca72bc94SLiu Zhe 		typeKeys("<down>");
319ca72bc94SLiu Zhe 		sleep(1);
320b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
321ca72bc94SLiu Zhe 
322ca72bc94SLiu Zhe 	}
323ca72bc94SLiu Zhe 
324ca72bc94SLiu Zhe 	// set column width and verify
325ca72bc94SLiu Zhe 	@Test
326ca72bc94SLiu Zhe 	public void testTableColumnWidth() throws Exception {
327b4d2d410SLiu Zhe 		writerInsertTable.ok();
328b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
329ca72bc94SLiu Zhe 		// set column width
330ca72bc94SLiu Zhe 		writer.focus();
331ca72bc94SLiu Zhe 		writer.openContextMenu();
332b4d2d410SLiu Zhe 		swTableColumnWidthMenu.select();
333b4d2d410SLiu Zhe 		swTableSetColumnWidth.focus();
334ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
335ca72bc94SLiu Zhe 		typeKeys("<delete>");
336ca72bc94SLiu Zhe 		typeKeys("2");
337b4d2d410SLiu Zhe 		swTableSetColumnDialog.ok();
338ca72bc94SLiu Zhe 		// verify column width
339ca72bc94SLiu Zhe 		writer.focus();
340ca72bc94SLiu Zhe 		writer.openContextMenu();
341b4d2d410SLiu Zhe 		swTableColumnWidthMenu.select();
342b4d2d410SLiu Zhe 		assertEquals("2.00\"", swTableSetColumnWidth.getText());
343ca72bc94SLiu Zhe 
344ca72bc94SLiu Zhe 	}
345ca72bc94SLiu Zhe 
346ca72bc94SLiu Zhe 	// select column and verify
347ca72bc94SLiu Zhe 	@Test
348ca72bc94SLiu Zhe 	public void testTableColumnSelect() throws Exception {
349b4d2d410SLiu Zhe 		writerInsertTable.ok();
350b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
351ca72bc94SLiu Zhe 		writer.focus();
352ca72bc94SLiu Zhe 		writer.openContextMenu();
353b4d2d410SLiu Zhe 		swTableColumnSelectMenu.select();
354ca72bc94SLiu Zhe 
355ca72bc94SLiu Zhe 		// verify select one column
356ca72bc94SLiu Zhe 		typeKeys("<ctrl c>");
357ca72bc94SLiu Zhe 		typeKeys("<down>");
358ca72bc94SLiu Zhe 		typeKeys("<down>");
359ca72bc94SLiu Zhe 		typeKeys("<enter>");
360ca72bc94SLiu Zhe 		typeKeys("<ctrl v>");
361ca72bc94SLiu Zhe 		typeKeys("<up>");
362b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
363ca72bc94SLiu Zhe 
364ca72bc94SLiu Zhe 	}
365ca72bc94SLiu Zhe 
366ca72bc94SLiu Zhe 	// insert column and verify
367ca72bc94SLiu Zhe 	@Test
368ca72bc94SLiu Zhe 	public void testTableColumnInsert() throws Exception {
369b4d2d410SLiu Zhe 		writerInsertTable.ok();
370b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
371ca72bc94SLiu Zhe 		// insert column
372ca72bc94SLiu Zhe 		writer.focus();
373ca72bc94SLiu Zhe 		writer.openContextMenu();
374b4d2d410SLiu Zhe 		swTableColumnInsertMenu.select();
375b4d2d410SLiu Zhe 		swTableInsertRowColumnSetNumber.focus();
376ca72bc94SLiu Zhe 		typeKeys("<ctrl a>");
377ca72bc94SLiu Zhe 		typeKeys("<delete>");
378ca72bc94SLiu Zhe 		typeKeys("3");
379b4d2d410SLiu Zhe 		swTableInsertColumn.ok();
380ca72bc94SLiu Zhe 		// verify insert column successfully
381ca72bc94SLiu Zhe 		writer.focus();
382b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
383ca72bc94SLiu Zhe 		for (int i = 0; i < 9; i++) {
384ca72bc94SLiu Zhe 			typeKeys("<right>");
385ca72bc94SLiu Zhe 			sleep(1);
386b4d2d410SLiu Zhe 			assertTrue(tableToolbar.exists());
387ca72bc94SLiu Zhe 		}
388ca72bc94SLiu Zhe 		typeKeys("<right>");
389ca72bc94SLiu Zhe 		sleep(1);
390b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
391ca72bc94SLiu Zhe 	}
392ca72bc94SLiu Zhe 
393ca72bc94SLiu Zhe 	// delete column and verify whether delete or not
394ca72bc94SLiu Zhe 	public void testTableColumnDelete() throws Exception {
395b4d2d410SLiu Zhe 		writerInsertTable.ok();
396b4d2d410SLiu Zhe 		assertNotNull(statusBar.getItemTextById(8));
397ca72bc94SLiu Zhe 		// delete column
398ca72bc94SLiu Zhe 		writer.focus();
399ca72bc94SLiu Zhe 		writer.openContextMenu();
400b4d2d410SLiu Zhe 		swTableColumnDeleteMenu.select();
401ca72bc94SLiu Zhe 		// verify delete column
402ca72bc94SLiu Zhe 		writer.focus();
403b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
404ca72bc94SLiu Zhe 		for (int i = 0; i < 7; i++) {
405ca72bc94SLiu Zhe 			typeKeys("<right>");
406b4d2d410SLiu Zhe 			assertTrue(tableToolbar.exists());
407ca72bc94SLiu Zhe 		}
408ca72bc94SLiu Zhe 		sleep(1);
409b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
410ca72bc94SLiu Zhe 	}
411ca72bc94SLiu Zhe 
412ca72bc94SLiu Zhe 	// split cell
413ca72bc94SLiu Zhe 	@Test
414ca72bc94SLiu Zhe 	public void testTableCellSplit() throws Exception {
415b4d2d410SLiu Zhe 		writerInsertTable.ok();
416b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
417ca72bc94SLiu Zhe 		for (int k = 0; k < 2; k++) {
418ca72bc94SLiu Zhe 			writer.focus();
419ca72bc94SLiu Zhe 			writer.openContextMenu();
420b4d2d410SLiu Zhe 			swTableCellSplitMenu.select();
421b4d2d410SLiu Zhe 			swTableCellSplitNumber.focus();
422ca72bc94SLiu Zhe 			typeKeys("<ctrl a>");
423ca72bc94SLiu Zhe 			typeKeys("<delete>");
424ca72bc94SLiu Zhe 			typeKeys("2");
425ca72bc94SLiu Zhe 			if (k == 0) {
426b4d2d410SLiu Zhe 				swTableCellSplitDialog.ok(); // split table cell horizontally
427ca72bc94SLiu Zhe 			} else {
428b4d2d410SLiu Zhe 				swTableCellSplitVERTButton.check(); // split table cell
429ca72bc94SLiu Zhe 				// vertically
430b4d2d410SLiu Zhe 				swTableCellSplitDialog.ok();
431ca72bc94SLiu Zhe 			}
432ca72bc94SLiu Zhe 		}
433ca72bc94SLiu Zhe 		// verify cell split successfully
434ca72bc94SLiu Zhe 		writer.focus();
435b4d2d410SLiu Zhe 		assertTrue(tableToolbar.exists());
436ca72bc94SLiu Zhe 		for (int i = 0; i < 7; i++) {
437ca72bc94SLiu Zhe 			typeKeys("<right>");
438b4d2d410SLiu Zhe 			assertTrue(tableToolbar.exists());
439ca72bc94SLiu Zhe 		}
440ca72bc94SLiu Zhe 		sleep(1);
441b4d2d410SLiu Zhe 		assertFalse(tableToolbar.exists());
442ca72bc94SLiu Zhe 	}
443ca72bc94SLiu Zhe 
444ca72bc94SLiu Zhe 	/**
445ca72bc94SLiu Zhe 	 * Test convert table to text in text document
446ca72bc94SLiu Zhe 	 *
447ca72bc94SLiu Zhe 	 * @throws Exception
448ca72bc94SLiu Zhe 	 */
449ca72bc94SLiu Zhe 	@Test
450ca72bc94SLiu Zhe 	public void testConvertTableToText() throws Exception {
451b4d2d410SLiu Zhe 		writerInsertTable.ok();
452ca72bc94SLiu Zhe 		writer.focus();
453ca72bc94SLiu Zhe 		typeKeys("1<right>2<right>3<right>4");
454ca72bc94SLiu Zhe 		sleep(1);
455ca72bc94SLiu Zhe 
456ca72bc94SLiu Zhe 		// Convert table to text
457ca72bc94SLiu Zhe 		app.dispatch(".uno:ConvertTableToText");
458b4d2d410SLiu Zhe 		assertTrue("Convert Table to Text dialog pop up", writerConvertTableToTextDlg.exists());
459ca72bc94SLiu Zhe 		// typeKeys("<enter>");
460b4d2d410SLiu Zhe 		writerConvertTableToTextDlg.ok(); // "Enter" does not work on linux
461ca72bc94SLiu Zhe 
462ca72bc94SLiu Zhe 		// Verify if text is converted successfully
463ca72bc94SLiu Zhe 		app.dispatch(".uno:SelectAll");
464ca72bc94SLiu Zhe 		app.dispatch(".uno:Copy");
465ca72bc94SLiu Zhe 		if (SystemUtil.isWindows())
466ca72bc94SLiu Zhe 			assertEquals("Converted text", "1\t2\r\n3\t4\r\n", app.getClipboard()); // in
467ca72bc94SLiu Zhe 																					// windows,
468ca72bc94SLiu Zhe 																					// \n
469ca72bc94SLiu Zhe 																					// is
470ca72bc94SLiu Zhe 																					// \r\n
471ca72bc94SLiu Zhe 		else
472ca72bc94SLiu Zhe 			assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
473ca72bc94SLiu Zhe 	}
47483ae2205SHerbert Dürr }
475