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 .
20 import lib
.MultiMethodTest
;
22 import util
.ValueChanger
;
23 import util
.ValueComparer
;
25 import com
.sun
.star
.beans
.XHierarchicalPropertySet
;
26 import com
.sun
.star
.beans
.XHierarchicalPropertySetInfo
;
29 public class _XHierarchicalPropertySet
extends MultiMethodTest
{
30 public XHierarchicalPropertySet oObj
;
32 public void _getHierarchicalPropertySetInfo() {
33 XHierarchicalPropertySetInfo hpsi
= oObj
.getHierarchicalPropertySetInfo();
39 "The component doesn't provide HierarchicalPropertySetInfo");
40 tRes
.tested("getHierarchicalPropertySetInfo()",
41 Status
.skipped(true));
46 tRes
.tested("getHierarchicalPropertySetInfo()", res
);
49 public void _getHierarchicalPropertyValue() {
50 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
51 String
[] pTypes
= (String
[]) tEnv
.getObjRelation("PropertyTypes");
54 for (int i
= 0; i
< pNames
.length
; i
++) {
56 log
.print("Property " + pNames
[i
]);
58 Object getting
= oObj
.getHierarchicalPropertyValue(pNames
[i
]);
59 log
.println(" has Value " + getting
.toString());
60 res
&= checkType(pNames
[i
], pTypes
[i
], getting
);
61 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
62 log
.println(" is unknown");
63 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
64 log
.println(" is illegal");
65 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
66 log
.println(" throws expeption " + e
.getMessage());
70 tRes
.tested("getHierarchicalPropertyValue()", res
);
73 public void _setHierarchicalPropertyValue() {
74 String ro
= (String
) tEnv
.getObjRelation("allReadOnly");
78 tRes
.tested("setHierarchicalPropertyValue()", Status
.skipped(true));
85 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
87 for (int k
= 0; k
< pNames
.length
; k
++) {
89 Object oldValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
90 Object newValue
= ValueChanger
.changePValue(oldValue
);
91 oObj
.setHierarchicalPropertyValue(pNames
[k
], newValue
);
93 Object getValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
94 boolean localRes
= ValueComparer
.equalValue(getValue
, newValue
);
97 log
.println("Expected " + newValue
.toString());
98 log
.println("Gained " + getValue
.toString());
103 oObj
.setHierarchicalPropertyValue(pNames
[k
], oldValue
);
106 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
107 log
.println("Property is unknown");
108 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
109 log
.println("IllegalArgument "+e
.getMessage());
110 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
111 log
.println("VetoException "+e
.getMessage());
112 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
113 log
.println("WrappedTarget "+e
.getMessage());
118 tRes
.tested("setHierarchicalPropertyValue()", res
);
121 protected boolean checkType(String name
, String type
, Object value
) {
122 boolean result
= true;
124 if (type
.equals("Boolean")) {
125 result
= (value
instanceof Boolean
);
128 log
.println("Wrong Type for property " + name
);
129 log
.println("Expected " + type
);
130 log
.println("getting " + value
.getClass());
132 } else if (type
.equals("Short")) {
133 result
= (value
instanceof Short
);
136 log
.println("Wrong Type for property " + name
);
137 log
.println("Expected " + type
);
138 log
.println("getting " + value
.getClass());