tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _XChartDataArray.java
blob5021657ea99e474653aa26234a5f6bbcffef7bce
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 @Override
53 protected void before() {
54 Object o = tEnv.getObjRelation("CRDESC");
55 if (o != null) {
56 mbExcludeSetRowAndSetColumn = true;
57 msExcludeMessage = (String)o;
59 if (mbExcludeSetRowAndSetColumn) {
60 return;
62 XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oObj);
63 if(xProp != null) {
64 try {
65 boolean columnAsLabel = ((Boolean)xProp.getPropertyValue("ChartColumnAsLabel")).booleanValue();
66 boolean rowAsLabel = ((Boolean)xProp.getPropertyValue("ChartRowAsLabel")).booleanValue();
67 if (!columnAsLabel) {
68 xProp.setPropertyValue("ChartColumnAsLabel", Boolean.TRUE);
70 if (!rowAsLabel) {
71 xProp.setPropertyValue("ChartRowAsLabel", Boolean.TRUE);
74 catch(Exception e) {
75 // ignore
80 /**
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() {
85 bResult = true;
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 :
104 * <ul>
105 * <li> <code> setColumnDescriptions </code></li>
106 * </ul>
108 public void _setRowDescriptions() {
109 bResult = true;
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 :
128 * <ul>
129 * <li> <code> setRowDescriptions </code></li>
130 * </ul>
132 public void _setData() {
133 rowDscs = oObj.getRowDescriptions();
134 colDscs = oObj.getColumnDescriptions();
136 bResult = true;
137 double[][] _data = oObj.getData();
138 data = _data;
139 if(rowDscs.length != 0 && rowDscs.length != data.length)
140 bResult = false;
141 if(colDscs.length != 0 && colDscs.length != data[0].length)
142 bResult = false;
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);
147 oObj.setData(data);
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 :
157 * <ul>
158 * <li> <code> setData </code> : to set and restore new values </li>
159 * </ul>
161 public void _getColumnDescriptions() {
162 requiredMethod("setColumnDescriptions()");
164 String[] dscs = oObj.getColumnDescriptions();
165 bResult = dscs.length == colDscs.length;
166 if (bResult) {
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])) {
170 bResult = false;
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 :
183 * <ul>
184 * <li> <code> setData </code> : to set and restore new values </li>
185 * </ul>
187 public void _getRowDescriptions() {
188 requiredMethod("setRowDescriptions()");
190 String[] dscs = oObj.getRowDescriptions();
191 bResult = dscs.length == rowDscs.length;
192 if (bResult) {
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])) {
196 bResult = false;
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 :
209 * <ul>
210 * <li> <code> setData </code> : to set and restore new values </li>
211 * </ul>
213 public void _getData() {
214 requiredMethod("setData()");
215 bResult = true;
217 double[][] _data = oObj.getData();
218 data = _data;
219 if(rowDscs.length != 0 && rowDscs.length != data.length)
220 bResult = false;
221 if(colDscs.length != 0 && colDscs.length != data[0].length)
222 bResult = false;
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]) {
226 bResult = false;
231 tRes.tested("getData()", bResult);
234 @Override
235 protected void after() {
236 disposeEnvironment();