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