merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / ui / _XUIElementFactoryRegistration.java
blob64303c216abcb3a2cf37f6a82848af27dcb63537
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XUIElementFactoryRegistration.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.ui;
33 import com.sun.star.beans.PropertyValue;
34 import com.sun.star.ui.XUIElementFactory;
35 import com.sun.star.ui.XUIElementFactoryRegistration;
36 import lib.MultiMethodTest;
38 public class _XUIElementFactoryRegistration extends MultiMethodTest {
40 public XUIElementFactoryRegistration oObj;
42 public void _registerFactory() {
43 boolean result = true;
44 try {
45 oObj.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory");
47 catch(com.sun.star.container.ElementExistException e) {
48 result = false;
49 e.printStackTrace(log);
51 tRes.tested("registerFactory()", result);
54 public void _getRegisteredFactories() {
55 requiredMethod("registerFactory()");
56 PropertyValue[][]props = oObj.getRegisteredFactories();
57 if (props == null) {
58 log.println("Null was returned as PropertyValue[][]");
59 props = new PropertyValue[0][0];
61 for(int i=0; i<props.length; i++)
62 for(int j=0; j<props[i].length; j++)
63 log.println("Factory: " + props[i][j].Name + " - " + props[i][j].Value);
64 tRes.tested("getRegisteredFactories()", props.length != 0);
67 public void _getFactory() {
68 requiredMethod("registerFactory()");
69 XUIElementFactory xFactory = oObj.getFactory("private:resource/menubar/menubar", "");
70 tRes.tested("getFactory()", xFactory != null);
73 public void _deregisterFactory() {
74 executeMethod("getRegisteredFactory()");
75 executeMethod("getFactory()");
76 boolean result = true;
77 try {
78 oObj.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", "");
80 catch(com.sun.star.container.NoSuchElementException e) {
81 result = false;
82 e.printStackTrace(log);
84 tRes.tested("deregisterFactory()", true);