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 package mod._sm;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 import util.SOfficeFactory;
33 
34 import com.sun.star.lang.XComponent;
35 import com.sun.star.lang.XMultiServiceFactory;
36 
37 /**
38  * Test for object which is represented by
39  * <code>'StarMath'</code> document. <p>
40  *
41  * Object implements the following interfaces :
42  * <ul>
43  *  <li> <code>com::sun::star::formula::FormulaProperties</code></li>
44  * </ul> <p>
45  *
46  * This object test <b> is NOT </b> designed to be run in several
47  * threads concurently.
48  *
49  * @see com.sun.star.formula.FormulaProperties
50  * @see ifc.formula._FormulaProperties
51  */
52 public class SmModel extends TestCase {
53     XComponent xMathDoc;
54 
55     /**
56      * Creating a Testenvironment for the interfaces to be tested.
57      * Creates a <code>StarMath</code> document and passes it as
58      * tested component.
59      */
createTestEnvironment( TestParameters Param, PrintWriter log )60     public synchronized TestEnvironment createTestEnvironment
61             ( TestParameters Param, PrintWriter log )
62             throws StatusException {
63 
64         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() );
65         try {
66             xMathDoc = SOF.openDoc("smath","_blank");
67         } catch (com.sun.star.lang.IllegalArgumentException ex) {
68             ex.printStackTrace( log );
69             throw new StatusException( "Couldn't create document", ex );
70         } catch (com.sun.star.io.IOException ex) {
71             ex.printStackTrace( log );
72             throw new StatusException( "Couldn't create document", ex );
73         } catch (com.sun.star.uno.Exception ex) {
74             ex.printStackTrace( log );
75             throw new StatusException( "Couldn't create document", ex );
76         }
77 
78         String Iname = util.utils.getImplName(xMathDoc);
79         log.println("Implementation Name: "+Iname);
80         TestEnvironment tEnv = new TestEnvironment(xMathDoc);
81         return tEnv;
82     }
83 
84     /**
85      * Disposes the document created in <code>createTestEnvironment</code>
86      * method.
87      */
cleanup( TestParameters Param, PrintWriter log)88     protected void cleanup( TestParameters Param, PrintWriter log) {
89 
90         log.println( "    disposing xMathDoc " );
91         xMathDoc.dispose();
92     }
93 
94 
95 }    // finish class SmModel
96 
97