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._fwk;
25 
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.uno.UnoRuntime;
28 import com.sun.star.uno.XInterface;
29 import java.io.PrintWriter;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.util.XCloseable;
32 import lib.StatusException;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
36 import util.utils;
37 
38 /**
39  */
40 public class ObjectMenuController extends TestCase {
41     XInterface oObj = null;
42     XTextDocument xTextDoc;
43 
44     /**
45      * Cleanup: close the created document
46      * @param tParam The test parameters.
47      * @param The log writer.
48      * @return The test environment.
49      */
50     protected void cleanup(TestParameters tParam, PrintWriter log) {
51         log.println("    disposing xTextDoc ");
52 
53         try {
54             XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
55             XCloseable.class, xTextDoc);
56             closer.close(true);
57         } catch (com.sun.star.util.CloseVetoException e) {
58             log.println("couldn't close document");
59         } catch (com.sun.star.lang.DisposedException e) {
60             log.println("couldn't close document");
61         }
62     }
63 
64     /**
65      * Create test environment:
66      * <ul>
67      * <li>create a text doc</li>
68      * <li>get the model from the text doc</li>
69      * <li>query model for XUIConfigurationManagerSupplier interface</li>
70      * <li>get the manager from the supplier</li>
71      * </ul>
72      * @param tParam The test parameters.
73      * @param The log writer.
74      * @return The test environment.
75      */
76     protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
77         TestEnvironment tEnv = null;
78         XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
79 
80         try {
81             oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ObjectMenuController");
82         }
83         catch(com.sun.star.uno.Exception e) {
84             e.printStackTrace(log);
85             throw new StatusException("Could not create object 'ControlMenuController'", e);
86         }
87         log.println("TestObject: " + utils.getImplName(oObj));
88         tEnv = new TestEnvironment(oObj);
89         return tEnv;
90     }
91 }
92 
93 
94