Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XCalculatable.java
blob260b452b131c88e91f91f84927fa274cd7d6e18a
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 @Override
39 public void before() {
40 xCells = (XCell[])tEnv.getObjRelation("XCalculatable.Cells");
41 if (xCells == null || xCells.length != 3)
42 throw new StatusException(Status.failed("Couldn't find correct object relation 'XCalculatable.Cells'"));
46 /**
47 * Restore begin setting
49 @Override
50 public void after() {
51 // reset to begin value
52 oObj.enableAutomaticCalculation(bIsAutomaticCalculationEnabled);
56 public void _calculate() {
57 requiredMethod("isAutomaticCalculationEnabled()");
58 boolean result = true;
59 double ergValue1 = xCells[2].getValue();
60 double sourceValue1 = xCells[0].getValue();
61 xCells[0].setValue(sourceValue1 +1);
62 double ergValue2 = xCells[2].getValue();
63 result &= ergValue1 == ergValue2;
64 oObj.calculate();
65 ergValue2 = xCells[2].getValue();
66 result &= ergValue1 != ergValue2;
67 tRes.tested("calculate()", result);
70 public void _calculateAll() {
71 requiredMethod("isAutomaticCalculationEnabled()");
72 boolean result = true;
73 double ergValue1 = xCells[2].getValue();
74 double sourceValue1 = xCells[0].getValue();
75 xCells[0].setValue(sourceValue1 +1);
76 double ergValue2 = xCells[2].getValue();
77 result &= ergValue1 == ergValue2;
78 oObj.calculateAll();
79 ergValue2 = xCells[2].getValue();
80 result &= ergValue1 != ergValue2;
81 oObj.calculateAll();
82 tRes.tested("calculateAll()", result);
85 public void _enableAutomaticCalculation() {
86 bIsAutomaticCalculationEnabled = oObj.isAutomaticCalculationEnabled();
87 oObj.enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
88 tRes.tested("enableAutomaticCalculation()", true);
91 public void _isAutomaticCalculationEnabled() {
92 requiredMethod("enableAutomaticCalculation()");
93 boolean result = oObj.isAutomaticCalculationEnabled();
94 oObj.enableAutomaticCalculation(false);
95 tRes.tested("isAutomaticCalculationEnabled()", result != bIsAutomaticCalculationEnabled);