Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCellSeries.java
blob72e078e9c0cba938c11faf67ce04f2f88dafbbae
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 @Override
40 protected void before() {
41 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
43 if (oSheet == null) {
44 log.println("Object relation oSheet is missing");
45 log.println("Trying to query the needed Interface");
46 oSheet = UnoRuntime.queryInterface(
47 XSpreadsheet.class, tEnv.getTestObject());
49 if (oSheet == null) {
50 throw new StatusException(Status.failed(
51 "Object relation oSheet is missing"));
52 } else {
53 isSpreadSheet = true;
57 Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO");
59 if (myFillAuto != null) fillAuto = myFillAuto.booleanValue();
61 if (tParam.containsKey("force_fillauto")){
62 fillAuto = tParam.getBool("force_fillauto");
63 forceFillAuto = tParam.getBool("force_fillauto");
67 public void _fillAuto() {
69 if ((isSpreadSheet && !forceFillAuto) || !fillAuto) {
70 log.println("This method consumes to much time for a complete SpreadSheet");
71 log.println("Please use parameter '-force_fillauto true' to force this test");
72 tRes.tested("fillAuto()",Status.skipped(true));
73 return;
76 boolean res = true;
78 try {
79 oSheet.getCellByPosition(0, 0).setValue(2);
81 log.println(
82 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
83 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1);
84 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
86 double getting = oSheet.getCellByPosition(0, 4).getValue();
87 boolean locres = (getting == 14);
89 if (!locres) {
90 log.println("Operation failed");
91 } else {
92 log.println("Successful");
95 res &= locres;
97 log.println(
98 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
99 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1);
100 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
101 getting = oSheet.getCellByPosition(4, 0).getValue();
102 locres = (getting == 14);
104 if (!locres) {
105 log.println("Operation failed");
106 } else {
107 log.println("Successful");
110 res &= locres;
111 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
112 log.println("Couldn't set initial version to cell");
113 res = false;
116 tRes.tested("fillAuto()", res);
119 public void _fillSeries() {
121 if (isSpreadSheet) {
122 log.println("This method consumes to much time for a complete SpreadSheet");
123 tRes.tested("fillSeries()",Status.skipped(true));
124 return;
127 boolean res = true;
129 try {
130 oSheet.getCellByPosition(0, 0).setValue(2);
132 LoggingThread logger = new LoggingThread((LogWriter)log, tParam);
133 logger.start();
135 log.println(
136 "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)");
137 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
138 com.sun.star.sheet.FillMode.LINEAR,
139 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
140 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
142 double getting = oSheet.getCellByPosition(0, 4).getValue();
143 boolean locres = (getting == 20);
145 logger.finish();
147 if (!locres) {
148 log.println("Operation failed");
149 } else {
150 log.println("Successful");
153 res &= locres;
155 logger = new LoggingThread((LogWriter)log, tParam);
156 logger.start();
158 log.println(
159 "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)");
160 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
161 com.sun.star.sheet.FillMode.GROWTH,
162 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
163 16);
164 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
165 getting = oSheet.getCellByPosition(0, 4).getValue();
166 locres = (getting == 30);
168 logger.finish();
170 if (!locres) {
171 log.println("Operation failed");
172 } else {
173 log.println("Successful");
176 res &= locres;
178 logger = new LoggingThread((LogWriter)log, tParam);
179 logger.start();
181 log.println(
182 "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)");
183 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
184 com.sun.star.sheet.FillMode.LINEAR,
185 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
186 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
187 getting = oSheet.getCellByPosition(4, 0).getValue();
188 locres = (getting == 20);
190 logger.finish();
192 if (!locres) {
193 log.println("Operation failed");
194 } else {
195 log.println("Successful");
198 res &= locres;
200 logger = new LoggingThread((LogWriter)log, tParam);
201 logger.start();
203 log.println(
204 "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)");
205 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
206 com.sun.star.sheet.FillMode.GROWTH,
207 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
208 16);
209 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
210 getting = oSheet.getCellByPosition(4, 0).getValue();
211 locres = (getting == 30);
213 logger.finish();
215 if (!locres) {
216 log.println("Operation failed");
217 } else {
218 log.println("Successful");
221 res &= locres;
222 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
223 log.println("Couldn't set initial version to cell");
224 res = false;
227 tRes.tested("fillSeries()", res);
231 * Forces environment recreation.
233 @Override
234 public void after() {
235 disposeEnvironment();