1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
5 *
6 * OpenOffice.org - a multi-platform office productivity suite
7 *
8 * This file is part of OpenOffice.org.
9 *
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
13 *
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org.  If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
25 
26 package org.openoffice.testgraphical.qa.graphical;
27 
28 import org.openoffice.Runner;
29 import org.openoffice.test.OfficeConnection;
30 import static org.junit.Assert.*;
31 
32 import helper.ProcessHandler;
33 import graphical.FileHelper;
34 import java.io.File;
35 
36 public final class Test {
37     @org.junit.Before
38     public void setUp() throws Exception
39         {
40             connection.setUp();
41         }
42 
43     @org.junit.After
44     public void tearDown() throws Exception
45         {
46             connection.tearDown();
47         }
48 
49     @org.junit.Test
50     public void test()
51         {
52             boolean good = true;
53 
54             final String sPerlEXE = System.getenv("PERL");
55             // System.out.println("PERL:=" + sPerlEXE);
56 
57             final String sPRJ = System.getenv("PRJ");
58             // System.out.println("PRJ:=" + sPRJ);
59 
60             String sShow = "";
61             if (System.getProperty("SHOW") != null)
62             {
63                 sShow = "-show";
64             }
65 
66             final String sComparePath = FileHelper.appendPath(sPRJ, "source");
67             final String sCompareName = FileHelper.appendPath(sComparePath, "compare.pl");
68 
69             File aCompareFile = new File(sCompareName);
70             if (!aCompareFile.exists())
71             {
72                 System.out.println("Path to compare.pl is wrong: '" + aCompareFile.getAbsolutePath() + "'");
73                 assertTrue(false);
74             }
75 
76             final String sConnectionString = connection.getDescription();
77 
78             String[] sCommandArray =
79                 {
80                     sPerlEXE,
81                     aCompareFile.getAbsolutePath(),
82                     "-creatortype", "pdf",
83 
84 // If you make changes here, do it also in ../../source/makefile.mk in selftest: target!
85 
86                     "-pool",        "singletest",
87                     "-document",    "eis-test.odt",
88                     // "-pool",        "demo",
89                     // "-document",    "CurrentTime.ods",
90                     "-connectionstring", sConnectionString,
91                     // "-verbose",
92                     sShow
93                 };
94 
95             ProcessHandler aHandler = new ProcessHandler(sCommandArray);
96             boolean bBackValue = aHandler.executeSynchronously();
97             int nExitCode = aHandler.getExitCode();
98 
99             // String sBack = aHandler.getOutputText();
100             if (nExitCode != 0)
101             {
102                 good = false;
103             }
104 
105             assertTrue(good);
106 
107             // Runner.run(
108             //     "-sce", "sw.sce", "-xcl", "knownissues.xcl", "-tdoc",
109             //     "testdocuments", "-cs", connection.getDescription()));
110     }
111 
112     private final OfficeConnection connection = new OfficeConnection();
113 }
114