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 ContentHandlerFactory 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.ContentHandlerFactory</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         //now get the OButtonControl
72         try {
73             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
74                 ("com.sun.star.frame.ContentHandlerFactory") ;
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 ContentHandlerFactory", 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         log.println("ImplName: "+utils.getImplName(oObj));
88 
89         log.println( "creating a new environment for object" );
90         TestEnvironment tEnv = new TestEnvironment( oObj );
91 
92         XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface
93             (XNameAccess.class, oObj);
94         tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
95         String[] dummy = xNA.getElementNames();
96 
97         // com.sun.star.container.XContainerQuery
98         NamedValue[] querySequenze = new NamedValue[1];
99 		NamedValue query = new NamedValue();
100 		query.Name = "Name";
101         query.Value = "com.sun.star.comp.framework.SoundHandler";
102         querySequenze[0] = query;
103 
104         tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
105             querySequenze);
106 
107         return tEnv;
108     } // finish method getTestEnvironment
109 
110 }
111 
112