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 com
.sun
.star
.beans
.XPropertySet
;
22 import lib
.MultiMethodTest
;
24 import lib
.StatusException
;
26 import com
.sun
.star
.chart
.XChartDataArray
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
30 * Testing <code>com.sun.star.chart.XChartDataArray</code>
33 * <li><code> getColumnDescriptions()</code></li>
34 * <li><code> getData()</code></li>
35 * <li><code> getRowDescriptions()</code></li>
36 * <li><code> setColumnDescriptions()</code></li>
37 * <li><code> setData()</code></li>
38 * <li><code> setRowDescriptions()</code></li>
40 * @see com.sun.star.chart.XChartDataArray
42 public class _XChartDataArray
extends MultiMethodTest
{
44 public XChartDataArray oObj
= null;
45 boolean bResult
= true;
46 String
[] colDscs
= new String
[3];
47 String
[] rowDscs
= new String
[3];
48 double[][] data
= null;
49 private boolean mbExcludeSetRowAndSetColumn
= false;
50 private String msExcludeMessage
;
52 protected void before() {
53 Object o
= tEnv
.getObjRelation("CRDESC");
55 mbExcludeSetRowAndSetColumn
= true;
56 msExcludeMessage
= (String
)o
;
58 if (!mbExcludeSetRowAndSetColumn
) {
59 XPropertySet xProp
= UnoRuntime
.queryInterface(XPropertySet
.class, oObj
);
62 boolean columnAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartColumnAsLabel")).booleanValue();
63 boolean rowAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartRowAsLabel")).booleanValue();
65 xProp
.setPropertyValue("ChartColumnAsLabel", Boolean
.TRUE
);
68 xProp
.setPropertyValue("ChartRowAsLabel", Boolean
.TRUE
);
79 * Test calls the method and restores new values. <p>
80 * Has <b> OK </b> status if the method successfully returns. <p>
82 public void _setColumnDescriptions() {
85 colDscs
= oObj
.getColumnDescriptions();
86 if (mbExcludeSetRowAndSetColumn
) {
87 log
.println(msExcludeMessage
);
88 throw new StatusException(Status
.skipped(true));
90 for (int i
= 0; i
< colDscs
.length
; i
++) {
91 colDscs
[i
] = "Col" + i
;
93 oObj
.setColumnDescriptions(colDscs
);
95 tRes
.tested("setColumnDescriptions()", bResult
);
99 * Test calls the method and restores new values. <p>
100 * Has <b> OK </b> status if the method successfully returns. <p>
101 * The following method tests are to be completed successfully before :
103 * <li> <code> setColumnDescriptions </code></li>
106 public void _setRowDescriptions() {
109 rowDscs
= oObj
.getRowDescriptions();
110 if (mbExcludeSetRowAndSetColumn
) {
111 log
.println(msExcludeMessage
);
112 throw new StatusException(Status
.skipped(true));
114 for (int i
= 0; i
< rowDscs
.length
; i
++) {
115 rowDscs
[i
] = "Row" + i
;
117 oObj
.setRowDescriptions(rowDscs
);
119 tRes
.tested("setRowDescriptions()", bResult
);
123 * Test calls the method and restores new values. <p>
124 * Has <b> OK </b> status if the method successfully returns. <p>
125 * The following method tests are to be completed successfully before :
127 * <li> <code> setRowDescriptions </code></li>
130 public void _setData() {
131 rowDscs
= oObj
.getRowDescriptions();
132 colDscs
= oObj
.getColumnDescriptions();
135 double[][] _data
= oObj
.getData();
138 for (int i
= 0; i
< rowDscs
.length
; i
++) {
139 for (int j
= 0; j
< colDscs
.length
; j
++)
140 data
[i
][j
] = i
* (j
+ 1);
144 tRes
.tested("setData()", bResult
);
148 * Test calls the method and compare returned values with values restored
149 * after method <code>setColumnDescriptions</code>. <p>
150 * Has <b> OK </b> status if the returned values equils to restored values. <p>
151 * The following method tests are to be completed successfully before :
153 * <li> <code> setData </code> : to set and restore new values </li>
156 public void _getColumnDescriptions() {
157 requiredMethod("setColumnDescriptions()");
160 String
[] dscs
= oObj
.getColumnDescriptions();
161 bResult
&= dscs
.length
== colDscs
.length
;
163 for (int i
= 0; i
< dscs
.length
; i
++) {
164 bResult
&= dscs
[i
].equals(colDscs
[i
]);
168 tRes
.tested("getColumnDescriptions()", bResult
);
172 * Test calls the method and compare returned values with values restored
173 * after method <code>setRowDescriptions</code>. <p>
174 * Has <b> OK </b> status if the returned values equils to restored values. <p>
175 * The following method tests are to be completed successfully before :
177 * <li> <code> setData </code> : to set and restore new values </li>
180 public void _getRowDescriptions() {
181 requiredMethod("setRowDescriptions()");
184 String
[] dscs
= oObj
.getRowDescriptions();
185 bResult
&= dscs
.length
== rowDscs
.length
;
187 for (int i
= 0; i
< dscs
.length
; i
++) {
188 bResult
&= dscs
[i
].equals(rowDscs
[i
]);
192 tRes
.tested("getRowDescriptions()", bResult
);
196 * Test calls the method and compare returned values with values restored
197 * after method <code>setData</code>. <p>
198 * Has <b> OK </b> status if the returned values equils to restored values. <p>
199 * The following method tests are to be completed successfully before :
201 * <li> <code> setData </code> : to set and restore new values </li>
204 public void _getData() {
205 requiredMethod("setData()");
208 double[][] _data
= oObj
.getData();
210 for (int i
= 0; i
< rowDscs
.length
; i
++) {
211 for (int j
= 0; j
< colDscs
.length
; j
++) {
212 bResult
&= data
[i
][j
] == _data
[i
][j
];
216 tRes
.tested("getData()", bResult
);
219 protected void after() {
220 disposeEnvironment();