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