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 ifc.ui;
25 
26 import com.sun.star.beans.PropertyValue;
27 import com.sun.star.ui.XUIElementFactory;
28 import com.sun.star.ui.XUIElementFactoryRegistration;
29 import lib.MultiMethodTest;
30 
31 public class _XUIElementFactoryRegistration extends MultiMethodTest {
32 
33     public XUIElementFactoryRegistration oObj;
34 
_registerFactory()35     public void _registerFactory() {
36         boolean result = true;
37         try {
38             oObj.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory");
39         }
40         catch(com.sun.star.container.ElementExistException e) {
41             result = false;
42             e.printStackTrace(log);
43         }
44         tRes.tested("registerFactory()", result);
45     }
46 
_getRegisteredFactories()47     public void _getRegisteredFactories() {
48         requiredMethod("registerFactory()");
49         PropertyValue[][]props = oObj.getRegisteredFactories();
50         if (props == null) {
51             log.println("Null was returned as PropertyValue[][]");
52             props = new PropertyValue[0][0];
53         }
54         for(int i=0; i<props.length; i++)
55             for(int j=0; j<props[i].length; j++)
56                 log.println("Factory: " + props[i][j].Name + "    -    " + props[i][j].Value);
57         tRes.tested("getRegisteredFactories()", props.length != 0);
58     }
59 
_getFactory()60     public void _getFactory() {
61         requiredMethod("registerFactory()");
62         XUIElementFactory xFactory = oObj.getFactory("private:resource/menubar/menubar", "");
63         tRes.tested("getFactory()", xFactory != null);
64     }
65 
_deregisterFactory()66     public void _deregisterFactory() {
67         executeMethod("getRegisteredFactory()");
68         executeMethod("getFactory()");
69         boolean result = true;
70         try {
71             oObj.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", "");
72         }
73         catch(com.sun.star.container.NoSuchElementException e) {
74             result = false;
75             e.printStackTrace(log);
76         }
77         tRes.tested("deregisterFactory()", true);
78     }
79 }
80