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.
53 protected void before() {
54 XChartDocument doc
= (XChartDocument
) tEnv
.getObjRelation("CHARTDOC");
55 if (doc
== null) throw new StatusException(Status
.failed
56 ("Relation 'CHARTDOC' not found"));
58 oObj
= UnoRuntime
.queryInterface( XPropertySet
.class, doc
.getDiagram() );
61 public void _HasYAxis() {
63 log
.println("Property HasYAxis");
64 boolean res
= ((Boolean
)oObj
.getPropertyValue(
65 "HasYAxis")).booleanValue();
67 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
68 // test connected property HasYAxisDescription
69 if (!((Boolean
)oObj
.getPropertyValue(
70 "HasYAxisDescription")).booleanValue())
71 oObj
.setPropertyValue("HasYAxisDescription", Boolean
.TRUE
);
73 oObj
.setPropertyValue("HasYAxis", Boolean
.FALSE
);
74 boolean setVal
= ((Boolean
)oObj
.getPropertyValue(
75 "HasYAxis")).booleanValue();
76 log
.println("Start value: " + setVal
);
77 // description should also be false now
78 setVal
|= ((Boolean
)oObj
.getPropertyValue(
79 "HasYAxisDescription")).booleanValue();
80 log
.println("Connected value axis description: " + setVal
);
82 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
83 setVal
|= !((Boolean
)oObj
.getPropertyValue(
84 "HasYAxis")).booleanValue();
85 log
.println("Changed value: " + !setVal
);
87 // description should be true again
88 setVal
|= !((Boolean
)oObj
.getPropertyValue(
89 "HasYAxisDescription")).booleanValue();
90 log
.println("Changed connected value axis description: "+!setVal
);
92 tRes
.tested("HasYAxis", !setVal
);
93 // leave axis untouched
94 oObj
.setPropertyValue("HasYAxis", Boolean
.valueOf(res
));
96 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
97 log
.println(e
.getMessage());
98 e
.printStackTrace(log
);
99 tRes
.tested("HasYAxis", false);
101 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
102 log
.println(e
.getMessage());
103 e
.printStackTrace(log
);
104 tRes
.tested("HasYAxis", false);
106 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
107 log
.println(e
.getMessage());
108 e
.printStackTrace(log
);
109 tRes
.tested("HasYAxis", false);
111 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
112 log
.println(e
.getMessage());
113 e
.printStackTrace(log
);
114 tRes
.tested("HasYAxis", false);
118 public void _HasYAxisDescription() {
119 requiredMethod("HasYAxis");
121 log
.println("Property HasYAxisDescription");
122 if (!((Boolean
)oObj
.getPropertyValue("HasYAxis")).booleanValue())
123 oObj
.setPropertyValue("HasYAxis", Boolean
.TRUE
);
125 boolean res
= ((Boolean
)oObj
.getPropertyValue(
126 "HasYAxisDescription")).booleanValue();
127 log
.println("Start value: " + res
);
129 oObj
.setPropertyValue("HasYAxisDescription", Boolean
.valueOf(!res
));
130 boolean setValue
= ((Boolean
)oObj
.getPropertyValue(
131 "HasYAxisDescription")).booleanValue();
132 log
.println("Changed value: " + setValue
);
133 tRes
.tested("HasYAxisDescription", res
!= setValue
);
135 catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
136 log
.println(e
.getMessage());
137 e
.printStackTrace(log
);
138 tRes
.tested("HasYAxisDescription", false);
140 catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
141 log
.println(e
.getMessage());
142 e
.printStackTrace(log
);
143 tRes
.tested("HasYAxisDescription", false);
145 catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
146 log
.println(e
.getMessage());
147 e
.printStackTrace(log
);
148 tRes
.tested("HasYAxisDescription", false);
150 catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
151 log
.println(e
.getMessage());
152 e
.printStackTrace(log
);
153 tRes
.tested("HasYAxisDescription", false);
157 } // EOF ChartAxisYSupplier