xref: /AOO42X/test/testgui/source/fvt/gui/sw/table/TableGeneral.java (revision b0efeae40e43e6d4ccd561d22ec612d42773857b)
1*b0efeae4SJohn Bampton <<<<<<< HEAD
2c767ce6aSmseidel /**************************************************************
3c767ce6aSmseidel  *
4c767ce6aSmseidel  * Licensed to the Apache Software Foundation (ASF) under one
5c767ce6aSmseidel  * or more contributor license agreements.  See the NOTICE file
6c767ce6aSmseidel  * distributed with this work for additional information
7c767ce6aSmseidel  * regarding copyright ownership.  The ASF licenses this file
8c767ce6aSmseidel  * to you under the Apache License, Version 2.0 (the
9c767ce6aSmseidel  * "License"); you may not use this file except in compliance
10c767ce6aSmseidel  * with the License.  You may obtain a copy of the License at
11c767ce6aSmseidel  *
12c767ce6aSmseidel  *   http://www.apache.org/licenses/LICENSE-2.0
13c767ce6aSmseidel  *
14c767ce6aSmseidel  * Unless required by applicable law or agreed to in writing,
15c767ce6aSmseidel  * software distributed under the License is distributed on an
16c767ce6aSmseidel  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17c767ce6aSmseidel  * KIND, either express or implied.  See the License for the
18c767ce6aSmseidel  * specific language governing permissions and limitations
19c767ce6aSmseidel  * under the License.
20c767ce6aSmseidel  *
21c767ce6aSmseidel  *************************************************************/
22c767ce6aSmseidel 
23c767ce6aSmseidel package fvt.gui.sw.table;
24c767ce6aSmseidel 
25c767ce6aSmseidel import static org.junit.Assert.*;
26c767ce6aSmseidel import static org.openoffice.test.vcl.Tester.*;
27c767ce6aSmseidel import static testlib.gui.AppTool.*;
28c767ce6aSmseidel import static testlib.gui.UIMap.*;
29c767ce6aSmseidel 
30c767ce6aSmseidel import org.junit.After;
31c767ce6aSmseidel import org.junit.Before;
32c767ce6aSmseidel import org.junit.Ignore;
33c767ce6aSmseidel import org.junit.Rule;
34c767ce6aSmseidel import org.junit.Test;
35c767ce6aSmseidel import org.openoffice.test.common.Logger;
36c767ce6aSmseidel import org.openoffice.test.common.SystemUtil;
37c767ce6aSmseidel 
38c767ce6aSmseidel import testlib.gui.AppTool;
39c767ce6aSmseidel 
40c767ce6aSmseidel public class TableGeneral {
41c767ce6aSmseidel 
42c767ce6aSmseidel     @Rule
43c767ce6aSmseidel     public Logger log = Logger.getLogger(this);
44c767ce6aSmseidel 
45c767ce6aSmseidel     @Before
46c767ce6aSmseidel     public void setUp() throws Exception {
47c767ce6aSmseidel         // Start OpenOffice
48c767ce6aSmseidel         app.start();
49c767ce6aSmseidel 
50c767ce6aSmseidel         AppTool.newTextDocument();
51c767ce6aSmseidel         // Insert a table
52c767ce6aSmseidel         app.dispatch(".uno:InsertTable");
53c767ce6aSmseidel     }
54c767ce6aSmseidel 
55c767ce6aSmseidel     @After
56c767ce6aSmseidel     public void tearDown() throws Exception {
57c767ce6aSmseidel         app.stop();
58c767ce6aSmseidel     }
59c767ce6aSmseidel 
60c767ce6aSmseidel     /**
61c767ce6aSmseidel      * Test setting table size in text document
62c767ce6aSmseidel      *
63c767ce6aSmseidel      * @throws Exception
64c767ce6aSmseidel      */
65c767ce6aSmseidel     @Test
66c767ce6aSmseidel     public void testTableSize() throws Exception {
67c767ce6aSmseidel 
68c767ce6aSmseidel         swTableSizeColBox.focus();
69c767ce6aSmseidel         typeKeys("<delete>");
70c767ce6aSmseidel         typeKeys("3");
71c767ce6aSmseidel         swTableSizeRowBox.focus();
72c767ce6aSmseidel         typeKeys("<delete>");
73c767ce6aSmseidel         typeKeys("4");
74c767ce6aSmseidel         writerInsertTable.ok();
75c767ce6aSmseidel 
76c767ce6aSmseidel         writer.focus();
77c767ce6aSmseidel         // verify the rows in the table
78c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
79c767ce6aSmseidel         for (int i = 0; i < 3; i++) {
80c767ce6aSmseidel             typeKeys("<down>");
81c767ce6aSmseidel             assertNotNull(statusBar.getItemTextById(8));
82c767ce6aSmseidel         }
83c767ce6aSmseidel         typeKeys("<down>");
84c767ce6aSmseidel         sleep(1);
85c767ce6aSmseidel         assertFalse(tableToolbar.exists());
86c767ce6aSmseidel     }
87c767ce6aSmseidel 
88c767ce6aSmseidel     /**
89c767ce6aSmseidel      * Test setting table cell background in text document
90c767ce6aSmseidel      *
91c767ce6aSmseidel      * @throws Exception
92c767ce6aSmseidel      */
93c767ce6aSmseidel     @Test
94c767ce6aSmseidel     @Ignore("Bug #120378- the table cell fill color change when copy one table cell in word processor to presentation")
95c767ce6aSmseidel     public void testTableBackground() throws Exception {
96c767ce6aSmseidel         writerInsertTable.ok();
97c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
98c767ce6aSmseidel         writer.focus();
99c767ce6aSmseidel         // set table cell background
100c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
101c767ce6aSmseidel         swTableBackground.select();
102c767ce6aSmseidel         assertTrue("Table background property dialog pop up",
103c767ce6aSmseidel                 swTableBackground.exists());
104c767ce6aSmseidel         swTableBackgroundColor.focus();
105c767ce6aSmseidel         swTableBackgroundColor.click(50, 50);
106c767ce6aSmseidel         swTableBackground.ok();
107c767ce6aSmseidel         // verify table cell background color
108c767ce6aSmseidel         writer.focus();
109c767ce6aSmseidel         // select the cell which is filled with color
110c767ce6aSmseidel         app.dispatch(".uno:EntireCell");
111c767ce6aSmseidel 
112c767ce6aSmseidel         typeKeys("<ctrl c>");
113c767ce6aSmseidel         AppTool.newPresentation();
114c767ce6aSmseidel         typeKeys("<ctrl v>");
115c767ce6aSmseidel         // enable table cell area format dialog
116c767ce6aSmseidel         app.dispatch(".uno:FormatArea");
117c767ce6aSmseidel         sleep(1);
118c767ce6aSmseidel         assertEquals("Light red", sdTableBACGColorListbox.getSelText());
119c767ce6aSmseidel         // close table cell area format dialog
120c767ce6aSmseidel         sdTableBACGColorArea.cancel();
121c767ce6aSmseidel     }
122c767ce6aSmseidel 
123c767ce6aSmseidel     /**
124c767ce6aSmseidel      * Test setting table border in text document
125c767ce6aSmseidel      *
126c767ce6aSmseidel      * @throws Exception
127c767ce6aSmseidel      */
128c767ce6aSmseidel     @Test
129c767ce6aSmseidel     public void testTableBorder() throws Exception {
130c767ce6aSmseidel         writerInsertTable.ok();
131c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
132c767ce6aSmseidel         // set table border as none
133c767ce6aSmseidel         writer.focus();
134c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
135c767ce6aSmseidel         swTableBorder.select();
136c767ce6aSmseidel         assertTrue("Table border property dialog pop up",
137c767ce6aSmseidel                 swTableBorder.exists());
138c767ce6aSmseidel         swTableBorderLineArrange.click(10, 10);
139c767ce6aSmseidel         swTableBorder.ok();
140c767ce6aSmseidel     }
141c767ce6aSmseidel 
142c767ce6aSmseidel     /**
143c767ce6aSmseidel      * Test setting table border line style,line color,spacing to content in
144c767ce6aSmseidel      * text document
145c767ce6aSmseidel      *
146c767ce6aSmseidel      * @throws Exception
147c767ce6aSmseidel      */
148c767ce6aSmseidel     @Test
149c767ce6aSmseidel     public void testTableBorderLineStyle() throws Exception {
150c767ce6aSmseidel         writerInsertTable.ok();
151c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
152c767ce6aSmseidel         writer.focus();
153c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
154c767ce6aSmseidel         swTableBorder.select();
155c767ce6aSmseidel         assertTrue("Table border property dialog pop up",
156c767ce6aSmseidel                 swTableBorder.exists());
157c767ce6aSmseidel         // set line style
158c767ce6aSmseidel         swTableBorderLineStyle.select(8);
159c767ce6aSmseidel         // set line color
160c767ce6aSmseidel         final int nMagentaIndex = 16; // for AOO's colorpicker as of #i118828#
161c767ce6aSmseidel         swTableBorderLineColor.select( nMagentaIndex);
162c767ce6aSmseidel         // set spacing to content
163c767ce6aSmseidel         swTableSTCLeft.focus();
164c767ce6aSmseidel         typeKeys("<ctrl a>");
165c767ce6aSmseidel         typeKeys("<delete>");
166c767ce6aSmseidel         // set spacing to content
167c767ce6aSmseidel         typeKeys("0.5");
168c767ce6aSmseidel         // set table shadow
169c767ce6aSmseidel         swTableShadow.click(40, 10);
170c767ce6aSmseidel         swTableShadowSize.focus();
171c767ce6aSmseidel         typeKeys("<ctrl a>");
172c767ce6aSmseidel         typeKeys("<delete>");
173c767ce6aSmseidel         typeKeys("2");
174c767ce6aSmseidel         swTableShadowColor.select( nMagentaIndex);
175c767ce6aSmseidel         swTableBorder.ok();
176c767ce6aSmseidel         // verify the setting property of table
177c767ce6aSmseidel         writer.focus();
178c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
179c767ce6aSmseidel         swTableBorder.select();
180c767ce6aSmseidel         assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
181c767ce6aSmseidel         assertEquals("Magenta", swTableBorderLineColor.getItemText( nMagentaIndex));
182c767ce6aSmseidel         assertEquals("0.50 \"", swTableSTCLeft.getText());
183c767ce6aSmseidel         assertEquals("0.50 \"", swTableSTCRight.getText());
184c767ce6aSmseidel         assertEquals("0.50 \"", swTableSTCTop.getText());
185c767ce6aSmseidel         assertEquals("0.50 \"", swTableSTCBottom.getText());
186c767ce6aSmseidel         assertEquals("1.97 \"", swTableShadowSize.getText());
187c767ce6aSmseidel         assertEquals("Magenta", swTableShadowColor.getItemText( nMagentaIndex));
188c767ce6aSmseidel         assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
189c767ce6aSmseidel         swTableBorder.close();
190c767ce6aSmseidel 
191c767ce6aSmseidel         // uncheck Synchronize box and set spacing to content
192c767ce6aSmseidel         writer.focus();
193c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
194c767ce6aSmseidel         swTableBorder.select();
195c767ce6aSmseidel         swTableSTCSYNC.uncheck();
196c767ce6aSmseidel         // set left spacing to content
197c767ce6aSmseidel         swTableSTCLeft.focus();
198c767ce6aSmseidel         typeKeys("<ctrl a>");
199c767ce6aSmseidel         typeKeys("<delete>");
200c767ce6aSmseidel         typeKeys("0.5");
201c767ce6aSmseidel         // set right spacing to content
202c767ce6aSmseidel         swTableSTCRight.focus();
203c767ce6aSmseidel         typeKeys("<ctrl a>");
204c767ce6aSmseidel         typeKeys("<delete>");
205c767ce6aSmseidel         typeKeys("0.8");
206c767ce6aSmseidel         // set top spacing to content
207c767ce6aSmseidel         swTableSTCTop.focus();
208c767ce6aSmseidel         typeKeys("<ctrl a>");
209c767ce6aSmseidel         typeKeys("<delete>");
210c767ce6aSmseidel         typeKeys("1.0");
211c767ce6aSmseidel         // set bottom spacing to content
212c767ce6aSmseidel         swTableSTCBottom.focus();
213c767ce6aSmseidel         typeKeys("<ctrl a>");
214c767ce6aSmseidel         typeKeys("<delete>");
215c767ce6aSmseidel         typeKeys("2");
216c767ce6aSmseidel         swTableBorder.ok();
217c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
218c767ce6aSmseidel 
219c767ce6aSmseidel         writer.focus();
220c767ce6aSmseidel         // verify the setting value of spacing to content for table
221c767ce6aSmseidel         app.dispatch(".uno:TableDialog");
222c767ce6aSmseidel         swTableBorder.select();
223c767ce6aSmseidel         assertEquals("0.50 \"", swTableSTCLeft.getText());
224c767ce6aSmseidel         assertEquals("0.80 \"", swTableSTCRight.getText());
225c767ce6aSmseidel         assertEquals("1.00 \"", swTableSTCTop.getText());
226c767ce6aSmseidel         assertEquals("1.97 \"", swTableSTCBottom.getText());
227c767ce6aSmseidel         assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
228c767ce6aSmseidel         swTableBorder.close();
229c767ce6aSmseidel     }
230c767ce6aSmseidel 
231c767ce6aSmseidel     /**
232c767ce6aSmseidel      * create table with auto format
233c767ce6aSmseidel      *
234c767ce6aSmseidel      * @throws Exception
235c767ce6aSmseidel      */
236c767ce6aSmseidel     @Test
237c767ce6aSmseidel     public void testTableAutoFormat() throws Exception {
238c767ce6aSmseidel         // create table with auto format
239c767ce6aSmseidel         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
240c767ce6aSmseidel         assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
241c767ce6aSmseidel         swTableAutoFormatListbox.select(3);
242c767ce6aSmseidel         swTableAutoFMT.ok();
243c767ce6aSmseidel         // verify the auto format is that just selected
244c767ce6aSmseidel         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
245c767ce6aSmseidel         assertEquals("Blue", swTableAutoFormatListbox.getSelText());
246c767ce6aSmseidel         swTableAutoFMT.close();
247c767ce6aSmseidel         writerInsertTable.ok();
248c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
249c767ce6aSmseidel 
250c767ce6aSmseidel     }
251c767ce6aSmseidel 
252c767ce6aSmseidel     /**
253c767ce6aSmseidel      * set row height and select row,insert/delete row
254c767ce6aSmseidel      *
255c767ce6aSmseidel      * @throws Exception
256c767ce6aSmseidel      */
257c767ce6aSmseidel     @Test
258c767ce6aSmseidel     public void testTableRowHeight() throws Exception {
259c767ce6aSmseidel         writerInsertTable.ok();
260c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
261c767ce6aSmseidel 
262c767ce6aSmseidel         // set row height
263c767ce6aSmseidel         writer.focus();
264c767ce6aSmseidel         writer.openContextMenu();
265c767ce6aSmseidel         swTableRowHeightMenu.select();
266c767ce6aSmseidel         assertTrue(swTableSetRowHeightDialog.exists());
267c767ce6aSmseidel         swTableSetRowHeight.focus();
268c767ce6aSmseidel         typeKeys("<ctrl a>");
269c767ce6aSmseidel         typeKeys("<delete>");
270c767ce6aSmseidel         typeKeys("0.5");
271c767ce6aSmseidel         swTableSetRowHeightDialog.ok();
272c767ce6aSmseidel 
273c767ce6aSmseidel         // verify row height
274c767ce6aSmseidel         writer.focus();
275c767ce6aSmseidel         writer.openContextMenu();
276c767ce6aSmseidel         swTableRowHeightMenu.select();
277c767ce6aSmseidel         assertTrue(swTableSetRowHeightDialog.exists());
278c767ce6aSmseidel         assertEquals("0.50 \"", swTableSetRowHeight.getText());
279c767ce6aSmseidel         swTableSetRowHeightDialog.close();
280c767ce6aSmseidel     }
281c767ce6aSmseidel 
282c767ce6aSmseidel     /**
283c767ce6aSmseidel      * test select row
284c767ce6aSmseidel      *
285c767ce6aSmseidel      * @throws Exception
286c767ce6aSmseidel      */
287c767ce6aSmseidel     @Test
288c767ce6aSmseidel     public void testTableSelectRow() throws Exception {
289c767ce6aSmseidel         writerInsertTable.ok();
290c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
291c767ce6aSmseidel         // select row
292c767ce6aSmseidel         writer.focus();
293c767ce6aSmseidel         writer.openContextMenu();
294c767ce6aSmseidel         swTableSelectRowMenu.select();
295c767ce6aSmseidel 
296c767ce6aSmseidel         // verify select one row successfully
297c767ce6aSmseidel         typeKeys("<ctrl c>");
298c767ce6aSmseidel         typeKeys("<down>");
299c767ce6aSmseidel         typeKeys("<down>");
300c767ce6aSmseidel         typeKeys("<enter>");
301c767ce6aSmseidel         typeKeys("<ctrl v>");
302c767ce6aSmseidel         typeKeys("<up>");
303c767ce6aSmseidel         assertTrue(tableToolbar.exists());
304c767ce6aSmseidel 
305c767ce6aSmseidel     }
306c767ce6aSmseidel 
307c767ce6aSmseidel     /**
308c767ce6aSmseidel      * insert row and verify how many row inserted
309c767ce6aSmseidel      *
310c767ce6aSmseidel      * @throws Exception
311c767ce6aSmseidel      */
312c767ce6aSmseidel     @Test
313c767ce6aSmseidel     public void testTableInsertRow() throws Exception {
314c767ce6aSmseidel         writerInsertTable.ok();
315c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
316c767ce6aSmseidel         writer.focus();
317c767ce6aSmseidel         writer.openContextMenu();
318c767ce6aSmseidel         swTableInsertRowMenu.select();
319c767ce6aSmseidel         assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists());
320c767ce6aSmseidel         swTableInsertRowColumnSetNumber.focus();
321c767ce6aSmseidel         typeKeys("<ctrl a>");
322c767ce6aSmseidel         typeKeys("<delete>");
323c767ce6aSmseidel         typeKeys("3");
324c767ce6aSmseidel         swTableInsertRow.ok();
325c767ce6aSmseidel 
326c767ce6aSmseidel         writer.focus();
327c767ce6aSmseidel         // verify how many rows in the table
328c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
329c767ce6aSmseidel         for (int i = 0; i < 4; i++) {
330c767ce6aSmseidel             typeKeys("<down>");
331c767ce6aSmseidel             assertNotNull(statusBar.getItemTextById(8));
332c767ce6aSmseidel         }
333c767ce6aSmseidel         typeKeys("<down>");
334c767ce6aSmseidel         sleep(1);
335c767ce6aSmseidel         assertFalse(tableToolbar.exists());
336c767ce6aSmseidel     }
337c767ce6aSmseidel 
338c767ce6aSmseidel     /**
339c767ce6aSmseidel      * delete row and verify row
340c767ce6aSmseidel      *
341c767ce6aSmseidel      * @throws Exception
342c767ce6aSmseidel      */
343c767ce6aSmseidel     @Test
344c767ce6aSmseidel     public void testTableRowDelete() throws Exception {
345c767ce6aSmseidel         writerInsertTable.ok();
346c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
347c767ce6aSmseidel         // delete row
348c767ce6aSmseidel         writer.focus();
349c767ce6aSmseidel         writer.openContextMenu();
350c767ce6aSmseidel         swTableRowDleteMenu.select();
351c767ce6aSmseidel         // verify whether delete row
352c767ce6aSmseidel         writer.focus();
353c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
354c767ce6aSmseidel         typeKeys("<down>");
355c767ce6aSmseidel         sleep(1);
356c767ce6aSmseidel         assertFalse(tableToolbar.exists());
357c767ce6aSmseidel 
358c767ce6aSmseidel     }
359c767ce6aSmseidel 
360c767ce6aSmseidel     /**
361c767ce6aSmseidel      * set column width and verify
362c767ce6aSmseidel      *
363c767ce6aSmseidel      * @throws Exception
364c767ce6aSmseidel      */
365c767ce6aSmseidel     @Test
366c767ce6aSmseidel     public void testTableColumnWidth() throws Exception {
367c767ce6aSmseidel         writerInsertTable.ok();
368c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
369c767ce6aSmseidel         // set column width
370c767ce6aSmseidel         writer.focus();
371c767ce6aSmseidel         writer.openContextMenu();
372c767ce6aSmseidel         swTableColumnWidthMenu.select();
373c767ce6aSmseidel         swTableSetColumnWidth.focus();
374c767ce6aSmseidel         typeKeys("<ctrl a>");
375c767ce6aSmseidel         typeKeys("<delete>");
376c767ce6aSmseidel         typeKeys("2");
377c767ce6aSmseidel         swTableSetColumnDialog.ok();
378c767ce6aSmseidel         // verify column width
379c767ce6aSmseidel         writer.focus();
380c767ce6aSmseidel         writer.openContextMenu();
381c767ce6aSmseidel         swTableColumnWidthMenu.select();
382c767ce6aSmseidel         assertEquals("2.00 \"", swTableSetColumnWidth.getText());
383c767ce6aSmseidel 
384c767ce6aSmseidel     }
385c767ce6aSmseidel 
386c767ce6aSmseidel     /**
387c767ce6aSmseidel      * select column and verify
388c767ce6aSmseidel      *
389c767ce6aSmseidel      * @throws Exception
390c767ce6aSmseidel      */
391c767ce6aSmseidel     @Test
392c767ce6aSmseidel     public void testTableColumnSelect() throws Exception {
393c767ce6aSmseidel         writerInsertTable.ok();
394c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
395c767ce6aSmseidel         writer.focus();
396c767ce6aSmseidel         writer.openContextMenu();
397c767ce6aSmseidel         swTableColumnSelectMenu.select();
398c767ce6aSmseidel 
399c767ce6aSmseidel         // verify select one column
400c767ce6aSmseidel         typeKeys("<ctrl c>");
401c767ce6aSmseidel         typeKeys("<down>");
402c767ce6aSmseidel         typeKeys("<down>");
403c767ce6aSmseidel         typeKeys("<enter>");
404c767ce6aSmseidel         typeKeys("<ctrl v>");
405c767ce6aSmseidel         typeKeys("<up>");
406c767ce6aSmseidel         assertTrue(tableToolbar.exists());
407c767ce6aSmseidel 
408c767ce6aSmseidel     }
409c767ce6aSmseidel 
410c767ce6aSmseidel     /**
411c767ce6aSmseidel      * insert column and verify
412c767ce6aSmseidel      *
413c767ce6aSmseidel      * @throws Exception
414c767ce6aSmseidel      */
415c767ce6aSmseidel     @Test
416c767ce6aSmseidel     public void testTableColumnInsert() throws Exception {
417c767ce6aSmseidel         writerInsertTable.ok();
418c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
419c767ce6aSmseidel         // insert column
420c767ce6aSmseidel         writer.focus();
421c767ce6aSmseidel         writer.openContextMenu();
422c767ce6aSmseidel         swTableColumnInsertMenu.select();
423c767ce6aSmseidel         swTableInsertRowColumnSetNumber.focus();
424c767ce6aSmseidel         typeKeys("<ctrl a>");
425c767ce6aSmseidel         typeKeys("<delete>");
426c767ce6aSmseidel         typeKeys("3");
427c767ce6aSmseidel         swTableInsertColumn.ok();
428c767ce6aSmseidel         // verify insert column successfully
429c767ce6aSmseidel         writer.focus();
430c767ce6aSmseidel         assertTrue(tableToolbar.exists());
431c767ce6aSmseidel         for (int i = 0; i < 9; i++) {
432c767ce6aSmseidel             typeKeys("<right>");
433c767ce6aSmseidel             sleep(1);
434c767ce6aSmseidel             assertTrue(tableToolbar.exists());
435c767ce6aSmseidel         }
436c767ce6aSmseidel         typeKeys("<right>");
437c767ce6aSmseidel         sleep(1);
438c767ce6aSmseidel         assertFalse(tableToolbar.exists());
439c767ce6aSmseidel     }
440c767ce6aSmseidel 
441c767ce6aSmseidel     /**
442c767ce6aSmseidel      * delete column and verify whether delete or not
443c767ce6aSmseidel      *
444c767ce6aSmseidel      * @throws Exception
445c767ce6aSmseidel      */
446c767ce6aSmseidel     public void testTableColumnDelete() throws Exception {
447c767ce6aSmseidel         writerInsertTable.ok();
448c767ce6aSmseidel         assertNotNull(statusBar.getItemTextById(8));
449c767ce6aSmseidel         // delete column
450c767ce6aSmseidel         writer.focus();
451c767ce6aSmseidel         writer.openContextMenu();
452c767ce6aSmseidel         swTableColumnDeleteMenu.select();
453c767ce6aSmseidel         // verify delete column
454c767ce6aSmseidel         writer.focus();
455c767ce6aSmseidel         assertTrue(tableToolbar.exists());
456c767ce6aSmseidel         for (int i = 0; i < 7; i++) {
457c767ce6aSmseidel             typeKeys("<right>");
458c767ce6aSmseidel             assertTrue(tableToolbar.exists());
459c767ce6aSmseidel         }
460c767ce6aSmseidel         sleep(1);
461c767ce6aSmseidel         assertFalse(tableToolbar.exists());
462c767ce6aSmseidel     }
463c767ce6aSmseidel 
464c767ce6aSmseidel     /**
465c767ce6aSmseidel      * split cell
466c767ce6aSmseidel      *
467c767ce6aSmseidel      * @throws Exception
468c767ce6aSmseidel      */
469c767ce6aSmseidel     @Test
470c767ce6aSmseidel     public void testTableCellSplit() throws Exception {
471c767ce6aSmseidel         writerInsertTable.ok();
472c767ce6aSmseidel         assertTrue(tableToolbar.exists());
473c767ce6aSmseidel         for (int k = 0; k < 2; k++) {
474c767ce6aSmseidel             writer.focus();
475c767ce6aSmseidel             writer.openContextMenu();
476c767ce6aSmseidel             swTableCellSplitMenu.select();
477c767ce6aSmseidel             swTableCellSplitNumber.focus();
478c767ce6aSmseidel             typeKeys("<ctrl a>");
479c767ce6aSmseidel             typeKeys("<delete>");
480c767ce6aSmseidel             typeKeys("2");
481c767ce6aSmseidel             if (k == 0) {
482c767ce6aSmseidel                 // split table cell horizontally
483c767ce6aSmseidel                 swTableCellSplitDialog.ok();
484c767ce6aSmseidel             } else {
485c767ce6aSmseidel                 // split table cell
486c767ce6aSmseidel                 swTableCellSplitVERTButton.check();
487c767ce6aSmseidel                 // vertically
488c767ce6aSmseidel                 swTableCellSplitDialog.ok();
489c767ce6aSmseidel             }
490c767ce6aSmseidel         }
491c767ce6aSmseidel         // verify cell split successfully
492c767ce6aSmseidel         writer.focus();
493c767ce6aSmseidel         assertTrue(tableToolbar.exists());
494c767ce6aSmseidel         for (int i = 0; i < 7; i++) {
495c767ce6aSmseidel             typeKeys("<right>");
496c767ce6aSmseidel             assertTrue(tableToolbar.exists());
497c767ce6aSmseidel         }
498c767ce6aSmseidel         sleep(1);
499c767ce6aSmseidel         assertFalse(tableToolbar.exists());
500c767ce6aSmseidel     }
501c767ce6aSmseidel 
502c767ce6aSmseidel     /**
503c767ce6aSmseidel      * Test convert table to text in text document
504c767ce6aSmseidel      *
505c767ce6aSmseidel      * @throws Exception
506c767ce6aSmseidel      */
507c767ce6aSmseidel     @Test
508c767ce6aSmseidel     public void testConvertTableToText() throws Exception {
509c767ce6aSmseidel         writerInsertTable.ok();
510c767ce6aSmseidel         writer.focus();
511c767ce6aSmseidel         typeKeys("1<right>2<right>3<right>4");
512c767ce6aSmseidel         sleep(1);
513c767ce6aSmseidel 
514c767ce6aSmseidel         // Convert table to text
515c767ce6aSmseidel         app.dispatch(".uno:ConvertTableToText");
516c767ce6aSmseidel         assertTrue("Convert Table to Text dialog pop up",
517c767ce6aSmseidel                 writerConvertTableToTextDlg.exists());
518c767ce6aSmseidel         // typeKeys("<enter>");
519c767ce6aSmseidel         writerConvertTableToTextDlg.ok();
520c767ce6aSmseidel 
521c767ce6aSmseidel         // Verify if text is converted successfully
522c767ce6aSmseidel         app.dispatch(".uno:SelectAll");
523c767ce6aSmseidel         app.dispatch(".uno:Copy");
524c767ce6aSmseidel         if (SystemUtil.isWindows())
525c767ce6aSmseidel             assertEquals("Converted text", "1\t2\r\n3\t4\r\n",
526c767ce6aSmseidel                     app.getClipboard());
527c767ce6aSmseidel         else
528c767ce6aSmseidel             assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
529c767ce6aSmseidel     }
530c767ce6aSmseidel }
531*b0efeae4SJohn Bampton =======
532*b0efeae4SJohn Bampton /**************************************************************
533*b0efeae4SJohn Bampton  *
534*b0efeae4SJohn Bampton  * Licensed to the Apache Software Foundation (ASF) under one
535*b0efeae4SJohn Bampton  * or more contributor license agreements.  See the NOTICE file
536*b0efeae4SJohn Bampton  * distributed with this work for additional information
537*b0efeae4SJohn Bampton  * regarding copyright ownership.  The ASF licenses this file
538*b0efeae4SJohn Bampton  * to you under the Apache License, Version 2.0 (the
539*b0efeae4SJohn Bampton  * "License"); you may not use this file except in compliance
540*b0efeae4SJohn Bampton  * with the License.  You may obtain a copy of the License at
541*b0efeae4SJohn Bampton  *
542*b0efeae4SJohn Bampton  *   http://www.apache.org/licenses/LICENSE-2.0
543*b0efeae4SJohn Bampton  *
544*b0efeae4SJohn Bampton  * Unless required by applicable law or agreed to in writing,
545*b0efeae4SJohn Bampton  * software distributed under the License is distributed on an
546*b0efeae4SJohn Bampton  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
547*b0efeae4SJohn Bampton  * KIND, either express or implied.  See the License for the
548*b0efeae4SJohn Bampton  * specific language governing permissions and limitations
549*b0efeae4SJohn Bampton  * under the License.
550*b0efeae4SJohn Bampton  *
551*b0efeae4SJohn Bampton  *************************************************************/
552*b0efeae4SJohn Bampton 
553*b0efeae4SJohn Bampton package fvt.gui.sw.table;
554*b0efeae4SJohn Bampton 
555*b0efeae4SJohn Bampton import static org.junit.Assert.*;
556*b0efeae4SJohn Bampton import static org.openoffice.test.vcl.Tester.*;
557*b0efeae4SJohn Bampton import static testlib.gui.AppTool.*;
558*b0efeae4SJohn Bampton import static testlib.gui.UIMap.*;
559*b0efeae4SJohn Bampton 
560*b0efeae4SJohn Bampton import org.junit.After;
561*b0efeae4SJohn Bampton import org.junit.Before;
562*b0efeae4SJohn Bampton import org.junit.Ignore;
563*b0efeae4SJohn Bampton import org.junit.Rule;
564*b0efeae4SJohn Bampton import org.junit.Test;
565*b0efeae4SJohn Bampton import org.openoffice.test.common.Logger;
566*b0efeae4SJohn Bampton import org.openoffice.test.common.SystemUtil;
567*b0efeae4SJohn Bampton 
568*b0efeae4SJohn Bampton import testlib.gui.AppTool;
569*b0efeae4SJohn Bampton 
570*b0efeae4SJohn Bampton public class TableGeneral {
571*b0efeae4SJohn Bampton 
572*b0efeae4SJohn Bampton     @Rule
573*b0efeae4SJohn Bampton     public Logger log = Logger.getLogger(this);
574*b0efeae4SJohn Bampton 
575*b0efeae4SJohn Bampton     @Before
576*b0efeae4SJohn Bampton     public void setUp() throws Exception {
577*b0efeae4SJohn Bampton         // Start OpenOffice
578*b0efeae4SJohn Bampton         app.start();
579*b0efeae4SJohn Bampton 
580*b0efeae4SJohn Bampton         AppTool.newTextDocument();
581*b0efeae4SJohn Bampton         // Insert a table
582*b0efeae4SJohn Bampton         app.dispatch(".uno:InsertTable");
583*b0efeae4SJohn Bampton     }
584*b0efeae4SJohn Bampton 
585*b0efeae4SJohn Bampton     @After
586*b0efeae4SJohn Bampton     public void tearDown() throws Exception {
587*b0efeae4SJohn Bampton         app.stop();
588*b0efeae4SJohn Bampton     }
589*b0efeae4SJohn Bampton 
590*b0efeae4SJohn Bampton     /**
591*b0efeae4SJohn Bampton      * Test setting table size in text document
592*b0efeae4SJohn Bampton      *
593*b0efeae4SJohn Bampton      * @throws Exception
594*b0efeae4SJohn Bampton      */
595*b0efeae4SJohn Bampton     @Test
596*b0efeae4SJohn Bampton     public void testTableSize() throws Exception {
597*b0efeae4SJohn Bampton 
598*b0efeae4SJohn Bampton         swTableSizeColBox.focus();
599*b0efeae4SJohn Bampton         typeKeys("<delete>");
600*b0efeae4SJohn Bampton         typeKeys("3");
601*b0efeae4SJohn Bampton         swTableSizeRowBox.focus();
602*b0efeae4SJohn Bampton         typeKeys("<delete>");
603*b0efeae4SJohn Bampton         typeKeys("4");
604*b0efeae4SJohn Bampton         writerInsertTable.ok();
605*b0efeae4SJohn Bampton 
606*b0efeae4SJohn Bampton         writer.focus();
607*b0efeae4SJohn Bampton         // verify the rows in the table
608*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
609*b0efeae4SJohn Bampton         for (int i = 0; i < 3; i++) {
610*b0efeae4SJohn Bampton             typeKeys("<down>");
611*b0efeae4SJohn Bampton             assertNotNull(statusBar.getItemTextById(8));
612*b0efeae4SJohn Bampton         }
613*b0efeae4SJohn Bampton         typeKeys("<down>");
614*b0efeae4SJohn Bampton         sleep(1);
615*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
616*b0efeae4SJohn Bampton     }
617*b0efeae4SJohn Bampton 
618*b0efeae4SJohn Bampton     /**
619*b0efeae4SJohn Bampton      * Test setting table cell background in text document
620*b0efeae4SJohn Bampton      *
621*b0efeae4SJohn Bampton      * @throws Exception
622*b0efeae4SJohn Bampton      */
623*b0efeae4SJohn Bampton     @Test
624*b0efeae4SJohn Bampton     @Ignore("Bug #120378- the table cell fill color change when copy one table cell in word processor to presentation")
625*b0efeae4SJohn Bampton     public void testTableBackground() throws Exception {
626*b0efeae4SJohn Bampton         writerInsertTable.ok();
627*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
628*b0efeae4SJohn Bampton         writer.focus();
629*b0efeae4SJohn Bampton         // set table cell background
630*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
631*b0efeae4SJohn Bampton         swTableBackground.select();
632*b0efeae4SJohn Bampton         assertTrue("Table background property dialog pop up",
633*b0efeae4SJohn Bampton                 swTableBackground.exists());
634*b0efeae4SJohn Bampton         swTableBackgroundColor.focus();
635*b0efeae4SJohn Bampton         swTableBackgroundColor.click(50, 50);
636*b0efeae4SJohn Bampton         swTableBackground.ok();
637*b0efeae4SJohn Bampton         // verify table cell background color
638*b0efeae4SJohn Bampton         writer.focus();
639*b0efeae4SJohn Bampton         // select the cell which is filled with color
640*b0efeae4SJohn Bampton         app.dispatch(".uno:EntireCell");
641*b0efeae4SJohn Bampton 
642*b0efeae4SJohn Bampton         typeKeys("<ctrl c>");
643*b0efeae4SJohn Bampton         AppTool.newPresentation();
644*b0efeae4SJohn Bampton         typeKeys("<ctrl v>");
645*b0efeae4SJohn Bampton         // enable table cell area format dialog
646*b0efeae4SJohn Bampton         app.dispatch(".uno:FormatArea");
647*b0efeae4SJohn Bampton         sleep(1);
648*b0efeae4SJohn Bampton         assertEquals("Light red", sdTableBACGColorListbox.getSelText());
649*b0efeae4SJohn Bampton         // close table cell area format dialog
650*b0efeae4SJohn Bampton         sdTableBACGColorArea.cancel();
651*b0efeae4SJohn Bampton     }
652*b0efeae4SJohn Bampton 
653*b0efeae4SJohn Bampton     /**
654*b0efeae4SJohn Bampton      * Test setting table border in text document
655*b0efeae4SJohn Bampton      *
656*b0efeae4SJohn Bampton      * @throws Exception
657*b0efeae4SJohn Bampton      */
658*b0efeae4SJohn Bampton     @Test
659*b0efeae4SJohn Bampton     public void testTableBorder() throws Exception {
660*b0efeae4SJohn Bampton         writerInsertTable.ok();
661*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
662*b0efeae4SJohn Bampton         // set table border as none
663*b0efeae4SJohn Bampton         writer.focus();
664*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
665*b0efeae4SJohn Bampton         swTableBorder.select();
666*b0efeae4SJohn Bampton         assertTrue("Table border property dialog pop up",
667*b0efeae4SJohn Bampton                 swTableBorder.exists());
668*b0efeae4SJohn Bampton         swTableBorderLineArrange.click(10, 10);
669*b0efeae4SJohn Bampton         swTableBorder.ok();
670*b0efeae4SJohn Bampton     }
671*b0efeae4SJohn Bampton 
672*b0efeae4SJohn Bampton     /**
673*b0efeae4SJohn Bampton      * Test setting table border line style,line color,spacing to content in
674*b0efeae4SJohn Bampton      * text document
675*b0efeae4SJohn Bampton      *
676*b0efeae4SJohn Bampton      * @throws Exception
677*b0efeae4SJohn Bampton      */
678*b0efeae4SJohn Bampton     @Test
679*b0efeae4SJohn Bampton     public void testTableBorderLineStyle() throws Exception {
680*b0efeae4SJohn Bampton         writerInsertTable.ok();
681*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
682*b0efeae4SJohn Bampton         writer.focus();
683*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
684*b0efeae4SJohn Bampton         swTableBorder.select();
685*b0efeae4SJohn Bampton         assertTrue("Table border property dialog pop up",
686*b0efeae4SJohn Bampton                 swTableBorder.exists());
687*b0efeae4SJohn Bampton         // set line style
688*b0efeae4SJohn Bampton         swTableBorderLineStyle.select(8);
689*b0efeae4SJohn Bampton         // set line color
690*b0efeae4SJohn Bampton         final int nMagentaIndex = 16; // for AOO's colorpicker as of #i118828#
691*b0efeae4SJohn Bampton         swTableBorderLineColor.select( nMagentaIndex);
692*b0efeae4SJohn Bampton         // set spacing to content
693*b0efeae4SJohn Bampton         swTableSTCLeft.focus();
694*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
695*b0efeae4SJohn Bampton         typeKeys("<delete>");
696*b0efeae4SJohn Bampton         // set spacing to content
697*b0efeae4SJohn Bampton         typeKeys("0.5");
698*b0efeae4SJohn Bampton         // set table shadow
699*b0efeae4SJohn Bampton         swTableShadow.click(40, 10);
700*b0efeae4SJohn Bampton         swTableShadowSize.focus();
701*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
702*b0efeae4SJohn Bampton         typeKeys("<delete>");
703*b0efeae4SJohn Bampton         typeKeys("2");
704*b0efeae4SJohn Bampton         swTableShadowColor.select( nMagentaIndex);
705*b0efeae4SJohn Bampton         swTableBorder.ok();
706*b0efeae4SJohn Bampton         // verify the setting property of table
707*b0efeae4SJohn Bampton         writer.focus();
708*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
709*b0efeae4SJohn Bampton         swTableBorder.select();
710*b0efeae4SJohn Bampton         assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
711*b0efeae4SJohn Bampton         assertEquals("Magenta", swTableBorderLineColor.getItemText( nMagentaIndex));
712*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSTCLeft.getText());
713*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSTCRight.getText());
714*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSTCTop.getText());
715*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSTCBottom.getText());
716*b0efeae4SJohn Bampton         assertEquals("1.97 \"", swTableShadowSize.getText());
717*b0efeae4SJohn Bampton         assertEquals("Magenta", swTableShadowColor.getItemText( nMagentaIndex));
718*b0efeae4SJohn Bampton         assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
719*b0efeae4SJohn Bampton         swTableBorder.close();
720*b0efeae4SJohn Bampton 
721*b0efeae4SJohn Bampton         // uncheck Synchronize box and set spacing to content
722*b0efeae4SJohn Bampton         writer.focus();
723*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
724*b0efeae4SJohn Bampton         swTableBorder.select();
725*b0efeae4SJohn Bampton         swTableSTCSYNC.uncheck();
726*b0efeae4SJohn Bampton         // set left spacing to content
727*b0efeae4SJohn Bampton         swTableSTCLeft.focus();
728*b0efeae4SJohn Bampton         sleep(0.2);
729*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
730*b0efeae4SJohn Bampton         typeKeys("<delete>");
731*b0efeae4SJohn Bampton         typeKeys("0.5");
732*b0efeae4SJohn Bampton         // set right spacing to content
733*b0efeae4SJohn Bampton         swTableSTCRight.focus();
734*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
735*b0efeae4SJohn Bampton         typeKeys("<delete>");
736*b0efeae4SJohn Bampton         typeKeys("0.8");
737*b0efeae4SJohn Bampton         // set top spacing to content
738*b0efeae4SJohn Bampton         swTableSTCTop.focus();
739*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
740*b0efeae4SJohn Bampton         typeKeys("<delete>");
741*b0efeae4SJohn Bampton         typeKeys("1.0");
742*b0efeae4SJohn Bampton         // set bottom spacing to content
743*b0efeae4SJohn Bampton         swTableSTCBottom.focus();
744*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
745*b0efeae4SJohn Bampton         typeKeys("<delete>");
746*b0efeae4SJohn Bampton         typeKeys("2");
747*b0efeae4SJohn Bampton         swTableBorder.ok();
748*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
749*b0efeae4SJohn Bampton 
750*b0efeae4SJohn Bampton         writer.focus();
751*b0efeae4SJohn Bampton         // verify the setting value of spacing to content for table
752*b0efeae4SJohn Bampton         app.dispatch(".uno:TableDialog");
753*b0efeae4SJohn Bampton         swTableBorder.select();
754*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSTCLeft.getText());
755*b0efeae4SJohn Bampton         assertEquals("0.80 \"", swTableSTCRight.getText());
756*b0efeae4SJohn Bampton         assertEquals("1.00 \"", swTableSTCTop.getText());
757*b0efeae4SJohn Bampton         assertEquals("1.97 \"", swTableSTCBottom.getText());
758*b0efeae4SJohn Bampton         assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
759*b0efeae4SJohn Bampton         swTableBorder.close();
760*b0efeae4SJohn Bampton     }
761*b0efeae4SJohn Bampton 
762*b0efeae4SJohn Bampton     /**
763*b0efeae4SJohn Bampton      * create table with auto format
764*b0efeae4SJohn Bampton      *
765*b0efeae4SJohn Bampton      * @throws Exception
766*b0efeae4SJohn Bampton      */
767*b0efeae4SJohn Bampton     @Test
768*b0efeae4SJohn Bampton     public void testTableAutoFormat() throws Exception {
769*b0efeae4SJohn Bampton         // create table with auto format
770*b0efeae4SJohn Bampton         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
771*b0efeae4SJohn Bampton         assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
772*b0efeae4SJohn Bampton         swTableAutoFormatListbox.select(3);
773*b0efeae4SJohn Bampton         swTableAutoFMT.ok();
774*b0efeae4SJohn Bampton         // verify the auto format is that just selected
775*b0efeae4SJohn Bampton         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
776*b0efeae4SJohn Bampton         assertEquals("Blue", swTableAutoFormatListbox.getSelText());
777*b0efeae4SJohn Bampton         swTableAutoFMT.close();
778*b0efeae4SJohn Bampton         writerInsertTable.ok();
779*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
780*b0efeae4SJohn Bampton 
781*b0efeae4SJohn Bampton     }
782*b0efeae4SJohn Bampton 
783*b0efeae4SJohn Bampton     /**
784*b0efeae4SJohn Bampton      * set row height and select row,insert/delete row
785*b0efeae4SJohn Bampton      *
786*b0efeae4SJohn Bampton      * @throws Exception
787*b0efeae4SJohn Bampton      */
788*b0efeae4SJohn Bampton     @Test
789*b0efeae4SJohn Bampton     public void testTableRowHeight() throws Exception {
790*b0efeae4SJohn Bampton         writerInsertTable.ok();
791*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
792*b0efeae4SJohn Bampton 
793*b0efeae4SJohn Bampton         // set row height
794*b0efeae4SJohn Bampton         writer.focus();
795*b0efeae4SJohn Bampton         writer.openContextMenu();
796*b0efeae4SJohn Bampton         swTableRowHeightMenu.select();
797*b0efeae4SJohn Bampton         assertTrue(swTableSetRowHeightDialog.exists());
798*b0efeae4SJohn Bampton         swTableSetRowHeight.focus();
799*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
800*b0efeae4SJohn Bampton         typeKeys("<delete>");
801*b0efeae4SJohn Bampton         typeKeys("0.5");
802*b0efeae4SJohn Bampton         swTableSetRowHeightDialog.ok();
803*b0efeae4SJohn Bampton 
804*b0efeae4SJohn Bampton         // verify row height
805*b0efeae4SJohn Bampton         writer.focus();
806*b0efeae4SJohn Bampton         writer.openContextMenu();
807*b0efeae4SJohn Bampton         swTableRowHeightMenu.select();
808*b0efeae4SJohn Bampton         assertTrue(swTableSetRowHeightDialog.exists());
809*b0efeae4SJohn Bampton         assertEquals("0.50 \"", swTableSetRowHeight.getText());
810*b0efeae4SJohn Bampton         swTableSetRowHeightDialog.close();
811*b0efeae4SJohn Bampton     }
812*b0efeae4SJohn Bampton 
813*b0efeae4SJohn Bampton     /**
814*b0efeae4SJohn Bampton      * test select row
815*b0efeae4SJohn Bampton      *
816*b0efeae4SJohn Bampton      * @throws Exception
817*b0efeae4SJohn Bampton      */
818*b0efeae4SJohn Bampton     @Test
819*b0efeae4SJohn Bampton     public void testTableSelectRow() throws Exception {
820*b0efeae4SJohn Bampton         writerInsertTable.ok();
821*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
822*b0efeae4SJohn Bampton         // select row
823*b0efeae4SJohn Bampton         writer.focus();
824*b0efeae4SJohn Bampton         writer.openContextMenu();
825*b0efeae4SJohn Bampton         swTableSelectRowMenu.select();
826*b0efeae4SJohn Bampton 
827*b0efeae4SJohn Bampton         // verify select one row successfully
828*b0efeae4SJohn Bampton         typeKeys("<ctrl c>");
829*b0efeae4SJohn Bampton         typeKeys("<down>");
830*b0efeae4SJohn Bampton         typeKeys("<down>");
831*b0efeae4SJohn Bampton         typeKeys("<enter>");
832*b0efeae4SJohn Bampton         typeKeys("<ctrl v>");
833*b0efeae4SJohn Bampton         typeKeys("<up>");
834*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
835*b0efeae4SJohn Bampton 
836*b0efeae4SJohn Bampton     }
837*b0efeae4SJohn Bampton 
838*b0efeae4SJohn Bampton     /**
839*b0efeae4SJohn Bampton      * insert row and verify how many row inserted
840*b0efeae4SJohn Bampton      *
841*b0efeae4SJohn Bampton      * @throws Exception
842*b0efeae4SJohn Bampton      */
843*b0efeae4SJohn Bampton     @Test
844*b0efeae4SJohn Bampton     public void testTableInsertRow() throws Exception {
845*b0efeae4SJohn Bampton         writerInsertTable.ok();
846*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
847*b0efeae4SJohn Bampton         writer.focus();
848*b0efeae4SJohn Bampton         writer.openContextMenu();
849*b0efeae4SJohn Bampton         swTableInsertRowMenu.select();
850*b0efeae4SJohn Bampton         assertTrue("SWTable_InsertRow Dialog pop up", swTableInsertRow.exists());
851*b0efeae4SJohn Bampton         swTableInsertRowColumnSetNumber.focus();
852*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
853*b0efeae4SJohn Bampton         typeKeys("<delete>");
854*b0efeae4SJohn Bampton         typeKeys("3");
855*b0efeae4SJohn Bampton         swTableInsertRow.ok();
856*b0efeae4SJohn Bampton 
857*b0efeae4SJohn Bampton         writer.focus();
858*b0efeae4SJohn Bampton         // verify how many rows in the table
859*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
860*b0efeae4SJohn Bampton         for (int i = 0; i < 4; i++) {
861*b0efeae4SJohn Bampton             typeKeys("<down>");
862*b0efeae4SJohn Bampton             assertNotNull(statusBar.getItemTextById(8));
863*b0efeae4SJohn Bampton         }
864*b0efeae4SJohn Bampton         typeKeys("<down>");
865*b0efeae4SJohn Bampton         sleep(1);
866*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
867*b0efeae4SJohn Bampton     }
868*b0efeae4SJohn Bampton 
869*b0efeae4SJohn Bampton     /**
870*b0efeae4SJohn Bampton      * delete row and verify row
871*b0efeae4SJohn Bampton      *
872*b0efeae4SJohn Bampton      * @throws Exception
873*b0efeae4SJohn Bampton      */
874*b0efeae4SJohn Bampton     @Test
875*b0efeae4SJohn Bampton     public void testTableRowDelete() throws Exception {
876*b0efeae4SJohn Bampton         writerInsertTable.ok();
877*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
878*b0efeae4SJohn Bampton         // delete row
879*b0efeae4SJohn Bampton         writer.focus();
880*b0efeae4SJohn Bampton         writer.openContextMenu();
881*b0efeae4SJohn Bampton         swTableRowDleteMenu.select();
882*b0efeae4SJohn Bampton         // verify whether delete row
883*b0efeae4SJohn Bampton         writer.focus();
884*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
885*b0efeae4SJohn Bampton         typeKeys("<down>");
886*b0efeae4SJohn Bampton         sleep(1);
887*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
888*b0efeae4SJohn Bampton 
889*b0efeae4SJohn Bampton     }
890*b0efeae4SJohn Bampton 
891*b0efeae4SJohn Bampton     /**
892*b0efeae4SJohn Bampton      * set column width and verify
893*b0efeae4SJohn Bampton      *
894*b0efeae4SJohn Bampton      * @throws Exception
895*b0efeae4SJohn Bampton      */
896*b0efeae4SJohn Bampton     @Test
897*b0efeae4SJohn Bampton     public void testTableColumnWidth() throws Exception {
898*b0efeae4SJohn Bampton         writerInsertTable.ok();
899*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
900*b0efeae4SJohn Bampton         // set column width
901*b0efeae4SJohn Bampton         writer.focus();
902*b0efeae4SJohn Bampton         writer.openContextMenu();
903*b0efeae4SJohn Bampton         swTableColumnWidthMenu.select();
904*b0efeae4SJohn Bampton         swTableSetColumnWidth.focus();
905*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
906*b0efeae4SJohn Bampton         typeKeys("<delete>");
907*b0efeae4SJohn Bampton         typeKeys("2");
908*b0efeae4SJohn Bampton         swTableSetColumnDialog.ok();
909*b0efeae4SJohn Bampton         // verify column width
910*b0efeae4SJohn Bampton         writer.focus();
911*b0efeae4SJohn Bampton         writer.openContextMenu();
912*b0efeae4SJohn Bampton         swTableColumnWidthMenu.select();
913*b0efeae4SJohn Bampton         assertEquals("2.00 \"", swTableSetColumnWidth.getText());
914*b0efeae4SJohn Bampton 
915*b0efeae4SJohn Bampton     }
916*b0efeae4SJohn Bampton 
917*b0efeae4SJohn Bampton     /**
918*b0efeae4SJohn Bampton      * select column and verify
919*b0efeae4SJohn Bampton      *
920*b0efeae4SJohn Bampton      * @throws Exception
921*b0efeae4SJohn Bampton      */
922*b0efeae4SJohn Bampton     @Test
923*b0efeae4SJohn Bampton     public void testTableColumnSelect() throws Exception {
924*b0efeae4SJohn Bampton         writerInsertTable.ok();
925*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
926*b0efeae4SJohn Bampton         writer.focus();
927*b0efeae4SJohn Bampton         writer.openContextMenu();
928*b0efeae4SJohn Bampton         swTableColumnSelectMenu.select();
929*b0efeae4SJohn Bampton 
930*b0efeae4SJohn Bampton         // verify select one column
931*b0efeae4SJohn Bampton         typeKeys("<ctrl c>");
932*b0efeae4SJohn Bampton         typeKeys("<down>");
933*b0efeae4SJohn Bampton         typeKeys("<down>");
934*b0efeae4SJohn Bampton         typeKeys("<enter>");
935*b0efeae4SJohn Bampton         typeKeys("<ctrl v>");
936*b0efeae4SJohn Bampton         typeKeys("<up>");
937*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
938*b0efeae4SJohn Bampton 
939*b0efeae4SJohn Bampton     }
940*b0efeae4SJohn Bampton 
941*b0efeae4SJohn Bampton     /**
942*b0efeae4SJohn Bampton      * insert column and verify
943*b0efeae4SJohn Bampton      *
944*b0efeae4SJohn Bampton      * @throws Exception
945*b0efeae4SJohn Bampton      */
946*b0efeae4SJohn Bampton     @Test
947*b0efeae4SJohn Bampton     public void testTableColumnInsert() throws Exception {
948*b0efeae4SJohn Bampton         writerInsertTable.ok();
949*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
950*b0efeae4SJohn Bampton         // insert column
951*b0efeae4SJohn Bampton         writer.focus();
952*b0efeae4SJohn Bampton         writer.openContextMenu();
953*b0efeae4SJohn Bampton         swTableColumnInsertMenu.select();
954*b0efeae4SJohn Bampton         swTableInsertRowColumnSetNumber.focus();
955*b0efeae4SJohn Bampton         typeKeys("<ctrl a>");
956*b0efeae4SJohn Bampton         typeKeys("<delete>");
957*b0efeae4SJohn Bampton         typeKeys("3");
958*b0efeae4SJohn Bampton         swTableInsertColumn.ok();
959*b0efeae4SJohn Bampton         // verify insert column successfully
960*b0efeae4SJohn Bampton         writer.focus();
961*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
962*b0efeae4SJohn Bampton         for (int i = 0; i < 9; i++) {
963*b0efeae4SJohn Bampton             typeKeys("<right>");
964*b0efeae4SJohn Bampton             sleep(1);
965*b0efeae4SJohn Bampton             assertTrue(tableToolbar.exists());
966*b0efeae4SJohn Bampton         }
967*b0efeae4SJohn Bampton         typeKeys("<right>");
968*b0efeae4SJohn Bampton         sleep(1);
969*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
970*b0efeae4SJohn Bampton     }
971*b0efeae4SJohn Bampton 
972*b0efeae4SJohn Bampton     /**
973*b0efeae4SJohn Bampton      * delete column and verify whether delete or not
974*b0efeae4SJohn Bampton      *
975*b0efeae4SJohn Bampton      * @throws Exception
976*b0efeae4SJohn Bampton      */
977*b0efeae4SJohn Bampton     public void testTableColumnDelete() throws Exception {
978*b0efeae4SJohn Bampton         writerInsertTable.ok();
979*b0efeae4SJohn Bampton         assertNotNull(statusBar.getItemTextById(8));
980*b0efeae4SJohn Bampton         // delete column
981*b0efeae4SJohn Bampton         writer.focus();
982*b0efeae4SJohn Bampton         writer.openContextMenu();
983*b0efeae4SJohn Bampton         swTableColumnDeleteMenu.select();
984*b0efeae4SJohn Bampton         // verify delete column
985*b0efeae4SJohn Bampton         writer.focus();
986*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
987*b0efeae4SJohn Bampton         for (int i = 0; i < 7; i++) {
988*b0efeae4SJohn Bampton             typeKeys("<right>");
989*b0efeae4SJohn Bampton             assertTrue(tableToolbar.exists());
990*b0efeae4SJohn Bampton         }
991*b0efeae4SJohn Bampton         sleep(1);
992*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
993*b0efeae4SJohn Bampton     }
994*b0efeae4SJohn Bampton 
995*b0efeae4SJohn Bampton     /**
996*b0efeae4SJohn Bampton      * split cell
997*b0efeae4SJohn Bampton      *
998*b0efeae4SJohn Bampton      * @throws Exception
999*b0efeae4SJohn Bampton      */
1000*b0efeae4SJohn Bampton     @Test
1001*b0efeae4SJohn Bampton     public void testTableCellSplit() throws Exception {
1002*b0efeae4SJohn Bampton         writerInsertTable.ok();
1003*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
1004*b0efeae4SJohn Bampton         for (int k = 0; k < 2; k++) {
1005*b0efeae4SJohn Bampton             writer.focus();
1006*b0efeae4SJohn Bampton             writer.openContextMenu();
1007*b0efeae4SJohn Bampton             swTableCellSplitMenu.select();
1008*b0efeae4SJohn Bampton             swTableCellSplitNumber.focus();
1009*b0efeae4SJohn Bampton             typeKeys("<ctrl a>");
1010*b0efeae4SJohn Bampton             typeKeys("<delete>");
1011*b0efeae4SJohn Bampton             typeKeys("2");
1012*b0efeae4SJohn Bampton             if (k == 0) {
1013*b0efeae4SJohn Bampton                 // split table cell horizontally
1014*b0efeae4SJohn Bampton                 swTableCellSplitDialog.ok();
1015*b0efeae4SJohn Bampton             } else {
1016*b0efeae4SJohn Bampton                 // split table cell
1017*b0efeae4SJohn Bampton                 swTableCellSplitVERTButton.check();
1018*b0efeae4SJohn Bampton                 // vertically
1019*b0efeae4SJohn Bampton                 swTableCellSplitDialog.ok();
1020*b0efeae4SJohn Bampton             }
1021*b0efeae4SJohn Bampton         }
1022*b0efeae4SJohn Bampton         // verify cell split successfully
1023*b0efeae4SJohn Bampton         writer.focus();
1024*b0efeae4SJohn Bampton         assertTrue(tableToolbar.exists());
1025*b0efeae4SJohn Bampton         for (int i = 0; i < 7; i++) {
1026*b0efeae4SJohn Bampton             typeKeys("<right>");
1027*b0efeae4SJohn Bampton             assertTrue(tableToolbar.exists());
1028*b0efeae4SJohn Bampton         }
1029*b0efeae4SJohn Bampton         sleep(1);
1030*b0efeae4SJohn Bampton         assertFalse(tableToolbar.exists());
1031*b0efeae4SJohn Bampton     }
1032*b0efeae4SJohn Bampton 
1033*b0efeae4SJohn Bampton     /**
1034*b0efeae4SJohn Bampton      * Test convert table to text in text document
1035*b0efeae4SJohn Bampton      *
1036*b0efeae4SJohn Bampton      * @throws Exception
1037*b0efeae4SJohn Bampton      */
1038*b0efeae4SJohn Bampton     @Test
1039*b0efeae4SJohn Bampton     public void testConvertTableToText() throws Exception {
1040*b0efeae4SJohn Bampton         writerInsertTable.ok();
1041*b0efeae4SJohn Bampton         writer.focus();
1042*b0efeae4SJohn Bampton         typeKeys("1<right>2<right>3<right>4");
1043*b0efeae4SJohn Bampton         sleep(1);
1044*b0efeae4SJohn Bampton 
1045*b0efeae4SJohn Bampton         // Convert table to text
1046*b0efeae4SJohn Bampton         app.dispatch(".uno:ConvertTableToText");
1047*b0efeae4SJohn Bampton         assertTrue("Convert Table to Text dialog pop up",
1048*b0efeae4SJohn Bampton                 writerConvertTableToTextDlg.exists());
1049*b0efeae4SJohn Bampton         // typeKeys("<enter>");
1050*b0efeae4SJohn Bampton         writerConvertTableToTextDlg.ok();
1051*b0efeae4SJohn Bampton 
1052*b0efeae4SJohn Bampton         // Verify if text is converted successfully
1053*b0efeae4SJohn Bampton         app.dispatch(".uno:SelectAll");
1054*b0efeae4SJohn Bampton         app.dispatch(".uno:Copy");
1055*b0efeae4SJohn Bampton         if (SystemUtil.isWindows())
1056*b0efeae4SJohn Bampton             assertEquals("Converted text", "1\t2\r\n3\t4\r\n",
1057*b0efeae4SJohn Bampton                     app.getClipboard());
1058*b0efeae4SJohn Bampton         else
1059*b0efeae4SJohn Bampton             assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
1060*b0efeae4SJohn Bampton     }
1061*b0efeae4SJohn Bampton }
1062*b0efeae4SJohn Bampton >>>>>>> 3309286857 (pre-commit auto remove trailing whitespace from java files (#382))
1063