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