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()");
164 String
[] dscs
= oObj
.getColumnDescriptions();
165 bResult
= dscs
.length
== colDscs
.length
;
167 for (int i
= 0; i
< dscs
.length
; i
++) {
168 log
.println("Col " + i
+ ": got " + dscs
[i
] + " expected: " + colDscs
[i
]);
169 if (!dscs
[i
].equals(colDscs
[i
])) {
175 tRes
.tested("getColumnDescriptions()", bResult
);
179 * Test calls the method and compare returned values with values restored
180 * after method <code>setRowDescriptions</code>. <p>
181 * Has <b> OK </b> status if the returned values equils to restored values. <p>
182 * The following method tests are to be completed successfully before :
184 * <li> <code> setData </code> : to set and restore new values </li>
187 public void _getRowDescriptions() {
188 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 if (!dscs
[i
].equals(rowDscs
[i
])) {
201 tRes
.tested("getRowDescriptions()", bResult
);
205 * Test calls the method and compare returned values with values restored
206 * after method <code>setData</code>. <p>
207 * Has <b> OK </b> status if the returned values equils to restored values. <p>
208 * The following method tests are to be completed successfully before :
210 * <li> <code> setData </code> : to set and restore new values </li>
213 public void _getData() {
214 requiredMethod("setData()");
217 double[][] _data
= oObj
.getData();
219 if(rowDscs
.length
!= 0 && rowDscs
.length
!= data
.length
)
221 if(colDscs
.length
!= 0 && colDscs
.length
!= data
[0].length
)
223 for (int i
= 0; i
< data
.length
; i
++) {
224 for (int j
= 0; j
< data
[i
].length
; j
++) {
225 if (data
[i
][j
] != _data
[i
][j
]) {
231 tRes
.tested("getData()", bResult
);
235 protected void after() {
236 disposeEnvironment();