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