xref: /AOO41X/test/testgui/source/bvt/gui/BasicFunctionTest.java (revision 133efdc14496caaf90c15e33666ab1c0c1e2fbea)
180a6f5c5SLiu Zhe /**************************************************************
280a6f5c5SLiu Zhe  *
380a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
480a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
580a6f5c5SLiu Zhe  * distributed with this work for additional information
680a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
780a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
880a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
980a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
1080a6f5c5SLiu Zhe  *
1180a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1280a6f5c5SLiu Zhe  *
1380a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1480a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
1580a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1680a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
1780a6f5c5SLiu Zhe  * specific language governing permissions and limitations
1880a6f5c5SLiu Zhe  * under the License.
1980a6f5c5SLiu Zhe  *
2080a6f5c5SLiu Zhe  *************************************************************/
2180a6f5c5SLiu Zhe 
2280a6f5c5SLiu Zhe /**
2380a6f5c5SLiu Zhe  *
2480a6f5c5SLiu Zhe  */
2580a6f5c5SLiu Zhe package bvt.gui;
2680a6f5c5SLiu Zhe 
2780a6f5c5SLiu Zhe import static org.junit.Assert.*;
2880a6f5c5SLiu Zhe import static org.openoffice.test.common.Testspace.*;
2980a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
3080a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
3180a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
3280a6f5c5SLiu Zhe 
3380a6f5c5SLiu Zhe import java.awt.Rectangle;
3491745ed9SLiu Zhe import java.io.File;
3580a6f5c5SLiu Zhe 
3691745ed9SLiu Zhe import org.junit.AfterClass;
3780a6f5c5SLiu Zhe import org.junit.Before;
3880a6f5c5SLiu Zhe import org.junit.BeforeClass;
3980a6f5c5SLiu Zhe import org.junit.Rule;
4080a6f5c5SLiu Zhe import org.junit.Test;
4180a6f5c5SLiu Zhe import org.openoffice.test.common.FileUtil;
4280a6f5c5SLiu Zhe import org.openoffice.test.common.GraphicsUtil;
4380a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
4480a6f5c5SLiu Zhe 
4580a6f5c5SLiu Zhe import testlib.gui.SCTool;
4680a6f5c5SLiu Zhe 
4780a6f5c5SLiu Zhe /**
4880a6f5c5SLiu Zhe  *
4980a6f5c5SLiu Zhe  */
5080a6f5c5SLiu Zhe public class BasicFunctionTest {
5180a6f5c5SLiu Zhe 
5280a6f5c5SLiu Zhe 	@Rule
5380a6f5c5SLiu Zhe 	public Logger log = Logger.getLogger(this);
5480a6f5c5SLiu Zhe 
5580a6f5c5SLiu Zhe 	@BeforeClass
beforeClass()569edf8282SLiu Zhe 	public static void beforeClass() {
5780a6f5c5SLiu Zhe 		app.clean();
5880a6f5c5SLiu Zhe 	}
5980a6f5c5SLiu Zhe 
6091745ed9SLiu Zhe 	@AfterClass
afterClass()619edf8282SLiu Zhe 	public static void afterClass() {
629edf8282SLiu Zhe 		app.stop();
6391745ed9SLiu Zhe 	}
6491745ed9SLiu Zhe 
6580a6f5c5SLiu Zhe 	@Before
before()6680a6f5c5SLiu Zhe 	public void before() {
679edf8282SLiu Zhe 		app.stop();
6880a6f5c5SLiu Zhe 		app.start();
6980a6f5c5SLiu Zhe 	}
7080a6f5c5SLiu Zhe 
719edf8282SLiu Zhe 
7280a6f5c5SLiu Zhe 	@Test
smokeTest()7391745ed9SLiu Zhe 	public void smokeTest() {
7491745ed9SLiu Zhe 		File smoketestOutput = new File(aoo.getUserInstallation(), "user/temp");
7591745ed9SLiu Zhe 		prepareData("TestExtension.oxt");
7691745ed9SLiu Zhe 		// Open sample file smoketestdoc.sxw
7791745ed9SLiu Zhe 		open(prepareData("smoketestdoc.sxw"));
7891745ed9SLiu Zhe 		writer.waitForEnabled(10, 2);
7991745ed9SLiu Zhe 		// Run test cases
8091745ed9SLiu Zhe 		app.dispatch("vnd.sun.star.script:Standard.Global.StartTestWithDefaultOptions?language=Basic&location=document", 120);
8191745ed9SLiu Zhe 		String smoketestlog = FileUtil.readFileAsString(new File(smoketestOutput, "smoketest.log"));
8291745ed9SLiu Zhe 		String testclosurelog = FileUtil.readFileAsString(new File(smoketestOutput, "testclosure.log"));
8391745ed9SLiu Zhe 		log.info(smoketestlog + "\n" + testclosurelog);
8491745ed9SLiu Zhe 		assertTrue("No Error", !smoketestlog.contains("error") && !testclosurelog.contains("error"));
8591745ed9SLiu Zhe 
8691745ed9SLiu Zhe 	}
8791745ed9SLiu Zhe 
8891745ed9SLiu Zhe 	@Test
testExportAsPDF()8980a6f5c5SLiu Zhe 	public void testExportAsPDF() throws Exception {
9080a6f5c5SLiu Zhe 		String file = prepareData("bvt/pdf.odt");
9180a6f5c5SLiu Zhe 		String exportTo1 = getPath("temp/1.pdf");
9280a6f5c5SLiu Zhe 		String exportTo2 = getPath("temp/2.pdf");
9380a6f5c5SLiu Zhe 		deleteFile(exportTo1);
9480a6f5c5SLiu Zhe 		deleteFile(exportTo2);
9580a6f5c5SLiu Zhe 		open(file);
9680a6f5c5SLiu Zhe 		writer.waitForExistence(10, 1);
9780a6f5c5SLiu Zhe 		app.dispatch(".uno:ExportToPDF");
9880a6f5c5SLiu Zhe 		pdfGeneralPage.ok();
9980a6f5c5SLiu Zhe 		submitSaveDlg(exportTo1);
10080a6f5c5SLiu Zhe 		sleep(1);
10180a6f5c5SLiu Zhe 		String magic = FileUtil.readFileAsString(exportTo1).substring(0, 4);
10280a6f5c5SLiu Zhe 		assertEquals("PDF is exported?", "%PDF", magic);
10380a6f5c5SLiu Zhe 
10480a6f5c5SLiu Zhe 		button(".uno:ExportDirectToPDF").click();//Click via toolbar
10580a6f5c5SLiu Zhe 		submitSaveDlg(exportTo2);
10680a6f5c5SLiu Zhe 		sleep(1);
10780a6f5c5SLiu Zhe 		magic = FileUtil.readFileAsString(exportTo2).substring(0, 4);
10880a6f5c5SLiu Zhe 		assertEquals("PDF is exported directly?", "%PDF", magic);
10980a6f5c5SLiu Zhe 	}
11080a6f5c5SLiu Zhe 
11180a6f5c5SLiu Zhe 	/**
11280a6f5c5SLiu Zhe 	 * Test the File -- Print Dialog show
11380a6f5c5SLiu Zhe 	 *
11480a6f5c5SLiu Zhe 	 */
11580a6f5c5SLiu Zhe 	@Test
testPrinter()11680a6f5c5SLiu Zhe 	public void testPrinter() {
11780a6f5c5SLiu Zhe 		// Create a new text document
11880a6f5c5SLiu Zhe 		newTextDocument();
11980a6f5c5SLiu Zhe 		app.dispatch(".uno:PrinterSetup");
12080a6f5c5SLiu Zhe 		if (activeMsgBox.exists(2))
12180a6f5c5SLiu Zhe 			activeMsgBox.ok();
12280a6f5c5SLiu Zhe 
12380a6f5c5SLiu Zhe //		PrintService[] ps = PrintServiceLookup.lookupPrintServices(null, null);
12480a6f5c5SLiu Zhe //		String[] names = new String[ps.length];
12580a6f5c5SLiu Zhe //		for (int i = 0; i < ps.length; i++) {
12680a6f5c5SLiu Zhe //			names[i] = ps[i].getName();
12780a6f5c5SLiu Zhe //		}
12880a6f5c5SLiu Zhe //
12980a6f5c5SLiu Zhe //		assertArrayEquals("Printers Names", names, printerSetUpDlgPrinterNames.getItemsText());
13080a6f5c5SLiu Zhe 		assertTrue("Printer Setup dialog appears", printerSetUpDlg.exists(3));
13180a6f5c5SLiu Zhe 		printerSetUpDlg.cancel();
13280a6f5c5SLiu Zhe 	}
13380a6f5c5SLiu Zhe 
13480a6f5c5SLiu Zhe 	/**
13580a6f5c5SLiu Zhe 	 * Test the File -- Java Dialog show
13680a6f5c5SLiu Zhe 	 *
13780a6f5c5SLiu Zhe 	 */
13880a6f5c5SLiu Zhe //	@Test
13980a6f5c5SLiu Zhe //	public void testJavaDialog() {
14080a6f5c5SLiu Zhe //
14180a6f5c5SLiu Zhe //		// Create a new text document and launch a Wizards dialog which need JVM
14280a6f5c5SLiu Zhe //		// work correctly.
14380a6f5c5SLiu Zhe //		app.dispatch("private:factory/swriter");
14480a6f5c5SLiu Zhe //		File tempfile = new File(oo.getUserInstallation(), "user/template/myAgendaTemplate.ott");
14580a6f5c5SLiu Zhe //		FileUtil.deleteFile(tempfile);
14680a6f5c5SLiu Zhe //		sleep(3);
14780a6f5c5SLiu Zhe //		app.dispatch("service:com.sun.star.wizards.agenda.CallWizard?start");
14880a6f5c5SLiu Zhe //		sleep(5);
14980a6f5c5SLiu Zhe //		assertTrue(Wizards_AgendaDialog.exists(10));
15080a6f5c5SLiu Zhe //		Wizards_AgendaDialog_FinishButton.click();
15180a6f5c5SLiu Zhe //		sleep(10);
15280a6f5c5SLiu Zhe //		writer.focus();
15380a6f5c5SLiu Zhe //		sleep(1);
15480a6f5c5SLiu Zhe //		app.dispatch(".uno:SelectAll");
15580a6f5c5SLiu Zhe //		typeKeys("<$copy>");
15680a6f5c5SLiu Zhe //		// System.out.println("now txt:"+app.getClipboard());
15780a6f5c5SLiu Zhe //		// assertTrue(app.getClipboard().startsWith("<Name>"));
15880a6f5c5SLiu Zhe //		assertNotNull(app.getClipboard());
15980a6f5c5SLiu Zhe //	}
16080a6f5c5SLiu Zhe 
16180a6f5c5SLiu Zhe 	/**
16280a6f5c5SLiu Zhe 	 * Test the Tools / Macros / Organize Dialogs" show
16380a6f5c5SLiu Zhe 	 *
16480a6f5c5SLiu Zhe 	 */
16580a6f5c5SLiu Zhe 	@Test
testRunMacro()16680a6f5c5SLiu Zhe 	public void testRunMacro() {
16780a6f5c5SLiu Zhe 		open(prepareData("bvt/macro.ods"));
16880a6f5c5SLiu Zhe 		calc.waitForExistence(10, 2);
16980a6f5c5SLiu Zhe 		app.dispatch(".uno:RunMacro");
17080a6f5c5SLiu Zhe 		runMacroDlgCategories.expand("macro.ods");
17180a6f5c5SLiu Zhe 		runMacroDlgCategories.expand("Standard");
17280a6f5c5SLiu Zhe 		runMacroDlgCategories.select("Module1");
17380a6f5c5SLiu Zhe 		runMacroDlgCommands.select(0);
17480a6f5c5SLiu Zhe 		runMacroDlg.ok();
17580a6f5c5SLiu Zhe 		assertEquals("A3 should be =1+3", "4", SCTool.getCellText("A3"));
17680a6f5c5SLiu Zhe 		discard();
17780a6f5c5SLiu Zhe 	}
17880a6f5c5SLiu Zhe 
17980a6f5c5SLiu Zhe 	/**
18080a6f5c5SLiu Zhe 	 * Test the About Dialog show
18180a6f5c5SLiu Zhe 	 *
18280a6f5c5SLiu Zhe 	 */
18380a6f5c5SLiu Zhe 	@Test
testHelp()18480a6f5c5SLiu Zhe 	public void testHelp() {
18580a6f5c5SLiu Zhe 		app.dispatch(".uno:About");
18680a6f5c5SLiu Zhe 		assertTrue(aboutDialog.exists(5));
18780a6f5c5SLiu Zhe 		aboutDialog.ok();
18880a6f5c5SLiu Zhe 		sleep(1);
18980a6f5c5SLiu Zhe 		typeKeys("<F1>");
19080a6f5c5SLiu Zhe 		assertTrue(helpWindow.exists(5));
19180a6f5c5SLiu Zhe 		helpWindow.close();
19280a6f5c5SLiu Zhe 	}
19380a6f5c5SLiu Zhe 
19480a6f5c5SLiu Zhe 	/**
19580a6f5c5SLiu Zhe 	 * Test inserting a picture in text document
19680a6f5c5SLiu Zhe 	 *
19780a6f5c5SLiu Zhe 	 * @throws Exception
19880a6f5c5SLiu Zhe 	 */
19980a6f5c5SLiu Zhe 
20080a6f5c5SLiu Zhe 	@Test
testInsertPictureInDocument()20180a6f5c5SLiu Zhe 	public void testInsertPictureInDocument() throws Exception {
20280a6f5c5SLiu Zhe 		String bmp_green = prepareData("image/green_256x256.bmp");
20380a6f5c5SLiu Zhe 		String bmp_red = prepareData("image/red_256x256.bmp");
20480a6f5c5SLiu Zhe 
20580a6f5c5SLiu Zhe 		// Create a new text document
20680a6f5c5SLiu Zhe 		newTextDocument();
20780a6f5c5SLiu Zhe 		// Insert a picture fully filled with green
20880a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
20980a6f5c5SLiu Zhe 		submitOpenDlg(bmp_green);
21080a6f5c5SLiu Zhe 		writer.click(5,200);
21180a6f5c5SLiu Zhe 		sleep(1);
21280a6f5c5SLiu Zhe 
21380a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
21480a6f5c5SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFF00FF00);
21580a6f5c5SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
21680a6f5c5SLiu Zhe 		// insert another picture
21780a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
21880a6f5c5SLiu Zhe 		submitOpenDlg(bmp_red);
21980a6f5c5SLiu Zhe 		writer.click(5, 200);
22080a6f5c5SLiu Zhe 		sleep(1);
22180a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
22280a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFFFF0000);
22380a6f5c5SLiu Zhe 		assertTrue("Green Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
22480a6f5c5SLiu Zhe 		discard();
22580a6f5c5SLiu Zhe 	}
22680a6f5c5SLiu Zhe 
22780a6f5c5SLiu Zhe 	@Test
testInsertPictureInSpreadsheet()22880a6f5c5SLiu Zhe 	public void testInsertPictureInSpreadsheet() throws Exception {
22980a6f5c5SLiu Zhe 		String bmp_green = prepareData("image/green_64x64.png");
23080a6f5c5SLiu Zhe 		String bmp_red = prepareData("image/red_64x64.png");
23180a6f5c5SLiu Zhe 		newSpreadsheet();
23280a6f5c5SLiu Zhe 		// Insert a picture fully filled with green
23380a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
23480a6f5c5SLiu Zhe 		submitOpenDlg(bmp_green);
23580a6f5c5SLiu Zhe 		calc.click(5, 150);
23680a6f5c5SLiu Zhe 		sleep(1);
23780a6f5c5SLiu Zhe 
23880a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
23980a6f5c5SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFF00FF00);
24080a6f5c5SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
24180a6f5c5SLiu Zhe 
24280a6f5c5SLiu Zhe 		SCTool.selectRange("C1");
24380a6f5c5SLiu Zhe 		// insert another picture
24480a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
24580a6f5c5SLiu Zhe 		submitOpenDlg(bmp_red);
24680a6f5c5SLiu Zhe 		calc.click(5, 150);
24780a6f5c5SLiu Zhe 		sleep(1);
24880a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
24980a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFFFF0000);
25080a6f5c5SLiu Zhe 		assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
25180a6f5c5SLiu Zhe 		discard();
25280a6f5c5SLiu Zhe 	}
25380a6f5c5SLiu Zhe 
25480a6f5c5SLiu Zhe 	@Test
testInsertPictureInPresentation()25580a6f5c5SLiu Zhe 	public void testInsertPictureInPresentation() throws Exception {
25680a6f5c5SLiu Zhe 		String bmp_green = prepareData("image/green_256x256.bmp");
25780a6f5c5SLiu Zhe 		String bmp_red = prepareData("image/red_256x256.bmp");
25880a6f5c5SLiu Zhe 		newPresentation();
25980a6f5c5SLiu Zhe 		// Insert a picture fully filled with green
26080a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
26180a6f5c5SLiu Zhe 		submitOpenDlg(bmp_green);
26280a6f5c5SLiu Zhe 		impress.click(5, 5);
26380a6f5c5SLiu Zhe 		sleep(1);
26480a6f5c5SLiu Zhe 
26580a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
26680a6f5c5SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFF00FF00);
26780a6f5c5SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
26880a6f5c5SLiu Zhe 		// insert another picture
26980a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
27080a6f5c5SLiu Zhe 		submitOpenDlg(bmp_red);
27180a6f5c5SLiu Zhe 		impress.click(1, 1);
27280a6f5c5SLiu Zhe 		sleep(1);
27380a6f5c5SLiu Zhe 		// Verify if the picture is inserted successfully
27480a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFFFF0000);
27580a6f5c5SLiu Zhe 		assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
27680a6f5c5SLiu Zhe 		discard();
27780a6f5c5SLiu Zhe 	}
27880a6f5c5SLiu Zhe 
27980a6f5c5SLiu Zhe 	@Test
testSlideShow()28080a6f5c5SLiu Zhe 	public void testSlideShow() throws Exception {
28180a6f5c5SLiu Zhe 		open(prepareData("bvt/slideshow.odp"));
28280a6f5c5SLiu Zhe 		impress.waitForExistence(10, 2);
28380a6f5c5SLiu Zhe 		sleep(1);
28480a6f5c5SLiu Zhe 		impress.typeKeys("<F5>");
28580a6f5c5SLiu Zhe 		sleep(3);
28680a6f5c5SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFFFF0000);
28780a6f5c5SLiu Zhe 		assertNotNull("1st slide appears", rectangle);
28880a6f5c5SLiu Zhe 		slideShow.click(0.5, 0.5);
28980a6f5c5SLiu Zhe 		sleep(2);
29080a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF00FF00);
29180a6f5c5SLiu Zhe 		assertNotNull("2nd slide appears", rectangle);
29280a6f5c5SLiu Zhe 		typeKeys("<enter>");
29380a6f5c5SLiu Zhe 		sleep(2);
29480a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF);
29580a6f5c5SLiu Zhe 		assertNotNull("3rd slide appears", rectangle);
29680a6f5c5SLiu Zhe 		slideShow.click(0.5, 0.5);
29780a6f5c5SLiu Zhe 		sleep(2);
29880a6f5c5SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF);
29980a6f5c5SLiu Zhe 		assertNull("The end", rectangle);
30080a6f5c5SLiu Zhe 		slideShow.click(0.5, 0.5);
30180a6f5c5SLiu Zhe 		sleep(3);
30280a6f5c5SLiu Zhe 		assertFalse("Quit", slideShow.exists());
30380a6f5c5SLiu Zhe 	}
30480a6f5c5SLiu Zhe 
30580a6f5c5SLiu Zhe 	@Test
testFind()30680a6f5c5SLiu Zhe 	public void testFind() {
30780a6f5c5SLiu Zhe 		open(prepareData("bvt/find.odt"));
30880a6f5c5SLiu Zhe 		writer.waitForExistence(10, 2);
30980a6f5c5SLiu Zhe 		app.dispatch(".uno:SearchDialog");
31080a6f5c5SLiu Zhe 		findDlgFor.setText("OpenOffice");
31180a6f5c5SLiu Zhe 		findDlgFind.click();
31280a6f5c5SLiu Zhe 		sleep(1);
31380a6f5c5SLiu Zhe 		writer.typeKeys("<$copy>");
31480a6f5c5SLiu Zhe 		assertEquals("OpenOffice", app.getClipboard());
31580a6f5c5SLiu Zhe 		findDlgFindAll.click();
31680a6f5c5SLiu Zhe 		sleep(1);
31780a6f5c5SLiu Zhe 		writer.typeKeys("<$copy>");
31880a6f5c5SLiu Zhe 		assertEquals("OpenOfficeOpenOfficeOpenOffice", app.getClipboard());
31980a6f5c5SLiu Zhe 		findDlgReplaceWith.setText("Awesome OpenOffice");
32080a6f5c5SLiu Zhe 		findDlgReplaceAll.click();
32180a6f5c5SLiu Zhe 		sleep(1);
32280a6f5c5SLiu Zhe 		msgbox("Search key replaced 3 times.").ok();
32380a6f5c5SLiu Zhe 		findDlg.close();
32480a6f5c5SLiu Zhe 		sleep(1);
32580a6f5c5SLiu Zhe 		assertEquals(
32680a6f5c5SLiu 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. ",
32780a6f5c5SLiu Zhe 				copyAll());
32844cf0280SCarl Marcum 		discard();
32980a6f5c5SLiu Zhe 	}
330*133efdc1SDamjan Jovanovic 
331*133efdc1SDamjan Jovanovic 	@Test
testFindFormulasAndValues()332*133efdc1SDamjan Jovanovic 	public void testFindFormulasAndValues() {
333*133efdc1SDamjan Jovanovic 	    open(prepareData("bvt/searchFormulasValues.ods"));
334*133efdc1SDamjan Jovanovic 	    calc.waitForExistence(10, 2);
335*133efdc1SDamjan Jovanovic 
336*133efdc1SDamjan Jovanovic 	    // Searching for 2003 by formula finds A2
337*133efdc1SDamjan Jovanovic 	    SCTool.selectRange("A1");
338*133efdc1SDamjan Jovanovic 	    app.dispatch(".uno:SearchDialog");
339*133efdc1SDamjan Jovanovic         findDlgFor.setText("2003");
340*133efdc1SDamjan Jovanovic         findDlgMore.click();
341*133efdc1SDamjan Jovanovic         findDlgCalcSearchIn.select("Formulas");
342*133efdc1SDamjan Jovanovic         findDlgFind.click();
343*133efdc1SDamjan Jovanovic         sleep(1);
344*133efdc1SDamjan Jovanovic 	    assertEquals("wrong cell found for formulas search", "A2", scInputBarPosition.getText());
345*133efdc1SDamjan Jovanovic 	    findDlg.close();
346*133efdc1SDamjan Jovanovic 
347*133efdc1SDamjan Jovanovic 	    // Searching for October by value finds A2
348*133efdc1SDamjan Jovanovic 	    SCTool.selectRange("A1");
349*133efdc1SDamjan Jovanovic 	    app.dispatch(".uno:SearchDialog");
350*133efdc1SDamjan Jovanovic 	    findDlgFor.setText("October");
351*133efdc1SDamjan Jovanovic 	    findDlgMore.click();
352*133efdc1SDamjan Jovanovic 	    findDlgCalcSearchIn.select("Values");
353*133efdc1SDamjan Jovanovic 	    findDlgFind.click();
354*133efdc1SDamjan Jovanovic 	    sleep(1);
355*133efdc1SDamjan Jovanovic 	    assertEquals("wrong cell found for values search", "A2", scInputBarPosition.getText());
356*133efdc1SDamjan Jovanovic 	    findDlg.close();
357*133efdc1SDamjan Jovanovic 
358*133efdc1SDamjan Jovanovic 	    discard();
359*133efdc1SDamjan Jovanovic 	}
36080a6f5c5SLiu Zhe 
36180a6f5c5SLiu Zhe 	@Test
testFillInSpreadsheet()36280a6f5c5SLiu Zhe 	public void testFillInSpreadsheet() {
36380a6f5c5SLiu Zhe 		String[][] expected1 = new String[][] { { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, };
36480a6f5c5SLiu Zhe 		String[][] expected2 = new String[][] { { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, };
36580a6f5c5SLiu Zhe 		String[][] expected3 = new String[][] { { "Hi friends", "Hi friends", "Hi friends", "Hi friends" } };
36680a6f5c5SLiu Zhe 		String[][] expected4 = new String[][] { { "99999.999", "99999.999", "99999.999", "99999.999" } };
36780a6f5c5SLiu Zhe 		String[][] expected5 = new String[][] {
36880a6f5c5SLiu Zhe 		{ "99999.999", "-10" }, { "100000.999", "-9" }, { "100001.999", "-8" }, { "100002.999", "-7" }, { "100003.999", "-6" }
36980a6f5c5SLiu Zhe 		};
37080a6f5c5SLiu Zhe 		newSpreadsheet();
37180a6f5c5SLiu Zhe 		SCTool.selectRange("C5");
37280a6f5c5SLiu Zhe 		typeKeys("1<enter>");
37380a6f5c5SLiu Zhe 		SCTool.selectRange("C5:C10");
37480a6f5c5SLiu Zhe 		app.dispatch(".uno:FillDown");
37580a6f5c5SLiu Zhe 		assertArrayEquals("Fill Down:", expected1, SCTool.getCellTexts("C5:C10"));
37680a6f5c5SLiu Zhe 
37780a6f5c5SLiu Zhe 		SCTool.selectRange("D10");
37880a6f5c5SLiu Zhe 		typeKeys("2<enter>");
37980a6f5c5SLiu Zhe 		SCTool.selectRange("D5:D10");
38080a6f5c5SLiu Zhe 		app.dispatch(".uno:FillUp");
38180a6f5c5SLiu Zhe 		assertArrayEquals("Fill Up:", expected2, SCTool.getCellTexts("D5:D10"));
38280a6f5c5SLiu Zhe 
38380a6f5c5SLiu Zhe 		SCTool.selectRange("A1");
38480a6f5c5SLiu Zhe 		typeKeys("Hi friends<enter>");
38580a6f5c5SLiu Zhe 		SCTool.selectRange("A1:D1");
38680a6f5c5SLiu Zhe 		app.dispatch(".uno:FillRight");
38780a6f5c5SLiu Zhe 		assertArrayEquals("Fill Right:", expected3, SCTool.getCellTexts("A1:D1"));
38880a6f5c5SLiu Zhe 
38980a6f5c5SLiu Zhe 		SCTool.selectRange("D2");
39080a6f5c5SLiu Zhe 		typeKeys("99999.999<enter>");
39180a6f5c5SLiu Zhe 		SCTool.selectRange("A2:D2");
39280a6f5c5SLiu Zhe 		app.dispatch(".uno:FillLeft");
39380a6f5c5SLiu Zhe 		assertArrayEquals("Fill left:", expected4, SCTool.getCellTexts("A2:D2"));
39480a6f5c5SLiu Zhe 
39580a6f5c5SLiu Zhe 		SCTool.selectRange("E1");
39680a6f5c5SLiu Zhe 		typeKeys("99999.999<tab>-10<enter>");
39780a6f5c5SLiu Zhe 
39880a6f5c5SLiu Zhe 		SCTool.selectRange("E1:F5");
39980a6f5c5SLiu Zhe 		app.dispatch(".uno:FillSeries");
40080a6f5c5SLiu Zhe 		fillSeriesDlg.ok();
40180a6f5c5SLiu Zhe 		sleep(1);
40280a6f5c5SLiu Zhe 		assertArrayEquals("Fill series..", expected5, SCTool.getCellTexts("E1:F5"));
40380a6f5c5SLiu Zhe 		discard();
40480a6f5c5SLiu Zhe 	}
40580a6f5c5SLiu Zhe 
40680a6f5c5SLiu Zhe 	@Test
testSort()40780a6f5c5SLiu Zhe 	public void testSort() {
40880a6f5c5SLiu Zhe 		String[][] expected1 = new String[][] { { "-9999999" }, { "-1.1" }, { "-1.1" }, { "0" }, { "0" }, { "0.1" }, { "10" }, { "12" }, { "9999999" }, { "9999999" },
40980a6f5c5SLiu Zhe 
41080a6f5c5SLiu Zhe 		};
41180a6f5c5SLiu Zhe 		String[][] expected2 = new String[][] { { "TRUE", "Oracle" }, { "TRUE", "OpenOffice" }, { "FALSE", "OpenOffice" }, { "TRUE", "IBM" }, { "FALSE", "IBM" },
41280a6f5c5SLiu Zhe 				{ "TRUE", "Google" }, { "FALSE", "facebook " }, { "TRUE", "Apache" }, { "TRUE", "!yahoo" }, { "TRUE", "" },
41380a6f5c5SLiu Zhe 
41480a6f5c5SLiu Zhe 		};
41580a6f5c5SLiu Zhe 
41680a6f5c5SLiu Zhe 		String[][] expected3 = new String[][] { { "Sunday" }, { "Monday" }, { "Tuesday" }, { "Wednesday" }, { "Thursday" }, { "Friday" }, { "Saturday" },
41780a6f5c5SLiu Zhe 
41880a6f5c5SLiu Zhe 		};
41980a6f5c5SLiu Zhe 
42080a6f5c5SLiu Zhe 		String[][] expected4 = new String[][] { { "-$10.00" }, { "$0.00" }, { "$0.00" }, { "$1.00" }, { "$3.00" }, { "$9.00" }, { "$123.00" }, { "$200.00" }, { "$400.00" },
42180a6f5c5SLiu Zhe 				{ "$10,000.00" },
42280a6f5c5SLiu Zhe 
42380a6f5c5SLiu Zhe 		};
42480a6f5c5SLiu Zhe 		open(prepareData("bvt/sort.ods"));
42580a6f5c5SLiu Zhe 		calc.waitForExistence(10, 2);
42680a6f5c5SLiu Zhe 		SCTool.selectRange("A1:A10");
42780a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSort");
42880a6f5c5SLiu Zhe 		sortWarningDlgCurrent.click();
42980a6f5c5SLiu Zhe 		assertEquals(1, sortPageBy1.getSelIndex());
43080a6f5c5SLiu Zhe 		sortPage.ok();
43180a6f5c5SLiu Zhe 		sleep(1);
43280a6f5c5SLiu Zhe 		assertArrayEquals("Sorted Data", expected1, SCTool.getCellTexts("A1:A10"));
43380a6f5c5SLiu Zhe 		SCTool.selectRange("B1:C10");
43480a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSort");
43580a6f5c5SLiu Zhe 
43680a6f5c5SLiu Zhe 		sortPageBy1.select(2);
43780a6f5c5SLiu Zhe 		sortPageDescending1.check();
43880a6f5c5SLiu Zhe 		assertFalse(sortPageBy3.isEnabled());
43980a6f5c5SLiu Zhe 		assertFalse(sortPageAscending3.isEnabled());
44080a6f5c5SLiu Zhe 		assertFalse(sortPageDescending3.isEnabled());
44180a6f5c5SLiu Zhe 		sortPageBy2.select(1);
44280a6f5c5SLiu Zhe 		assertTrue(sortPageBy3.isEnabled());
44380a6f5c5SLiu Zhe 		assertTrue(sortPageAscending3.isEnabled());
44480a6f5c5SLiu Zhe 		assertTrue(sortPageDescending3.isEnabled());
44580a6f5c5SLiu Zhe 		sortPageDescending2.check();
44680a6f5c5SLiu Zhe 		sortPageBy2.select(0);
44780a6f5c5SLiu Zhe 		assertFalse(sortPageBy3.isEnabled());
44880a6f5c5SLiu Zhe 		assertFalse(sortPageAscending3.isEnabled());
44980a6f5c5SLiu Zhe 		assertFalse(sortPageDescending3.isEnabled());
45080a6f5c5SLiu Zhe 		sortPageBy2.select(1);
45180a6f5c5SLiu Zhe 		sortPage.ok();
45280a6f5c5SLiu Zhe 		sleep(1);
45380a6f5c5SLiu Zhe 
45480a6f5c5SLiu Zhe 		assertArrayEquals("Sorted Data", expected2, SCTool.getCellTexts("B1:C10"));
45580a6f5c5SLiu Zhe 		SCTool.selectRange("D1:D7");
45680a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSort");
45780a6f5c5SLiu Zhe 		sortWarningDlgCurrent.click();
45880a6f5c5SLiu Zhe 		sortOptionsPage.select();
45980a6f5c5SLiu Zhe 		sortOptionsPageRangeContainsColumnLabels.uncheck();
46080a6f5c5SLiu Zhe 		sortOptionsPageCustomSortOrder.check();
46180a6f5c5SLiu Zhe 		sortOptionsPageCustomSortOrderList.select("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday");
46280a6f5c5SLiu Zhe 		sortOptionsPage.ok();
46380a6f5c5SLiu Zhe 		sleep(1);
46480a6f5c5SLiu Zhe 		assertArrayEquals("Sorted Data", expected3, SCTool.getCellTexts("D1:D7"));
46580a6f5c5SLiu Zhe 
46680a6f5c5SLiu Zhe 		SCTool.selectRange("E1:E10");
46780a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSort");
46880a6f5c5SLiu Zhe 		sortWarningDlgCurrent.click();
46980a6f5c5SLiu Zhe 		sortPage.ok();
47080a6f5c5SLiu Zhe 		sleep(1);
47180a6f5c5SLiu Zhe 		assertArrayEquals("Sorted Data", expected4, SCTool.getCellTexts("E1:E10"));
47280a6f5c5SLiu Zhe 		discard();
47380a6f5c5SLiu Zhe 	}
47480a6f5c5SLiu Zhe 
47580a6f5c5SLiu Zhe 	/**
47680a6f5c5SLiu Zhe 	 * Test insert a chart in a draw document 1. New a draw document 2. Insert a
47780a6f5c5SLiu Zhe 	 * chart 3. Check if the chart is inserted successfully
47880a6f5c5SLiu Zhe 	 *
47980a6f5c5SLiu Zhe 	 * @throws Exception
48080a6f5c5SLiu Zhe 	 */
48180a6f5c5SLiu Zhe 	@Test
testInsertChartInDraw()48280a6f5c5SLiu Zhe 	public void testInsertChartInDraw() throws Exception {
48380a6f5c5SLiu Zhe 		// Create a new drawing document
48480a6f5c5SLiu Zhe 		newDrawing();
48580a6f5c5SLiu Zhe 		// Insert a chart
48680a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
48780a6f5c5SLiu Zhe 		sleep(3);
48880a6f5c5SLiu Zhe 
48980a6f5c5SLiu Zhe 		// Verify if the chart is inserted successfully
49080a6f5c5SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
49180a6f5c5SLiu Zhe 		// Focus on edit pane
49280a6f5c5SLiu Zhe 		draw.click(5, 5);
49380a6f5c5SLiu Zhe 		sleep(1);
49480a6f5c5SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
49580a6f5c5SLiu Zhe 		discard();
49680a6f5c5SLiu Zhe 	}
49780a6f5c5SLiu Zhe 
49880a6f5c5SLiu Zhe 	/**
49980a6f5c5SLiu Zhe 	 * Test insert a chart in a text document 1. New a text document 2. Insert a
50080a6f5c5SLiu Zhe 	 * chart 3. Check if the chart is inserted successfully
50180a6f5c5SLiu Zhe 	 *
50280a6f5c5SLiu Zhe 	 * @throws Exception
50380a6f5c5SLiu Zhe 	 */
50480a6f5c5SLiu Zhe 	@Test
testInsertChartInDocument()50580a6f5c5SLiu Zhe 	public void testInsertChartInDocument() throws Exception {
50680a6f5c5SLiu Zhe 		// Create a new text document
50780a6f5c5SLiu Zhe 		newTextDocument();
50880a6f5c5SLiu Zhe 		// Insert a chart
50980a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
51080a6f5c5SLiu Zhe 		sleep(3);
51180a6f5c5SLiu Zhe 
51280a6f5c5SLiu Zhe 		// Verify if the chart is inserted successfully
51380a6f5c5SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
51480a6f5c5SLiu Zhe 		// Focus on edit pane
51580a6f5c5SLiu Zhe 		writer.click(5, 5);
51680a6f5c5SLiu Zhe 		sleep(1);
51780a6f5c5SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
51880a6f5c5SLiu Zhe 		discard();
51980a6f5c5SLiu Zhe 	}
52080a6f5c5SLiu Zhe 
52180a6f5c5SLiu Zhe 	/**
52280a6f5c5SLiu Zhe 	 * Test insert a chart in a spreadsheet document 1. New a spreadsheet
52380a6f5c5SLiu Zhe 	 * document 2. Insert a chart 3. Check if the chart is inserted successfully
52480a6f5c5SLiu Zhe 	 *
52580a6f5c5SLiu Zhe 	 * @throws Exception
52680a6f5c5SLiu Zhe 	 */
52780a6f5c5SLiu Zhe 	@Test
testInsertChartInSpreadsheet()52880a6f5c5SLiu Zhe 	public void testInsertChartInSpreadsheet() throws Exception {
52980a6f5c5SLiu Zhe 		// Create a new spreadsheet document
53080a6f5c5SLiu Zhe 		newSpreadsheet();
53180a6f5c5SLiu Zhe 		// Insert a chart
53280a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
53380a6f5c5SLiu Zhe 		sleep(3);
53480a6f5c5SLiu Zhe 		chartWizard.ok();
53580a6f5c5SLiu Zhe 
53680a6f5c5SLiu Zhe 		// Verify if the chart is inserted successfully
53780a6f5c5SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
53880a6f5c5SLiu Zhe 		// Focus on edit pane
53980a6f5c5SLiu Zhe 		calc.click(5, 5);
54080a6f5c5SLiu Zhe 		sleep(1);
54180a6f5c5SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
54280a6f5c5SLiu Zhe 		discard();
54380a6f5c5SLiu Zhe 	}
54480a6f5c5SLiu Zhe 
54580a6f5c5SLiu Zhe 	/**
54680a6f5c5SLiu Zhe 	 * Test insert a chart in a presentation document 1. New a presentation
54780a6f5c5SLiu Zhe 	 * document 2. Insert a chart 3. Check if the chart is inserted successfully
54880a6f5c5SLiu Zhe 	 *
54980a6f5c5SLiu Zhe 	 * @throws Exception
55080a6f5c5SLiu Zhe 	 */
55180a6f5c5SLiu Zhe 	@Test
testInsertChartInPresentation()55280a6f5c5SLiu Zhe 	public void testInsertChartInPresentation() throws Exception {
55380a6f5c5SLiu Zhe 		// Create a new presentation document
55480a6f5c5SLiu Zhe 		newPresentation();
55580a6f5c5SLiu Zhe 		// Insert a chart
55680a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
55780a6f5c5SLiu Zhe 		sleep(3);
55880a6f5c5SLiu Zhe 		// Verify if the chart is inserted successfully
55980a6f5c5SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
56080a6f5c5SLiu Zhe 		// Focus on edit pane
56180a6f5c5SLiu Zhe 		impress.click(5, 5);
56280a6f5c5SLiu Zhe 		sleep(1);
56380a6f5c5SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
56480a6f5c5SLiu Zhe 		discard();
56580a6f5c5SLiu Zhe 	}
56680a6f5c5SLiu Zhe 
56780a6f5c5SLiu Zhe 	/**
56880a6f5c5SLiu Zhe 	 * Test insert a table in a draw document 1. New a draw document 2. Insert a
56980a6f5c5SLiu Zhe 	 * default table 3. Check if the table is inserted successfully
57080a6f5c5SLiu Zhe 	 *
57180a6f5c5SLiu Zhe 	 * @throws Exception
57280a6f5c5SLiu Zhe 	 */
57380a6f5c5SLiu Zhe 	@Test
testInsertTableInDraw()57480a6f5c5SLiu Zhe 	public void testInsertTableInDraw() throws Exception {
57580a6f5c5SLiu Zhe 		// Create a new drawing document
57680a6f5c5SLiu Zhe 		newDrawing();
57780a6f5c5SLiu Zhe 		// Insert a table
57880a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertTable");
57980a6f5c5SLiu Zhe 		insertTable.ok();
58080a6f5c5SLiu Zhe 		sleep(1);
58180a6f5c5SLiu Zhe 		draw.typeKeys("3");
58280a6f5c5SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
58380a6f5c5SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
58480a6f5c5SLiu Zhe 		discard();
58580a6f5c5SLiu Zhe 	}
58680a6f5c5SLiu Zhe 
58780a6f5c5SLiu Zhe 	/**
58880a6f5c5SLiu Zhe 	 * Test insert a table in a text document 1. New a text document 2. Insert a
58980a6f5c5SLiu Zhe 	 * default table 3. Check if the table is inserted successfully
59080a6f5c5SLiu Zhe 	 *
59180a6f5c5SLiu Zhe 	 * @throws Exception
59280a6f5c5SLiu Zhe 	 */
59380a6f5c5SLiu Zhe 	@Test
testInsertTableInDocument()59480a6f5c5SLiu Zhe 	public void testInsertTableInDocument() throws Exception {
59580a6f5c5SLiu Zhe 		// Create a new text document
59680a6f5c5SLiu Zhe 		newTextDocument();
59780a6f5c5SLiu Zhe 		// Insert a table
59880a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertTable");
59980a6f5c5SLiu Zhe 		writerInsertTable.ok();
60080a6f5c5SLiu Zhe 		sleep(1);
60180a6f5c5SLiu Zhe 		writer.typeKeys("3");
60280a6f5c5SLiu Zhe 		// Verify if the table toolbar is active
60380a6f5c5SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
60480a6f5c5SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
60580a6f5c5SLiu Zhe 		discard();
60680a6f5c5SLiu Zhe 	}
60780a6f5c5SLiu Zhe 
60880a6f5c5SLiu Zhe 	/**
60980a6f5c5SLiu Zhe 	 * Test insert a table in a presentation document 1. New a presentation
61080a6f5c5SLiu Zhe 	 * document 2. Insert a default table 3. Check if the table is inserted
61180a6f5c5SLiu Zhe 	 * successfully
61280a6f5c5SLiu Zhe 	 *
61380a6f5c5SLiu Zhe 	 * @throws Exception
61480a6f5c5SLiu Zhe 	 */
61580a6f5c5SLiu Zhe 	@Test
testInsertTableInPresentation()61680a6f5c5SLiu Zhe 	public void testInsertTableInPresentation() throws Exception {
61780a6f5c5SLiu Zhe 		// Create a new presentation document
61880a6f5c5SLiu Zhe 		newPresentation();
61980a6f5c5SLiu Zhe 
62080a6f5c5SLiu Zhe 		// Insert a table
62180a6f5c5SLiu Zhe 		app.dispatch(".uno:InsertTable");
62280a6f5c5SLiu Zhe 		insertTable.ok();
62380a6f5c5SLiu Zhe 		sleep(1);
62480a6f5c5SLiu Zhe 		impress.typeKeys("3");
62580a6f5c5SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
62680a6f5c5SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
62780a6f5c5SLiu Zhe 		discard();
62880a6f5c5SLiu Zhe 	}
62980a6f5c5SLiu Zhe 
63080a6f5c5SLiu Zhe 	/**
63180a6f5c5SLiu Zhe 	 * Test insert a function in a spreadsheet document via Sum button 1. New a
63280a6f5c5SLiu Zhe 	 * spreadsheet document 2. Insert a function via Sum button 3. Check if the
63380a6f5c5SLiu Zhe 	 * result is correct
63480a6f5c5SLiu Zhe 	 *
63580a6f5c5SLiu Zhe 	 * @throws Exception
63680a6f5c5SLiu Zhe 	 */
63780a6f5c5SLiu Zhe 	@Test
testSumInFormulaBar()63880a6f5c5SLiu Zhe 	public void testSumInFormulaBar() throws Exception {
63980a6f5c5SLiu Zhe 		// Create a new spreadsheet document
64080a6f5c5SLiu Zhe 		newSpreadsheet();
64180a6f5c5SLiu Zhe 		// Insert source numbers
64280a6f5c5SLiu Zhe 		String sourceNumber1 = "5";
64380a6f5c5SLiu Zhe 		String sourceNumber2 = "3";
64480a6f5c5SLiu Zhe 		String expectedResult = "8";
64580a6f5c5SLiu Zhe 		SCTool.selectRange("A1");
64680a6f5c5SLiu Zhe 		typeKeys(sourceNumber1);
64780a6f5c5SLiu Zhe 		SCTool.selectRange("B1");
64880a6f5c5SLiu Zhe 		typeKeys(sourceNumber2);
64980a6f5c5SLiu Zhe 		// Insert a function via Sum button
65080a6f5c5SLiu Zhe 		SCTool.selectRange("C1");
65180a6f5c5SLiu Zhe 		scInputBarSum.click();
65280a6f5c5SLiu Zhe 		typeKeys("<enter>");
65380a6f5c5SLiu Zhe 		// Verify if the calculated result is equal to the expected result
65480a6f5c5SLiu Zhe 		assertEquals("The calculated result", expectedResult, SCTool.getCellText("C1"));
65580a6f5c5SLiu Zhe 		discard();
65680a6f5c5SLiu Zhe 	}
65780a6f5c5SLiu Zhe 
65880a6f5c5SLiu Zhe 	/**
65980a6f5c5SLiu Zhe 	 * Test insert a function in a spreadsheet document via inputbar 1. New a
66080a6f5c5SLiu Zhe 	 * spreadsheet document 2. Insert a function via inputbar: COS 3. Check if
66180a6f5c5SLiu Zhe 	 * the result is correct
66280a6f5c5SLiu Zhe 	 *
66380a6f5c5SLiu Zhe 	 * @throws Exception
66480a6f5c5SLiu Zhe 	 */
66580a6f5c5SLiu Zhe 	@Test
testInsertFunctionViaFormulaBar()66680a6f5c5SLiu Zhe 	public void testInsertFunctionViaFormulaBar() throws Exception {
66780a6f5c5SLiu Zhe 		// Create a new spreadsheet document
66880a6f5c5SLiu Zhe 		newSpreadsheet();
66980a6f5c5SLiu Zhe 		// Insert source numbers and expected result
67080a6f5c5SLiu Zhe 		String sourceData = "0";
67180a6f5c5SLiu Zhe 		String expectedResult = "1";
67280a6f5c5SLiu Zhe 		SCTool.selectRange("A1");
67380a6f5c5SLiu Zhe 		typeKeys(sourceData);
67480a6f5c5SLiu Zhe 
67580a6f5c5SLiu Zhe 		// Insert a function via inputbar: COS
67680a6f5c5SLiu Zhe 		SCTool.selectRange("D1");
67780a6f5c5SLiu Zhe 		scInputBarInput.inputKeys("=COS(A1)");
67880a6f5c5SLiu Zhe 		typeKeys("<enter>");
67980a6f5c5SLiu Zhe 
68080a6f5c5SLiu Zhe 		// Verify if the calculated result is equal to the expected result
68180a6f5c5SLiu Zhe 		assertEquals("The calculated result", expectedResult, SCTool.getCellText("D1"));
68280a6f5c5SLiu Zhe 		discard();
68380a6f5c5SLiu Zhe 	}
68480a6f5c5SLiu Zhe 
68580a6f5c5SLiu Zhe 	/**
68680a6f5c5SLiu Zhe 	 * Test insert a function in a spreadsheet document via Function Wizard
68780a6f5c5SLiu Zhe 	 * Dialog 1. New a spreadsheet document 2. Insert a function via Function
68880a6f5c5SLiu Zhe 	 * Wizard Dialog: ABS 3. Check if the result is correct
68980a6f5c5SLiu Zhe 	 *
69080a6f5c5SLiu Zhe 	 * @throws Exception
69180a6f5c5SLiu Zhe 	 */
69280a6f5c5SLiu Zhe 	@Test
testFunctionWizardInFormulaBar()69380a6f5c5SLiu Zhe 	public void testFunctionWizardInFormulaBar() throws Exception {
69480a6f5c5SLiu Zhe 		// Create a new spreadsheet document
69580a6f5c5SLiu Zhe 		newSpreadsheet();
69680a6f5c5SLiu Zhe 		// Insert source number
69780a6f5c5SLiu Zhe 		String sourceNumber = "-5";
69880a6f5c5SLiu Zhe 		String expectedResult = "5";
69980a6f5c5SLiu Zhe 		SCTool.selectRange("A1");
70080a6f5c5SLiu Zhe 		typeKeys(sourceNumber);
70180a6f5c5SLiu Zhe 		typeKeys("<enter>");
70280a6f5c5SLiu Zhe 		// Insert a function via Function Wizard Dialog: ABS
70380a6f5c5SLiu Zhe 		SCTool.selectRange("B1");
70480a6f5c5SLiu Zhe 		app.dispatch(".uno:FunctionDialog");
70580a6f5c5SLiu Zhe 		// SC_FunctionWizardDlg_FunctionList.doubleClick(5, 5);
70680a6f5c5SLiu Zhe 		scFunctionWizardDlgFunctionList.select("ABS");
70780a6f5c5SLiu Zhe 		scFunctionWizardDlgNext.click(); // Use "Next" button
70844cf0280SCarl Marcum 		scFunctionWizardDlgEdit1.typeKeys("A1");
70980a6f5c5SLiu Zhe 		scFunctionWizardDlg.ok();
71080a6f5c5SLiu Zhe 		// Verify if the calculated result is equal to the expected result
71180a6f5c5SLiu Zhe 		assertEquals("The calculated result", expectedResult, SCTool.getCellText("B1"));
71280a6f5c5SLiu Zhe 		discard();
71380a6f5c5SLiu Zhe 	}
7147d082fd9SCarl Marcum 
7157d082fd9SCarl Marcum 	/**
7167d082fd9SCarl Marcum 	 * Test open a non-http(s) type hyperlink (with host only) in a text document.
7177d082fd9SCarl Marcum 	 * (coverage included in fvt.gui.sw.hyperlink.WarningDialog
7187d082fd9SCarl Marcum 	 * testHyperlinkDisplaysWarning() and included here for build verification)
7197d082fd9SCarl Marcum 	 * 1. New a text document
7207d082fd9SCarl Marcum 	 * 2. Insert a dav type hyperlink
7217d082fd9SCarl Marcum 	 * 3. Open hyperlink
7227d082fd9SCarl Marcum 	 * 4. Verify security warning dialog is displayed
7237d082fd9SCarl Marcum 	 *
7247d082fd9SCarl Marcum 	 * @throws Exception
7257d082fd9SCarl Marcum 	 */
7267d082fd9SCarl Marcum 	@Test
testNonHttpHyperlinkWithHostOnly()7277d082fd9SCarl Marcum 	public void testNonHttpHyperlinkWithHostOnly() throws Exception {
7287d082fd9SCarl Marcum 		// Create a new text document
7297d082fd9SCarl Marcum 		newTextDocument();
7307d082fd9SCarl Marcum 		writer.waitForExistence(10, 2);
7317d082fd9SCarl Marcum 		// open the hyperlink dialog
7327d082fd9SCarl Marcum 		writer.typeKeys("<alt i>"); // insert menu
7337d082fd9SCarl Marcum 		writer.typeKeys("h"); // hyperlink
7347d082fd9SCarl Marcum 		hyperlinkInetPathComboBox.setText("dav://nonexistant.url.com"); //target
7357d082fd9SCarl Marcum 		hyperlinkInetText.setText("dav://nonexistant.url.com"); // displayed text
7367d082fd9SCarl Marcum 		hyperlinkDialogOkBtn.click(); // apply
7377d082fd9SCarl Marcum 		hyperlinkDialogCancelBtn.click(); // close
7387d082fd9SCarl Marcum 		sleep(1); // give the dialog time to close
7397d082fd9SCarl Marcum 		typeKeys("<shift F10>"); // context menu
7407d082fd9SCarl Marcum 		typeKeys("o"); // open hyperlink
7417d082fd9SCarl Marcum 		// we can't be sure of the language so just check for the dialog
7427d082fd9SCarl Marcum 		boolean msgExists = activeMsgBox.exists(1); // wait 1 second for the dialog
7437d082fd9SCarl Marcum 		if (msgExists) {
7447d082fd9SCarl Marcum 			activeMsgBox.no(); // close dialog
7457d082fd9SCarl Marcum 		}
7467d082fd9SCarl Marcum 		assertTrue("security warning not displayed", msgExists);
7477d082fd9SCarl Marcum 		discard();
7487d082fd9SCarl Marcum 	}
7497d082fd9SCarl Marcum 
75080a6f5c5SLiu Zhe }