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