1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._sm;
29 
30 import java.io.PrintWriter;
31 
32 import lib.StatusException;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
36 import util.SOfficeFactory;
37 
38 import com.sun.star.lang.XComponent;
39 import com.sun.star.lang.XMultiServiceFactory;
40 
41 /**
42  * Test for object which is represented by
43  * <code>'StarMath'</code> document. <p>
44  *
45  * Object implements the following interfaces :
46  * <ul>
47  *  <li> <code>com::sun::star::formula::FormulaProperties</code></li>
48  * </ul> <p>
49  *
50  * This object test <b> is NOT </b> designed to be run in several
51  * threads concurently.
52  *
53  * @see com.sun.star.formula.FormulaProperties
54  * @see ifc.formula._FormulaProperties
55  */
56 public class SmModel extends TestCase {
57     XComponent xMathDoc;
58 
59     /**
60      * Creating a Testenvironment for the interfaces to be tested.
61      * Creates a <code>StarMath</code> document and passes it as
62      * tested component.
63      */
64     public synchronized TestEnvironment createTestEnvironment
65             ( TestParameters Param, PrintWriter log )
66             throws StatusException {
67 
68         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() );
69         try {
70             xMathDoc = SOF.openDoc("smath","_blank");
71         } catch (com.sun.star.lang.IllegalArgumentException ex) {
72             ex.printStackTrace( log );
73             throw new StatusException( "Couldn't create document", ex );
74         } catch (com.sun.star.io.IOException ex) {
75             ex.printStackTrace( log );
76             throw new StatusException( "Couldn't create document", ex );
77         } catch (com.sun.star.uno.Exception ex) {
78             ex.printStackTrace( log );
79             throw new StatusException( "Couldn't create document", ex );
80         }
81 
82         String Iname = util.utils.getImplName(xMathDoc);
83         log.println("Implementation Name: "+Iname);
84         TestEnvironment tEnv = new TestEnvironment(xMathDoc);
85         return tEnv;
86     }
87 
88     /**
89      * Disposes the document created in <code>createTestEnvironment</code>
90      * method.
91      */
92     protected void cleanup( TestParameters Param, PrintWriter log) {
93 
94         log.println( "    disposing xMathDoc " );
95         xMathDoc.dispose();
96     }
97 
98 
99 }    // finish class SmModel
100 
101