bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCellSeries.java
blob6152d2c243ee2b8be7396be074d2c8bb4d82e49b
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 .
18 package ifc.sheet;
20 import helper.LoggingThread;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.sheet.XCellSeries;
26 import com.sun.star.sheet.XSpreadsheet;
27 import com.sun.star.uno.UnoRuntime;
28 import share.LogWriter;
31 public class _XCellSeries extends MultiMethodTest {
32 public XCellSeries oObj = null;
33 protected XSpreadsheet oSheet = null;
34 protected boolean isSpreadSheet = false;
35 protected boolean fillAuto = true;
36 protected boolean forceFillAuto = false;
39 protected void before() {
40 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
42 if (oSheet == null) {
43 log.println("Object relation oSheet is missing");
44 log.println("Trying to query the needed Interface");
45 oSheet = UnoRuntime.queryInterface(
46 XSpreadsheet.class, tEnv.getTestObject());
48 if (oSheet == null) {
49 throw new StatusException(Status.failed(
50 "Object relation oSheet is missing"));
51 } else {
52 isSpreadSheet = true;
56 Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO");
58 if (myFillAuto != null) fillAuto = myFillAuto.booleanValue();
60 if (tParam.containsKey("force_fillauto")){
61 fillAuto = tParam.getBool("force_fillauto");
62 forceFillAuto = tParam.getBool("force_fillauto");
66 public void _fillAuto() {
68 if ((isSpreadSheet && !forceFillAuto) || !fillAuto) {
69 log.println("This method consumes to much time for a complete SpreadSheet");
70 log.println("Please use parameter '-force_fillauto true' to force this test");
71 tRes.tested("fillAuto()",Status.skipped(true));
72 return;
75 boolean res = true;
77 try {
78 oSheet.getCellByPosition(0, 0).setValue(2);
80 log.println(
81 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
82 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1);
83 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
85 double getting = oSheet.getCellByPosition(0, 4).getValue();
86 boolean locres = (getting == 14);
88 if (!locres) {
89 log.println("Operation failed");
90 } else {
91 log.println("Successful");
94 res &= locres;
96 log.println(
97 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
98 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1);
99 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
100 getting = oSheet.getCellByPosition(4, 0).getValue();
101 locres = (getting == 14);
103 if (!locres) {
104 log.println("Operation failed");
105 } else {
106 log.println("Successful");
109 res &= locres;
110 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
111 log.println("Couldn't set initial version to cell");
112 res = false;
115 tRes.tested("fillAuto()", res);
118 public void _fillSeries() {
120 if (isSpreadSheet) {
121 log.println("This method consumes to much time for a complete SpreadSheet");
122 tRes.tested("fillSeries()",Status.skipped(true));
123 return;
126 boolean res = true;
128 try {
129 oSheet.getCellByPosition(0, 0).setValue(2);
131 LoggingThread logger = new LoggingThread((LogWriter)log, tParam);
132 logger.start();
134 log.println(
135 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)");
136 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
137 com.sun.star.sheet.FillMode.LINEAR,
138 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
139 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
141 double getting = oSheet.getCellByPosition(0, 4).getValue();
142 boolean locres = (getting == 20);
144 logger.finish();
146 if (!locres) {
147 log.println("Operation failed");
148 } else {
149 log.println("Successful");
152 res &= locres;
154 logger = new LoggingThread((LogWriter)log, tParam);
155 logger.start();
157 log.println(
158 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)");
159 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
160 com.sun.star.sheet.FillMode.GROWTH,
161 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
162 16);
163 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
164 getting = oSheet.getCellByPosition(0, 4).getValue();
165 locres = (getting == 30);
167 logger.finish();
169 if (!locres) {
170 log.println("Operation failed");
171 } else {
172 log.println("Successful");
175 res &= locres;
177 logger = new LoggingThread((LogWriter)log, tParam);
178 logger.start();
180 log.println(
181 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)");
182 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
183 com.sun.star.sheet.FillMode.LINEAR,
184 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
185 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
186 getting = oSheet.getCellByPosition(4, 0).getValue();
187 locres = (getting == 20);
189 logger.finish();
191 if (!locres) {
192 log.println("Operation failed");
193 } else {
194 log.println("Successful");
197 res &= locres;
199 logger = new LoggingThread((LogWriter)log, tParam);
200 logger.start();
202 log.println(
203 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)");
204 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
205 com.sun.star.sheet.FillMode.GROWTH,
206 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
207 16);
208 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
209 getting = oSheet.getCellByPosition(4, 0).getValue();
210 locres = (getting == 30);
212 logger.finish();
214 if (!locres) {
215 log.println("Operation failed");
216 } else {
217 log.println("Successful");
220 res &= locres;
221 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
222 log.println("Couldn't set initial version to cell");
223 res = false;
226 tRes.tested("fillSeries()", res);
230 * Forces environment recreation.
232 public void after() {
233 disposeEnvironment();