1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XHierarchicalPropertySet.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import lib
.MultiMethodTest
;
34 import util
.ValueChanger
;
35 import util
.ValueComparer
;
37 import com
.sun
.star
.beans
.XHierarchicalPropertySet
;
38 import com
.sun
.star
.beans
.XHierarchicalPropertySetInfo
;
41 public class _XHierarchicalPropertySet
extends MultiMethodTest
{
42 public XHierarchicalPropertySet oObj
;
44 public void _getHierarchicalPropertySetInfo() {
45 XHierarchicalPropertySetInfo hpsi
= oObj
.getHierarchicalPropertySetInfo();
49 res
= checkHPSI(hpsi
);
52 "The component doesn't provide HierarchicalPropertySetInfo");
53 tRes
.tested("getHierarchicalPropertySetInfo()",
54 Status
.skipped(true));
59 tRes
.tested("getHierarchicalPropertySetInfo()", res
);
62 public void _getHierarchicalPropertyValue() {
63 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
64 String
[] pTypes
= (String
[]) tEnv
.getObjRelation("PropertyTypes");
67 for (int i
= 0; i
< pNames
.length
; i
++) {
69 log
.print("Property " + pNames
[i
]);
71 Object getting
= oObj
.getHierarchicalPropertyValue(pNames
[i
]);
72 log
.println(" has Value " + getting
.toString());
73 res
&= checkType(pNames
[i
], pTypes
[i
], getting
);
74 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
75 log
.println(" is unknown");
76 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
77 log
.println(" is illegal");
78 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
79 log
.println(" throws expeption " + e
.getMessage());
83 tRes
.tested("getHierarchicalPropertyValue()", res
);
86 public void _setHierarchicalPropertyValue() {
87 String ro
= (String
) tEnv
.getObjRelation("allReadOnly");
91 tRes
.tested("setHierarchicalPropertyValue()", Status
.skipped(true));
98 String
[] pNames
= (String
[]) tEnv
.getObjRelation("PropertyNames");
100 for (int k
= 0; k
< pNames
.length
; k
++) {
102 Object oldValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
103 Object newValue
= ValueChanger
.changePValue(oldValue
);
104 oObj
.setHierarchicalPropertyValue(pNames
[k
], newValue
);
106 Object getValue
= oObj
.getHierarchicalPropertyValue(pNames
[k
]);
107 boolean localRes
= ValueComparer
.equalValue(getValue
, newValue
);
110 log
.println("Expected " + newValue
.toString());
111 log
.println("Gained " + getValue
.toString());
116 oObj
.setHierarchicalPropertyValue(pNames
[k
], oldValue
);
119 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
120 log
.println("Property is unknown");
121 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
122 log
.println("IllegalArgument "+e
.getMessage());
123 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
124 log
.println("VetoException "+e
.getMessage());
125 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
126 log
.println("WrappedTarget "+e
.getMessage());
131 tRes
.tested("setHierarchicalPropertyValue()", res
);
134 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi
) {
135 log
.println("Checking the resulting HierarchicalPropertySetInfo");
136 log
.println("### NOT yet implemented");
141 protected boolean checkType(String name
, String type
, Object value
) {
142 boolean result
= true;
144 if (type
.equals("Boolean")) {
145 result
= (value
instanceof Boolean
);
148 log
.println("Wrong Type for property " + name
);
149 log
.println("Expected " + type
);
150 log
.println("getting " + value
.getClass());
152 } else if (type
.equals("Short")) {
153 result
= (value
instanceof Short
);
156 log
.println("Wrong Type for property " + name
);
157 log
.println("Expected " + type
);
158 log
.println("getting " + value
.getClass());