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