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