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
.XHierarchicalPropertySetInfo
;
26 import com
.sun
.star
.beans
.XMultiHierarchicalPropertySet
;
29 public class _XMultiHierarchicalPropertySet
extends MultiMethodTest
{
30 public XMultiHierarchicalPropertySet 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("getMultiHierarchicalPropertySetInfo()", res
);
50 public void _getHierarchicalPropertyValues() {
51 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
52 String
[] pTypes
= (String
[]) tEnv
.getObjRelation("PropertyTypes");
56 Object
[] getting
= oObj
.getHierarchicalPropertyValues(pNames
);
57 res
&= checkType(pNames
, pTypes
, getting
);
58 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
59 log
.println("Exception " + e
.getMessage());
60 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
61 log
.println("Exception " + e
.getMessage());
64 tRes
.tested("getHierarchicalPropertyValues()", res
);
67 public void _setHierarchicalPropertyValues() {
68 String ro
= (String
) tEnv
.getObjRelation("allReadOnly");
72 tRes
.tested("setHierarchicalPropertyValues()",
73 Status
.skipped(true));
78 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
82 Object
[] oldValues
= oObj
.getHierarchicalPropertyValues(pNames
);
83 Object
[] newValues
= new Object
[oldValues
.length
];
85 for (int k
= 0; k
< oldValues
.length
; k
++) {
86 newValues
[k
] = ValueChanger
.changePValue(oldValues
[k
]);
89 oObj
.setHierarchicalPropertyValues(pNames
, newValues
);
91 Object
[] getValues
= oObj
.getHierarchicalPropertyValues(pNames
);
93 for (int k
= 0; k
< pNames
.length
; k
++) {
94 boolean localRes
= ValueComparer
.equalValue(getValues
[k
],
98 log
.println("didn't work for " + pNames
[k
]);
99 log
.println("Expected " + newValues
[k
].toString());
100 log
.println("Getting " + getValues
[k
].toString());
103 oObj
.setHierarchicalPropertyValues(pNames
, oldValues
);
105 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
106 log
.println("IllegalArgument " + e
.getMessage());
107 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
108 log
.println("VetoException " + e
.getMessage());
109 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
110 log
.println("WrappedTarget " + e
.getMessage());
113 tRes
.tested("setHierarchicalPropertyValues()", res
);
116 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi
) {
117 log
.println("Checking the resulting HierarchicalPropertySetInfo");
118 log
.println("### NOT yet implemented");
123 protected boolean checkType(String
[] name
, String
[] type
, Object
[] value
) {
124 boolean result
= true;
126 for (int k
= 0; k
< name
.length
; k
++) {
127 if (type
[k
].equals("Boolean")) {
128 result
&= (value
[k
] instanceof Boolean
);
130 if (!(value
[k
] instanceof Boolean
)) {
131 log
.println("Wrong Type for property " + name
[k
]);
132 log
.println("Expected " + type
[k
]);
133 log
.println("getting " + value
[k
].getClass());
135 } else if (type
[k
].equals("Short")) {
136 result
&= (value
[k
] instanceof Short
);
138 if (!(value
[k
] instanceof Short
)) {
139 log
.println("Wrong Type for property " + name
[k
]);
140 log
.println("Expected " + type
[k
]);
141 log
.println("getting " + value
[k
].getClass());