bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _XChartDataArray.java
blob5233db64848dbe842cd15f1738496b3bae7aadea
1 /*
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 .
19 package ifc.chart;
21 import com.sun.star.beans.XPropertySet;
22 import lib.MultiMethodTest;
23 import lib.Status;
24 import lib.StatusException;
26 import com.sun.star.chart.XChartDataArray;
27 import com.sun.star.uno.UnoRuntime;
29 /**
30 * Testing <code>com.sun.star.chart.XChartDataArray</code>
31 * interface methods :
32 * <ul>
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>
39 * </ul> <p>
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");
54 if (o != null) {
55 mbExcludeSetRowAndSetColumn = true;
56 msExcludeMessage = (String)o;
58 if (!mbExcludeSetRowAndSetColumn) {
59 XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oObj);
60 if(xProp != null) {
61 try {
62 boolean columnAsLabel = ((Boolean)xProp.getPropertyValue("ChartColumnAsLabel")).booleanValue();
63 boolean rowAsLabel = ((Boolean)xProp.getPropertyValue("ChartRowAsLabel")).booleanValue();
64 if (!columnAsLabel) {
65 xProp.setPropertyValue("ChartColumnAsLabel", Boolean.TRUE);
67 if (!rowAsLabel) {
68 xProp.setPropertyValue("ChartRowAsLabel", Boolean.TRUE);
71 catch(Exception e) {
72 // ignore
78 /**
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() {
83 bResult = true;
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);
98 /**
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 :
102 * <ul>
103 * <li> <code> setColumnDescriptions </code></li>
104 * </ul>
106 public void _setRowDescriptions() {
107 bResult = true;
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 :
126 * <ul>
127 * <li> <code> setRowDescriptions </code></li>
128 * </ul>
130 public void _setData() {
131 rowDscs = oObj.getRowDescriptions();
132 colDscs = oObj.getColumnDescriptions();
134 bResult = true;
135 double[][] _data = oObj.getData();
136 data = _data;
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);
142 oObj.setData(data);
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 :
152 * <ul>
153 * <li> <code> setData </code> : to set and restore new values </li>
154 * </ul>
156 public void _getColumnDescriptions() {
157 requiredMethod("setColumnDescriptions()");
158 bResult = true;
160 String[] dscs = oObj.getColumnDescriptions();
161 bResult &= dscs.length == colDscs.length;
162 if (bResult) {
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 :
176 * <ul>
177 * <li> <code> setData </code> : to set and restore new values </li>
178 * </ul>
180 public void _getRowDescriptions() {
181 requiredMethod("setRowDescriptions()");
182 bResult = true;
184 String[] dscs = oObj.getRowDescriptions();
185 bResult &= dscs.length == rowDscs.length;
186 if (bResult) {
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 :
200 * <ul>
201 * <li> <code> setData </code> : to set and restore new values </li>
202 * </ul>
204 public void _getData() {
205 requiredMethod("setData()");
206 bResult = true;
208 double[][] _data = oObj.getData();
209 data = _data;
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();