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 .
21 import lib
.MultiPropertyTest
;
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
;
31 * Testing <code>com.sun.star.chart.ChartAxisZSupplier</code>
32 * service properties :
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>
40 * This test needs the following object relations :
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>
47 * @see com.sun.star.chart.ChartAxisZSupplier
49 public class _ChartAxisZSupplier
extends MultiPropertyTest
{
52 * Retrieves object relations and prepares a chart document.
53 * @throws StatusException if one of relations not found.
56 protected void before() {
57 log
.println("Setting Diagram type to BarDiagram");
58 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
59 if (doc
== null) throw new StatusException(Status
.failed
60 ("Relation 'CHARTDOC' not found"));
62 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
63 if (bar
== null) throw new StatusException(Status
.failed
64 ("Relation 'BAR' not found"));
67 log
.println("Set it to 3D");
68 oObj
= UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
70 oObj
.setPropertyValue("Dim3D", Boolean
.TRUE
);
71 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
72 log
.println("Exception while set property value");
73 e
.printStackTrace(log
);
74 throw new StatusException("Exception while set property value", e
);
75 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
76 log
.println("Exception while set property value");
77 e
.printStackTrace(log
);
78 throw new StatusException("Exception while set property value", e
);
79 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
80 log
.println("Exception while set property value");
81 e
.printStackTrace(log
);
82 throw new StatusException("Exception while set property value", e
);
83 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
84 log
.println("Exception while set property value");
85 e
.printStackTrace(log
);
86 throw new StatusException("Exception while set property value", e
);
90 public void _HasZAxis() {
92 log
.println("Property HasZAxis");
93 boolean res
= ((Boolean
)oObj
.getPropertyValue(
94 "HasZAxis")).booleanValue();
96 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
97 // test connected property HasZAxisDescription
98 if (!((Boolean
)oObj
.getPropertyValue(
99 "HasZAxisDescription")).booleanValue())
100 oObj
.setPropertyValue("HasZAxisDescription", Boolean
.TRUE
);
102 oObj
.setPropertyValue("HasZAxis", Boolean
.FALSE
);
103 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
104 "HasZAxis")).booleanValue();
105 log
.println("Start value: " + setVal
);
106 // description should also be false now
107 setVal
|= ((Boolean
)oObj
.getPropertyValue(
108 "HasZAxisDescription")).booleanValue();
109 log
.println("Connected value axis description: " + setVal
);
111 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
112 setVal
|= !((Boolean
)oObj
.getPropertyValue(
113 "HasZAxis")).booleanValue();
114 log
.println("Changed value: " + !setVal
);
116 // description should be true again
117 setVal
|= !((Boolean
)oObj
.getPropertyValue(
118 "HasZAxisDescription")).booleanValue();
119 log
.println("Changed connected value axis description: " + !setVal
);
121 tRes
.tested("HasZAxis", !setVal
);
122 // leave axis untouched
123 oObj
.setPropertyValue("HasZAxis", Boolean
.valueOf(res
));
125 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
126 log
.println(e
.getMessage());
127 e
.printStackTrace(log
);
128 tRes
.tested("HasZAxis", false);
130 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
131 log
.println(e
.getMessage());
132 e
.printStackTrace(log
);
133 tRes
.tested("HasZAxis", false);
135 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
136 log
.println(e
.getMessage());
137 e
.printStackTrace(log
);
138 tRes
.tested("HasZAxis", false);
140 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
141 log
.println(e
.getMessage());
142 e
.printStackTrace(log
);
143 tRes
.tested("HasZAxis", false);
147 public void _HasZAxisDescription() {
148 requiredMethod("HasZAxis");
150 log
.println("Property HasZAxisDescription");
151 if (!((Boolean
)oObj
.getPropertyValue("HasZAxis")).booleanValue())
152 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
154 boolean res
= ((Boolean
)oObj
.getPropertyValue(
155 "HasZAxisDescription")).booleanValue();
156 log
.println("Start value: " + res
);
158 oObj
.setPropertyValue("HasZAxisDescription", Boolean
.valueOf(!res
));
159 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
160 "HasZAxisDescription")).booleanValue();
161 log
.println("Changed value: " + setValue
);
162 tRes
.tested("HasZAxisDescription", res
!= setValue
);
164 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
165 log
.println(e
.getMessage());
166 e
.printStackTrace(log
);
167 tRes
.tested("HasZAxisDescription", false);
169 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
170 log
.println(e
.getMessage());
171 e
.printStackTrace(log
);
172 tRes
.tested("HasZAxisDescription", false);
174 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
175 log
.println(e
.getMessage());
176 e
.printStackTrace(log
);
177 tRes
.tested("HasZAxisDescription", false);
179 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
180 log
.println(e
.getMessage());
181 e
.printStackTrace(log
);
182 tRes
.tested("HasZAxisDescription", false);
188 * Forces environment recreation.
191 protected void after() {
192 disposeEnvironment();
195 } // EOF ChartAxisZSupplier