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