1b164ae3eSLei De Bin /**************************************************************
22c9c3879Smseidel  *
3b164ae3eSLei De Bin  * Licensed to the Apache Software Foundation (ASF) under one
4b164ae3eSLei De Bin  * or more contributor license agreements.  See the NOTICE file
5b164ae3eSLei De Bin  * distributed with this work for additional information
6b164ae3eSLei De Bin  * regarding copyright ownership.  The ASF licenses this file
7b164ae3eSLei De Bin  * to you under the Apache License, Version 2.0 (the
8b164ae3eSLei De Bin  * "License"); you may not use this file except in compliance
9b164ae3eSLei De Bin  * with the License.  You may obtain a copy of the License at
102c9c3879Smseidel  *
11b164ae3eSLei De Bin  *   http://www.apache.org/licenses/LICENSE-2.0
122c9c3879Smseidel  *
13b164ae3eSLei De Bin  * Unless required by applicable law or agreed to in writing,
14b164ae3eSLei De Bin  * software distributed under the License is distributed on an
15b164ae3eSLei De Bin  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b164ae3eSLei De Bin  * KIND, either express or implied.  See the License for the
17b164ae3eSLei De Bin  * specific language governing permissions and limitations
18b164ae3eSLei De Bin  * under the License.
192c9c3879Smseidel  *
20b164ae3eSLei De Bin  *************************************************************/
21b164ae3eSLei De Bin 
222c9c3879Smseidel 
232c9c3879Smseidel 
24faa4b864SLei De Bin /**
252c9c3879Smseidel  *
26faa4b864SLei De Bin  */
2780a6f5c5SLiu Zhe package bvt.gui;
2832c31156SLiu Zhe 
2922a14f28SLiu Zhe import static org.junit.Assert.*;
3022a14f28SLiu Zhe import static org.openoffice.test.common.Testspace.*;
3122a14f28SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
32b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
3322a14f28SLiu Zhe import static testlib.gui.UIMap.*;
34faa4b864SLei De Bin 
35faa4b864SLei De Bin import java.awt.Rectangle;
3691745ed9SLiu Zhe import java.io.File;
37faa4b864SLei De Bin 
3891745ed9SLiu Zhe import org.junit.AfterClass;
39faa4b864SLei De Bin import org.junit.Before;
40b4d2d410SLiu Zhe import org.junit.BeforeClass;
41faa4b864SLei De Bin import org.junit.Rule;
42faa4b864SLei De Bin import org.junit.Test;
43faa4b864SLei De Bin import org.openoffice.test.common.FileUtil;
44faa4b864SLei De Bin import org.openoffice.test.common.GraphicsUtil;
4522a14f28SLiu Zhe import org.openoffice.test.common.Logger;
46faa4b864SLei De Bin 
47b4d2d410SLiu Zhe import testlib.gui.SCTool;
48faa4b864SLei De Bin 
49faa4b864SLei De Bin /**
502c9c3879Smseidel  *
51faa4b864SLei De Bin  */
5209c344eeSLiu Zhe public class BasicFunctionTest {
53faa4b864SLei De Bin 
54faa4b864SLei De Bin 	@Rule
5522a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
5632c31156SLiu Zhe 
57b4d2d410SLiu Zhe 	@BeforeClass
beforeClass()589edf8282SLiu Zhe 	public static void beforeClass() {
59b4d2d410SLiu Zhe 		app.clean();
602fc12ec5SLiu Zhe 	}
612fc12ec5SLiu Zhe 
6291745ed9SLiu Zhe 	@AfterClass
afterClass()639edf8282SLiu Zhe 	public static void afterClass() {
649edf8282SLiu Zhe 		app.stop();
6591745ed9SLiu Zhe 	}
662c9c3879Smseidel 
67b4d2d410SLiu Zhe 	@Before
before()68b4d2d410SLiu Zhe 	public void before() {
699edf8282SLiu Zhe 		app.stop();
70b4d2d410SLiu Zhe 		app.start();
71faa4b864SLei De Bin 	}
722c9c3879Smseidel 
7332c31156SLiu Zhe 
7491745ed9SLiu Zhe 	@Test
smokeTest()7591745ed9SLiu Zhe 	public void smokeTest() {
7691745ed9SLiu Zhe 		File smoketestOutput = new File(aoo.getUserInstallation(), "user/temp");
77a622bb93SDamjan Jovanovic 		File testDir = getFile().getParentFile();
78a622bb93SDamjan Jovanovic 		File smokeTestDir = new File(testDir, "smoketestdoc");
79a622bb93SDamjan Jovanovic 		File smokeTestTargetDir = new File(smokeTestDir, "target");
80a622bb93SDamjan Jovanovic 		prepareData(new File(smokeTestTargetDir, "TestExtension.oxt").getAbsolutePath());
8191745ed9SLiu Zhe 		// Open sample file smoketestdoc.sxw
82a622bb93SDamjan Jovanovic 		open(prepareData(new File(smokeTestTargetDir, "smoketestdoc.odt").getAbsolutePath()));
8391745ed9SLiu Zhe 		writer.waitForEnabled(10, 2);
8491745ed9SLiu Zhe 		// Run test cases
8591745ed9SLiu Zhe 		app.dispatch("vnd.sun.star.script:Standard.Global.StartTestWithDefaultOptions?language=Basic&location=document", 120);
8691745ed9SLiu Zhe 		String smoketestlog = FileUtil.readFileAsString(new File(smoketestOutput, "smoketest.log"));
8791745ed9SLiu Zhe 		String testclosurelog = FileUtil.readFileAsString(new File(smoketestOutput, "testclosure.log"));
8891745ed9SLiu Zhe 		log.info(smoketestlog + "\n" + testclosurelog);
8991745ed9SLiu Zhe 		assertTrue("No Error", !smoketestlog.contains("error") && !testclosurelog.contains("error"));
9091745ed9SLiu Zhe 
9191745ed9SLiu Zhe 	}
922c9c3879Smseidel 
93faa4b864SLei De Bin 	@Test
testExportAsPDF()9432c31156SLiu Zhe 	public void testExportAsPDF() throws Exception {
95b4d2d410SLiu Zhe 		String file = prepareData("bvt/pdf.odt");
96b4d2d410SLiu Zhe 		String exportTo1 = getPath("temp/1.pdf");
97b4d2d410SLiu Zhe 		String exportTo2 = getPath("temp/2.pdf");
98b4d2d410SLiu Zhe 		deleteFile(exportTo1);
99b4d2d410SLiu Zhe 		deleteFile(exportTo2);
100b4d2d410SLiu Zhe 		open(file);
101b4d2d410SLiu Zhe 		writer.waitForExistence(10, 1);
102cb6199d5SLiu Zhe 		app.dispatch(".uno:ExportToPDF");
103b4d2d410SLiu Zhe 		pdfGeneralPage.ok();
104b4d2d410SLiu Zhe 		submitSaveDlg(exportTo1);
105b4d2d410SLiu Zhe 		sleep(1);
106b4d2d410SLiu Zhe 		String magic = FileUtil.readFileAsString(exportTo1).substring(0, 4);
107b4d2d410SLiu Zhe 		assertEquals("PDF is exported?", "%PDF", magic);
1082c9c3879Smseidel 
109b4d2d410SLiu Zhe 		button(".uno:ExportDirectToPDF").click();//Click via toolbar
110b4d2d410SLiu Zhe 		submitSaveDlg(exportTo2);
111b4d2d410SLiu Zhe 		sleep(1);
112b4d2d410SLiu Zhe 		magic = FileUtil.readFileAsString(exportTo2).substring(0, 4);
113b4d2d410SLiu Zhe 		assertEquals("PDF is exported directly?", "%PDF", magic);
114faa4b864SLei De Bin 	}
11532c31156SLiu Zhe 
116faa4b864SLei De Bin 	/**
11732c31156SLiu Zhe 	 * Test the File -- Print Dialog show
1182c9c3879Smseidel 	 *
11932c31156SLiu Zhe 	 */
120faa4b864SLei De Bin 	@Test
testPrinter()121b4d2d410SLiu Zhe 	public void testPrinter() {
12232c31156SLiu Zhe 		// Create a new text document
123b4d2d410SLiu Zhe 		newTextDocument();
124b4d2d410SLiu Zhe 		app.dispatch(".uno:PrinterSetup");
125b4d2d410SLiu Zhe 		if (activeMsgBox.exists(2))
126b4d2d410SLiu Zhe 			activeMsgBox.ok();
1272c9c3879Smseidel 
128b4d2d410SLiu Zhe //		PrintService[] ps = PrintServiceLookup.lookupPrintServices(null, null);
129b4d2d410SLiu Zhe //		String[] names = new String[ps.length];
130b4d2d410SLiu Zhe //		for (int i = 0; i < ps.length; i++) {
131b4d2d410SLiu Zhe //			names[i] = ps[i].getName();
132b4d2d410SLiu Zhe //		}
1332c9c3879Smseidel //
134b4d2d410SLiu Zhe //		assertArrayEquals("Printers Names", names, printerSetUpDlgPrinterNames.getItemsText());
135b4d2d410SLiu Zhe 		assertTrue("Printer Setup dialog appears", printerSetUpDlg.exists(3));
136b4d2d410SLiu Zhe 		printerSetUpDlg.cancel();
13732c31156SLiu Zhe 	}
13832c31156SLiu Zhe 
139faa4b864SLei De Bin 	/**
14032c31156SLiu Zhe 	 * Test the File -- Java Dialog show
1412c9c3879Smseidel 	 *
14232c31156SLiu Zhe 	 */
143b4d2d410SLiu Zhe //	@Test
144b4d2d410SLiu Zhe //	public void testJavaDialog() {
145b4d2d410SLiu Zhe //
146b4d2d410SLiu Zhe //		// Create a new text document and launch a Wizards dialog which need JVM
147b4d2d410SLiu Zhe //		// work correctly.
148b4d2d410SLiu Zhe //		app.dispatch("private:factory/swriter");
149b4d2d410SLiu Zhe //		File tempfile = new File(oo.getUserInstallation(), "user/template/myAgendaTemplate.ott");
150b4d2d410SLiu Zhe //		FileUtil.deleteFile(tempfile);
151b4d2d410SLiu Zhe //		sleep(3);
152b4d2d410SLiu Zhe //		app.dispatch("service:com.sun.star.wizards.agenda.CallWizard?start");
153b4d2d410SLiu Zhe //		sleep(5);
154b4d2d410SLiu Zhe //		assertTrue(Wizards_AgendaDialog.exists(10));
155b4d2d410SLiu Zhe //		Wizards_AgendaDialog_FinishButton.click();
156b4d2d410SLiu Zhe //		sleep(10);
157b4d2d410SLiu Zhe //		writer.focus();
158b4d2d410SLiu Zhe //		sleep(1);
159b4d2d410SLiu Zhe //		app.dispatch(".uno:SelectAll");
160b4d2d410SLiu Zhe //		typeKeys("<$copy>");
161b4d2d410SLiu Zhe //		// System.out.println("now txt:"+app.getClipboard());
162b4d2d410SLiu Zhe //		// assertTrue(app.getClipboard().startsWith("<Name>"));
163b4d2d410SLiu Zhe //		assertNotNull(app.getClipboard());
164b4d2d410SLiu Zhe //	}
16532c31156SLiu Zhe 
166faa4b864SLei De Bin 	/**
16732c31156SLiu Zhe 	 * Test the Tools / Macros / Organize Dialogs" show
1682c9c3879Smseidel 	 *
16932c31156SLiu Zhe 	 */
170faa4b864SLei De Bin 	@Test
testRunMacro()171b4d2d410SLiu Zhe 	public void testRunMacro() {
172b4d2d410SLiu Zhe 		open(prepareData("bvt/macro.ods"));
173b4d2d410SLiu Zhe 		calc.waitForExistence(10, 2);
174b4d2d410SLiu Zhe 		app.dispatch(".uno:RunMacro");
175b4d2d410SLiu Zhe 		runMacroDlgCategories.expand("macro.ods");
176b4d2d410SLiu Zhe 		runMacroDlgCategories.expand("Standard");
177b4d2d410SLiu Zhe 		runMacroDlgCategories.select("Module1");
178b4d2d410SLiu Zhe 		runMacroDlgCommands.select(0);
179b4d2d410SLiu Zhe 		runMacroDlg.ok();
180882d61ebSCarl Marcum 		sleep(1);
181b4d2d410SLiu Zhe 		assertEquals("A3 should be =1+3", "4", SCTool.getCellText("A3"));
182b4d2d410SLiu Zhe 		discard();
183faa4b864SLei De Bin 	}
18432c31156SLiu Zhe 
185faa4b864SLei De Bin 	/**
18632c31156SLiu Zhe 	 * Test the About Dialog show
1872c9c3879Smseidel 	 *
18832c31156SLiu Zhe 	 */
189faa4b864SLei De Bin 	@Test
testHelp()190b4d2d410SLiu Zhe 	public void testHelp() {
191cb6199d5SLiu Zhe 		app.dispatch(".uno:About");
192b4d2d410SLiu Zhe 		assertTrue(aboutDialog.exists(5));
193b4d2d410SLiu Zhe 		aboutDialog.ok();
194b4d2d410SLiu Zhe 		sleep(1);
195b4d2d410SLiu Zhe 		typeKeys("<F1>");
196b4d2d410SLiu Zhe 		assertTrue(helpWindow.exists(5));
197b4d2d410SLiu Zhe 		helpWindow.close();
198faa4b864SLei De Bin 	}
19932c31156SLiu Zhe 
200faa4b864SLei De Bin 	/**
201faa4b864SLei De Bin 	 * Test inserting a picture in text document
2022c9c3879Smseidel 	 *
203faa4b864SLei De Bin 	 * @throws Exception
204faa4b864SLei De Bin 	 */
20532c31156SLiu Zhe 
206faa4b864SLei De Bin 	@Test
testInsertPictureInDocument()207faa4b864SLei De Bin 	public void testInsertPictureInDocument() throws Exception {
2086b55ece7SLiu Zhe 		String bmp_green = prepareData("image/green_256x256.bmp");
2096b55ece7SLiu Zhe 		String bmp_red = prepareData("image/red_256x256.bmp");
21032c31156SLiu Zhe 
21132c31156SLiu Zhe 		// Create a new text document
212b4d2d410SLiu Zhe 		newTextDocument();
21332c31156SLiu Zhe 		// Insert a picture fully filled with green
21432c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
215faa4b864SLei De Bin 		submitOpenDlg(bmp_green);
216b4d2d410SLiu Zhe 		writer.click(5,200);
217faa4b864SLei De Bin 		sleep(1);
21832c31156SLiu Zhe 
219faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
22022a14f28SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFF00FF00);
221b4d2d410SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
22232c31156SLiu Zhe 		// insert another picture
22332c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
224faa4b864SLei De Bin 		submitOpenDlg(bmp_red);
225b4d2d410SLiu Zhe 		writer.click(5, 200);
226faa4b864SLei De Bin 		sleep(1);
227faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
22822a14f28SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(writer.getScreenRectangle(), 0xFFFF0000);
229b4d2d410SLiu Zhe 		assertTrue("Green Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
230b4d2d410SLiu Zhe 		discard();
231faa4b864SLei De Bin 	}
232faa4b864SLei De Bin 
233faa4b864SLei De Bin 	@Test
testInsertPictureInSpreadsheet()234faa4b864SLei De Bin 	public void testInsertPictureInSpreadsheet() throws Exception {
235b4d2d410SLiu Zhe 		String bmp_green = prepareData("image/green_64x64.png");
236b4d2d410SLiu Zhe 		String bmp_red = prepareData("image/red_64x64.png");
237b4d2d410SLiu Zhe 		newSpreadsheet();
23832c31156SLiu Zhe 		// Insert a picture fully filled with green
23932c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
240faa4b864SLei De Bin 		submitOpenDlg(bmp_green);
241b4d2d410SLiu Zhe 		calc.click(5, 150);
242faa4b864SLei De Bin 		sleep(1);
24332c31156SLiu Zhe 
244faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
24522a14f28SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFF00FF00);
246b4d2d410SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
2472c9c3879Smseidel 
248b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
24932c31156SLiu Zhe 		// insert another picture
25032c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
251faa4b864SLei De Bin 		submitOpenDlg(bmp_red);
252b4d2d410SLiu Zhe 		calc.click(5, 150);
253faa4b864SLei De Bin 		sleep(1);
254faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
25522a14f28SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(calc.getScreenRectangle(), 0xFFFF0000);
256b4d2d410SLiu Zhe 		assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
257b4d2d410SLiu Zhe 		discard();
258faa4b864SLei De Bin 	}
25932c31156SLiu Zhe 
260faa4b864SLei De Bin 	@Test
testInsertPictureInPresentation()261faa4b864SLei De Bin 	public void testInsertPictureInPresentation() throws Exception {
2626b55ece7SLiu Zhe 		String bmp_green = prepareData("image/green_256x256.bmp");
2636b55ece7SLiu Zhe 		String bmp_red = prepareData("image/red_256x256.bmp");
264b4d2d410SLiu Zhe 		newPresentation();
26532c31156SLiu Zhe 		// Insert a picture fully filled with green
26632c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
267faa4b864SLei De Bin 		submitOpenDlg(bmp_green);
26832c31156SLiu Zhe 		impress.click(5, 5);
269faa4b864SLei De Bin 		sleep(1);
27032c31156SLiu Zhe 
271faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
27222a14f28SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFF00FF00);
273b4d2d410SLiu Zhe 		assertTrue("Green Picture is inserted?" + rectangle, rectangle != null && rectangle.getWidth() > 10);
27432c31156SLiu Zhe 		// insert another picture
27532c31156SLiu Zhe 		app.dispatch(".uno:InsertGraphic");
276faa4b864SLei De Bin 		submitOpenDlg(bmp_red);
277faa4b864SLei De Bin 		impress.click(1, 1);
278faa4b864SLei De Bin 		sleep(1);
279faa4b864SLei De Bin 		// Verify if the picture is inserted successfully
28022a14f28SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(impress.getScreenRectangle(), 0xFFFF0000);
281b4d2d410SLiu Zhe 		assertTrue("Red Picture is inserted? " + rectangle, rectangle != null && rectangle.getWidth() > 10);
282b4d2d410SLiu Zhe 		discard();
283faa4b864SLei De Bin 	}
28432c31156SLiu Zhe 
285faa4b864SLei De Bin 	@Test
testSlideShow()286faa4b864SLei De Bin 	public void testSlideShow() throws Exception {
287b4d2d410SLiu Zhe 		open(prepareData("bvt/slideshow.odp"));
288faa4b864SLei De Bin 		impress.waitForExistence(10, 2);
289b4d2d410SLiu Zhe 		sleep(1);
290b4d2d410SLiu Zhe 		impress.typeKeys("<F5>");
291faa4b864SLei De Bin 		sleep(3);
292b4d2d410SLiu Zhe 		Rectangle rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFFFF0000);
293faa4b864SLei De Bin 		assertNotNull("1st slide appears", rectangle);
294b4d2d410SLiu Zhe 		slideShow.click(0.5, 0.5);
295faa4b864SLei De Bin 		sleep(2);
296b4d2d410SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF00FF00);
297faa4b864SLei De Bin 		assertNotNull("2nd slide appears", rectangle);
298faa4b864SLei De Bin 		typeKeys("<enter>");
299faa4b864SLei De Bin 		sleep(2);
300b4d2d410SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF);
301faa4b864SLei De Bin 		assertNotNull("3rd slide appears", rectangle);
302b4d2d410SLiu Zhe 		slideShow.click(0.5, 0.5);
303faa4b864SLei De Bin 		sleep(2);
304b4d2d410SLiu Zhe 		rectangle = GraphicsUtil.findRectangle(slideShow.getScreenRectangle(), 0xFF0000FF);
305faa4b864SLei De Bin 		assertNull("The end", rectangle);
306b4d2d410SLiu Zhe 		slideShow.click(0.5, 0.5);
307faa4b864SLei De Bin 		sleep(3);
308b4d2d410SLiu Zhe 		assertFalse("Quit", slideShow.exists());
309faa4b864SLei De Bin 	}
31032c31156SLiu Zhe 
311faa4b864SLei De Bin 	@Test
testFind()312faa4b864SLei De Bin 	public void testFind() {
313b4d2d410SLiu Zhe 		open(prepareData("bvt/find.odt"));
314faa4b864SLei De Bin 		writer.waitForExistence(10, 2);
31532c31156SLiu Zhe 		app.dispatch(".uno:SearchDialog");
316b4d2d410SLiu Zhe 		findDlgFor.setText("OpenOffice");
317b4d2d410SLiu Zhe 		findDlgFind.click();
318faa4b864SLei De Bin 		sleep(1);
319b4d2d410SLiu Zhe 		writer.typeKeys("<$copy>");
320faa4b864SLei De Bin 		assertEquals("OpenOffice", app.getClipboard());
321b4d2d410SLiu Zhe 		findDlgFindAll.click();
322faa4b864SLei De Bin 		sleep(1);
323b4d2d410SLiu Zhe 		writer.typeKeys("<$copy>");
324faa4b864SLei De Bin 		assertEquals("OpenOfficeOpenOfficeOpenOffice", app.getClipboard());
325b4d2d410SLiu Zhe 		findDlgReplaceWith.setText("Awesome OpenOffice");
326b4d2d410SLiu Zhe 		findDlgReplaceAll.click();
327faa4b864SLei De Bin 		sleep(1);
328faa4b864SLei De Bin 		msgbox("Search key replaced 3 times.").ok();
329b4d2d410SLiu Zhe 		findDlg.close();
330faa4b864SLei De Bin 		sleep(1);
33132c31156SLiu Zhe 		assertEquals(
332*190f2c20Scbmarcum 				"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. ",
333b4d2d410SLiu Zhe 				copyAll());
334bf385f73SDamjan Jovanovic 		discard();
335faa4b864SLei De Bin 	}
3362c9c3879Smseidel 
3372e4d2335SDamjan Jovanovic 	@Test
testFindFormulasAndValues()3382e4d2335SDamjan Jovanovic 	public void testFindFormulasAndValues() {
3392c9c3879Smseidel 		open(prepareData("bvt/searchFormulasValues.ods"));
3402c9c3879Smseidel 		calc.waitForExistence(10, 2);
3412c9c3879Smseidel 
3422c9c3879Smseidel 		// Searching for 2003 by formula finds A2
3432c9c3879Smseidel 		SCTool.selectRange("A1");
3442c9c3879Smseidel 		app.dispatch(".uno:SearchDialog");
3452c9c3879Smseidel 		findDlgFor.setText("2003");
3462c9c3879Smseidel 		findDlgMore.click();
3472c9c3879Smseidel 		findDlgCalcSearchIn.select("Formulas");
3482c9c3879Smseidel 		findDlgFind.click();
3492c9c3879Smseidel 		sleep(1);
3502c9c3879Smseidel 		assertEquals("wrong cell found for formulas search", "A2", scInputBarPosition.getText());
3512c9c3879Smseidel 		findDlg.close();
3522c9c3879Smseidel 
3532c9c3879Smseidel 		// Searching for October by value finds A2
3542c9c3879Smseidel 		SCTool.selectRange("A1");
3552c9c3879Smseidel 		app.dispatch(".uno:SearchDialog");
3562c9c3879Smseidel 		findDlgFor.setText("October");
3572c9c3879Smseidel 		findDlgMore.click();
3582c9c3879Smseidel 		findDlgCalcSearchIn.select("Values");
3592c9c3879Smseidel 		findDlgFind.click();
3602c9c3879Smseidel 		sleep(1);
3612c9c3879Smseidel 		assertEquals("wrong cell found for values search", "A2", scInputBarPosition.getText());
3622c9c3879Smseidel 		findDlg.close();
3632c9c3879Smseidel 
3642c9c3879Smseidel 		discard();
3652e4d2335SDamjan Jovanovic 	}
36632c31156SLiu Zhe 
367faa4b864SLei De Bin 	@Test
testFillInSpreadsheet()368faa4b864SLei De Bin 	public void testFillInSpreadsheet() {
36922a14f28SLiu Zhe 		String[][] expected1 = new String[][] { { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, { "1" }, };
37022a14f28SLiu Zhe 		String[][] expected2 = new String[][] { { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, { "2" }, };
37122a14f28SLiu Zhe 		String[][] expected3 = new String[][] { { "Hi friends", "Hi friends", "Hi friends", "Hi friends" } };
37222a14f28SLiu Zhe 		String[][] expected4 = new String[][] { { "99999.999", "99999.999", "99999.999", "99999.999" } };
373faa4b864SLei De Bin 		String[][] expected5 = new String[][] {
37422a14f28SLiu Zhe 		{ "99999.999", "-10" }, { "100000.999", "-9" }, { "100001.999", "-8" }, { "100002.999", "-7" }, { "100003.999", "-6" }
375faa4b864SLei De Bin 		};
376b4d2d410SLiu Zhe 		newSpreadsheet();
377b4d2d410SLiu Zhe 		SCTool.selectRange("C5");
378faa4b864SLei De Bin 		typeKeys("1<enter>");
379b4d2d410SLiu Zhe 		SCTool.selectRange("C5:C10");
38032c31156SLiu Zhe 		app.dispatch(".uno:FillDown");
381b4d2d410SLiu Zhe 		assertArrayEquals("Fill Down:", expected1, SCTool.getCellTexts("C5:C10"));
38232c31156SLiu Zhe 
383b4d2d410SLiu Zhe 		SCTool.selectRange("D10");
384faa4b864SLei De Bin 		typeKeys("2<enter>");
385b4d2d410SLiu Zhe 		SCTool.selectRange("D5:D10");
38632c31156SLiu Zhe 		app.dispatch(".uno:FillUp");
387b4d2d410SLiu Zhe 		assertArrayEquals("Fill Up:", expected2, SCTool.getCellTexts("D5:D10"));
38832c31156SLiu Zhe 
389b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
390faa4b864SLei De Bin 		typeKeys("Hi friends<enter>");
391b4d2d410SLiu Zhe 		SCTool.selectRange("A1:D1");
39232c31156SLiu Zhe 		app.dispatch(".uno:FillRight");
393b4d2d410SLiu Zhe 		assertArrayEquals("Fill Right:", expected3, SCTool.getCellTexts("A1:D1"));
39432c31156SLiu Zhe 
395b4d2d410SLiu Zhe 		SCTool.selectRange("D2");
396faa4b864SLei De Bin 		typeKeys("99999.999<enter>");
397b4d2d410SLiu Zhe 		SCTool.selectRange("A2:D2");
39832c31156SLiu Zhe 		app.dispatch(".uno:FillLeft");
399b4d2d410SLiu Zhe 		assertArrayEquals("Fill left:", expected4, SCTool.getCellTexts("A2:D2"));
400faa4b864SLei De Bin 
401b4d2d410SLiu Zhe 		SCTool.selectRange("E1");
402faa4b864SLei De Bin 		typeKeys("99999.999<tab>-10<enter>");
40332c31156SLiu Zhe 
404b4d2d410SLiu Zhe 		SCTool.selectRange("E1:F5");
40532c31156SLiu Zhe 		app.dispatch(".uno:FillSeries");
406b4d2d410SLiu Zhe 		fillSeriesDlg.ok();
407faa4b864SLei De Bin 		sleep(1);
408b4d2d410SLiu Zhe 		assertArrayEquals("Fill series..", expected5, SCTool.getCellTexts("E1:F5"));
409b4d2d410SLiu Zhe 		discard();
410faa4b864SLei De Bin 	}
41132c31156SLiu Zhe 
412faa4b864SLei De Bin 	@Test
testSort()413faa4b864SLei De Bin 	public void testSort() {
41422a14f28SLiu Zhe 		String[][] expected1 = new String[][] { { "-9999999" }, { "-1.1" }, { "-1.1" }, { "0" }, { "0" }, { "0.1" }, { "10" }, { "12" }, { "9999999" }, { "9999999" },
415faa4b864SLei De Bin 
416faa4b864SLei De Bin 		};
41722a14f28SLiu Zhe 		String[][] expected2 = new String[][] { { "TRUE", "Oracle" }, { "TRUE", "OpenOffice" }, { "FALSE", "OpenOffice" }, { "TRUE", "IBM" }, { "FALSE", "IBM" },
41822a14f28SLiu Zhe 				{ "TRUE", "Google" }, { "FALSE", "facebook " }, { "TRUE", "Apache" }, { "TRUE", "!yahoo" }, { "TRUE", "" },
419faa4b864SLei De Bin 
420faa4b864SLei De Bin 		};
421faa4b864SLei De Bin 
42222a14f28SLiu Zhe 		String[][] expected3 = new String[][] { { "Sunday" }, { "Monday" }, { "Tuesday" }, { "Wednesday" }, { "Thursday" }, { "Friday" }, { "Saturday" },
423faa4b864SLei De Bin 
424faa4b864SLei De Bin 		};
42532c31156SLiu Zhe 
42622a14f28SLiu Zhe 		String[][] expected4 = new String[][] { { "-$10.00" }, { "$0.00" }, { "$0.00" }, { "$1.00" }, { "$3.00" }, { "$9.00" }, { "$123.00" }, { "$200.00" }, { "$400.00" },
42722a14f28SLiu Zhe 				{ "$10,000.00" },
428faa4b864SLei De Bin 
429faa4b864SLei De Bin 		};
430b4d2d410SLiu Zhe 		open(prepareData("bvt/sort.ods"));
431faa4b864SLei De Bin 		calc.waitForExistence(10, 2);
432b4d2d410SLiu Zhe 		SCTool.selectRange("A1:A10");
433cb6199d5SLiu Zhe 		app.dispatch(".uno:DataSort");
434b4d2d410SLiu Zhe 		sortWarningDlgCurrent.click();
435b4d2d410SLiu Zhe 		assertEquals(1, sortPageBy1.getSelIndex());
436b4d2d410SLiu Zhe 		sortPage.ok();
437faa4b864SLei De Bin 		sleep(1);
438b4d2d410SLiu Zhe 		assertArrayEquals("Sorted Data", expected1, SCTool.getCellTexts("A1:A10"));
439b4d2d410SLiu Zhe 		SCTool.selectRange("B1:C10");
440cb6199d5SLiu Zhe 		app.dispatch(".uno:DataSort");
4417dd7871fSLei De Bin 
442b4d2d410SLiu Zhe 		sortPageBy1.select(2);
443b4d2d410SLiu Zhe 		sortPageDescending1.check();
444b4d2d410SLiu Zhe 		assertFalse(sortPageBy3.isEnabled());
445b4d2d410SLiu Zhe 		assertFalse(sortPageAscending3.isEnabled());
446b4d2d410SLiu Zhe 		assertFalse(sortPageDescending3.isEnabled());
447b4d2d410SLiu Zhe 		sortPageBy2.select(1);
448b4d2d410SLiu Zhe 		assertTrue(sortPageBy3.isEnabled());
449b4d2d410SLiu Zhe 		assertTrue(sortPageAscending3.isEnabled());
450b4d2d410SLiu Zhe 		assertTrue(sortPageDescending3.isEnabled());
451b4d2d410SLiu Zhe 		sortPageDescending2.check();
452b4d2d410SLiu Zhe 		sortPageBy2.select(0);
453b4d2d410SLiu Zhe 		assertFalse(sortPageBy3.isEnabled());
454b4d2d410SLiu Zhe 		assertFalse(sortPageAscending3.isEnabled());
455b4d2d410SLiu Zhe 		assertFalse(sortPageDescending3.isEnabled());
456b4d2d410SLiu Zhe 		sortPageBy2.select(1);
457b4d2d410SLiu Zhe 		sortPage.ok();
458faa4b864SLei De Bin 		sleep(1);
45932c31156SLiu Zhe 
460b4d2d410SLiu Zhe 		assertArrayEquals("Sorted Data", expected2, SCTool.getCellTexts("B1:C10"));
461b4d2d410SLiu Zhe 		SCTool.selectRange("D1:D7");
462cb6199d5SLiu Zhe 		app.dispatch(".uno:DataSort");
463b4d2d410SLiu Zhe 		sortWarningDlgCurrent.click();
464b4d2d410SLiu Zhe 		sortOptionsPage.select();
465b4d2d410SLiu Zhe 		sortOptionsPageRangeContainsColumnLabels.uncheck();
466b4d2d410SLiu Zhe 		sortOptionsPageCustomSortOrder.check();
467b4d2d410SLiu Zhe 		sortOptionsPageCustomSortOrderList.select("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday");
468b4d2d410SLiu Zhe 		sortOptionsPage.ok();
469faa4b864SLei De Bin 		sleep(1);
470b4d2d410SLiu Zhe 		assertArrayEquals("Sorted Data", expected3, SCTool.getCellTexts("D1:D7"));
47132c31156SLiu Zhe 
472b4d2d410SLiu Zhe 		SCTool.selectRange("E1:E10");
473cb6199d5SLiu Zhe 		app.dispatch(".uno:DataSort");
474b4d2d410SLiu Zhe 		sortWarningDlgCurrent.click();
475b4d2d410SLiu Zhe 		sortPage.ok();
476faa4b864SLei De Bin 		sleep(1);
477b4d2d410SLiu Zhe 		assertArrayEquals("Sorted Data", expected4, SCTool.getCellTexts("E1:E10"));
478b4d2d410SLiu Zhe 		discard();
479faa4b864SLei De Bin 	}
48032c31156SLiu Zhe 
4817dd2b5bbSLiu Zhe 	/**
48232c31156SLiu Zhe 	 * Test insert a chart in a draw document 1. New a draw document 2. Insert a
48332c31156SLiu Zhe 	 * chart 3. Check if the chart is inserted successfully
4842c9c3879Smseidel 	 *
4857dd2b5bbSLiu Zhe 	 * @throws Exception
4867dd2b5bbSLiu Zhe 	 */
4877dd2b5bbSLiu Zhe 	@Test
testInsertChartInDraw()48832c31156SLiu Zhe 	public void testInsertChartInDraw() throws Exception {
4897dd2b5bbSLiu Zhe 		// Create a new drawing document
490b4d2d410SLiu Zhe 		newDrawing();
4917dd2b5bbSLiu Zhe 		// Insert a chart
49232c31156SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
4937dd2b5bbSLiu Zhe 		sleep(3);
49432c31156SLiu Zhe 
4957dd2b5bbSLiu Zhe 		// Verify if the chart is inserted successfully
496b4d2d410SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
4977dd2b5bbSLiu Zhe 		// Focus on edit pane
49832c31156SLiu Zhe 		draw.click(5, 5);
4997dd2b5bbSLiu Zhe 		sleep(1);
500b4d2d410SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
501b4d2d410SLiu Zhe 		discard();
5027dd2b5bbSLiu Zhe 	}
50332c31156SLiu Zhe 
5047dd2b5bbSLiu Zhe 	/**
50532c31156SLiu Zhe 	 * Test insert a chart in a text document 1. New a text document 2. Insert a
50632c31156SLiu Zhe 	 * chart 3. Check if the chart is inserted successfully
5072c9c3879Smseidel 	 *
5087dd2b5bbSLiu Zhe 	 * @throws Exception
5097dd2b5bbSLiu Zhe 	 */
5107dd2b5bbSLiu Zhe 	@Test
testInsertChartInDocument()51132c31156SLiu Zhe 	public void testInsertChartInDocument() throws Exception {
5127dd2b5bbSLiu Zhe 		// Create a new text document
513b4d2d410SLiu Zhe 		newTextDocument();
5147dd2b5bbSLiu Zhe 		// Insert a chart
51532c31156SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
5167dd2b5bbSLiu Zhe 		sleep(3);
51732c31156SLiu Zhe 
5187dd2b5bbSLiu Zhe 		// Verify if the chart is inserted successfully
519b4d2d410SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
5207dd2b5bbSLiu Zhe 		// Focus on edit pane
52132c31156SLiu Zhe 		writer.click(5, 5);
5227dd2b5bbSLiu Zhe 		sleep(1);
523b4d2d410SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
524b4d2d410SLiu Zhe 		discard();
5257dd2b5bbSLiu Zhe 	}
52632c31156SLiu Zhe 
5277dd2b5bbSLiu Zhe 	/**
52832c31156SLiu Zhe 	 * Test insert a chart in a spreadsheet document 1. New a spreadsheet
52932c31156SLiu Zhe 	 * document 2. Insert a chart 3. Check if the chart is inserted successfully
5302c9c3879Smseidel 	 *
5317dd2b5bbSLiu Zhe 	 * @throws Exception
5327dd2b5bbSLiu Zhe 	 */
5337dd2b5bbSLiu Zhe 	@Test
testInsertChartInSpreadsheet()53432c31156SLiu Zhe 	public void testInsertChartInSpreadsheet() throws Exception {
5357dd2b5bbSLiu Zhe 		// Create a new spreadsheet document
536b4d2d410SLiu Zhe 		newSpreadsheet();
5377dd2b5bbSLiu Zhe 		// Insert a chart
53832c31156SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
5397dd2b5bbSLiu Zhe 		sleep(3);
540b4d2d410SLiu Zhe 		chartWizard.ok();
54132c31156SLiu Zhe 
5427dd2b5bbSLiu Zhe 		// Verify if the chart is inserted successfully
543b4d2d410SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
5447dd2b5bbSLiu Zhe 		// Focus on edit pane
54532c31156SLiu Zhe 		calc.click(5, 5);
54632c31156SLiu Zhe 		sleep(1);
547b4d2d410SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
548b4d2d410SLiu Zhe 		discard();
5497dd2b5bbSLiu Zhe 	}
55032c31156SLiu Zhe 
5517dd2b5bbSLiu Zhe 	/**
55232c31156SLiu Zhe 	 * Test insert a chart in a presentation document 1. New a presentation
55332c31156SLiu Zhe 	 * document 2. Insert a chart 3. Check if the chart is inserted successfully
5542c9c3879Smseidel 	 *
5557dd2b5bbSLiu Zhe 	 * @throws Exception
5567dd2b5bbSLiu Zhe 	 */
5572aaec72aSLiu Zhe 	@Test
testInsertChartInPresentation()55832c31156SLiu Zhe 	public void testInsertChartInPresentation() throws Exception {
5597dd2b5bbSLiu Zhe 		// Create a new presentation document
560b4d2d410SLiu Zhe 		newPresentation();
5617dd2b5bbSLiu Zhe 		// Insert a chart
56232c31156SLiu Zhe 		app.dispatch(".uno:InsertObjectChart");
5637dd2b5bbSLiu Zhe 		sleep(3);
5647dd2b5bbSLiu Zhe 		// Verify if the chart is inserted successfully
565b4d2d410SLiu Zhe 		assertTrue("Chart Editor appears", chart.exists(3));
5667dd2b5bbSLiu Zhe 		// Focus on edit pane
56732c31156SLiu Zhe 		impress.click(5, 5);
56832c31156SLiu Zhe 		sleep(1);
569b4d2d410SLiu Zhe 		assertFalse("Chart Editor appears", chart.exists());
570b4d2d410SLiu Zhe 		discard();
5717dd2b5bbSLiu Zhe 	}
57232c31156SLiu Zhe 
5737dd2b5bbSLiu Zhe 	/**
57432c31156SLiu Zhe 	 * Test insert a table in a draw document 1. New a draw document 2. Insert a
57532c31156SLiu Zhe 	 * default table 3. Check if the table is inserted successfully
5762c9c3879Smseidel 	 *
5777dd2b5bbSLiu Zhe 	 * @throws Exception
5787dd2b5bbSLiu Zhe 	 */
5797dd2b5bbSLiu Zhe 	@Test
testInsertTableInDraw()58032c31156SLiu Zhe 	public void testInsertTableInDraw() throws Exception {
5817dd2b5bbSLiu Zhe 		// Create a new drawing document
582b4d2d410SLiu Zhe 		newDrawing();
5837dd2b5bbSLiu Zhe 		// Insert a table
58432c31156SLiu Zhe 		app.dispatch(".uno:InsertTable");
585b4d2d410SLiu Zhe 		insertTable.ok();
5867dd2b5bbSLiu Zhe 		sleep(1);
587b4d2d410SLiu Zhe 		draw.typeKeys("3");
588b4d2d410SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
589b4d2d410SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
590b4d2d410SLiu Zhe 		discard();
5917dd2b5bbSLiu Zhe 	}
59232c31156SLiu Zhe 
5937dd2b5bbSLiu Zhe 	/**
59432c31156SLiu Zhe 	 * Test insert a table in a text document 1. New a text document 2. Insert a
59532c31156SLiu Zhe 	 * default table 3. Check if the table is inserted successfully
5962c9c3879Smseidel 	 *
5977dd2b5bbSLiu Zhe 	 * @throws Exception
5987dd2b5bbSLiu Zhe 	 */
5997dd2b5bbSLiu Zhe 	@Test
testInsertTableInDocument()60032c31156SLiu Zhe 	public void testInsertTableInDocument() throws Exception {
6017dd2b5bbSLiu Zhe 		// Create a new text document
602b4d2d410SLiu Zhe 		newTextDocument();
6037dd2b5bbSLiu Zhe 		// Insert a table
60432c31156SLiu Zhe 		app.dispatch(".uno:InsertTable");
605b4d2d410SLiu Zhe 		writerInsertTable.ok();
6067dd2b5bbSLiu Zhe 		sleep(1);
607b4d2d410SLiu Zhe 		writer.typeKeys("3");
608b4d2d410SLiu Zhe 		// Verify if the table toolbar is active
609b4d2d410SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
610b4d2d410SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
611b4d2d410SLiu Zhe 		discard();
6127dd2b5bbSLiu Zhe 	}
61332c31156SLiu Zhe 
6147dd2b5bbSLiu Zhe 	/**
61532c31156SLiu Zhe 	 * Test insert a table in a presentation document 1. New a presentation
61632c31156SLiu Zhe 	 * document 2. Insert a default table 3. Check if the table is inserted
61732c31156SLiu Zhe 	 * successfully
6182c9c3879Smseidel 	 *
6197dd2b5bbSLiu Zhe 	 * @throws Exception
6207dd2b5bbSLiu Zhe 	 */
6217dd2b5bbSLiu Zhe 	@Test
testInsertTableInPresentation()62232c31156SLiu Zhe 	public void testInsertTableInPresentation() throws Exception {
6237dd2b5bbSLiu Zhe 		// Create a new presentation document
624b4d2d410SLiu Zhe 		newPresentation();
62532c31156SLiu Zhe 
6267dd2b5bbSLiu Zhe 		// Insert a table
62732c31156SLiu Zhe 		app.dispatch(".uno:InsertTable");
628b4d2d410SLiu Zhe 		insertTable.ok();
6297dd2b5bbSLiu Zhe 		sleep(1);
630b4d2d410SLiu Zhe 		impress.typeKeys("3");
631b4d2d410SLiu Zhe 		assertTrue("Table Toolbar appears", tableToolbar.exists(3));
632b4d2d410SLiu Zhe //		assertEquals("The cell content", "3", copyAll());
633b4d2d410SLiu Zhe 		discard();
6347dd2b5bbSLiu Zhe 	}
6357dd2b5bbSLiu Zhe 
6367dd2b5bbSLiu Zhe 	/**
63732c31156SLiu Zhe 	 * Test insert a function in a spreadsheet document via Sum button 1. New a
63832c31156SLiu Zhe 	 * spreadsheet document 2. Insert a function via Sum button 3. Check if the
63932c31156SLiu Zhe 	 * result is correct
6402c9c3879Smseidel 	 *
6417dd2b5bbSLiu Zhe 	 * @throws Exception
6427dd2b5bbSLiu Zhe 	 */
6437dd2b5bbSLiu Zhe 	@Test
testSumInFormulaBar()644b4d2d410SLiu Zhe 	public void testSumInFormulaBar() throws Exception {
6457dd2b5bbSLiu Zhe 		// Create a new spreadsheet document
646b4d2d410SLiu Zhe 		newSpreadsheet();
6477dd2b5bbSLiu Zhe 		// Insert source numbers
6487dd2b5bbSLiu Zhe 		String sourceNumber1 = "5";
6497dd2b5bbSLiu Zhe 		String sourceNumber2 = "3";
6507dd2b5bbSLiu Zhe 		String expectedResult = "8";
651b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
6527dd2b5bbSLiu Zhe 		typeKeys(sourceNumber1);
653b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
65432c31156SLiu Zhe 		typeKeys(sourceNumber2);
6557dd2b5bbSLiu Zhe 		// Insert a function via Sum button
656b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
657b4d2d410SLiu Zhe 		scInputBarSum.click();
6587dd2b5bbSLiu Zhe 		typeKeys("<enter>");
6597dd2b5bbSLiu Zhe 		// Verify if the calculated result is equal to the expected result
660b4d2d410SLiu Zhe 		assertEquals("The calculated result", expectedResult, SCTool.getCellText("C1"));
661b4d2d410SLiu Zhe 		discard();
6627dd2b5bbSLiu Zhe 	}
66332c31156SLiu Zhe 
6647dd2b5bbSLiu Zhe 	/**
66532c31156SLiu Zhe 	 * Test insert a function in a spreadsheet document via inputbar 1. New a
66632c31156SLiu Zhe 	 * spreadsheet document 2. Insert a function via inputbar: COS 3. Check if
66732c31156SLiu Zhe 	 * the result is correct
6682c9c3879Smseidel 	 *
6697dd2b5bbSLiu Zhe 	 * @throws Exception
6707dd2b5bbSLiu Zhe 	 */
6717dd2b5bbSLiu Zhe 	@Test
testInsertFunctionViaFormulaBar()672b4d2d410SLiu Zhe 	public void testInsertFunctionViaFormulaBar() throws Exception {
6737dd2b5bbSLiu Zhe 		// Create a new spreadsheet document
674b4d2d410SLiu Zhe 		newSpreadsheet();
6757dd2b5bbSLiu Zhe 		// Insert source numbers and expected result
67632c31156SLiu Zhe 		String sourceData = "0";
67732c31156SLiu Zhe 		String expectedResult = "1";
678b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
67932c31156SLiu Zhe 		typeKeys(sourceData);
68032c31156SLiu Zhe 
68132c31156SLiu Zhe 		// Insert a function via inputbar: COS
682b4d2d410SLiu Zhe 		SCTool.selectRange("D1");
683b4d2d410SLiu Zhe 		scInputBarInput.inputKeys("=COS(A1)");
6847dd2b5bbSLiu Zhe 		typeKeys("<enter>");
6852c9c3879Smseidel 		sleep(1);
6867dd2b5bbSLiu Zhe 		// Verify if the calculated result is equal to the expected result
6872c9c3879Smseidel 		String result = SCTool.getCellText("D1");
688882d61ebSCarl Marcum 		sleep(1);
6892c9c3879Smseidel 		assertEquals("The calculated result", expectedResult, result);
690b4d2d410SLiu Zhe 		discard();
6917dd2b5bbSLiu Zhe 	}
69232c31156SLiu Zhe 
6937dd2b5bbSLiu Zhe 	/**
69432c31156SLiu Zhe 	 * Test insert a function in a spreadsheet document via Function Wizard
69532c31156SLiu Zhe 	 * Dialog 1. New a spreadsheet document 2. Insert a function via Function
69632c31156SLiu Zhe 	 * Wizard Dialog: ABS 3. Check if the result is correct
6972c9c3879Smseidel 	 *
6987dd2b5bbSLiu Zhe 	 * @throws Exception
6997dd2b5bbSLiu Zhe 	 */
7007dd2b5bbSLiu Zhe 	@Test
testFunctionWizardInFormulaBar()701b4d2d410SLiu Zhe 	public void testFunctionWizardInFormulaBar() throws Exception {
7027dd2b5bbSLiu Zhe 		// Create a new spreadsheet document
703b4d2d410SLiu Zhe 		newSpreadsheet();
7047dd2b5bbSLiu Zhe 		// Insert source number
7057dd2b5bbSLiu Zhe 		String sourceNumber = "-5";
7067dd2b5bbSLiu Zhe 		String expectedResult = "5";
707b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
7087dd2b5bbSLiu Zhe 		typeKeys(sourceNumber);
7097dd2b5bbSLiu Zhe 		typeKeys("<enter>");
7107dd2b5bbSLiu Zhe 		// Insert a function via Function Wizard Dialog: ABS
711b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
71232c31156SLiu Zhe 		app.dispatch(".uno:FunctionDialog");
71322a14f28SLiu Zhe 		// SC_FunctionWizardDlg_FunctionList.doubleClick(5, 5);
714b4d2d410SLiu Zhe 		scFunctionWizardDlgFunctionList.select("ABS");
715b4d2d410SLiu Zhe 		scFunctionWizardDlgNext.click(); // Use "Next" button
716f9b06548Sdamjan 		scFunctionWizardDlgEdit1.typeKeys("A1");
717882d61ebSCarl Marcum 		sleep(1);
718b4d2d410SLiu Zhe 		scFunctionWizardDlg.ok();
719882d61ebSCarl Marcum 		sleep(1);
7207dd2b5bbSLiu Zhe 		// Verify if the calculated result is equal to the expected result
7212c9c3879Smseidel 		String result = SCTool.getCellText("B1");
722882d61ebSCarl Marcum 		sleep(1);
7232c9c3879Smseidel 		assertEquals("The calculated result", expectedResult, result);
724b4d2d410SLiu Zhe 		discard();
7257dd2b5bbSLiu Zhe 	}
726be190f59SCarl Marcum 
727be190f59SCarl Marcum 	/**
728be190f59SCarl Marcum 	 * Test open a non-http(s) type hyperlink (with host only) in a text document.
729be190f59SCarl Marcum 	 * (coverage included in fvt.gui.sw.hyperlink.WarningDialog
730be190f59SCarl Marcum 	 * testHyperlinkDisplaysWarning() and included here for build verification)
731be190f59SCarl Marcum 	 * 1. New a text document
732be190f59SCarl Marcum 	 * 2. Insert a dav type hyperlink
733be190f59SCarl Marcum 	 * 3. Open hyperlink
734be190f59SCarl Marcum 	 * 4. Verify security warning dialog is displayed
735be190f59SCarl Marcum 	 *
736be190f59SCarl Marcum 	 * @throws Exception
737be190f59SCarl Marcum 	 */
738be190f59SCarl Marcum 	@Test
testNonHttpHyperlinkWithHostOnly()739be190f59SCarl Marcum 	public void testNonHttpHyperlinkWithHostOnly() throws Exception {
740be190f59SCarl Marcum 		// Create a new text document
741be190f59SCarl Marcum 		newTextDocument();
742be190f59SCarl Marcum 		writer.waitForExistence(10, 2);
743be190f59SCarl Marcum 		// open the hyperlink dialog
744be190f59SCarl Marcum 		writer.typeKeys("<alt i>"); // insert menu
745be190f59SCarl Marcum 		writer.typeKeys("h"); // hyperlink
746be190f59SCarl Marcum 		hyperlinkInetPathComboBox.setText("dav://nonexistant.url.com"); //target
747be190f59SCarl Marcum 		hyperlinkInetText.setText("dav://nonexistant.url.com"); // displayed text
748be190f59SCarl Marcum 		hyperlinkDialogOkBtn.click(); // apply
749be190f59SCarl Marcum 		hyperlinkDialogCancelBtn.click(); // close
750be190f59SCarl Marcum 		sleep(1); // give the dialog time to close
751be190f59SCarl Marcum 		typeKeys("<shift F10>"); // context menu
752be190f59SCarl Marcum 		typeKeys("o"); // open hyperlink
753be190f59SCarl Marcum 		// we can't be sure of the language so just check for the dialog
754be190f59SCarl Marcum 		boolean msgExists = activeMsgBox.exists(1); // wait 1 second for the dialog
755be190f59SCarl Marcum 		if (msgExists) {
756be190f59SCarl Marcum 			activeMsgBox.no(); // close dialog
757be190f59SCarl Marcum 		}
758be190f59SCarl Marcum 		assertTrue("security warning not displayed", msgExists);
759be190f59SCarl Marcum 		discard();
760be190f59SCarl Marcum 	}
761be190f59SCarl Marcum 
7622c9c3879Smseidel }
763