bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCalculatable.java
blob7176d388d6400c60867c5cb731c6169a8110cf4a
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 com.sun.star.sheet.XCalculatable;
21 import com.sun.star.table.XCell;
22 import lib.MultiMethodTest;
23 import lib.Status;
24 import lib.StatusException;
26 /**
29 public class _XCalculatable extends MultiMethodTest {
30 public XCalculatable oObj = null;
31 private boolean bIsAutomaticCalculationEnabled = false;
32 private XCell[] xCells = null;
34 /**
35 * Get object relation: four cells with values and formulas.
36 * @see mod._sc.ScModelObj
38 public void before() {
39 xCells = (XCell[])tEnv.getObjRelation("XCalculatable.Cells");
40 if (xCells == null || xCells.length != 3)
41 throw new StatusException(Status.failed("Couldn't find correct object relation 'XCalculatable.Cells'"));
45 /**
46 * Restore begin setting
48 public void after() {
49 // reset to begin value
50 oObj.enableAutomaticCalculation(bIsAutomaticCalculationEnabled);
54 public void _calculate() {
55 requiredMethod("isAutomaticCalculationEnabled()");
56 boolean result = true;
57 double ergValue1 = xCells[2].getValue();
58 double sourceValue1 = xCells[0].getValue();
59 xCells[0].setValue(sourceValue1 +1);
60 double ergValue2 = xCells[2].getValue();
61 result &= ergValue1 == ergValue2;
62 oObj.calculate();
63 ergValue2 = xCells[2].getValue();
64 result &= ergValue1 != ergValue2;
65 tRes.tested("calculate()", result);
68 public void _calculateAll() {
69 requiredMethod("isAutomaticCalculationEnabled()");
70 boolean result = true;
71 double ergValue1 = xCells[2].getValue();
72 double sourceValue1 = xCells[0].getValue();
73 xCells[0].setValue(sourceValue1 +1);
74 double ergValue2 = xCells[2].getValue();
75 result &= ergValue1 == ergValue2;
76 oObj.calculateAll();
77 ergValue2 = xCells[2].getValue();
78 result &= ergValue1 != ergValue2;
79 oObj.calculateAll();
80 tRes.tested("calculateAll()", result);
83 public void _enableAutomaticCalculation() {
84 bIsAutomaticCalculationEnabled = oObj.isAutomaticCalculationEnabled();
85 oObj.enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
86 tRes.tested("enableAutomaticCalculation()", true);
89 public void _isAutomaticCalculationEnabled() {
90 requiredMethod("enableAutomaticCalculation()");
91 boolean result = oObj.isAutomaticCalculationEnabled();
92 oObj.enableAutomaticCalculation(false);
93 tRes.tested("isAutomaticCalculationEnabled()", result != bIsAutomaticCalculationEnabled);