xref: /trunk/test/testgui/source/fvt/gui/sw/table/TableGeneral.java (revision 83ae2205dd0b86b248ae82bfb48615c135a944fe)
180a6f5c5SLiu Zhe package fvt.gui.sw.table;
280a6f5c5SLiu Zhe 
380a6f5c5SLiu Zhe import static org.junit.Assert.*;
480a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
580a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
680a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
780a6f5c5SLiu Zhe 
880a6f5c5SLiu Zhe import org.junit.After;
980a6f5c5SLiu Zhe import org.junit.Before;
1080a6f5c5SLiu Zhe import org.junit.Ignore;
1180a6f5c5SLiu Zhe import org.junit.Rule;
1280a6f5c5SLiu Zhe import org.junit.Test;
1380a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
1480a6f5c5SLiu Zhe import org.openoffice.test.common.SystemUtil;
1580a6f5c5SLiu Zhe 
1680a6f5c5SLiu Zhe 
1780a6f5c5SLiu Zhe public class TableGeneral {
1880a6f5c5SLiu Zhe 
1980a6f5c5SLiu Zhe     @Rule
2080a6f5c5SLiu Zhe     public Logger log = Logger.getLogger(this);
2180a6f5c5SLiu Zhe 
2280a6f5c5SLiu Zhe     @Before
2380a6f5c5SLiu Zhe     public void setUp() throws Exception {
2480a6f5c5SLiu Zhe         // Start OpenOffice
2580a6f5c5SLiu Zhe         app.start();
2680a6f5c5SLiu Zhe 
2780a6f5c5SLiu Zhe         // Create a new text document
2880a6f5c5SLiu Zhe         app.dispatch("private:factory/swriter");
2980a6f5c5SLiu Zhe 
3080a6f5c5SLiu Zhe         // Insert a table
3180a6f5c5SLiu Zhe         app.dispatch(".uno:InsertTable");
3280a6f5c5SLiu Zhe         assertTrue("Insert Table dialog pop up", writerInsertTable.exists());
3380a6f5c5SLiu Zhe     }
3480a6f5c5SLiu Zhe 
3580a6f5c5SLiu Zhe     @After
3680a6f5c5SLiu Zhe     public void tearDown() throws Exception {
3780a6f5c5SLiu Zhe         app.close();
3880a6f5c5SLiu Zhe     }
3980a6f5c5SLiu Zhe 
4080a6f5c5SLiu Zhe     @Test
4180a6f5c5SLiu Zhe     // Test setting table size in text document
4280a6f5c5SLiu Zhe     public void testTableSize() throws Exception {
4380a6f5c5SLiu Zhe 
4480a6f5c5SLiu Zhe         swTableSizeColBox.focus();
4580a6f5c5SLiu Zhe         typeKeys("<delete>");
4680a6f5c5SLiu Zhe         typeKeys("3");
4780a6f5c5SLiu Zhe         swTableSizeRowBox.focus();
4880a6f5c5SLiu Zhe         typeKeys("<delete>");
4980a6f5c5SLiu Zhe         typeKeys("4");
5080a6f5c5SLiu Zhe         writerInsertTable.ok();
5180a6f5c5SLiu Zhe 
5280a6f5c5SLiu Zhe         writer.focus(); // verify how many rows in the table
5380a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
5480a6f5c5SLiu Zhe         for (int i = 0; i < 3; i++) {
5580a6f5c5SLiu Zhe             typeKeys("<down>");
5680a6f5c5SLiu Zhe             assertNotNull(statusBar.getItemTextById(8));
5780a6f5c5SLiu Zhe         }
5880a6f5c5SLiu Zhe         typeKeys("<down>");
5980a6f5c5SLiu Zhe         sleep(1);
6080a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
6180a6f5c5SLiu Zhe     }
6280a6f5c5SLiu Zhe 
6380a6f5c5SLiu Zhe     // Test setting table cell background in text document
6480a6f5c5SLiu Zhe 
6580a6f5c5SLiu Zhe     @Test
66*83ae2205SHerbert Dürr     @Ignore("Bug #120378")
6780a6f5c5SLiu Zhe     public void testTableBackground() throws Exception {
6880a6f5c5SLiu Zhe         writerInsertTable.ok();
6980a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
7080a6f5c5SLiu Zhe         writer.focus();
7180a6f5c5SLiu Zhe         // set table cell background
7280a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
7380a6f5c5SLiu Zhe         swTableBackground.select();
7480a6f5c5SLiu Zhe         assertTrue("Table background property dialog pop up",
7580a6f5c5SLiu Zhe                 swTableBackground.exists());
7680a6f5c5SLiu Zhe         ;
7780a6f5c5SLiu Zhe         swTableBackgroundColor.focus();
7880a6f5c5SLiu Zhe         swTableBackgroundColor.click(50, 50);
7980a6f5c5SLiu Zhe         swTableBackground.ok();
8080a6f5c5SLiu Zhe         // verify table cell background color
8180a6f5c5SLiu Zhe         writer.focus();
8280a6f5c5SLiu Zhe         // select the cell which is filled with color
8380a6f5c5SLiu Zhe         app.dispatch(".uno:EntireCell");
8480a6f5c5SLiu Zhe 
8580a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
8680a6f5c5SLiu Zhe         app.dispatch("private:factory/simpress?slot=6686");
8780a6f5c5SLiu Zhe         presentationWizard.ok();
8880a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
8980a6f5c5SLiu Zhe         // enable table cell area format dialog
9080a6f5c5SLiu Zhe         app.dispatch(".uno:FormatArea");
9180a6f5c5SLiu Zhe         sleep(1);
9280a6f5c5SLiu Zhe         assertEquals("Light red", sdTableBACGColorListbox.getSelText());
9380a6f5c5SLiu Zhe         // close table cell area format dialog
9480a6f5c5SLiu Zhe         sdTableBACGColorArea.cancel();
9580a6f5c5SLiu Zhe     }
9680a6f5c5SLiu Zhe 
9780a6f5c5SLiu Zhe     // Test setting table border in text document
9880a6f5c5SLiu Zhe 
9980a6f5c5SLiu Zhe     @Test
10080a6f5c5SLiu Zhe     public void testTableBorder() throws Exception {
10180a6f5c5SLiu Zhe         writerInsertTable.ok();
10280a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
10380a6f5c5SLiu Zhe         // set table border as none
10480a6f5c5SLiu Zhe         writer.focus();
10580a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
10680a6f5c5SLiu Zhe         swTableBorder.select();
10780a6f5c5SLiu Zhe         assertTrue("Table border property dialog pop up",
10880a6f5c5SLiu Zhe                 swTableBorder.exists());
10980a6f5c5SLiu Zhe         ;
11080a6f5c5SLiu Zhe         swTableBorderLineArrange.click(10, 10);
11180a6f5c5SLiu Zhe         swTableBorder.ok();
11280a6f5c5SLiu Zhe     }
11380a6f5c5SLiu Zhe 
11480a6f5c5SLiu Zhe     // Test setting table border line style,line color,spacing to content in
11580a6f5c5SLiu Zhe     // text document
11680a6f5c5SLiu Zhe 
11780a6f5c5SLiu Zhe     @Test
11880a6f5c5SLiu Zhe     public void testTableBorderLineStyle() throws Exception {
11980a6f5c5SLiu Zhe         writerInsertTable.ok();
12080a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
12180a6f5c5SLiu Zhe         writer.focus();
12280a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
12380a6f5c5SLiu Zhe         swTableBorder.select();
12480a6f5c5SLiu Zhe         assertTrue("Table border property dialog pop up",
12580a6f5c5SLiu Zhe                 swTableBorder.exists());
12680a6f5c5SLiu Zhe         ;
12780a6f5c5SLiu Zhe         swTableBorderLineStyle.select(8); // set line style
12880a6f5c5SLiu Zhe         swTableBorderLineColor.select(5); // set line color
12980a6f5c5SLiu Zhe         swTableSTCLeft.focus(); // set spacing to content
13080a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
13180a6f5c5SLiu Zhe         typeKeys("<delete>");
13280a6f5c5SLiu Zhe         typeKeys("0.5"); // set spacing to content
13380a6f5c5SLiu Zhe         swTableShadow.click(40, 10); // set table shadow
13480a6f5c5SLiu Zhe         swTableShadowSize.focus();
13580a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
13680a6f5c5SLiu Zhe         typeKeys("<delete>");
13780a6f5c5SLiu Zhe         typeKeys("2");
13880a6f5c5SLiu Zhe         swTableShadowColor.select(5);
13980a6f5c5SLiu Zhe         swTableBorder.ok();
14080a6f5c5SLiu Zhe 
14180a6f5c5SLiu Zhe         writer.focus(); // verify the setting property of table
14280a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
14380a6f5c5SLiu Zhe         swTableBorder.select();
14480a6f5c5SLiu Zhe         assertEquals("2.60 pt", swTableBorderLineStyle.getItemText(8));
14580a6f5c5SLiu Zhe         assertEquals("Magenta", swTableBorderLineColor.getItemText(5));
14680a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCLeft.getText());
14780a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCRight.getText());
14880a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCTop.getText());
14980a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCBottom.getText());
15080a6f5c5SLiu Zhe         assertEquals("1.97\"", swTableShadowSize.getText());
15180a6f5c5SLiu Zhe         assertEquals("Magenta", swTableShadowColor.getItemText(5));
15280a6f5c5SLiu Zhe         assertTrue("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
15380a6f5c5SLiu Zhe         swTableBorder.close();
15480a6f5c5SLiu Zhe 
15580a6f5c5SLiu Zhe         // uncheck Synchronize box and set spacing to content
15680a6f5c5SLiu Zhe 
15780a6f5c5SLiu Zhe         writer.focus();
15880a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
15980a6f5c5SLiu Zhe         swTableBorder.select();
16080a6f5c5SLiu Zhe         swTableSTCSYNC.uncheck();
16180a6f5c5SLiu Zhe         swTableSTCLeft.focus();// set left spacing to content
16280a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
16380a6f5c5SLiu Zhe         typeKeys("<delete>");
16480a6f5c5SLiu Zhe         typeKeys("0.5");
16580a6f5c5SLiu Zhe         swTableSTCRight.focus();// set right spacing to content
16680a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
16780a6f5c5SLiu Zhe         typeKeys("<delete>");
16880a6f5c5SLiu Zhe         typeKeys("0.8");
16980a6f5c5SLiu Zhe         swTableSTCTop.focus();// set top spacing to content
17080a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
17180a6f5c5SLiu Zhe         typeKeys("<delete>");
17280a6f5c5SLiu Zhe         typeKeys("1.0");
17380a6f5c5SLiu Zhe         swTableSTCBottom.focus();// set bottom spacing to content
17480a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
17580a6f5c5SLiu Zhe         typeKeys("<delete>");
17680a6f5c5SLiu Zhe         typeKeys("2");
17780a6f5c5SLiu Zhe         swTableBorder.ok();
17880a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
17980a6f5c5SLiu Zhe 
18080a6f5c5SLiu Zhe         writer.focus(); // verify the setting value of spacing to content for
18180a6f5c5SLiu Zhe                         // tabel
18280a6f5c5SLiu Zhe         app.dispatch(".uno:TableDialog");
18380a6f5c5SLiu Zhe         swTableBorder.select();
18480a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSTCLeft.getText());
18580a6f5c5SLiu Zhe         assertEquals("0.80\"", swTableSTCRight.getText());
18680a6f5c5SLiu Zhe         assertEquals("1.00\"", swTableSTCTop.getText());
18780a6f5c5SLiu Zhe         assertEquals("1.97\"", swTableSTCBottom.getText());
18880a6f5c5SLiu Zhe         assertFalse("SWTableSTC_SYNC", swTableSTCSYNC.isChecked());
18980a6f5c5SLiu Zhe         swTableBorder.close();
19080a6f5c5SLiu Zhe     }
19180a6f5c5SLiu Zhe 
19280a6f5c5SLiu Zhe     // create table with auto format
19380a6f5c5SLiu Zhe 
19480a6f5c5SLiu Zhe     @Test
19580a6f5c5SLiu Zhe     public void testTableAutoFormat() throws Exception {
19680a6f5c5SLiu Zhe         // create table with auto format
19780a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
19880a6f5c5SLiu Zhe         assertTrue("Table auto format dialog pop up", swTableAutoFMT.exists());
19980a6f5c5SLiu Zhe         swTableAutoFormatListbox.select(3);
20080a6f5c5SLiu Zhe         swTableAutoFMT.ok();
20180a6f5c5SLiu Zhe         // verify the auto format is that just selected
20280a6f5c5SLiu Zhe         button("sw:PushButton:DLG_INSERT_TABLE:BT_AUTOFORMAT").click();
20380a6f5c5SLiu Zhe         assertEquals("Blue", swTableAutoFormatListbox.getSelText());
20480a6f5c5SLiu Zhe         swTableAutoFMT.close();
20580a6f5c5SLiu Zhe         writerInsertTable.ok();
20680a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
20780a6f5c5SLiu Zhe 
20880a6f5c5SLiu Zhe     }
20980a6f5c5SLiu Zhe 
21080a6f5c5SLiu Zhe     // set row height and select row,insert/delete row
21180a6f5c5SLiu Zhe 
21280a6f5c5SLiu Zhe     @Test
21380a6f5c5SLiu Zhe     public void testTableRowHeight() throws Exception {
21480a6f5c5SLiu Zhe         writerInsertTable.ok();
21580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
21680a6f5c5SLiu Zhe 
21780a6f5c5SLiu Zhe         // set row height
21880a6f5c5SLiu Zhe         writer.focus();
21980a6f5c5SLiu Zhe         writer.openContextMenu();
22080a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
22180a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
22280a6f5c5SLiu Zhe         swTableSetRowHeight.focus();
22380a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
22480a6f5c5SLiu Zhe         typeKeys("<delete>");
22580a6f5c5SLiu Zhe         typeKeys("0.5");
22680a6f5c5SLiu Zhe         swTableSetRowHeightDialog.ok();
22780a6f5c5SLiu Zhe 
22880a6f5c5SLiu Zhe         // verify row height
22980a6f5c5SLiu Zhe         writer.focus();
23080a6f5c5SLiu Zhe         writer.openContextMenu();
23180a6f5c5SLiu Zhe         swTableRowHeightMenu.select();
23280a6f5c5SLiu Zhe         assertTrue(swTableSetRowHeightDialog.exists());
23380a6f5c5SLiu Zhe         assertEquals("0.50\"", swTableSetRowHeight.getText());
23480a6f5c5SLiu Zhe         swTableSetRowHeightDialog.close();
23580a6f5c5SLiu Zhe     }
23680a6f5c5SLiu Zhe 
23780a6f5c5SLiu Zhe     // select row
23880a6f5c5SLiu Zhe     @Test
23980a6f5c5SLiu Zhe     public void testTableSelectRow() throws Exception {
24080a6f5c5SLiu Zhe         writerInsertTable.ok();
24180a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
24280a6f5c5SLiu Zhe         // select row
24380a6f5c5SLiu Zhe         writer.focus();
24480a6f5c5SLiu Zhe         writer.openContextMenu();
24580a6f5c5SLiu Zhe         swTableSelectRowMenu.select();
24680a6f5c5SLiu Zhe 
24780a6f5c5SLiu Zhe         // verify select one row successfully
24880a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
24980a6f5c5SLiu Zhe         typeKeys("<down>");
25080a6f5c5SLiu Zhe         typeKeys("<down>");
25180a6f5c5SLiu Zhe         typeKeys("<enter>");
25280a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
25380a6f5c5SLiu Zhe         typeKeys("<up>");
25480a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
25580a6f5c5SLiu Zhe 
25680a6f5c5SLiu Zhe     }
25780a6f5c5SLiu Zhe 
25880a6f5c5SLiu Zhe     // insert row and verify how many row inserted
25980a6f5c5SLiu Zhe     @Test
26080a6f5c5SLiu Zhe     public void testTableInsertRow() throws Exception {
26180a6f5c5SLiu Zhe         writerInsertTable.ok();
26280a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
26380a6f5c5SLiu Zhe         writer.focus();
26480a6f5c5SLiu Zhe         writer.openContextMenu();
26580a6f5c5SLiu Zhe         swTableInsertRowMenu.select();
26680a6f5c5SLiu Zhe         assertTrue("SWTable_InsertRow Dialog pop up",
26780a6f5c5SLiu Zhe                 swTableInsertRow.exists());
26880a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
26980a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
27080a6f5c5SLiu Zhe         typeKeys("<delete>");
27180a6f5c5SLiu Zhe         typeKeys("3");
27280a6f5c5SLiu Zhe         swTableInsertRow.ok();
27380a6f5c5SLiu Zhe 
27480a6f5c5SLiu Zhe         writer.focus(); // verify how many rows in the table
27580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
27680a6f5c5SLiu Zhe         for (int i = 0; i < 4; i++) {
27780a6f5c5SLiu Zhe             typeKeys("<down>");
27880a6f5c5SLiu Zhe             assertNotNull(statusBar.getItemTextById(8));
27980a6f5c5SLiu Zhe         }
28080a6f5c5SLiu Zhe         typeKeys("<down>");
28180a6f5c5SLiu Zhe         sleep(1);
28280a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
28380a6f5c5SLiu Zhe     }
28480a6f5c5SLiu Zhe 
28580a6f5c5SLiu Zhe     // delete row and verify row
28680a6f5c5SLiu Zhe     @Test
28780a6f5c5SLiu Zhe     public void testTableRowDelete() throws Exception {
28880a6f5c5SLiu Zhe         writerInsertTable.ok();
28980a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
29080a6f5c5SLiu Zhe         // delete row
29180a6f5c5SLiu Zhe         writer.focus();
29280a6f5c5SLiu Zhe         writer.openContextMenu();
29380a6f5c5SLiu Zhe         swTableRowDleteMenu.select();
29480a6f5c5SLiu Zhe         // verify whether delete row
29580a6f5c5SLiu Zhe         writer.focus();
29680a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
29780a6f5c5SLiu Zhe         typeKeys("<down>");
29880a6f5c5SLiu Zhe         sleep(1);
29980a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
30080a6f5c5SLiu Zhe 
30180a6f5c5SLiu Zhe     }
30280a6f5c5SLiu Zhe 
30380a6f5c5SLiu Zhe     // set column width and verify
30480a6f5c5SLiu Zhe     @Test
30580a6f5c5SLiu Zhe     public void testTableColumnWidth() throws Exception {
30680a6f5c5SLiu Zhe         writerInsertTable.ok();
30780a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
30880a6f5c5SLiu Zhe         // set column width
30980a6f5c5SLiu Zhe         writer.focus();
31080a6f5c5SLiu Zhe         writer.openContextMenu();
31180a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
31280a6f5c5SLiu Zhe         swTableSetColumnWidth.focus();
31380a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
31480a6f5c5SLiu Zhe         typeKeys("<delete>");
31580a6f5c5SLiu Zhe         typeKeys("2");
31680a6f5c5SLiu Zhe         swTableSetColumnDialog.ok();
31780a6f5c5SLiu Zhe         // verify column width
31880a6f5c5SLiu Zhe         writer.focus();
31980a6f5c5SLiu Zhe         writer.openContextMenu();
32080a6f5c5SLiu Zhe         swTableColumnWidthMenu.select();
32180a6f5c5SLiu Zhe         assertEquals("2.00\"", swTableSetColumnWidth.getText());
32280a6f5c5SLiu Zhe 
32380a6f5c5SLiu Zhe     }
32480a6f5c5SLiu Zhe 
32580a6f5c5SLiu Zhe     // select column and verify
32680a6f5c5SLiu Zhe     @Test
32780a6f5c5SLiu Zhe     public void testTableColumnSelect() throws Exception {
32880a6f5c5SLiu Zhe         writerInsertTable.ok();
32980a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
33080a6f5c5SLiu Zhe         writer.focus();
33180a6f5c5SLiu Zhe         writer.openContextMenu();
33280a6f5c5SLiu Zhe         swTableColumnSelectMenu.select();
33380a6f5c5SLiu Zhe 
33480a6f5c5SLiu Zhe         // verify select one column
33580a6f5c5SLiu Zhe         typeKeys("<ctrl c>");
33680a6f5c5SLiu Zhe         typeKeys("<down>");
33780a6f5c5SLiu Zhe         typeKeys("<down>");
33880a6f5c5SLiu Zhe         typeKeys("<enter>");
33980a6f5c5SLiu Zhe         typeKeys("<ctrl v>");
34080a6f5c5SLiu Zhe         typeKeys("<up>");
34180a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
34280a6f5c5SLiu Zhe 
34380a6f5c5SLiu Zhe     }
34480a6f5c5SLiu Zhe 
34580a6f5c5SLiu Zhe     // insert column and verify
34680a6f5c5SLiu Zhe     @Test
34780a6f5c5SLiu Zhe     public void testTableColumnInsert() throws Exception {
34880a6f5c5SLiu Zhe         writerInsertTable.ok();
34980a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
35080a6f5c5SLiu Zhe         // insert column
35180a6f5c5SLiu Zhe         writer.focus();
35280a6f5c5SLiu Zhe         writer.openContextMenu();
35380a6f5c5SLiu Zhe         swTableColumnInsertMenu.select();
35480a6f5c5SLiu Zhe         swTableInsertRowColumnSetNumber.focus();
35580a6f5c5SLiu Zhe         typeKeys("<ctrl a>");
35680a6f5c5SLiu Zhe         typeKeys("<delete>");
35780a6f5c5SLiu Zhe         typeKeys("3");
35880a6f5c5SLiu Zhe         swTableInsertColumn.ok();
35980a6f5c5SLiu Zhe         // verify insert column successfully
36080a6f5c5SLiu Zhe         writer.focus();
36180a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
36280a6f5c5SLiu Zhe         for (int i = 0; i < 9; i++) {
36380a6f5c5SLiu Zhe             typeKeys("<right>");
36480a6f5c5SLiu Zhe             sleep(1);
36580a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
36680a6f5c5SLiu Zhe         }
36780a6f5c5SLiu Zhe         typeKeys("<right>");
36880a6f5c5SLiu Zhe         sleep(1);
36980a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
37080a6f5c5SLiu Zhe     }
37180a6f5c5SLiu Zhe 
37280a6f5c5SLiu Zhe     // delete column and verify whether delete or not
37380a6f5c5SLiu Zhe     public void testTableColumnDelete() throws Exception {
37480a6f5c5SLiu Zhe         writerInsertTable.ok();
37580a6f5c5SLiu Zhe         assertNotNull(statusBar.getItemTextById(8));
37680a6f5c5SLiu Zhe         // delete column
37780a6f5c5SLiu Zhe         writer.focus();
37880a6f5c5SLiu Zhe         writer.openContextMenu();
37980a6f5c5SLiu Zhe         swTableColumnDeleteMenu.select();
38080a6f5c5SLiu Zhe         // verify delete column
38180a6f5c5SLiu Zhe         writer.focus();
38280a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
38380a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
38480a6f5c5SLiu Zhe             typeKeys("<right>");
38580a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
38680a6f5c5SLiu Zhe         }
38780a6f5c5SLiu Zhe         sleep(1);
38880a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
38980a6f5c5SLiu Zhe     }
39080a6f5c5SLiu Zhe 
39180a6f5c5SLiu Zhe     // split cell
39280a6f5c5SLiu Zhe     @Test
39380a6f5c5SLiu Zhe     public void testTableCellSplit() throws Exception {
39480a6f5c5SLiu Zhe         writerInsertTable.ok();
39580a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
39680a6f5c5SLiu Zhe         for (int k = 0; k < 2; k++) {
39780a6f5c5SLiu Zhe             writer.focus();
39880a6f5c5SLiu Zhe             writer.openContextMenu();
39980a6f5c5SLiu Zhe             swTableCellSplitMenu.select();
40080a6f5c5SLiu Zhe             swTableCellSplitNumber.focus();
40180a6f5c5SLiu Zhe             typeKeys("<ctrl a>");
40280a6f5c5SLiu Zhe             typeKeys("<delete>");
40380a6f5c5SLiu Zhe             typeKeys("2");
40480a6f5c5SLiu Zhe             if (k == 0) {
40580a6f5c5SLiu Zhe                 swTableCellSplitDialog.ok(); // split table cell horizontally
40680a6f5c5SLiu Zhe             } else {
40780a6f5c5SLiu Zhe                 swTableCellSplitVERTButton.check(); // split table cell
40880a6f5c5SLiu Zhe                 // vertically
40980a6f5c5SLiu Zhe                 swTableCellSplitDialog.ok();
41080a6f5c5SLiu Zhe             }
41180a6f5c5SLiu Zhe         }
41280a6f5c5SLiu Zhe         // verify cell split successfully
41380a6f5c5SLiu Zhe         writer.focus();
41480a6f5c5SLiu Zhe         assertTrue(tableToolbar.exists());
41580a6f5c5SLiu Zhe         for (int i = 0; i < 7; i++) {
41680a6f5c5SLiu Zhe             typeKeys("<right>");
41780a6f5c5SLiu Zhe             assertTrue(tableToolbar.exists());
41880a6f5c5SLiu Zhe         }
41980a6f5c5SLiu Zhe         sleep(1);
42080a6f5c5SLiu Zhe         assertFalse(tableToolbar.exists());
42180a6f5c5SLiu Zhe     }
42280a6f5c5SLiu Zhe 
42380a6f5c5SLiu Zhe     /**
42480a6f5c5SLiu Zhe      * Test convert table to text in text document
42580a6f5c5SLiu Zhe      *
42680a6f5c5SLiu Zhe      * @throws Exception
42780a6f5c5SLiu Zhe      */
42880a6f5c5SLiu Zhe     @Test
42980a6f5c5SLiu Zhe     public void testConvertTableToText() throws Exception {
43080a6f5c5SLiu Zhe         writerInsertTable.ok();
43180a6f5c5SLiu Zhe         writer.focus();
43280a6f5c5SLiu Zhe         typeKeys("1<right>2<right>3<right>4");
43380a6f5c5SLiu Zhe         sleep(1);
43480a6f5c5SLiu Zhe 
43580a6f5c5SLiu Zhe         // Convert table to text
43680a6f5c5SLiu Zhe         app.dispatch(".uno:ConvertTableToText");
43780a6f5c5SLiu Zhe         assertTrue("Convert Table to Text dialog pop up", writerConvertTableToTextDlg.exists());
43880a6f5c5SLiu Zhe         // typeKeys("<enter>");
43980a6f5c5SLiu Zhe         writerConvertTableToTextDlg.ok(); // "Enter" does not work on linux
44080a6f5c5SLiu Zhe 
44180a6f5c5SLiu Zhe         // Verify if text is converted successfully
44280a6f5c5SLiu Zhe         app.dispatch(".uno:SelectAll");
44380a6f5c5SLiu Zhe         app.dispatch(".uno:Copy");
44480a6f5c5SLiu Zhe         if (SystemUtil.isWindows())
44580a6f5c5SLiu Zhe             assertEquals("Converted text", "1\t2\r\n3\t4\r\n", app.getClipboard()); // in
44680a6f5c5SLiu Zhe                                                                                     // windows,
44780a6f5c5SLiu Zhe                                                                                     // \n
44880a6f5c5SLiu Zhe                                                                                     // is
44980a6f5c5SLiu Zhe                                                                                     // \r\n
45080a6f5c5SLiu Zhe         else
45180a6f5c5SLiu Zhe             assertEquals("Converted text", "1\t2\n3\t4\n", app.getClipboard());
45280a6f5c5SLiu Zhe     }
45380a6f5c5SLiu Zhe }
454