1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 /** 23 * 24 */ 25 package bvt.gui; 26 27 import static org.junit.Assert.*; 28 import static org.openoffice.test.common.Testspace.*; 29 import static org.openoffice.test.vcl.Tester.*; 30 import static testlib.gui.AppTool.*; 31 import static testlib.gui.UIMap.*; 32 33 import java.awt.Rectangle; 34 import java.io.File; 35 36 import org.junit.AfterClass; 37 import org.junit.Before; 38 import org.junit.BeforeClass; 39 import org.junit.Rule; 40 import org.junit.Test; 41 import org.openoffice.test.common.FileUtil; 42 import org.openoffice.test.common.GraphicsUtil; 43 import org.openoffice.test.common.Logger; 44 45 import testlib.gui.SCTool; 46 47 /** 48 * 49 */ 50 public class BasicFunctionTest { 51 52 @Rule 53 public Logger log = Logger.getLogger(this); 54 55 @BeforeClass 56 public static void beforeClass() { 57 app.clean(); 58 } 59 60 @AfterClass 61 public static void afterClass() { 62 app.stop(); 63 } 64 65 @Before 66 public void before() { 67 app.stop(); 68 app.start(); 69 } 70 71 72 @Test 73 public void smokeTest() { 74 File smoketestOutput = new File(aoo.getUserInstallation(), "user/temp"); 75 prepareData("TestExtension.oxt"); 76 // Open sample file smoketestdoc.sxw 77 open(prepareData("smoketestdoc.sxw")); 78 writer.waitForEnabled(10, 2); 79 // Run test cases 80 app.dispatch("vnd.sun.star.script:Standard.Global.StartTestWithDefaultOptions?language=Basic&location=document", 120); 81 String smoketestlog = FileUtil.readFileAsString(new File(smoketestOutput, "smoketest.log")); 82 String testclosurelog = FileUtil.readFileAsString(new File(smoketestOutput, "testclosure.log")); 83 log.info(smoketestlog + "\n" + testclosurelog); 84 assertTrue("No Error", !smoketestlog.contains("error") && !testclosurelog.contains("error")); 85 86 } 87 88 @Test 89 public void testExportAsPDF() throws Exception { 90 String file = prepareData("bvt/pdf.odt"); 91 String exportTo1 = getPath("temp/1.pdf"); 92 String exportTo2 = getPath("temp/2.pdf"); 93 deleteFile(exportTo1); 94 deleteFile(exportTo2); 95 open(file); 96 writer.waitForExistence(10, 1); 97 app.dispatch(".uno:ExportToPDF"); 98 pdfGeneralPage.ok(); 99 submitSaveDlg(exportTo1); 100 sleep(1); 101 String magic = FileUtil.readFileAsString(exportTo1).substring(0, 4); 102 assertEquals("PDF is exported?", "%PDF", magic); 103 104 button(".uno:ExportDirectToPDF").click();//Click via toolbar 105 submitSaveDlg(exportTo2); 106 sleep(1); 107 magic = FileUtil.readFileAsString(exportTo2).substring(0, 4); 108 assertEquals("PDF is exported directly?", "%PDF", magic); 109 } 110 111 /** 112 * Test the File -- Print Dialog show 113 * 114 */ 115 @Test 116 public void testPrinter() { 117 // Create a new text document 118 newTextDocument(); 119 app.dispatch(".uno:PrinterSetup"); 120 if (activeMsgBox.exists(2)) 121 activeMsgBox.ok(); 122 123 // PrintService[] ps = PrintServiceLookup.lookupPrintServices(null, null); 124 // String[] names = new String[ps.length]; 125 // for (int i = 0; i < ps.length; i++) { 126 // names[i] = ps[i].getName(); 127 // } 128 // 129 // assertArrayEquals("Printers Names", names, printerSetUpDlgPrinterNames.getItemsText()); 130 assertTrue("Printer Setup dialog appears", printerSetUpDlg.exists(3)); 131 printerSetUpDlg.cancel(); 132 } 133 134 /** 135 * Test the File -- Java Dialog show 136 * 137 */ 138 // @Test 139 // public void testJavaDialog() { 140 // 141 // // Create a new text document and launch a Wizards dialog which need JVM 142 // // work correctly. 143 // app.dispatch("private:factory/swriter"); 144 // File tempfile = new File(oo.getUserInstallation(), "user/template/myAgendaTemplate.ott"); 145 // FileUtil.deleteFile(tempfile); 146 // sleep(3); 147 // app.dispatch("service:com.sun.star.wizards.agenda.CallWizard?start"); 148 // sleep(5); 149 // assertTrue(Wizards_AgendaDialog.exists(10)); 150 // Wizards_AgendaDialog_FinishButton.click(); 151 // sleep(10); 152 // writer.focus(); 153 // sleep(1); 154 // app.dispatch(".uno:SelectAll"); 155 // typeKeys("<$copy>"); 156 // // System.out.println("now txt:"+app.getClipboard()); 157 // // assertTrue(app.getClipboard().startsWith("<Name>")); 158 // assertNotNull(app.getClipboard()); 159 // } 160 161 /** 162 * Test the Tools / Macros / Organize Dialogs" show 163 * 164 */ 165 @Test 166 public void testRunMacro() { 167 open(prepareData("bvt/macro.ods")); 168 calc.waitForExistence(10, 2); 169 app.dispatch(".uno:RunMacro"); 170 runMacroDlgCategories.expand("macro.ods"); 171 runMacroDlgCategories.expand("Standard"); 172 runMacroDlgCategories.select("Module1"); 173 runMacroDlgCommands.select(0); 174 runMacroDlg.ok(); 175 assertEquals("A3 should be =1+3", "4", SCTool.getCellText("A3")); 176 discard(); 177 } 178 179 /** 180 * Test the About Dialog show 181 * 182 */ 183 @Test 184 public void testHelp() { 185 app.dispatch(".uno:About"); 186 assertTrue(aboutDialog.exists(5)); 187 aboutDialog.ok(); 188 sleep(1); 189 typeKeys("<F1>"); 190 assertTrue(helpWindow.exists(5)); 191 helpWindow.close(); 192 } 193 194 /** 195 * Test inserting a picture in text document 196 * 197 * @throws Exception 198 */ 199 200 @Test 201 public void testInsertPictureInDocument() throws Exception { 202 String bmp_green = prepareData("image/green_256x256.bmp"); 203 String bmp_red = prepareData("image/red_256x256.bmp"); 204 205 // Create a new text document 206 newTextDocument(); 207 // Insert a picture fully filled with green 208 app.dispatch(".uno:InsertGraphic"); 209 submitOpenDlg(bmp_green); 210 writer.click(5,200); 211 sleep(1); 212 213 // Verify if the picture is inserted successfully 214 Rectangle rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFF00FF00); 215 assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10); 216 // insert another picture 217 app.dispatch(".uno:InsertGraphic"); 218 submitOpenDlg(bmp_red); 219 writer.click(5, 200); 220 sleep(1); 221 // Verify if the picture is inserted successfully 222 rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFFFF0000); 223 assertTrue("Green Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10); 224 discard(); 225 } 226 227 @Test 228 public void testInsertPictureInSpreadsheet() throws Exception { 229 String bmp_green = prepareData("image/green_64x64.png"); 230 String bmp_red = prepareData("image/red_64x64.png"); 231 newSpreadsheet(); 232 // Insert a picture fully filled with green 233 app.dispatch(".uno:InsertGraphic"); 234 submitOpenDlg(bmp_green); 235 calc.click(5, 150); 236 sleep(1); 237 238 // Verify if the picture is inserted successfully 239 Rectangle rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFF00FF00); 240 assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10); 241 242 SCTool.selectRange("C1"); 243 // insert another picture 244 app.dispatch(".uno:InsertGraphic"); 245 submitOpenDlg(bmp_red); 246 calc.click(5, 150); 247 sleep(1); 248 // Verify if the picture is inserted successfully 249 rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFFFF0000); 250 assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10); 251 discard(); 252 } 253 254 @Test 255 public void testInsertPictureInPresentation() throws Exception { 256 String bmp_green = prepareData("image/green_256x256.bmp"); 257 String bmp_red = prepareData("image/red_256x256.bmp"); 258 newPresentation(); 259 // Insert a picture fully filled with green 260 app.dispatch(".uno:InsertGraphic"); 261 submitOpenDlg(bmp_green); 262 impress.click(5, 5); 263 sleep(1); 264 265 // Verify if the picture is inserted successfully 266 Rectangle rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFF00FF00); 267 assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10); 268 // insert another picture 269 app.dispatch(".uno:InsertGraphic"); 270 submitOpenDlg(bmp_red); 271 impress.click(1, 1); 272 sleep(1); 273 // Verify if the picture is inserted successfully 274 rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFFFF0000); 275 assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10); 276 discard(); 277 } 278 279 @Test 280 public void testSlideShow() throws Exception { 281 open(prepareData("bvt/slideshow.odp")); 282 impress.waitForExistence(10, 2); 283 sleep(1); 284 impress.typeKeys("<F5>"); 285 sleep(3); 286 Rectangle rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFFFF0000); 287 assertNotNull("1st slide appears", rectangle); 288 slideShow.click(0.5, 0.5); 289 sleep(2); 290 rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF00FF00); 291 assertNotNull("2nd slide appears", rectangle); 292 typeKeys("<enter>"); 293 sleep(2); 294 rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF); 295 assertNotNull("3rd slide appears", rectangle); 296 slideShow.click(0.5, 0.5); 297 sleep(2); 298 rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF); 299 assertNull("The end", rectangle); 300 slideShow.click(0.5, 0.5); 301 sleep(3); 302 assertFalse("Quit", slideShow.exists()); 303 } 304 305 @Test 306 public void testFind() { 307 open(prepareData("bvt/find.odt")); 308 writer.waitForExistence(10, 2); 309 app.dispatch(".uno:SearchDialog"); 310 findDlgFor.setText("OpenOffice"); 311 findDlgFind.click(); 312 sleep(1); 313 writer.typeKeys("<$copy>"); 314 assertEquals("OpenOffice", app.getClipboard()); 315 findDlgFindAll.click(); 316 sleep(1); 317 writer.typeKeys("<$copy>"); 318 assertEquals("OpenOfficeOpenOfficeOpenOffice", app.getClipboard()); 319 findDlgReplaceWith.setText("Awesome OpenOffice"); 320 findDlgReplaceAll.click(); 321 sleep(1); 322 msgbox("Search key replaced 3 times.").ok(); 323 findDlg.close(); 324 sleep(1); 325 assertEquals( 326 "Apache Awesome OpenOffice is comprised of six personal productivity applications: a word processor (and its web-authoring component), spreadsheet, presentation graphics, drawing, equation editor, and database. Awesome OpenOffice is released on Windows, Solaris, Linux and Macintosh operation systems, with more communities joining, including a mature FreeBSD port. Awesome OpenOffice is localized, supporting over 110 languages worldwide. ", 327 copyAll()); 328 discard(); 329 } 330 331 @Test 332 public void testFindFormulasAndValues() { 333 open(prepareData("bvt/searchFormulasValues.ods")); 334 calc.waitForExistence(10, 2); 335 336 // Searching for 2003 by formula finds A2 337 SCTool.selectRange("A1"); 338 app.dispatch(".uno:SearchDialog"); 339 findDlgFor.setText("2003"); 340 findDlgMore.click(); 341 findDlgCalcSearchIn.select("Formulas"); 342 findDlgFind.click(); 343 sleep(1); 344 assertEquals("wrong cell found for formulas search", "A2", scInputBarPosition.getText()); 345 findDlg.close(); 346 347 // Searching for October by value finds A2 348 SCTool.selectRange("A1"); 349 app.dispatch(".uno:SearchDialog"); 350 findDlgFor.setText("October"); 351 findDlgMore.click(); 352 findDlgCalcSearchIn.select("Values"); 353 findDlgFind.click(); 354 sleep(1); 355 assertEquals("wrong cell found for values search", "A2", scInputBarPosition.getText()); 356 findDlg.close(); 357 358 discard(); 359 } 360 361 @Test 362 public void testFillInSpreadsheet() { 363 String[][] expected1 = new String[][] { { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, }; 364 String[][] expected2 = new String[][] { { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, }; 365 String[][] expected3 = new String[][] { { "Hi friends", "Hi friends", "Hi friends", "Hi friends" } }; 366 String[][] expected4 = new String[][] { { "99999.999", "99999.999", "99999.999", "99999.999" } }; 367 String[][] expected5 = new String[][] { 368 { "99999.999", "-10" }, { "100000.999", "-9" }, { "100001.999", "-8" }, { "100002.999", "-7" }, { "100003.999", "-6" } 369 }; 370 newSpreadsheet(); 371 SCTool.selectRange("C5"); 372 typeKeys("1<enter>"); 373 SCTool.selectRange("C5:C10"); 374 app.dispatch(".uno:FillDown"); 375 assertArrayEquals("Fill Down:", expected1, SCTool.getCellTexts("C5:C10")); 376 377 SCTool.selectRange("D10"); 378 typeKeys("2<enter>"); 379 SCTool.selectRange("D5:D10"); 380 app.dispatch(".uno:FillUp"); 381 assertArrayEquals("Fill Up:", expected2, SCTool.getCellTexts("D5:D10")); 382 383 SCTool.selectRange("A1"); 384 typeKeys("Hi friends<enter>"); 385 SCTool.selectRange("A1:D1"); 386 app.dispatch(".uno:FillRight"); 387 assertArrayEquals("Fill Right:", expected3, SCTool.getCellTexts("A1:D1")); 388 389 SCTool.selectRange("D2"); 390 typeKeys("99999.999<enter>"); 391 SCTool.selectRange("A2:D2"); 392 app.dispatch(".uno:FillLeft"); 393 assertArrayEquals("Fill left:", expected4, SCTool.getCellTexts("A2:D2")); 394 395 SCTool.selectRange("E1"); 396 typeKeys("99999.999<tab>-10<enter>"); 397 398 SCTool.selectRange("E1:F5"); 399 app.dispatch(".uno:FillSeries"); 400 fillSeriesDlg.ok(); 401 sleep(1); 402 assertArrayEquals("Fill series..", expected5, SCTool.getCellTexts("E1:F5")); 403 discard(); 404 } 405 406 @Test 407 public void testSort() { 408 String[][] expected1 = new String[][] { { "-9999999" }, { "-1.1" }, { "-1.1" }, { "0" }, { "0" }, { "0.1" }, { "10" }, { "12" }, { "9999999" }, { "9999999" }, 409 410 }; 411 String[][] expected2 = new String[][] { { "TRUE", "Oracle" }, { "TRUE", "OpenOffice" }, { "FALSE", "OpenOffice" }, { "TRUE", "IBM" }, { "FALSE", "IBM" }, 412 { "TRUE", "Google" }, { "FALSE", "facebook " }, { "TRUE", "Apache" }, { "TRUE", "!yahoo" }, { "TRUE", "" }, 413 414 }; 415 416 String[][] expected3 = new String[][] { { "Sunday" }, { "Monday" }, { "Tuesday" }, { "Wednesday" }, { "Thursday" }, { "Friday" }, { "Saturday" }, 417 418 }; 419 420 String[][] expected4 = new String[][] { { "-$10.00" }, { "$0.00" }, { "$0.00" }, { "$1.00" }, { "$3.00" }, { "$9.00" }, { "$123.00" }, { "$200.00" }, { "$400.00" }, 421 { "$10,000.00" }, 422 423 }; 424 open(prepareData("bvt/sort.ods")); 425 calc.waitForExistence(10, 2); 426 SCTool.selectRange("A1:A10"); 427 app.dispatch(".uno:DataSort"); 428 sortWarningDlgCurrent.click(); 429 assertEquals(1, sortPageBy1.getSelIndex()); 430 sortPage.ok(); 431 sleep(1); 432 assertArrayEquals("Sorted Data", expected1, SCTool.getCellTexts("A1:A10")); 433 SCTool.selectRange("B1:C10"); 434 app.dispatch(".uno:DataSort"); 435 436 sortPageBy1.select(2); 437 sortPageDescending1.check(); 438 assertFalse(sortPageBy3.isEnabled()); 439 assertFalse(sortPageAscending3.isEnabled()); 440 assertFalse(sortPageDescending3.isEnabled()); 441 sortPageBy2.select(1); 442 assertTrue(sortPageBy3.isEnabled()); 443 assertTrue(sortPageAscending3.isEnabled()); 444 assertTrue(sortPageDescending3.isEnabled()); 445 sortPageDescending2.check(); 446 sortPageBy2.select(0); 447 assertFalse(sortPageBy3.isEnabled()); 448 assertFalse(sortPageAscending3.isEnabled()); 449 assertFalse(sortPageDescending3.isEnabled()); 450 sortPageBy2.select(1); 451 sortPage.ok(); 452 sleep(1); 453 454 assertArrayEquals("Sorted Data", expected2, SCTool.getCellTexts("B1:C10")); 455 SCTool.selectRange("D1:D7"); 456 app.dispatch(".uno:DataSort"); 457 sortWarningDlgCurrent.click(); 458 sortOptionsPage.select(); 459 sortOptionsPageRangeContainsColumnLabels.uncheck(); 460 sortOptionsPageCustomSortOrder.check(); 461 sortOptionsPageCustomSortOrderList.select("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"); 462 sortOptionsPage.ok(); 463 sleep(1); 464 assertArrayEquals("Sorted Data", expected3, SCTool.getCellTexts("D1:D7")); 465 466 SCTool.selectRange("E1:E10"); 467 app.dispatch(".uno:DataSort"); 468 sortWarningDlgCurrent.click(); 469 sortPage.ok(); 470 sleep(1); 471 assertArrayEquals("Sorted Data", expected4, SCTool.getCellTexts("E1:E10")); 472 discard(); 473 } 474 475 /** 476 * Test insert a chart in a draw document 1. New a draw document 2. Insert a 477 * chart 3. Check if the chart is inserted successfully 478 * 479 * @throws Exception 480 */ 481 @Test 482 public void testInsertChartInDraw() throws Exception { 483 // Create a new drawing document 484 newDrawing(); 485 // Insert a chart 486 app.dispatch(".uno:InsertObjectChart"); 487 sleep(3); 488 489 // Verify if the chart is inserted successfully 490 assertTrue("Chart Editor appears", chart.exists(3)); 491 // Focus on edit pane 492 draw.click(5, 5); 493 sleep(1); 494 assertFalse("Chart Editor appears", chart.exists()); 495 discard(); 496 } 497 498 /** 499 * Test insert a chart in a text document 1. New a text document 2. Insert a 500 * chart 3. Check if the chart is inserted successfully 501 * 502 * @throws Exception 503 */ 504 @Test 505 public void testInsertChartInDocument() throws Exception { 506 // Create a new text document 507 newTextDocument(); 508 // Insert a chart 509 app.dispatch(".uno:InsertObjectChart"); 510 sleep(3); 511 512 // Verify if the chart is inserted successfully 513 assertTrue("Chart Editor appears", chart.exists(3)); 514 // Focus on edit pane 515 writer.click(5, 5); 516 sleep(1); 517 assertFalse("Chart Editor appears", chart.exists()); 518 discard(); 519 } 520 521 /** 522 * Test insert a chart in a spreadsheet document 1. New a spreadsheet 523 * document 2. Insert a chart 3. Check if the chart is inserted successfully 524 * 525 * @throws Exception 526 */ 527 @Test 528 public void testInsertChartInSpreadsheet() throws Exception { 529 // Create a new spreadsheet document 530 newSpreadsheet(); 531 // Insert a chart 532 app.dispatch(".uno:InsertObjectChart"); 533 sleep(3); 534 chartWizard.ok(); 535 536 // Verify if the chart is inserted successfully 537 assertTrue("Chart Editor appears", chart.exists(3)); 538 // Focus on edit pane 539 calc.click(5, 5); 540 sleep(1); 541 assertFalse("Chart Editor appears", chart.exists()); 542 discard(); 543 } 544 545 /** 546 * Test insert a chart in a presentation document 1. New a presentation 547 * document 2. Insert a chart 3. Check if the chart is inserted successfully 548 * 549 * @throws Exception 550 */ 551 @Test 552 public void testInsertChartInPresentation() throws Exception { 553 // Create a new presentation document 554 newPresentation(); 555 // Insert a chart 556 app.dispatch(".uno:InsertObjectChart"); 557 sleep(3); 558 // Verify if the chart is inserted successfully 559 assertTrue("Chart Editor appears", chart.exists(3)); 560 // Focus on edit pane 561 impress.click(5, 5); 562 sleep(1); 563 assertFalse("Chart Editor appears", chart.exists()); 564 discard(); 565 } 566 567 /** 568 * Test insert a table in a draw document 1. New a draw document 2. Insert a 569 * default table 3. Check if the table is inserted successfully 570 * 571 * @throws Exception 572 */ 573 @Test 574 public void testInsertTableInDraw() throws Exception { 575 // Create a new drawing document 576 newDrawing(); 577 // Insert a table 578 app.dispatch(".uno:InsertTable"); 579 insertTable.ok(); 580 sleep(1); 581 draw.typeKeys("3"); 582 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 583 // assertEquals("The cell content", "3", copyAll()); 584 discard(); 585 } 586 587 /** 588 * Test insert a table in a text document 1. New a text document 2. Insert a 589 * default table 3. Check if the table is inserted successfully 590 * 591 * @throws Exception 592 */ 593 @Test 594 public void testInsertTableInDocument() throws Exception { 595 // Create a new text document 596 newTextDocument(); 597 // Insert a table 598 app.dispatch(".uno:InsertTable"); 599 writerInsertTable.ok(); 600 sleep(1); 601 writer.typeKeys("3"); 602 // Verify if the table toolbar is active 603 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 604 // assertEquals("The cell content", "3", copyAll()); 605 discard(); 606 } 607 608 /** 609 * Test insert a table in a presentation document 1. New a presentation 610 * document 2. Insert a default table 3. Check if the table is inserted 611 * successfully 612 * 613 * @throws Exception 614 */ 615 @Test 616 public void testInsertTableInPresentation() throws Exception { 617 // Create a new presentation document 618 newPresentation(); 619 620 // Insert a table 621 app.dispatch(".uno:InsertTable"); 622 insertTable.ok(); 623 sleep(1); 624 impress.typeKeys("3"); 625 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 626 // assertEquals("The cell content", "3", copyAll()); 627 discard(); 628 } 629 630 /** 631 * Test insert a function in a spreadsheet document via Sum button 1. New a 632 * spreadsheet document 2. Insert a function via Sum button 3. Check if the 633 * result is correct 634 * 635 * @throws Exception 636 */ 637 @Test 638 public void testSumInFormulaBar() throws Exception { 639 // Create a new spreadsheet document 640 newSpreadsheet(); 641 // Insert source numbers 642 String sourceNumber1 = "5"; 643 String sourceNumber2 = "3"; 644 String expectedResult = "8"; 645 SCTool.selectRange("A1"); 646 typeKeys(sourceNumber1); 647 SCTool.selectRange("B1"); 648 typeKeys(sourceNumber2); 649 // Insert a function via Sum button 650 SCTool.selectRange("C1"); 651 scInputBarSum.click(); 652 typeKeys("<enter>"); 653 // Verify if the calculated result is equal to the expected result 654 assertEquals("The calculated result", expectedResult, SCTool.getCellText("C1")); 655 discard(); 656 } 657 658 /** 659 * Test insert a function in a spreadsheet document via inputbar 1. New a 660 * spreadsheet document 2. Insert a function via inputbar: COS 3. Check if 661 * the result is correct 662 * 663 * @throws Exception 664 */ 665 @Test 666 public void testInsertFunctionViaFormulaBar() throws Exception { 667 // Create a new spreadsheet document 668 newSpreadsheet(); 669 // Insert source numbers and expected result 670 String sourceData = "0"; 671 String expectedResult = "1"; 672 SCTool.selectRange("A1"); 673 typeKeys(sourceData); 674 675 // Insert a function via inputbar: COS 676 SCTool.selectRange("D1"); 677 scInputBarInput.inputKeys("=COS(A1)"); 678 typeKeys("<enter>"); 679 680 // Verify if the calculated result is equal to the expected result 681 assertEquals("The calculated result", expectedResult, SCTool.getCellText("D1")); 682 discard(); 683 } 684 685 /** 686 * Test insert a function in a spreadsheet document via Function Wizard 687 * Dialog 1. New a spreadsheet document 2. Insert a function via Function 688 * Wizard Dialog: ABS 3. Check if the result is correct 689 * 690 * @throws Exception 691 */ 692 @Test 693 public void testFunctionWizardInFormulaBar() throws Exception { 694 // Create a new spreadsheet document 695 newSpreadsheet(); 696 // Insert source number 697 String sourceNumber = "-5"; 698 String expectedResult = "5"; 699 SCTool.selectRange("A1"); 700 typeKeys(sourceNumber); 701 typeKeys("<enter>"); 702 // Insert a function via Function Wizard Dialog: ABS 703 SCTool.selectRange("B1"); 704 app.dispatch(".uno:FunctionDialog"); 705 // SC_FunctionWizardDlg_FunctionList.doubleClick(5, 5); 706 scFunctionWizardDlgFunctionList.select("ABS"); 707 scFunctionWizardDlgNext.click(); // Use "Next" button 708 scFunctionWizardDlgEdit1.typeKeys("A1"); 709 scFunctionWizardDlg.ok(); 710 // Verify if the calculated result is equal to the expected result 711 assertEquals("The calculated result", expectedResult, SCTool.getCellText("B1")); 712 discard(); 713 } 714 } 715