Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCellSeries.java
blob7ed3b4e617612b604115f4623776d42476c195ff
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package ifc.sheet;
29 import helper.LoggingThread;
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
34 import com.sun.star.sheet.XCellSeries;
35 import com.sun.star.sheet.XSpreadsheet;
36 import com.sun.star.uno.UnoRuntime;
37 import share.LogWriter;
40 public class _XCellSeries extends MultiMethodTest {
41 public XCellSeries oObj = null;
42 protected XSpreadsheet oSheet = null;
43 protected boolean isSpreadSheet = false;
44 protected boolean fillAuto = true;
45 protected boolean forceFillAuto = false;
48 protected void before() {
49 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
51 if (oSheet == null) {
52 log.println("Object relation oSheet is missing");
53 log.println("Trying to query the needed Interface");
54 oSheet = (XSpreadsheet) UnoRuntime.queryInterface(
55 XSpreadsheet.class, tEnv.getTestObject());
57 if (oSheet == null) {
58 throw new StatusException(Status.failed(
59 "Object relation oSheet is missing"));
60 } else {
61 isSpreadSheet = true;
65 Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO");
67 if (myFillAuto != null) fillAuto = myFillAuto.booleanValue();
69 if (tParam.containsKey("force_fillauto")){
70 fillAuto = tParam.getBool("force_fillauto");
71 forceFillAuto = tParam.getBool("force_fillauto");
75 public void _fillAuto() {
77 if ((isSpreadSheet && !forceFillAuto) || !fillAuto) {
78 log.println("This method consumes to much time for a complete SpreadSheet");
79 log.println("Please use parameter '-force_fillauto true' to force this test");
80 tRes.tested("fillAuto()",Status.skipped(true));
81 return;
84 boolean res = true;
86 try {
87 oSheet.getCellByPosition(0, 0).setValue(2);
89 log.println(
90 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
91 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1);
92 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
94 double getting = oSheet.getCellByPosition(0, 4).getValue();
95 boolean locres = (getting == 14);
97 if (!locres) {
98 log.println("Operation failed");
99 } else {
100 log.println("Successful");
103 res &= locres;
105 log.println(
106 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
107 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1);
108 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
109 getting = oSheet.getCellByPosition(4, 0).getValue();
110 locres = (getting == 14);
112 if (!locres) {
113 log.println("Operation failed");
114 } else {
115 log.println("Successful");
118 res &= locres;
119 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
120 log.println("Couldn't set initial version to cell");
121 res = false;
124 tRes.tested("fillAuto()", res);
127 public void _fillSeries() {
129 if (isSpreadSheet) {
130 log.println("This method consumes to much time for a complete SpreadSheet");
131 tRes.tested("fillSeries()",Status.skipped(true));
132 return;
135 boolean res = true;
137 try {
138 oSheet.getCellByPosition(0, 0).setValue(2);
140 LoggingThread logger = new LoggingThread((LogWriter)log, tParam);
141 logger.start();
143 log.println(
144 "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)");
145 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
146 com.sun.star.sheet.FillMode.LINEAR,
147 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
148 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
150 double getting = oSheet.getCellByPosition(0, 4).getValue();
151 boolean locres = (getting == 20);
153 logger.finish();
155 if (!locres) {
156 log.println("Operation failed");
157 } else {
158 log.println("Successful");
161 res &= locres;
163 logger = new LoggingThread((LogWriter)log, tParam);
164 logger.start();
166 log.println(
167 "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)");
168 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
169 com.sun.star.sheet.FillMode.GROWTH,
170 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
171 16);
172 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
173 getting = oSheet.getCellByPosition(0, 4).getValue();
174 locres = (getting == 30);
176 logger.finish();
178 if (!locres) {
179 log.println("Operation failed");
180 } else {
181 log.println("Successful");
184 res &= locres;
186 logger = new LoggingThread((LogWriter)log, tParam);
187 logger.start();
189 log.println(
190 "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)");
191 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
192 com.sun.star.sheet.FillMode.LINEAR,
193 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
194 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
195 getting = oSheet.getCellByPosition(4, 0).getValue();
196 locres = (getting == 20);
198 logger.finish();
200 if (!locres) {
201 log.println("Operation failed");
202 } else {
203 log.println("Successful");
206 res &= locres;
208 logger = new LoggingThread((LogWriter)log, tParam);
209 logger.start();
211 log.println(
212 "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)");
213 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
214 com.sun.star.sheet.FillMode.GROWTH,
215 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
216 16);
217 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
218 getting = oSheet.getCellByPosition(4, 0).getValue();
219 locres = (getting == 30);
221 logger.finish();
223 if (!locres) {
224 log.println("Operation failed");
225 } else {
226 log.println("Successful");
229 res &= locres;
230 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
231 log.println("Couldn't set initial version to cell");
232 res = false;
235 tRes.tested("fillSeries()", res);
239 * Forces environment recreation.
241 public void after() {
242 disposeEnvironment();