bump product version to 6.3.0.0.beta1
[LibreOffice.git] / test / source / sheet / xcalculatable.cxx
blob4ee1cd80063064c7902fc8c83aa3468bec35ec21
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/sheet/xcalculatable.hxx>
12 #include <com/sun/star/sheet/XCalculatable.hpp>
13 #include <com/sun/star/table/XCell.hpp>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <com/sun/star/uno/Sequence.hxx>
18 #include <cppunit/extensions/HelperMacros.h>
20 using namespace com::sun::star;
21 using namespace com::sun::star::uno;
23 namespace apitest
25 void XCalculatable::testEnableAutomaticCaclulation()
27 uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
29 bool bIsAutomaticCalculationEnabled = xCalculatable->isAutomaticCalculationEnabled();
30 xCalculatable->enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
31 bool bIsAutomaticCalculationEnabledNew = xCalculatable->isAutomaticCalculationEnabled();
32 CPPUNIT_ASSERT_MESSAGE("Unable to set enableAutomaticCalculation()",
33 bIsAutomaticCalculationEnabled != bIsAutomaticCalculationEnabledNew);
36 void XCalculatable::testCalculate()
38 uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
39 xCalculatable->enableAutomaticCalculation(false);
41 uno::Sequence<uno::Reference<table::XCell>> xCells = getXCells();
43 double dProduct = xCells[2]->getValue();
44 double dFactor1 = xCells[0]->getValue();
45 xCells[0]->setValue(dFactor1 + 1.0);
46 double dProduct2 = xCells[2]->getValue();
47 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculated products are equal", dProduct, dProduct2, 0.5);
49 xCalculatable->calculate();
50 dProduct2 = xCells[2]->getValue();
51 CPPUNIT_ASSERT_MESSAGE("Calculated products are not equal", dProduct != dProduct2);
54 void XCalculatable::testCalculateAll()
56 uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
57 xCalculatable->enableAutomaticCalculation(false);
59 uno::Sequence<uno::Reference<table::XCell>> xCells = getXCells();
61 double dProduct = xCells[2]->getValue();
62 double dFactor1 = xCells[0]->getValue();
63 xCells[0]->setValue(dFactor1 + 1.0);
64 double dProduct2 = xCells[2]->getValue();
65 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculated products are equal", dProduct, dProduct2, 0.5);
67 xCalculatable->calculateAll();
68 dProduct2 = xCells[2]->getValue();
69 CPPUNIT_ASSERT_MESSAGE("Calculated products are not equal", dProduct != dProduct2);
70 xCalculatable->calculateAll();
72 } // namespace apitest
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */