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