1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import lib
.MultiMethodTest
;
31 import util
.ValueChanger
;
32 import util
.ValueComparer
;
34 import com
.sun
.star
.beans
.XHierarchicalPropertySet
;
35 import com
.sun
.star
.beans
.XHierarchicalPropertySetInfo
;
38 public class _XHierarchicalPropertySet
extends MultiMethodTest
{
39 public XHierarchicalPropertySet oObj
;
41 public void _getHierarchicalPropertySetInfo() {
42 XHierarchicalPropertySetInfo hpsi
= oObj
.getHierarchicalPropertySetInfo();
46 res
= checkHPSI(hpsi
);
49 "The component doesn't provide HierarchicalPropertySetInfo");
50 tRes
.tested("getHierarchicalPropertySetInfo()",
51 Status
.skipped(true));
56 tRes
.tested("getHierarchicalPropertySetInfo()", res
);
59 public void _getHierarchicalPropertyValue() {
60 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
61 String
[] pTypes
= (String
[]) tEnv
.getObjRelation("PropertyTypes");
64 for (int i
= 0; i
< pNames
.length
; i
++) {
66 log
.print("Property " + pNames
[i
]);
68 Object getting
= oObj
.getHierarchicalPropertyValue(pNames
[i
]);
69 log
.println(" has Value " + getting
.toString());
70 res
&= checkType(pNames
[i
], pTypes
[i
], getting
);
71 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
72 log
.println(" is unknown");
73 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
74 log
.println(" is illegal");
75 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
76 log
.println(" throws expeption " + e
.getMessage());
80 tRes
.tested("getHierarchicalPropertyValue()", res
);
83 public void _setHierarchicalPropertyValue() {
84 String ro
= (String
) tEnv
.getObjRelation("allReadOnly");
88 tRes
.tested("setHierarchicalPropertyValue()", Status
.skipped(true));
95 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
97 for (int k
= 0; k
< pNames
.length
; k
++) {
99 Object oldValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
100 Object newValue
= ValueChanger
.changePValue(oldValue
);
101 oObj
.setHierarchicalPropertyValue(pNames
[k
], newValue
);
103 Object getValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
104 boolean localRes
= ValueComparer
.equalValue(getValue
, newValue
);
107 log
.println("Expected " + newValue
.toString());
108 log
.println("Gained " + getValue
.toString());
113 oObj
.setHierarchicalPropertyValue(pNames
[k
], oldValue
);
116 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
117 log
.println("Property is unknown");
118 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
119 log
.println("IllegalArgument "+e
.getMessage());
120 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
121 log
.println("VetoException "+e
.getMessage());
122 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
123 log
.println("WrappedTarget "+e
.getMessage());
128 tRes
.tested("setHierarchicalPropertyValue()", res
);
131 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi
) {
132 log
.println("Checking the resulting HierarchicalPropertySetInfo");
133 log
.println("### NOT yet implemented");
138 protected boolean checkType(String name
, String type
, Object value
) {
139 boolean result
= true;
141 if (type
.equals("Boolean")) {
142 result
= (value
instanceof Boolean
);
145 log
.println("Wrong Type for property " + name
);
146 log
.println("Expected " + type
);
147 log
.println("getting " + value
.getClass());
149 } else if (type
.equals("Short")) {
150 result
= (value
instanceof Short
);
153 log
.println("Wrong Type for property " + name
);
154 log
.println("Expected " + type
);
155 log
.println("getting " + value
.getClass());