1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._sfx;
29 
30 import java.io.PrintWriter;
31 
32 import lib.Status;
33 import lib.StatusException;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 import util.dbg;
38 import util.utils;
39 
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.uno.XInterface;
42 
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.comp.office.FrameLoader</code>. <p>
46 * Object implements the following interfaces :
47 * <ul>
48 *  <li> <code>com::sun::star::frame::XFrameLoader</code></li>
49 * </ul>
50 * This object test <b> is NOT </b> designed to be run in several
51 * threads concurently.
52 * @see com.sun.star.frame.FrameLoader
53 * @see com.sun.star.frame.XSynchronousFrameLoader
54 */
55 public class FrameLoader extends TestCase {
56 
57     /**
58     * Creating a Testenvironment for the interfaces to be tested.
59     * Creates an instance of the service
60     * <code>com.sun.star.comp.office.FrameLoader</code>. <p>
61     *     Object relations created :
62     * <ul>
63     *  <li> <code>'FrameLoader.URL"'</code> for
64     *      {@link ifc.frame._XFrameLoader} </li>
65     * </ul>
66     */
67     protected TestEnvironment createTestEnvironment
68             (TestParameters Param, PrintWriter log) {
69         XInterface oObj = null;
70         Object oInterface = null ;
71 
72         //now get the OButtonControl
73         try {
74             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
75                 ("com.sun.star.comp.office.FrameLoader") ;
76 
77         } catch (com.sun.star.uno.Exception e) {
78             log.println("Couldn't get service");
79             e.printStackTrace(log);
80             throw new StatusException("Couldn't get GridControl", e );
81         }
82 
83         if (oInterface == null) {
84             log.println("Service wasn't created") ;
85             throw new StatusException
86                 (Status.failed("Service wasn't created")) ;
87         }
88 
89         oObj = (XInterface) oInterface ;
90         System.out.println("ImplName: "+utils.getImplName(oObj));
91         dbg.printInterfaces(oObj);
92 
93         log.println( "creating a new environment for object" );
94         TestEnvironment tEnv = new TestEnvironment( oObj );
95 
96         // adding relation for XFrameLoader
97         tEnv.addObjRelation("FrameLoader.URL","private:factory/swriter");
98 
99         return tEnv;
100     } // finish method getTestEnvironment
101 
102 }
103 
104