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._fwl;
25 
26 import com.sun.star.beans.NamedValue;
27 import java.io.PrintWriter;
28 
29 import lib.Status;
30 import lib.StatusException;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
34 import util.utils;
35 
36 import com.sun.star.container.XNameAccess;
37 import com.sun.star.lang.XMultiServiceFactory;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
40 
41 /**
42  * Test for object which is represented by service
43  * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
44  *
45  * Object implements the following interfaces :
46  * <ul>
47  *  <li> <code>com::sun::star::container::XNameAccess</code></li>
48  *  <li> <code>com::sun::star::container::XElementAccess</code></li>
49  *  <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
50  * </ul> <p>
51  *
52  * @see com.sun.star.container.XNameAccess
53  * @see com.sun.star.container.XElementAccess
54  * @see com.sun.star.lang.XMultiServiceFactory
55  * @see ifc.container._XNameAccess
56  * @see ifc.container._XElementAccess
57  * @see ifc.lang._XMultiServiceFactory
58  */
59 public class FrameLoaderFactory extends TestCase {
60 
61     /**
62     * Creating a Testenvironment for the interfaces to be tested.
63     * Creates an instance of the service
64     * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
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         try {
72             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
73                 ("com.sun.star.frame.FrameLoaderFactory") ;
74         } catch (com.sun.star.uno.Exception e) {
75             log.println("Couldn't get service");
76             e.printStackTrace(log);
77             throw new StatusException("Couldn't get FrameLoaderFactory", e );
78         }
79 
80         if (oInterface == null) {
81             log.println("Service wasn't created") ;
82             throw new StatusException(Status.failed("Service wasn't created")) ;
83         }
84 
85         oObj = (XInterface) oInterface ;
86         log.println("ImplName: "+utils.getImplName(oObj));
87 
88         log.println( "creating a new environment for object" );
89         TestEnvironment tEnv = new TestEnvironment( oObj );
90 
91         XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface
92             (XNameAccess.class, oObj);
93         tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
94 
95         // com.sun.star.container.XContainerQuery
96         NamedValue[] querySequenze = new NamedValue[1];
97 		NamedValue query = new NamedValue();
98 		query.Name = "Name";
99         query.Value = "com.sun.star.frame.Bibliography";
100         querySequenze[0] = query;
101 
102         tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
103             querySequenze);
104 
105         return tEnv;
106     } // finish method getTestEnvironment
107 
108 }
109 
110