bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / beans / _XMultiHierarchicalPropertySet.java
blobf915f6175c4cf63f991e948464fc72f2317bad86
1 /*
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 .
18 package ifc.beans;
20 import lib.MultiMethodTest;
21 import lib.Status;
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();
34 boolean res = true;
36 if (hpsi != null) {
37 res = checkHPSI(hpsi);
38 } else {
39 log.println(
40 "The component doesn't provide HierarchicalPropertySetInfo");
41 tRes.tested("getHierarchicalPropertySetInfo()",
42 Status.skipped(true));
44 return;
47 tRes.tested("getMultiHierarchicalPropertySetInfo()", res);
50 public void _getHierarchicalPropertyValues() {
51 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
52 String[] pTypes = (String[]) tEnv.getObjRelation("PropertyTypes");
53 boolean res = true;
55 try {
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");
70 if (ro != null) {
71 log.println(ro);
72 tRes.tested("setHierarchicalPropertyValues()",
73 Status.skipped(true));
75 return;
78 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
79 boolean res = true;
81 try {
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],
95 newValues[k]);
97 if (!localRes) {
98 log.println("didn't work for " + pNames[k]);
99 log.println("Expected " + newValues[k].toString());
100 log.println("Getting " + getValues[k].toString());
102 //reset properties
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");
120 return true;
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());
146 return result;