1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.ui; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.beans.PropertyValue; 27cdf0e10cSrcweir import com.sun.star.ui.XUIElementFactory; 28cdf0e10cSrcweir import com.sun.star.ui.XUIElementFactoryRegistration; 29cdf0e10cSrcweir import lib.MultiMethodTest; 30cdf0e10cSrcweir 31cdf0e10cSrcweir public class _XUIElementFactoryRegistration extends MultiMethodTest { 32cdf0e10cSrcweir 33cdf0e10cSrcweir public XUIElementFactoryRegistration oObj; 34cdf0e10cSrcweir _registerFactory()35cdf0e10cSrcweir public void _registerFactory() { 36cdf0e10cSrcweir boolean result = true; 37cdf0e10cSrcweir try { 38cdf0e10cSrcweir oObj.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory"); 39cdf0e10cSrcweir } 40cdf0e10cSrcweir catch(com.sun.star.container.ElementExistException e) { 41cdf0e10cSrcweir result = false; 42cdf0e10cSrcweir e.printStackTrace(log); 43cdf0e10cSrcweir } 44cdf0e10cSrcweir tRes.tested("registerFactory()", result); 45cdf0e10cSrcweir } 46cdf0e10cSrcweir _getRegisteredFactories()47cdf0e10cSrcweir public void _getRegisteredFactories() { 48cdf0e10cSrcweir requiredMethod("registerFactory()"); 49cdf0e10cSrcweir PropertyValue[][]props = oObj.getRegisteredFactories(); 50cdf0e10cSrcweir if (props == null) { 51cdf0e10cSrcweir log.println("Null was returned as PropertyValue[][]"); 52cdf0e10cSrcweir props = new PropertyValue[0][0]; 53cdf0e10cSrcweir } 54cdf0e10cSrcweir for(int i=0; i<props.length; i++) 55cdf0e10cSrcweir for(int j=0; j<props[i].length; j++) 56cdf0e10cSrcweir log.println("Factory: " + props[i][j].Name + " - " + props[i][j].Value); 57cdf0e10cSrcweir tRes.tested("getRegisteredFactories()", props.length != 0); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir _getFactory()60cdf0e10cSrcweir public void _getFactory() { 61cdf0e10cSrcweir requiredMethod("registerFactory()"); 62cdf0e10cSrcweir XUIElementFactory xFactory = oObj.getFactory("private:resource/menubar/menubar", ""); 63cdf0e10cSrcweir tRes.tested("getFactory()", xFactory != null); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir _deregisterFactory()66cdf0e10cSrcweir public void _deregisterFactory() { 67cdf0e10cSrcweir executeMethod("getRegisteredFactory()"); 68cdf0e10cSrcweir executeMethod("getFactory()"); 69cdf0e10cSrcweir boolean result = true; 70cdf0e10cSrcweir try { 71cdf0e10cSrcweir oObj.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", ""); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir catch(com.sun.star.container.NoSuchElementException e) { 74cdf0e10cSrcweir result = false; 75cdf0e10cSrcweir e.printStackTrace(log); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir tRes.tested("deregisterFactory()", true); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir } 80