1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _ChartAxisZSupplier.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiPropertyTest
;
35 import lib
.StatusException
;
37 import com
.sun
.star
.beans
.XPropertySet
;
38 import com
.sun
.star
.chart
.XChartDocument
;
39 import com
.sun
.star
.chart
.XDiagram
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
43 * Testing <code>com.sun.star.chart.ChartAxisZSupplier</code>
44 * service properties :
46 * <li><code> HasZAxis</code></li>
47 * <li><code> HasZAxisDescription</code></li>
48 * <li><code> HasZAxisGrid</code></li>
49 * <li><code> HasZAxisHelpGrid</code></li>
50 * <li><code> HasZAxisTitle</code></li>
52 * This test needs the following object relations :
54 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
55 * to have reference to chart document </li>
56 * <li> <code>'BAR'</code> (of type <code>XDiagram</code>):
57 * relation that use as parameter for method setDiagram of chart document</li>
59 * @see com.sun.star.chart.ChartAxisZSupplier
61 public class _ChartAxisZSupplier
extends MultiPropertyTest
{
64 * Retrieves object relations and prepares a chart document.
65 * @throws StatusException if one of relations not found.
67 protected void before() {
68 log
.println("Setting Diagram type to BarDiagram");
69 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
70 if (doc
== null) throw new StatusException(Status
.failed
71 ("Relation 'CHARTDOC' not found"));
73 XDiagram bar
= (XDiagram
) tEnv
.getObjRelation("BAR");
74 if (bar
== null) throw new StatusException(Status
.failed
75 ("Relation 'BAR' not found"));
78 log
.println("Set it to 3D");
80 UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
82 oObj
.setPropertyValue("Dim3D", new Boolean(true));
83 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
84 log
.println("Exception while set property value");
85 e
.printStackTrace(log
);
86 throw new StatusException("Exception while set property value", e
);
87 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
88 log
.println("Exception while set property value");
89 e
.printStackTrace(log
);
90 throw new StatusException("Exception while set property value", e
);
91 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
92 log
.println("Exception while set property value");
93 e
.printStackTrace(log
);
94 throw new StatusException("Exception while set property value", e
);
95 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
96 log
.println("Exception while set property value");
97 e
.printStackTrace(log
);
98 throw new StatusException("Exception while set property value", e
);
102 public void _HasZAxis() {
104 log
.println("Property HasZAxis");
105 boolean res
= ((Boolean
)oObj
.getPropertyValue(
106 "HasZAxis")).booleanValue();
108 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
109 // test connected property HasZAxisDescription
110 if (!((Boolean
)oObj
.getPropertyValue(
111 "HasZAxisDescription")).booleanValue())
112 oObj
.setPropertyValue("HasZAxisDescription", Boolean
.TRUE
);
114 oObj
.setPropertyValue("HasZAxis", Boolean
.FALSE
);
115 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
116 "HasZAxis")).booleanValue();
117 log
.println("Start value: " + setVal
);
118 // description should also be false now
119 setVal
|= ((Boolean
)oObj
.getPropertyValue(
120 "HasZAxisDescription")).booleanValue();
121 log
.println("Connected value axis description: " + setVal
);
123 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
124 setVal
|= !((Boolean
)oObj
.getPropertyValue(
125 "HasZAxis")).booleanValue();
126 log
.println("Changed value: " + !setVal
);
128 // description should be true again
129 setVal
|= !((Boolean
)oObj
.getPropertyValue(
130 "HasZAxisDescription")).booleanValue();
131 log
.println("Changed connected value axis description: " + !setVal
);
133 tRes
.tested("HasZAxis", !setVal
);
134 // leave axis untouched
135 oObj
.setPropertyValue("HasZAxis", new Boolean(res
));
137 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
138 log
.println(e
.getMessage());
139 e
.printStackTrace(log
);
140 tRes
.tested("HasZAxis", false);
142 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
143 log
.println(e
.getMessage());
144 e
.printStackTrace(log
);
145 tRes
.tested("HasZAxis", false);
147 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
148 log
.println(e
.getMessage());
149 e
.printStackTrace(log
);
150 tRes
.tested("HasZAxis", false);
152 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
153 log
.println(e
.getMessage());
154 e
.printStackTrace(log
);
155 tRes
.tested("HasZAxis", false);
159 public void _HasZAxisDescription() {
160 requiredMethod("HasZAxis");
162 log
.println("Property HasZAxisDescription");
163 if (!((Boolean
)oObj
.getPropertyValue("HasZAxis")).booleanValue())
164 oObj
.setPropertyValue("HasZAxis", Boolean
.TRUE
);
166 boolean res
= ((Boolean
)oObj
.getPropertyValue(
167 "HasZAxisDescription")).booleanValue();
168 log
.println("Start value: " + res
);
170 oObj
.setPropertyValue("HasZAxisDescription", new Boolean(!res
));
171 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
172 "HasZAxisDescription")).booleanValue();
173 log
.println("Changed value: " + setValue
);
174 tRes
.tested("HasZAxisDescription", res
!= setValue
);
176 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
177 log
.println(e
.getMessage());
178 e
.printStackTrace(log
);
179 tRes
.tested("HasZAxisDescription", false);
181 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
182 log
.println(e
.getMessage());
183 e
.printStackTrace(log
);
184 tRes
.tested("HasZAxisDescription", false);
186 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
187 log
.println(e
.getMessage());
188 e
.printStackTrace(log
);
189 tRes
.tested("HasZAxisDescription", false);
191 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
192 log
.println(e
.getMessage());
193 e
.printStackTrace(log
);
194 tRes
.tested("HasZAxisDescription", false);
200 * Forces environment recreation.
202 protected void after() {
203 disposeEnvironment();
206 } // EOF ChartAxisZSupplier