merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / chart / _XChartDataArray.java
blobe12afceae3d9a8498086ab237ae54020421e9837
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XChartDataArray.java,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 package ifc.chart;
33 import com.sun.star.beans.XPropertySet;
34 import lib.MultiMethodTest;
35 import lib.Status;
36 import lib.StatusException;
38 import com.sun.star.chart.XChartDataArray;
39 import com.sun.star.uno.UnoRuntime;
41 /**
42 * Testing <code>com.sun.star.chart.XChartDataArray</code>
43 * interface methods :
44 * <ul>
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>
51 * </ul> <p>
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");
66 if (o != null) {
67 mbExcludeSetRowAndSetColumn = true;
68 msExcludeMessage = (String)o;
70 if (!mbExcludeSetRowAndSetColumn) {
71 XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, oObj);
72 if(xProp != null) {
73 try {
74 boolean columnAsLabel = ((Boolean)xProp.getPropertyValue("ChartColumnAsLabel")).booleanValue();
75 boolean rowAsLabel = ((Boolean)xProp.getPropertyValue("ChartRowAsLabel")).booleanValue();
76 if (!columnAsLabel) {
77 xProp.setPropertyValue("ChartColumnAsLabel", Boolean.TRUE);
79 if (!rowAsLabel) {
80 xProp.setPropertyValue("ChartRowAsLabel", Boolean.TRUE);
83 catch(Exception e) {
84 // ignore
90 /**
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() {
95 bResult = true;
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 :
114 * <ul>
115 * <li> <code> setColumnDescriptions </code></li>
116 * </ul>
118 public void _setRowDescriptions() {
119 bResult = true;
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 :
138 * <ul>
139 * <li> <code> setRowDescriptions </code></li>
140 * </ul>
142 public void _setData() {
143 rowDscs = oObj.getRowDescriptions();
144 colDscs = oObj.getColumnDescriptions();
146 bResult = true;
147 double[][] _data = oObj.getData();
148 data = _data;
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);
154 oObj.setData(data);
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 :
164 * <ul>
165 * <li> <code> setData </code> : to set and restore new values </li>
166 * </ul>
168 public void _getColumnDescriptions() {
169 requiredMethod("setColumnDescriptions()");
170 bResult = true;
172 String[] dscs = oObj.getColumnDescriptions();
173 bResult &= dscs.length == colDscs.length;
174 if (bResult) {
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 :
188 * <ul>
189 * <li> <code> setData </code> : to set and restore new values </li>
190 * </ul>
192 public void _getRowDescriptions() {
193 requiredMethod("setRowDescriptions()");
194 bResult = true;
196 String[] dscs = oObj.getRowDescriptions();
197 bResult &= dscs.length == rowDscs.length;
198 if (bResult) {
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 :
212 * <ul>
213 * <li> <code> setData </code> : to set and restore new values </li>
214 * </ul>
216 public void _getData() {
217 requiredMethod("setData()");
218 bResult = true;
220 double[][] _data = oObj.getData();
221 data = _data;
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();