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