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
;
53 protected void before() {
54 Object o
= tEnv
.getObjRelation("CRDESC");
56 mbExcludeSetRowAndSetColumn
= true;
57 msExcludeMessage
= (String
)o
;
59 if (mbExcludeSetRowAndSetColumn
) {
62 XPropertySet xProp
= UnoRuntime
.queryInterface(XPropertySet
.class, oObj
);
65 boolean columnAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartColumnAsLabel")).booleanValue();
66 boolean rowAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartRowAsLabel")).booleanValue();
68 xProp
.setPropertyValue("ChartColumnAsLabel", Boolean
.TRUE
);
71 xProp
.setPropertyValue("ChartRowAsLabel", Boolean
.TRUE
);
81 * Test calls the method and restores new values. <p>
82 * Has <b> OK </b> status if the method successfully returns. <p>
84 public void _setColumnDescriptions() {
87 colDscs
= oObj
.getColumnDescriptions();
88 if (mbExcludeSetRowAndSetColumn
) {
89 log
.println(msExcludeMessage
);
90 throw new StatusException(Status
.skipped(true));
92 for (int i
= 0; i
< colDscs
.length
; i
++) {
93 colDscs
[i
] = "Col" + i
;
95 oObj
.setColumnDescriptions(colDscs
);
97 tRes
.tested("setColumnDescriptions()", bResult
);
101 * Test calls the method and restores new values. <p>
102 * Has <b> OK </b> status if the method successfully returns. <p>
103 * The following method tests are to be completed successfully before :
105 * <li> <code> setColumnDescriptions </code></li>
108 public void _setRowDescriptions() {
111 rowDscs
= oObj
.getRowDescriptions();
112 if (mbExcludeSetRowAndSetColumn
) {
113 log
.println(msExcludeMessage
);
114 throw new StatusException(Status
.skipped(true));
116 for (int i
= 0; i
< rowDscs
.length
; i
++) {
117 rowDscs
[i
] = "Row" + i
;
119 oObj
.setRowDescriptions(rowDscs
);
121 tRes
.tested("setRowDescriptions()", bResult
);
125 * Test calls the method and restores new values. <p>
126 * Has <b> OK </b> status if the method successfully returns. <p>
127 * The following method tests are to be completed successfully before :
129 * <li> <code> setRowDescriptions </code></li>
132 public void _setData() {
133 rowDscs
= oObj
.getRowDescriptions();
134 colDscs
= oObj
.getColumnDescriptions();
137 double[][] _data
= oObj
.getData();
139 if(rowDscs
.length
!= 0 && rowDscs
.length
!= data
.length
)
141 if(colDscs
.length
!= 0 && colDscs
.length
!= data
[0].length
)
143 for (int i
= 0; i
< data
.length
; i
++) {
144 for (int j
= 0; j
< data
[i
].length
; j
++)
145 data
[i
][j
] = i
* (j
+ 1);
149 tRes
.tested("setData()", bResult
);
153 * Test calls the method and compare returned values with values restored
154 * after method <code>setColumnDescriptions</code>. <p>
155 * Has <b> OK </b> status if the returned values equils to restored values. <p>
156 * The following method tests are to be completed successfully before :
158 * <li> <code> setData </code> : to set and restore new values </li>
161 public void _getColumnDescriptions() {
162 requiredMethod("setColumnDescriptions()");
165 String
[] dscs
= oObj
.getColumnDescriptions();
166 bResult
&= dscs
.length
== colDscs
.length
;
168 for (int i
= 0; i
< dscs
.length
; i
++) {
169 log
.println("Col " + i
+ ": got " + dscs
[i
] + " expected: " + colDscs
[i
]);
170 bResult
&= dscs
[i
].equals(colDscs
[i
]);
174 tRes
.tested("getColumnDescriptions()", bResult
);
178 * Test calls the method and compare returned values with values restored
179 * after method <code>setRowDescriptions</code>. <p>
180 * Has <b> OK </b> status if the returned values equils to restored values. <p>
181 * The following method tests are to be completed successfully before :
183 * <li> <code> setData </code> : to set and restore new values </li>
186 public void _getRowDescriptions() {
187 requiredMethod("setRowDescriptions()");
190 String
[] dscs
= oObj
.getRowDescriptions();
191 bResult
&= dscs
.length
== rowDscs
.length
;
193 for (int i
= 0; i
< dscs
.length
; i
++) {
194 log
.println("Row " + i
+ ": got " + dscs
[i
] + " expected: " + rowDscs
[i
]);
195 bResult
&= dscs
[i
].equals(rowDscs
[i
]);
199 tRes
.tested("getRowDescriptions()", bResult
);
203 * Test calls the method and compare returned values with values restored
204 * after method <code>setData</code>. <p>
205 * Has <b> OK </b> status if the returned values equils to restored values. <p>
206 * The following method tests are to be completed successfully before :
208 * <li> <code> setData </code> : to set and restore new values </li>
211 public void _getData() {
212 requiredMethod("setData()");
215 double[][] _data
= oObj
.getData();
217 if(rowDscs
.length
!= 0 && rowDscs
.length
!= data
.length
)
219 if(colDscs
.length
!= 0 && colDscs
.length
!= data
[0].length
)
221 for (int i
= 0; i
< data
.length
; i
++) {
222 for (int j
= 0; j
< data
[i
].length
; j
++) {
223 bResult
&= data
[i
][j
] == _data
[i
][j
];
227 tRes
.tested("getData()", bResult
);
231 protected void after() {
232 disposeEnvironment();