From 350eec67a5989365560e38e9270990dcd0a019e8 Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Fri, 1 Dec 2017 01:00:41 +0000 Subject: tdf#45904 Move _XMultipleOperation Java tests to C++ Change-Id: I102b726e673f69bfe64eff7e28e380dd6f15f1f8 Reviewed-on: https://gerrit.libreoffice.org/45629 Tested-by: Jenkins Reviewed-by: Jens Carl --- test/Library_subsequenttest.mk | 1 + test/source/sheet/xmultipleoperation.cxx | 96 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 test/source/sheet/xmultipleoperation.cxx (limited to 'test') diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 803f18303799..c398bb0cf10b 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -65,6 +65,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xlabelranges \ test/source/sheet/xnamedrange \ test/source/sheet/xnamedranges \ + test/source/sheet/xmultipleoperation \ test/source/sheet/xprintareas \ test/source/sheet/xscenarioenhanced \ test/source/sheet/xscenarios \ diff --git a/test/source/sheet/xmultipleoperation.cxx b/test/source/sheet/xmultipleoperation.cxx new file mode 100644 index 000000000000..5f5f100ea247 --- /dev/null +++ b/test/source/sheet/xmultipleoperation.cxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace css; +using namespace css::uno; + +namespace apitest +{ +void XMultipleOperation::testSetTableOperation() +{ + uno::Reference xMultipleOperation(init(), UNO_QUERY_THROW); + + uno::Reference xSheet(getXSpreadsheet(), UNO_QUERY_THROW); + uno::Reference xCellRange(xSheet->getCellRangeByName("$A$20:$A$20"), + UNO_QUERY_THROW); + uno::Reference xCellRangeAddr(xCellRange, UNO_QUERY_THROW); + + uno::Reference xCell = xSheet->getCellByPosition(0, 19); + xCell->setFormula("=a18+a19"); + + uno::Reference xCell1 = xSheet->getCellByPosition(0, 17); + uno::Reference xCellAddr1(xCell1, UNO_QUERY_THROW); + + uno::Reference xCell2 = xSheet->getCellByPosition(0, 18); + uno::Reference xCellAddr2(xCell2, UNO_QUERY_THROW); + + fillCells(xSheet); + xMultipleOperation->setTableOperation( + xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_ROW, + xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress()); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: ROW)", 5.0, + xSheet->getCellByPosition(1, 1)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,1 (OpMode: ROW)", 10.0, + xSheet->getCellByPosition(2, 1)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,1 (OpMode: ROW)", 15.0, + xSheet->getCellByPosition(3, 1)->getValue()); + + fillCells(xSheet); + xMultipleOperation->setTableOperation( + xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_COLUMN, + xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress()); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: COLUMN)", 12.0, + xSheet->getCellByPosition(1, 1)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,2 (OpMode: COLUMN)", 24.0, + xSheet->getCellByPosition(1, 2)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,3 (OpMode: COLUMN)", 36.0, + xSheet->getCellByPosition(1, 3)->getValue()); + + fillCells(xSheet); + xMultipleOperation->setTableOperation( + xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_BOTH, + xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress()); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: BOTH)", 17.0, + xSheet->getCellByPosition(1, 1)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,2 (OpMode: BOTH)", 34.0, + xSheet->getCellByPosition(2, 2)->getValue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,3 (OpMode: BOTH)", 51.0, + xSheet->getCellByPosition(3, 3)->getValue()); +} + +void XMultipleOperation::fillCells(uno::Reference& xSheet) +{ + for (unsigned int i = 1; i < 5; i++) + { + uno::Reference xCellFill = xSheet->getCellByPosition(0, i); + xCellFill->setValue(i * 12); + xCellFill = xSheet->getCellByPosition(i, 0); + xCellFill->setValue(i * 5); + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit