2 * This file is part of the LibreOffice project.
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/.
8 * This file incorporates work covered by the following license notice:
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 .
21 import com
.sun
.star
.beans
.PropertyValue
;
22 import com
.sun
.star
.ui
.XUIElementFactory
;
23 import com
.sun
.star
.ui
.XUIElementFactoryRegistration
;
24 import lib
.MultiMethodTest
;
26 public class _XUIElementFactoryRegistration
extends MultiMethodTest
{
28 public XUIElementFactoryRegistration oObj
;
30 public void _registerFactory() {
31 boolean result
= true;
33 oObj
.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory");
35 catch(com
.sun
.star
.container
.ElementExistException e
) {
37 e
.printStackTrace(log
);
39 tRes
.tested("registerFactory()", result
);
42 public void _getRegisteredFactories() {
43 requiredMethod("registerFactory()");
44 PropertyValue
[][]props
= oObj
.getRegisteredFactories();
46 log
.println("Null was returned as PropertyValue[][]");
47 props
= new PropertyValue
[0][0];
49 for(int i
=0; i
<props
.length
; i
++)
50 for(int j
=0; j
<props
[i
].length
; j
++)
51 log
.println("Factory: " + props
[i
][j
].Name
+ " - " + props
[i
][j
].Value
);
52 tRes
.tested("getRegisteredFactories()", props
.length
!= 0);
55 public void _getFactory() {
56 requiredMethod("registerFactory()");
57 XUIElementFactory xFactory
= oObj
.getFactory("private:resource/menubar/menubar", "");
58 tRes
.tested("getFactory()", xFactory
!= null);
61 public void _deregisterFactory() {
62 executeMethod("getRegisteredFactory()");
63 executeMethod("getFactory()");
65 oObj
.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", "");
67 catch(com
.sun
.star
.container
.NoSuchElementException e
) {
68 e
.printStackTrace(log
);
70 tRes
.tested("deregisterFactory()", true);