1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XChartDataArray.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import com
.sun
.star
.beans
.XPropertySet
;
34 import lib
.MultiMethodTest
;
36 import lib
.StatusException
;
38 import com
.sun
.star
.chart
.XChartDataArray
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
42 * Testing <code>com.sun.star.chart.XChartDataArray</code>
45 * <li><code> getColumnDescriptions()</code></li>
46 * <li><code> getData()</code></li>
47 * <li><code> getRowDescriptions()</code></li>
48 * <li><code> setColumnDescriptions()</code></li>
49 * <li><code> setData()</code></li>
50 * <li><code> setRowDescriptions()</code></li>
52 * @see com.sun.star.chart.XChartDataArray
54 public class _XChartDataArray
extends MultiMethodTest
{
56 public XChartDataArray oObj
= null;
57 boolean bResult
= true;
58 String
[] colDscs
= new String
[3];
59 String
[] rowDscs
= new String
[3];
60 double[][] data
= null;
61 private boolean mbExcludeSetRowAndSetColumn
= false;
62 private String msExcludeMessage
;
64 protected void before() {
65 Object o
= tEnv
.getObjRelation("CRDESC");
67 mbExcludeSetRowAndSetColumn
= true;
68 msExcludeMessage
= (String
)o
;
70 if (!mbExcludeSetRowAndSetColumn
) {
71 XPropertySet xProp
= (XPropertySet
)UnoRuntime
.queryInterface(XPropertySet
.class, oObj
);
74 boolean columnAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartColumnAsLabel")).booleanValue();
75 boolean rowAsLabel
= ((Boolean
)xProp
.getPropertyValue("ChartRowAsLabel")).booleanValue();
77 xProp
.setPropertyValue("ChartColumnAsLabel", Boolean
.TRUE
);
80 xProp
.setPropertyValue("ChartRowAsLabel", Boolean
.TRUE
);
91 * Test calls the method and restores new values. <p>
92 * Has <b> OK </b> status if the method successfully returns. <p>
94 public void _setColumnDescriptions() {
97 colDscs
= oObj
.getColumnDescriptions();
98 if (mbExcludeSetRowAndSetColumn
) {
99 log
.println(msExcludeMessage
);
100 throw new StatusException(Status
.skipped(true));
102 for (int i
= 0; i
< colDscs
.length
; i
++) {
103 colDscs
[i
] = "Col" + i
;
105 oObj
.setColumnDescriptions(colDscs
);
107 tRes
.tested("setColumnDescriptions()", bResult
);
111 * Test calls the method and restores new values. <p>
112 * Has <b> OK </b> status if the method successfully returns. <p>
113 * The following method tests are to be completed successfully before :
115 * <li> <code> setColumnDescriptions </code></li>
118 public void _setRowDescriptions() {
121 rowDscs
= oObj
.getRowDescriptions();
122 if (mbExcludeSetRowAndSetColumn
) {
123 log
.println(msExcludeMessage
);
124 throw new StatusException(Status
.skipped(true));
126 for (int i
= 0; i
< rowDscs
.length
; i
++) {
127 rowDscs
[i
] = "Row" + i
;
129 oObj
.setRowDescriptions(rowDscs
);
131 tRes
.tested("setRowDescriptions()", bResult
);
135 * Test calls the method and restores new values. <p>
136 * Has <b> OK </b> status if the method successfully returns. <p>
137 * The following method tests are to be completed successfully before :
139 * <li> <code> setRowDescriptions </code></li>
142 public void _setData() {
143 rowDscs
= oObj
.getRowDescriptions();
144 colDscs
= oObj
.getColumnDescriptions();
147 double[][] _data
= oObj
.getData();
150 for (int i
= 0; i
< rowDscs
.length
; i
++) {
151 for (int j
= 0; j
< colDscs
.length
; j
++)
152 data
[i
][j
] = i
* (j
+ 1);
156 tRes
.tested("setData()", bResult
);
160 * Test calls the method and compare returned values with values restored
161 * after method <code>setColumnDescriptions</code>. <p>
162 * Has <b> OK </b> status if the returned values equils to restored values. <p>
163 * The following method tests are to be completed successfully before :
165 * <li> <code> setData </code> : to set and restore new values </li>
168 public void _getColumnDescriptions() {
169 requiredMethod("setColumnDescriptions()");
172 String
[] dscs
= oObj
.getColumnDescriptions();
173 bResult
&= dscs
.length
== colDscs
.length
;
175 for (int i
= 0; i
< dscs
.length
; i
++) {
176 bResult
&= dscs
[i
].equals(colDscs
[i
]);
180 tRes
.tested("getColumnDescriptions()", bResult
);
184 * Test calls the method and compare returned values with values restored
185 * after method <code>setRowDescriptions</code>. <p>
186 * Has <b> OK </b> status if the returned values equils to restored values. <p>
187 * The following method tests are to be completed successfully before :
189 * <li> <code> setData </code> : to set and restore new values </li>
192 public void _getRowDescriptions() {
193 requiredMethod("setRowDescriptions()");
196 String
[] dscs
= oObj
.getRowDescriptions();
197 bResult
&= dscs
.length
== rowDscs
.length
;
199 for (int i
= 0; i
< dscs
.length
; i
++) {
200 bResult
&= dscs
[i
].equals(rowDscs
[i
]);
204 tRes
.tested("getRowDescriptions()", bResult
);
208 * Test calls the method and compare returned values with values restored
209 * after method <code>setData</code>. <p>
210 * Has <b> OK </b> status if the returned values equils to restored values. <p>
211 * The following method tests are to be completed successfully before :
213 * <li> <code> setData </code> : to set and restore new values </li>
216 public void _getData() {
217 requiredMethod("setData()");
220 double[][] _data
= oObj
.getData();
222 for (int i
= 0; i
< rowDscs
.length
; i
++) {
223 for (int j
= 0; j
< colDscs
.length
; j
++) {
224 bResult
&= data
[i
][j
] == _data
[i
][j
];
228 tRes
.tested("getData()", bResult
);
231 protected void after() {
232 disposeEnvironment();