Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / beans / _XMultiHierarchicalPropertySet.java
blobb9348befa147bf3d46c11f615bbf39740e2fe851
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 ************************************************************************/
27 package ifc.beans;
29 import lib.MultiMethodTest;
30 import lib.Status;
31 import util.ValueChanger;
32 import util.ValueComparer;
34 import com.sun.star.beans.XHierarchicalPropertySetInfo;
35 import com.sun.star.beans.XMultiHierarchicalPropertySet;
38 public class _XMultiHierarchicalPropertySet extends MultiMethodTest {
39 public XMultiHierarchicalPropertySet oObj;
41 public void _getHierarchicalPropertySetInfo() {
42 XHierarchicalPropertySetInfo hpsi = oObj.getHierarchicalPropertySetInfo();
43 boolean res = true;
45 if (hpsi != null) {
46 res = checkHPSI(hpsi);
47 } else {
48 log.println(
49 "The component doesn't provide HierarchicalPropertySetInfo");
50 tRes.tested("getHierarchicalPropertySetInfo()",
51 Status.skipped(true));
53 return;
56 tRes.tested("getMultiHierarchicalPropertySetInfo()", res);
59 public void _getHierarchicalPropertyValues() {
60 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
61 String[] pTypes = (String[]) tEnv.getObjRelation("PropertyTypes");
62 boolean res = true;
64 try {
65 Object[] getting = oObj.getHierarchicalPropertyValues(pNames);
66 res &= checkType(pNames, pTypes, getting);
67 } catch (com.sun.star.lang.IllegalArgumentException e) {
68 log.println("Exception " + e.getMessage());
69 } catch (com.sun.star.lang.WrappedTargetException e) {
70 log.println("Exception " + e.getMessage());
73 tRes.tested("getHierarchicalPropertyValues()", res);
76 public void _setHierarchicalPropertyValues() {
77 String ro = (String) tEnv.getObjRelation("allReadOnly");
79 if (ro != null) {
80 log.println(ro);
81 tRes.tested("setHierarchicalPropertyValues()",
82 Status.skipped(true));
84 return;
87 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
88 boolean res = true;
90 try {
91 Object[] oldValues = oObj.getHierarchicalPropertyValues(pNames);
92 Object[] newValues = new Object[oldValues.length];
94 for (int k = 0; k < oldValues.length; k++) {
95 newValues[k] = ValueChanger.changePValue(oldValues[k]);
98 oObj.setHierarchicalPropertyValues(pNames, newValues);
100 Object[] getValues = oObj.getHierarchicalPropertyValues(pNames);
102 for (int k = 0; k < pNames.length; k++) {
103 boolean localRes = ValueComparer.equalValue(getValues[k],
104 newValues[k]);
106 if (!localRes) {
107 log.println("didn't work for " + pNames[k]);
108 log.println("Expected " + newValues[k].toString());
109 log.println("Getting " + getValues[k].toString());
111 //reset properties
112 oObj.setHierarchicalPropertyValues(pNames, oldValues);
114 } catch (com.sun.star.lang.IllegalArgumentException e) {
115 log.println("IllegalArgument " + e.getMessage());
116 } catch (com.sun.star.beans.PropertyVetoException e) {
117 log.println("VetoException " + e.getMessage());
118 } catch (com.sun.star.lang.WrappedTargetException e) {
119 log.println("WrappedTarget " + e.getMessage());
122 tRes.tested("setHierarchicalPropertyValues()", res);
125 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi) {
126 log.println("Checking the resulting HierarchicalPropertySetInfo");
127 log.println("### NOT yet implemented");
129 return true;
132 protected boolean checkType(String[] name, String[] type, Object[] value) {
133 boolean result = true;
135 for (int k = 0; k < name.length; k++) {
136 if (type[k].equals("Boolean")) {
137 result &= (value[k] instanceof Boolean);
139 if (!(value[k] instanceof Boolean)) {
140 log.println("Wrong Type for property " + name[k]);
141 log.println("Expected " + type[k]);
142 log.println("getting " + value[k].getClass());
144 } else if (type[k].equals("Short")) {
145 result &= (value[k] instanceof Short);
147 if (!(value[k] instanceof Short)) {
148 log.println("Wrong Type for property " + name[k]);
149 log.println("Expected " + type[k]);
150 log.println("getting " + value[k].getClass());
155 return result;