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