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._sw;
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.beans.XPropertySet;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.text.XTextDocument;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
39 
40 /**
41  * Test for object which is represented by PropertySetInfo of
42  * text document.<p>
43  * Object implements the following interfaces :
44  * <ul>
45  *  <li> <code>com::sun::star::beans::XPropertySetInfo</code></li>
46  * </ul> <p>
47  * This object test <b> is NOT </b> designed to be run in several
48  * threads concurently.
49  * @see com.sun.star.beans.XPropertySetInfo
50  * @see ifc.beans._XPropertySetInfo
51  */
52 public class SwXPropertySetInfo extends TestCase {
53     XTextDocument xTextDoc;
54 
55     /**
56     * Disposes text document.
57     */
cleanup( TestParameters Param, PrintWriter log)58     protected void cleanup( TestParameters Param, PrintWriter log) {
59         log.println( "    disposing xTextDoc " );
60         util.DesktopTools.closeDoc(xTextDoc);
61     }
62 
63     /**
64     * Creating a Testenvironment for the interfaces to be tested. Method
65     * creates text document, then obtains PropertySetInfo of created text
66     * document using <code>XPropertySet</code> interface.
67     */
createTestEnvironment( TestParameters Param, PrintWriter log )68     public synchronized TestEnvironment createTestEnvironment(
69             TestParameters Param, PrintWriter log ) throws StatusException {
70         XInterface oObj = null;
71 
72         log.println( "creating a test environment" );
73         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() );
74         try {
75             log.println( "creating a textdocument" );
76             xTextDoc = SOF.createTextDoc( null );
77         } catch ( com.sun.star.uno.Exception e ) {
78             e.printStackTrace( log );
79             throw new StatusException( "Couldn't create document", e );
80         }
81 
82         log.println( "    getting the XPropertySetInfo" );
83         XPropertySet xProp = (XPropertySet)
84             UnoRuntime.queryInterface(XPropertySet.class, xTextDoc);
85         oObj = xProp.getPropertySetInfo();
86         log.println( "    creating a new environment for PropertySetInfo object" );
87 
88         TestEnvironment tEnv = new TestEnvironment( oObj );
89         return tEnv;
90     } // finish method getTestEnvironment
91 
92 }    // finish class SwXPropertySetInfo
93 
94