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
.uno
.UnoRuntime
;
30 * Testing <code>com.sun.star.chart.ChartAxisYSupplier</code>
31 * service properties :
33 * <li><code> HasYAxis</code></li>
34 * <li><code> HasYAxisDescription</code></li>
35 * <li><code> HasYAxisGrid</code></li>
36 * <li><code> HasYAxisHelpGrid</code></li>
37 * <li><code> HasYAxisTitle</code></li>
39 * This test needs the following object relations :
41 * <li> <code>'CHARTDOC'</code> (of type <code>XChartDocument</code>):
42 * to have reference to chart document </li>
44 * @see com.sun.star.chart.ChartAxisYSupplier
46 public class _ChartAxisYSupplier
extends MultiPropertyTest
{
49 * Retrieves object relations and prepares a chart document.
50 * @throws StatusException if one of relations not found.
52 protected void before() {
53 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
54 if (doc
== null) throw new StatusException(Status
.failed
55 ("Relation 'CHARTDOC' not found"));
57 oObj
= UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
60 public void _HasYAxis() {
62 log
.println("Property HasYAxis");
63 boolean res
= ((Boolean
)oObj
.getPropertyValue(
64 "HasYAxis")).booleanValue();
66 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
67 // test connected property HasYAxisDescription
68 if (!((Boolean
)oObj
.getPropertyValue(
69 "HasYAxisDescription")).booleanValue())
70 oObj
.setPropertyValue("HasYAxisDescription", Boolean
.TRUE
);
72 oObj
.setPropertyValue("HasYAxis", Boolean
.FALSE
);
73 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
74 "HasYAxis")).booleanValue();
75 log
.println("Start value: " + setVal
);
76 // description should also be false now
77 setVal
|= ((Boolean
)oObj
.getPropertyValue(
78 "HasYAxisDescription")).booleanValue();
79 log
.println("Connected value axis description: " + setVal
);
81 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
82 setVal
|= !((Boolean
)oObj
.getPropertyValue(
83 "HasYAxis")).booleanValue();
84 log
.println("Changed value: " + !setVal
);
86 // description should be true again
87 setVal
|= !((Boolean
)oObj
.getPropertyValue(
88 "HasYAxisDescription")).booleanValue();
89 log
.println("Changed connected value axis description: "+!setVal
);
91 tRes
.tested("HasYAxis", !setVal
);
92 // leave axis untouched
93 oObj
.setPropertyValue("HasYAxis", new Boolean(res
));
95 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
96 log
.println(e
.getMessage());
97 e
.printStackTrace(log
);
98 tRes
.tested("HasYAxis", false);
100 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
101 log
.println(e
.getMessage());
102 e
.printStackTrace(log
);
103 tRes
.tested("HasYAxis", false);
105 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
106 log
.println(e
.getMessage());
107 e
.printStackTrace(log
);
108 tRes
.tested("HasYAxis", false);
110 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
111 log
.println(e
.getMessage());
112 e
.printStackTrace(log
);
113 tRes
.tested("HasYAxis", false);
117 public void _HasYAxisDescription() {
118 requiredMethod("HasYAxis");
120 log
.println("Property HasYAxisDescription");
121 if (!((Boolean
)oObj
.getPropertyValue("HasYAxis")).booleanValue())
122 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
124 boolean res
= ((Boolean
)oObj
.getPropertyValue(
125 "HasYAxisDescription")).booleanValue();
126 log
.println("Start value: " + res
);
128 oObj
.setPropertyValue("HasYAxisDescription", new Boolean(!res
));
129 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
130 "HasYAxisDescription")).booleanValue();
131 log
.println("Changed value: " + setValue
);
132 tRes
.tested("HasYAxisDescription", res
!= setValue
);
134 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
135 log
.println(e
.getMessage());
136 e
.printStackTrace(log
);
137 tRes
.tested("HasYAxisDescription", false);
139 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
140 log
.println(e
.getMessage());
141 e
.printStackTrace(log
);
142 tRes
.tested("HasYAxisDescription", false);
144 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
145 log
.println(e
.getMessage());
146 e
.printStackTrace(log
);
147 tRes
.tested("HasYAxisDescription", false);
149 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
150 log
.println(e
.getMessage());
151 e
.printStackTrace(log
);
152 tRes
.tested("HasYAxisDescription", false);
156 } // EOF ChartAxisYSupplier