bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / beans / _XHierarchicalPropertySet.java
blobbd295d1dc9ff2fbd876f0b75946c28227a012eb6
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.XHierarchicalPropertySet;
26 import com.sun.star.beans.XHierarchicalPropertySetInfo;
29 public class _XHierarchicalPropertySet extends MultiMethodTest {
30 public XHierarchicalPropertySet 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("getHierarchicalPropertySetInfo()", res);
50 public void _getHierarchicalPropertyValue() {
51 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
52 String[] pTypes = (String[]) tEnv.getObjRelation("PropertyTypes");
53 boolean res = true;
55 for (int i = 0; i < pNames.length; i++) {
56 try {
57 log.print("Property " + pNames[i]);
59 Object getting = oObj.getHierarchicalPropertyValue(pNames[i]);
60 log.println(" has Value " + getting.toString());
61 res &= checkType(pNames[i], pTypes[i], getting);
62 } catch (com.sun.star.beans.UnknownPropertyException e) {
63 log.println(" is unknown");
64 } catch (com.sun.star.lang.IllegalArgumentException e) {
65 log.println(" is illegal");
66 } catch (com.sun.star.lang.WrappedTargetException e) {
67 log.println(" throws expeption " + e.getMessage());
71 tRes.tested("getHierarchicalPropertyValue()", res);
74 public void _setHierarchicalPropertyValue() {
75 String ro = (String) tEnv.getObjRelation("allReadOnly");
77 if (ro != null) {
78 log.println(ro);
79 tRes.tested("setHierarchicalPropertyValue()", Status.skipped(true));
81 return;
84 boolean res = true;
86 String[] pNames = (String[]) tEnv.getObjRelation("PropertyNames");
88 for (int k = 0; k < pNames.length; k++) {
89 try {
90 Object oldValue = oObj.getHierarchicalPropertyValue(pNames[k]);
91 Object newValue = ValueChanger.changePValue(oldValue);
92 oObj.setHierarchicalPropertyValue(pNames[k], newValue);
94 Object getValue = oObj.getHierarchicalPropertyValue(pNames[k]);
95 boolean localRes = ValueComparer.equalValue(getValue, newValue);
97 if (!localRes) {
98 log.println("Expected " + newValue.toString());
99 log.println("Gained " + getValue.toString());
103 //reset Value
104 oObj.setHierarchicalPropertyValue(pNames[k], oldValue);
106 res &= localRes;
107 } catch (com.sun.star.beans.UnknownPropertyException e) {
108 log.println("Property is unknown");
109 } catch (com.sun.star.lang.IllegalArgumentException e) {
110 log.println("IllegalArgument "+e.getMessage());
111 } catch (com.sun.star.beans.PropertyVetoException e) {
112 log.println("VetoException "+e.getMessage());
113 } catch (com.sun.star.lang.WrappedTargetException e) {
114 log.println("WrappedTarget "+e.getMessage());
119 tRes.tested("setHierarchicalPropertyValue()", res);
122 protected boolean checkHPSI(XHierarchicalPropertySetInfo hpsi) {
123 log.println("Checking the resulting HierarchicalPropertySetInfo");
124 log.println("### NOT yet implemented");
126 return true;
129 protected boolean checkType(String name, String type, Object value) {
130 boolean result = true;
132 if (type.equals("Boolean")) {
133 result = (value instanceof Boolean);
135 if (!result) {
136 log.println("Wrong Type for property " + name);
137 log.println("Expected " + type);
138 log.println("getting " + value.getClass());
140 } else if (type.equals("Short")) {
141 result = (value instanceof Short);
143 if (!result) {
144 log.println("Wrong Type for property " + name);
145 log.println("Expected " + type);
146 log.println("getting " + value.getClass());
150 return result;