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();
37 res
= checkHPSI(hpsi
);
40 "The component doesn't provide HierarchicalPropertySetInfo");
41 tRes
.tested("getHierarchicalPropertySetInfo()",
42 Status
.skipped(true));
47 tRes
.tested("getHierarchicalPropertySetInfo()", res
);
50 public void _getHierarchicalPropertyValue() {
51 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
52 String
[] pTypes
= (String
[]) tEnv
.getObjRelation("PropertyTypes");
55 for (int i
= 0; i
< pNames
.length
; i
++) {
57 log
.print("Property " + pNames
[i
]);
59 Object getting
= oObj
.getHierarchicalPropertyValue(pNames
[i
]);
60 log
.println(" has Value " + getting
.toString());
61 res
&= checkType(pNames
[i
], pTypes
[i
], getting
);
62 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
63 log
.println(" is unknown");
64 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
65 log
.println(" is illegal");
66 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
67 log
.println(" throws expeption " + e
.getMessage());
71 tRes
.tested("getHierarchicalPropertyValue()", res
);
74 public void _setHierarchicalPropertyValue() {
75 String ro
= (String
) tEnv
.getObjRelation("allReadOnly");
79 tRes
.tested("setHierarchicalPropertyValue()", Status
.skipped(true));
86 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
88 for (int k
= 0; k
< pNames
.length
; k
++) {
90 Object oldValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
91 Object newValue
= ValueChanger
.changePValue(oldValue
);
92 oObj
.setHierarchicalPropertyValue(pNames
[k
], newValue
);
94 Object getValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
95 boolean localRes
= ValueComparer
.equalValue(getValue
, newValue
);
98 log
.println("Expected " + newValue
.toString());
99 log
.println("Gained " + getValue
.toString());
104 oObj
.setHierarchicalPropertyValue(pNames
[k
], oldValue
);
107 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
108 log
.println("Property is unknown");
109 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
110 log
.println("IllegalArgument "+e
.getMessage());
111 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
112 log
.println("VetoException "+e
.getMessage());
113 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
114 log
.println("WrappedTarget "+e
.getMessage());
119 tRes
.tested("setHierarchicalPropertyValue()", res
);
122 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi
) {
123 log
.println("Checking the resulting HierarchicalPropertySetInfo");
124 log
.println("### NOT yet implemented");
129 protected boolean checkType(String name
, String type
, Object value
) {
130 boolean result
= true;
132 if (type
.equals("Boolean")) {
133 result
= (value
instanceof Boolean
);
136 log
.println("Wrong Type for property " + name
);
137 log
.println("Expected " + type
);
138 log
.println("getting " + value
.getClass());
140 } else if (type
.equals("Short")) {
141 result
= (value
instanceof Short
);
144 log
.println("Wrong Type for property " + name
);
145 log
.println("Expected " + type
);
146 log
.println("getting " + value
.getClass());