bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _ChartAxisZSupplier.java
blob42ba8b17af786171100ee48b850996cb52c53221
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 .
19 package ifc.chart;
21 import lib.MultiPropertyTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.beans.XPropertySet;
26 import com.sun.star.chart.XChartDocument;
27 import com.sun.star.chart.XDiagram;
28 import com.sun.star.uno.UnoRuntime;
30 /**
31 * Testing <code>com.sun.star.chart.ChartAxisZSupplier</code>
32 * service properties :
33 * <ul>
34 * <li><code> HasZAxis</code></li>
35 * <li><code> HasZAxisDescription</code></li>
36 * <li><code> HasZAxisGrid</code></li>
37 * <li><code> HasZAxisHelpGrid</code></li>
38 * <li><code> HasZAxisTitle</code></li>
39 * </ul> <p>
40 * This test needs the following object relations :
41 * <ul>
42 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
43 * to have reference to chart document </li>
44 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
45 * relation that use as parameter for method setDiagram of chart document</li>
46 * </ul> <p>
47 * @see com.sun.star.chart.ChartAxisZSupplier
49 public class _ChartAxisZSupplier extends MultiPropertyTest {
51 /**
52 * Retrieves object relations and prepares a chart document.
53 * @throws StatusException if one of relations not found.
55 protected void before() {
56 log.println("Setting Diagram type to BarDiagram");
57 XChartDocument doc = (XChartDocument) tEnv.getObjRelation("CHARTDOC");
58 if (doc == null) throw new StatusException(Status.failed
59 ("Relation 'CHARTDOC' not found"));
61 XDiagram bar = (XDiagram) tEnv.getObjRelation("BAR");
62 if (bar == null) throw new StatusException(Status.failed
63 ("Relation 'BAR' not found"));
65 doc.setDiagram(bar);
66 log.println("Set it to 3D");
67 oObj = UnoRuntime.queryInterface( XPropertySet.class, doc.getDiagram() );
68 try {
69 oObj.setPropertyValue("Dim3D", new Boolean(true));
70 } catch(com.sun.star.lang.WrappedTargetException e) {
71 log.println("Exception while set property value");
72 e.printStackTrace(log);
73 throw new StatusException("Exception while set property value", e);
74 } catch(com.sun.star.lang.IllegalArgumentException e) {
75 log.println("Exception while set property value");
76 e.printStackTrace(log);
77 throw new StatusException("Exception while set property value", e);
78 } catch(com.sun.star.beans.PropertyVetoException e) {
79 log.println("Exception while set property value");
80 e.printStackTrace(log);
81 throw new StatusException("Exception while set property value", e);
82 } catch(com.sun.star.beans.UnknownPropertyException e) {
83 log.println("Exception while set property value");
84 e.printStackTrace(log);
85 throw new StatusException("Exception while set property value", e);
89 public void _HasZAxis() {
90 try {
91 log.println("Property HasZAxis");
92 boolean res = ((Boolean)oObj.getPropertyValue(
93 "HasZAxis")).booleanValue();
94 if (!res)
95 oObj.setPropertyValue("HasZAxis", Boolean.TRUE);
96 // test connected property HasZAxisDescription
97 if (!((Boolean)oObj.getPropertyValue(
98 "HasZAxisDescription")).booleanValue())
99 oObj.setPropertyValue("HasZAxisDescription", Boolean.TRUE);
101 oObj.setPropertyValue("HasZAxis", Boolean.FALSE);
102 boolean setVal = ((Boolean)oObj.getPropertyValue(
103 "HasZAxis")).booleanValue();
104 log.println("Start value: " + setVal);
105 // description should also be false now
106 setVal |= ((Boolean)oObj.getPropertyValue(
107 "HasZAxisDescription")).booleanValue();
108 log.println("Connected value axis description: " + setVal);
110 oObj.setPropertyValue("HasZAxis", Boolean.TRUE);
111 setVal |= !((Boolean)oObj.getPropertyValue(
112 "HasZAxis")).booleanValue();
113 log.println("Changed value: " + !setVal);
115 // description should be true again
116 setVal |= !((Boolean)oObj.getPropertyValue(
117 "HasZAxisDescription")).booleanValue();
118 log.println("Changed connected value axis description: " + !setVal);
120 tRes.tested("HasZAxis", !setVal);
121 // leave axis untouched
122 oObj.setPropertyValue("HasZAxis", new Boolean(res));
124 catch (com.sun.star.lang.WrappedTargetException e) {
125 log.println(e.getMessage());
126 e.printStackTrace(log);
127 tRes.tested("HasZAxis", false);
129 catch (com.sun.star.lang.IllegalArgumentException e) {
130 log.println(e.getMessage());
131 e.printStackTrace(log);
132 tRes.tested("HasZAxis", false);
134 catch (com.sun.star.beans.UnknownPropertyException e) {
135 log.println(e.getMessage());
136 e.printStackTrace(log);
137 tRes.tested("HasZAxis", false);
139 catch (com.sun.star.beans.PropertyVetoException e) {
140 log.println(e.getMessage());
141 e.printStackTrace(log);
142 tRes.tested("HasZAxis", false);
146 public void _HasZAxisDescription() {
147 requiredMethod("HasZAxis");
148 try {
149 log.println("Property HasZAxisDescription");
150 if (!((Boolean)oObj.getPropertyValue("HasZAxis")).booleanValue())
151 oObj.setPropertyValue("HasZAxis", Boolean.TRUE);
153 boolean res = ((Boolean)oObj.getPropertyValue(
154 "HasZAxisDescription")).booleanValue();
155 log.println("Start value: " + res);
157 oObj.setPropertyValue("HasZAxisDescription", new Boolean(!res));
158 boolean setValue = ((Boolean)oObj.getPropertyValue(
159 "HasZAxisDescription")).booleanValue();
160 log.println("Changed value: " + setValue);
161 tRes.tested("HasZAxisDescription", res != setValue);
163 catch (com.sun.star.lang.WrappedTargetException e) {
164 log.println(e.getMessage());
165 e.printStackTrace(log);
166 tRes.tested("HasZAxisDescription", false);
168 catch (com.sun.star.lang.IllegalArgumentException e) {
169 log.println(e.getMessage());
170 e.printStackTrace(log);
171 tRes.tested("HasZAxisDescription", false);
173 catch (com.sun.star.beans.UnknownPropertyException e) {
174 log.println(e.getMessage());
175 e.printStackTrace(log);
176 tRes.tested("HasZAxisDescription", false);
178 catch (com.sun.star.beans.PropertyVetoException e) {
179 log.println(e.getMessage());
180 e.printStackTrace(log);
181 tRes.tested("HasZAxisDescription", false);
187 * Forces environment recreation.
189 protected void after() {
190 disposeEnvironment();
193 } // EOF ChartAxisZSupplier