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 testFillInSpreadsheet() { 333 String[][] expected1 = new String[][] { { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, }; 334 String[][] expected2 = new String[][] { { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, }; 335 String[][] expected3 = new String[][] { { "Hi friends", "Hi friends", "Hi friends", "Hi friends" } }; 336 String[][] expected4 = new String[][] { { "99999.999", "99999.999", "99999.999", "99999.999" } }; 337 String[][] expected5 = new String[][] { 338 { "99999.999", "-10" }, { "100000.999", "-9" }, { "100001.999", "-8" }, { "100002.999", "-7" }, { "100003.999", "-6" } 339 }; 340 newSpreadsheet(); 341 SCTool.selectRange("C5"); 342 typeKeys("1<enter>"); 343 SCTool.selectRange("C5:C10"); 344 app.dispatch(".uno:FillDown"); 345 assertArrayEquals("Fill Down:", expected1, SCTool.getCellTexts("C5:C10")); 346 347 SCTool.selectRange("D10"); 348 typeKeys("2<enter>"); 349 SCTool.selectRange("D5:D10"); 350 app.dispatch(".uno:FillUp"); 351 assertArrayEquals("Fill Up:", expected2, SCTool.getCellTexts("D5:D10")); 352 353 SCTool.selectRange("A1"); 354 typeKeys("Hi friends<enter>"); 355 SCTool.selectRange("A1:D1"); 356 app.dispatch(".uno:FillRight"); 357 assertArrayEquals("Fill Right:", expected3, SCTool.getCellTexts("A1:D1")); 358 359 SCTool.selectRange("D2"); 360 typeKeys("99999.999<enter>"); 361 SCTool.selectRange("A2:D2"); 362 app.dispatch(".uno:FillLeft"); 363 assertArrayEquals("Fill left:", expected4, SCTool.getCellTexts("A2:D2")); 364 365 SCTool.selectRange("E1"); 366 typeKeys("99999.999<tab>-10<enter>"); 367 368 SCTool.selectRange("E1:F5"); 369 app.dispatch(".uno:FillSeries"); 370 fillSeriesDlg.ok(); 371 sleep(1); 372 assertArrayEquals("Fill series..", expected5, SCTool.getCellTexts("E1:F5")); 373 discard(); 374 } 375 376 @Test 377 public void testSort() { 378 String[][] expected1 = new String[][] { { "-9999999" }, { "-1.1" }, { "-1.1" }, { "0" }, { "0" }, { "0.1" }, { "10" }, { "12" }, { "9999999" }, { "9999999" }, 379 380 }; 381 String[][] expected2 = new String[][] { { "TRUE", "Oracle" }, { "TRUE", "OpenOffice" }, { "FALSE", "OpenOffice" }, { "TRUE", "IBM" }, { "FALSE", "IBM" }, 382 { "TRUE", "Google" }, { "FALSE", "facebook " }, { "TRUE", "Apache" }, { "TRUE", "!yahoo" }, { "TRUE", "" }, 383 384 }; 385 386 String[][] expected3 = new String[][] { { "Sunday" }, { "Monday" }, { "Tuesday" }, { "Wednesday" }, { "Thursday" }, { "Friday" }, { "Saturday" }, 387 388 }; 389 390 String[][] expected4 = new String[][] { { "-$10.00" }, { "$0.00" }, { "$0.00" }, { "$1.00" }, { "$3.00" }, { "$9.00" }, { "$123.00" }, { "$200.00" }, { "$400.00" }, 391 { "$10,000.00" }, 392 393 }; 394 open(prepareData("bvt/sort.ods")); 395 calc.waitForExistence(10, 2); 396 SCTool.selectRange("A1:A10"); 397 app.dispatch(".uno:DataSort"); 398 sortWarningDlgCurrent.click(); 399 assertEquals(1, sortPageBy1.getSelIndex()); 400 sortPage.ok(); 401 sleep(1); 402 assertArrayEquals("Sorted Data", expected1, SCTool.getCellTexts("A1:A10")); 403 SCTool.selectRange("B1:C10"); 404 app.dispatch(".uno:DataSort"); 405 406 sortPageBy1.select(2); 407 sortPageDescending1.check(); 408 assertFalse(sortPageBy3.isEnabled()); 409 assertFalse(sortPageAscending3.isEnabled()); 410 assertFalse(sortPageDescending3.isEnabled()); 411 sortPageBy2.select(1); 412 assertTrue(sortPageBy3.isEnabled()); 413 assertTrue(sortPageAscending3.isEnabled()); 414 assertTrue(sortPageDescending3.isEnabled()); 415 sortPageDescending2.check(); 416 sortPageBy2.select(0); 417 assertFalse(sortPageBy3.isEnabled()); 418 assertFalse(sortPageAscending3.isEnabled()); 419 assertFalse(sortPageDescending3.isEnabled()); 420 sortPageBy2.select(1); 421 sortPage.ok(); 422 sleep(1); 423 424 assertArrayEquals("Sorted Data", expected2, SCTool.getCellTexts("B1:C10")); 425 SCTool.selectRange("D1:D7"); 426 app.dispatch(".uno:DataSort"); 427 sortWarningDlgCurrent.click(); 428 sortOptionsPage.select(); 429 sortOptionsPageRangeContainsColumnLabels.uncheck(); 430 sortOptionsPageCustomSortOrder.check(); 431 sortOptionsPageCustomSortOrderList.select("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"); 432 sortOptionsPage.ok(); 433 sleep(1); 434 assertArrayEquals("Sorted Data", expected3, SCTool.getCellTexts("D1:D7")); 435 436 SCTool.selectRange("E1:E10"); 437 app.dispatch(".uno:DataSort"); 438 sortWarningDlgCurrent.click(); 439 sortPage.ok(); 440 sleep(1); 441 assertArrayEquals("Sorted Data", expected4, SCTool.getCellTexts("E1:E10")); 442 discard(); 443 } 444 445 /** 446 * Test insert a chart in a draw document 1. New a draw document 2. Insert a 447 * chart 3. Check if the chart is inserted successfully 448 * 449 * @throws Exception 450 */ 451 @Test 452 public void testInsertChartInDraw() throws Exception { 453 // Create a new drawing document 454 newDrawing(); 455 // Insert a chart 456 app.dispatch(".uno:InsertObjectChart"); 457 sleep(3); 458 459 // Verify if the chart is inserted successfully 460 assertTrue("Chart Editor appears", chart.exists(3)); 461 // Focus on edit pane 462 draw.click(5, 5); 463 sleep(1); 464 assertFalse("Chart Editor appears", chart.exists()); 465 discard(); 466 } 467 468 /** 469 * Test insert a chart in a text document 1. New a text document 2. Insert a 470 * chart 3. Check if the chart is inserted successfully 471 * 472 * @throws Exception 473 */ 474 @Test 475 public void testInsertChartInDocument() throws Exception { 476 // Create a new text document 477 newTextDocument(); 478 // Insert a chart 479 app.dispatch(".uno:InsertObjectChart"); 480 sleep(3); 481 482 // Verify if the chart is inserted successfully 483 assertTrue("Chart Editor appears", chart.exists(3)); 484 // Focus on edit pane 485 writer.click(5, 5); 486 sleep(1); 487 assertFalse("Chart Editor appears", chart.exists()); 488 discard(); 489 } 490 491 /** 492 * Test insert a chart in a spreadsheet document 1. New a spreadsheet 493 * document 2. Insert a chart 3. Check if the chart is inserted successfully 494 * 495 * @throws Exception 496 */ 497 @Test 498 public void testInsertChartInSpreadsheet() throws Exception { 499 // Create a new spreadsheet document 500 newSpreadsheet(); 501 // Insert a chart 502 app.dispatch(".uno:InsertObjectChart"); 503 sleep(3); 504 chartWizard.ok(); 505 506 // Verify if the chart is inserted successfully 507 assertTrue("Chart Editor appears", chart.exists(3)); 508 // Focus on edit pane 509 calc.click(5, 5); 510 sleep(1); 511 assertFalse("Chart Editor appears", chart.exists()); 512 discard(); 513 } 514 515 /** 516 * Test insert a chart in a presentation document 1. New a presentation 517 * document 2. Insert a chart 3. Check if the chart is inserted successfully 518 * 519 * @throws Exception 520 */ 521 @Test 522 public void testInsertChartInPresentation() throws Exception { 523 // Create a new presentation document 524 newPresentation(); 525 // Insert a chart 526 app.dispatch(".uno:InsertObjectChart"); 527 sleep(3); 528 // Verify if the chart is inserted successfully 529 assertTrue("Chart Editor appears", chart.exists(3)); 530 // Focus on edit pane 531 impress.click(5, 5); 532 sleep(1); 533 assertFalse("Chart Editor appears", chart.exists()); 534 discard(); 535 } 536 537 /** 538 * Test insert a table in a draw document 1. New a draw document 2. Insert a 539 * default table 3. Check if the table is inserted successfully 540 * 541 * @throws Exception 542 */ 543 @Test 544 public void testInsertTableInDraw() throws Exception { 545 // Create a new drawing document 546 newDrawing(); 547 // Insert a table 548 app.dispatch(".uno:InsertTable"); 549 insertTable.ok(); 550 sleep(1); 551 draw.typeKeys("3"); 552 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 553 // assertEquals("The cell content", "3", copyAll()); 554 discard(); 555 } 556 557 /** 558 * Test insert a table in a text document 1. New a text document 2. Insert a 559 * default table 3. Check if the table is inserted successfully 560 * 561 * @throws Exception 562 */ 563 @Test 564 public void testInsertTableInDocument() throws Exception { 565 // Create a new text document 566 newTextDocument(); 567 // Insert a table 568 app.dispatch(".uno:InsertTable"); 569 writerInsertTable.ok(); 570 sleep(1); 571 writer.typeKeys("3"); 572 // Verify if the table toolbar is active 573 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 574 // assertEquals("The cell content", "3", copyAll()); 575 discard(); 576 } 577 578 /** 579 * Test insert a table in a presentation document 1. New a presentation 580 * document 2. Insert a default table 3. Check if the table is inserted 581 * successfully 582 * 583 * @throws Exception 584 */ 585 @Test 586 public void testInsertTableInPresentation() throws Exception { 587 // Create a new presentation document 588 newPresentation(); 589 590 // Insert a table 591 app.dispatch(".uno:InsertTable"); 592 insertTable.ok(); 593 sleep(1); 594 impress.typeKeys("3"); 595 assertTrue("Table Toolbar appears", tableToolbar.exists(3)); 596 // assertEquals("The cell content", "3", copyAll()); 597 discard(); 598 } 599 600 /** 601 * Test insert a function in a spreadsheet document via Sum button 1. New a 602 * spreadsheet document 2. Insert a function via Sum button 3. Check if the 603 * result is correct 604 * 605 * @throws Exception 606 */ 607 @Test 608 public void testSumInFormulaBar() throws Exception { 609 // Create a new spreadsheet document 610 newSpreadsheet(); 611 // Insert source numbers 612 String sourceNumber1 = "5"; 613 String sourceNumber2 = "3"; 614 String expectedResult = "8"; 615 SCTool.selectRange("A1"); 616 typeKeys(sourceNumber1); 617 SCTool.selectRange("B1"); 618 typeKeys(sourceNumber2); 619 // Insert a function via Sum button 620 SCTool.selectRange("C1"); 621 scInputBarSum.click(); 622 typeKeys("<enter>"); 623 // Verify if the calculated result is equal to the expected result 624 assertEquals("The calculated result", expectedResult, SCTool.getCellText("C1")); 625 discard(); 626 } 627 628 /** 629 * Test insert a function in a spreadsheet document via inputbar 1. New a 630 * spreadsheet document 2. Insert a function via inputbar: COS 3. Check if 631 * the result is correct 632 * 633 * @throws Exception 634 */ 635 @Test 636 public void testInsertFunctionViaFormulaBar() throws Exception { 637 // Create a new spreadsheet document 638 newSpreadsheet(); 639 // Insert source numbers and expected result 640 String sourceData = "0"; 641 String expectedResult = "1"; 642 SCTool.selectRange("A1"); 643 typeKeys(sourceData); 644 645 // Insert a function via inputbar: COS 646 SCTool.selectRange("D1"); 647 scInputBarInput.inputKeys("=COS(A1)"); 648 typeKeys("<enter>"); 649 650 // Verify if the calculated result is equal to the expected result 651 assertEquals("The calculated result", expectedResult, SCTool.getCellText("D1")); 652 discard(); 653 } 654 655 /** 656 * Test insert a function in a spreadsheet document via Function Wizard 657 * Dialog 1. New a spreadsheet document 2. Insert a function via Function 658 * Wizard Dialog: ABS 3. Check if the result is correct 659 * 660 * @throws Exception 661 */ 662 @Test 663 public void testFunctionWizardInFormulaBar() throws Exception { 664 // Create a new spreadsheet document 665 newSpreadsheet(); 666 // Insert source number 667 String sourceNumber = "-5"; 668 String expectedResult = "5"; 669 SCTool.selectRange("A1"); 670 typeKeys(sourceNumber); 671 typeKeys("<enter>"); 672 // Insert a function via Function Wizard Dialog: ABS 673 SCTool.selectRange("B1"); 674 app.dispatch(".uno:FunctionDialog"); 675 // SC_FunctionWizardDlg_FunctionList.doubleClick(5, 5); 676 scFunctionWizardDlgFunctionList.select("ABS"); 677 scFunctionWizardDlgNext.click(); // Use "Next" button 678 scFunctionWizardDlgEdit1.typeKeys("A1"); 679 scFunctionWizardDlg.ok(); 680 // Verify if the calculated result is equal to the expected result 681 assertEquals("The calculated result", expectedResult, SCTool.getCellText("B1")); 682 discard(); 683 } 684 685 /** 686 * Test open a non-http(s) type hyperlink (with host only) in a text document. 687 * (coverage included in fvt.gui.sw.hyperlink.WarningDialog 688 * testHyperlinkDisplaysWarning() and included here for build verification) 689 * 1. New a text document 690 * 2. Insert a dav type hyperlink 691 * 3. Open hyperlink 692 * 4. Verify security warning dialog is displayed 693 * 694 * @throws Exception 695 */ 696 @Test 697 public void testNonHttpHyperlinkWithHostOnly() throws Exception { 698 // Create a new text document 699 newTextDocument(); 700 writer.waitForExistence(10, 2); 701 // open the hyperlink dialog 702 writer.typeKeys("<alt i>"); // insert menu 703 writer.typeKeys("h"); // hyperlink 704 hyperlinkInetPathComboBox.setText("dav://nonexistant.url.com"); //target 705 hyperlinkInetText.setText("dav://nonexistant.url.com"); // displayed text 706 hyperlinkDialogOkBtn.click(); // apply 707 hyperlinkDialogCancelBtn.click(); // close 708 sleep(1); // give the dialog time to close 709 typeKeys("<shift F10>"); // context menu 710 typeKeys("o"); // open hyperlink 711 // we can't be sure of the language so just check for the dialog 712 boolean msgExists = activeMsgBox.exists(1); // wait 1 second for the dialog 713 if (msgExists) { 714 activeMsgBox.no(); // close dialog 715 } 716 assertTrue("security warning not displayed", msgExists); 717 discard(); 718 } 719 720 }