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._sfx;
25 
26 import java.io.PrintWriter;
27 
28 import lib.Status;
29 import lib.StatusException;
30 import lib.TestCase;
31 import lib.TestEnvironment;
32 import lib.TestParameters;
33 import util.dbg;
34 import util.utils;
35 
36 import com.sun.star.lang.XMultiServiceFactory;
37 import com.sun.star.uno.XInterface;
38 
39 /**
40  * Test for object which is represented by service
41  * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p>
42  * Object implements the following interfaces :
43  * <ul>
44  *  <li> <code>com::sun::star::frame::XDispatchProvider</code></li>
45  *  <li> <code>com::sun::star::lang::XInitialization</code></li>
46  * </ul>
47  * This object test <b> is NOT </b> designed to be run in several
48  * threads concurently.
49  * @see com.sun.star.frame.XDispatchProvider
50  * @see com.sun.star.lang.XInitialization
51  * @see ifc.frame._XDispatchProvider
52  * @see ifc.lang._XInitialization
53  */
54 public class AppDispatchProvider extends TestCase {
55 
56     /**
57     * Creating a Testenvironment for the interfaces to be tested.
58     * Creates an instance of the service
59     * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p>
60     *     Object relations created :
61     * <ul>
62     *  <li> <code>'FrameLoader.URL"'</code> for
63     *      {@link ifc.frame._XFrameLoader} </li>
64     * </ul>
65     */
createTestEnvironment(TestParameters Param, PrintWriter log)66     protected TestEnvironment createTestEnvironment
67             (TestParameters Param, PrintWriter log) {
68         XInterface oObj = null;
69         Object oInterface = null ;
70 
71         //now get the OButtonControl
72         try {
73             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
74                 ("com.sun.star.comp.sfx2.AppDispatchProvider") ;
75         } catch (com.sun.star.uno.Exception e) {
76             log.println("Couldn't get service");
77             e.printStackTrace(log);
78             throw new StatusException("Couldn't get GridControl", e );
79         }
80 
81         if (oInterface == null) {
82             log.println("Service wasn't created") ;
83             throw new StatusException(Status.failed("Service wasn't created")) ;
84         }
85 
86         oObj = (XInterface) oInterface ;
87         System.out.println("ImplName: "+utils.getImplName(oObj));
88         dbg.printInterfaces(oObj);
89 
90         log.println( "creating a new environment for object" );
91         TestEnvironment tEnv = new TestEnvironment( oObj );
92 
93         // adding relation for :XDispatchProvider
94         tEnv.addObjRelation("XDispatchProvider.URL", ".uno:BibliographyComponent") ;
95 
96         return tEnv;
97     } // finish method getTestEnvironment
98 
99 }
100 
101