1 /*
2  * This file is part of the LibreOffice project.
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
10  *   Licensed to the Apache Software Foundation (ASF) under one or more
11  *   contributor license agreements. See the NOTICE file distributed
12  *   with this work for additional information regarding copyright
13  *   ownership. The ASF licenses this file to you under the Apache
14  *   License, Version 2.0 (the "License"); you may not use this file
15  *   except in compliance with the License. You may obtain a copy of
16  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17  */
18 
19 package mod._fwl;
20 
21 import com.sun.star.beans.NamedValue;
22 import java.io.PrintWriter;
23 
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.utils;
28 
29 import com.sun.star.container.XNameAccess;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
32 
33 /**
34  * Test for object which is represented by service
35  * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
36  *
37  * Object implements the following interfaces :
38  * <ul>
39  *  <li> <code>com::sun::star::container::XNameAccess</code></li>
40  *  <li> <code>com::sun::star::container::XElementAccess</code></li>
41  *  <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
42  * </ul> <p>
43  *
44  * @see com.sun.star.container.XNameAccess
45  * @see com.sun.star.container.XElementAccess
46  * @see com.sun.star.lang.XMultiServiceFactory
47  * @see ifc.container._XNameAccess
48  * @see ifc.container._XElementAccess
49  * @see ifc.lang._XMultiServiceFactory
50  */
51 public class ContentHandlerFactory 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.frame.ContentHandlerFactory</code>. <p>
57     */
58     @Override
createTestEnvironment(TestParameters Param, PrintWriter log)59     protected TestEnvironment createTestEnvironment
60             (TestParameters Param, PrintWriter log) throws Exception {
61         XInterface oObj = null;
62         Object oInterface = null ;
63 
64         //now get the OButtonControl
65         oInterface = Param.getMSF().createInstance
66             ("com.sun.star.frame.ContentHandlerFactory") ;
67 
68         oObj = (XInterface) oInterface ;
69         log.println("ImplName: "+utils.getImplName(oObj));
70 
71         log.println( "creating a new environment for object" );
72         TestEnvironment tEnv = new TestEnvironment( oObj );
73 
74         XNameAccess xNA = UnoRuntime.queryInterface
75             (XNameAccess.class, oObj);
76         tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
77         xNA.getElementNames();
78 
79         // com.sun.star.container.XContainerQuery
80         NamedValue[] querySequenze = new NamedValue[1];
81         NamedValue query = new NamedValue();
82         query.Name = "Name";
83         query.Value = "com.sun.star.comp.framework.SoundHandler";
84         querySequenze[0] = query;
85 
86         tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
87             querySequenze);
88 
89         return tEnv;
90     } // finish method getTestEnvironment
91 
92 }
93 
94