diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-10-19 08:19:39 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-10-29 23:44:31 +0100 |
commit | a0b7cd137aac7529b328c813b011166a78074cb4 (patch) | |
tree | fcc63e82bfbbebef27e4c1a4b589117d9f4b6328 /sc | |
parent | 7ff9b44d5d2fc2b641fd28d8878d27051cfd8d25 (diff) |
tdf#45904: Move Java _XSheetOperation tests to C++
Change-Id: I5aaeebd074882bb05a78e6d4057162e1da61d673
Reviewed-on: https://gerrit.libreoffice.org/43539
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_cellrangesobj.mk | 105 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/sccellcursorobj.cxx | 21 | ||||
-rw-r--r-- | sc/qa/extras/sccellrangeobj.cxx | 28 | ||||
-rw-r--r-- | sc/qa/extras/sccellrangesobj.cxx | 115 | ||||
-rw-r--r-- | sc/qa/extras/sctablesheetobj.cxx | 8 |
6 files changed, 261 insertions, 17 deletions
diff --git a/sc/CppunitTest_sc_cellrangesobj.mk b/sc/CppunitTest_sc_cellrangesobj.mk new file mode 100644 index 000000000000..792f0dac3334 --- /dev/null +++ b/sc/CppunitTest_sc_cellrangesobj.mk @@ -0,0 +1,105 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_cellrangesobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_cellrangesobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellrangesobj, \ + sc/qa/extras/sccellrangesobj\ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_cellrangesobj, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tk \ + tl \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_cellrangesobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_cellrangesobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_cellrangesobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_cellrangesobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_cellrangesobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + filter/source/config/cache/filterconfig1 \ + filter/source/storagefilterdetect/storagefd \ + forms/util/frm \ + framework/util/fwk \ + i18npool/source/search/i18nsearch \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + uui/util/uui \ + xmloff/util/xo \ + svtools/util/svt \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_cellrangesobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 1c40074b114b..ed4e61855d45 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -132,6 +132,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_datapilotitemobj \ CppunitTest_sc_subtotalfieldobj \ CppunitTest_sc_arealinksobj \ + CppunitTest_sc_cellrangesobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/sccellcursorobj.cxx b/sc/qa/extras/sccellcursorobj.cxx index 5ccc1722320a..517d4ca41131 100644 --- a/sc/qa/extras/sccellcursorobj.cxx +++ b/sc/qa/extras/sccellcursorobj.cxx @@ -9,9 +9,10 @@ #include <test/calc_unoapi_test.hxx> #include <test/sheet/xcellseries.hxx> +#include <test/sheet/xsheetoperation.hxx> +#include <test/sheet/xsubtotalcalculatable.hxx> #include <test/sheet/xusedareacursor.hxx> #include <test/sheet/xuniquecellformatrangessupplier.hxx> -#include <test/sheet/xsubtotalcalculatable.hxx> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -22,11 +23,13 @@ using namespace css::uno; namespace sc_apitest { -#define NUMBER_OF_TESTS 7 +#define NUMBER_OF_TESTS 9 -class ScCellCursorObj : public CalcUnoApiTest, - public apitest::XCellSeries, public apitest::XUsedAreaCursor, - public apitest::XUniqueCellFormatRangesSupplier, public apitest::XSubTotalCalculatable +class ScCellCursorObj : public CalcUnoApiTest, public apitest::XCellSeries, + public apitest::XSheetOperation, + public apitest::XSubTotalCalculatable, + public apitest::XUsedAreaCursor, + public apitest::XUniqueCellFormatRangesSupplier { public: ScCellCursorObj(); @@ -46,13 +49,17 @@ public: CPPUNIT_TEST(testFillAuto); CPPUNIT_TEST(testFillSeries); - // XUniqueCellFormatRangesSupplier - CPPUNIT_TEST(testGetUniqueCellFormatRanges); + // XSheetOperation + CPPUNIT_TEST(testComputeFunction); + CPPUNIT_TEST(testClearContents); // XSubTotalCalculatable CPPUNIT_TEST(testCreateSubTotalDescriptor); CPPUNIT_TEST(testApplyRemoveSubTotals); + // XUniqueCellFormatRangesSupplier + CPPUNIT_TEST(testGetUniqueCellFormatRanges); + CPPUNIT_TEST_SUITE_END(); private: diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx index a062063c58b4..ad6df24af046 100644 --- a/sc/qa/extras/sccellrangeobj.cxx +++ b/sc/qa/extras/sccellrangeobj.cxx @@ -12,8 +12,9 @@ #include <test/sheet/xcellrangedata.hxx> #include <test/sheet/xcellrangesquery.hxx> #include <test/sheet/xcellseries.hxx> -#include <test/sheet/xuniquecellformatrangessupplier.hxx> +#include <test/sheet/xsheetoperation.hxx> #include <test/sheet/xsubtotalcalculatable.hxx> +#include <test/sheet/xuniquecellformatrangessupplier.hxx> #include <test/util/xreplaceable.hxx> #include <test/util/xsearchable.hxx> @@ -29,12 +30,17 @@ using namespace css::uno; namespace sc_apitest { -#define NUMBER_OF_TESTS 20 - -class ScCellRangeObj : public CalcUnoApiTest, public apitest::XCellRangesQuery, public apitest::CellProperties, - public apitest::XSearchable, public apitest::XReplaceable, public apitest::XCellRangeData, - public apitest::XCellSeries, public apitest::XUniqueCellFormatRangesSupplier, - public apitest::XSubTotalCalculatable +#define NUMBER_OF_TESTS 22 + +class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties, + public apitest::XCellRangeData, + public apitest::XCellRangesQuery, + public apitest::XCellSeries, + public apitest::XReplaceable, + public apitest::XSearchable, + public apitest::XSheetOperation, + public apitest::XSubTotalCalculatable, + public apitest::XUniqueCellFormatRangesSupplier { public: ScCellRangeObj(); @@ -83,6 +89,10 @@ public: // XUniqueCellFormatRangesSupplier CPPUNIT_TEST(testGetUniqueCellFormatRanges); + // XSheetOperation + CPPUNIT_TEST(testComputeFunction); + CPPUNIT_TEST(testClearContents); + // XSubTotalCalculatable CPPUNIT_TEST(testCreateSubTotalDescriptor); CPPUNIT_TEST(testApplyRemoveSubTotals); @@ -99,9 +109,9 @@ uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent; ScCellRangeObj::ScCellRangeObj(): CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XSearchable("15", 1), + apitest::XCellSeries(2, 1), apitest::XReplaceable("15", "35"), - apitest::XCellSeries(2, 1) + apitest::XSearchable("15", 1) { } diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx new file mode 100644 index 000000000000..9e8d287e125d --- /dev/null +++ b/sc/qa/extras/sccellrangesobj.cxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 <test/calc_unoapi_test.hxx> +#include <test/sheet/xsheetoperation.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/table/XCellRange.hpp> + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Reference.hxx> + +using namespace css; +using namespace css::uno; + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 2 + +class ScCellRangesObj : public CalcUnoApiTest, public apitest::XSheetOperation +{ +public: + ScCellRangesObj(); + + virtual void setUp() override; + virtual void tearDown() override; + + virtual uno::Reference< uno::XInterface > init() override; + + CPPUNIT_TEST_SUITE(ScCellRangesObj); + + // XSheetOperation + CPPUNIT_TEST(testComputeFunction); + CPPUNIT_TEST(testClearContents); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScCellRangesObj::nTest = 0; +uno::Reference< lang::XComponent > ScCellRangesObj::mxComponent; + +ScCellRangesObj::ScCellRangesObj(): + CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference< uno::XInterface > ScCellRangesObj::init() +{ + // create a calc document + if (!mxComponent.is()) + mxComponent = loadFromDesktop("private:factory/scalc"); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + + uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference< lang::XMultiServiceFactory > xMSF(xDoc, uno::UNO_QUERY_THROW); + uno::Reference< container::XNameContainer > xRanges(xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW); + + //uno::Reference< container::XNameContainer > xRanges(xSheet, uno::UNO_QUERY_THROW); + uno::Any xCellRange; + + xCellRange <<= xSheet->getCellRangeByName("C1:D4"); + xRanges->insertByName("Range1", xCellRange); + xCellRange <<= xSheet->getCellRangeByName("E2:F5"); + xRanges->insertByName("Range2", xCellRange); + xCellRange <<= xSheet->getCellRangeByName("G2:H3"); + xRanges->insertByName("Range3", xCellRange); + xCellRange <<= xSheet->getCellRangeByName("I7:J8"); + xRanges->insertByName("Range4", xCellRange); + + + return xRanges; +} + +void ScCellRangesObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScCellRangesObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangesObj); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx index 8f2a4647d26a..a3b246055965 100644 --- a/sc/qa/extras/sctablesheetobj.cxx +++ b/sc/qa/extras/sctablesheetobj.cxx @@ -10,6 +10,7 @@ #include <test/calc_unoapi_test.hxx> #include <test/sheet/xcellseries.hxx> #include <test/sheet/xprintareas.hxx> +#include <test/sheet/xsheetoperation.hxx> #include <test/sheet/xsheetpagebreak.hxx> #include <test/sheet/xspreadsheet.hxx> #include <test/sheet/xsubtotalcalculatable.hxx> @@ -26,12 +27,13 @@ using namespace css::uno; namespace sc_apitest { -#define NUMBER_OF_TESTS 17 +#define NUMBER_OF_TESTS 19 class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries, public apitest::XPrintAreas, public apitest::XReplaceable, public apitest::XSearchable, + public apitest::XSheetOperation, public apitest::XSheetPageBreak, public apitest::XSpreadsheet, public apitest::XSubTotalCalculatable, @@ -65,6 +67,10 @@ public: CPPUNIT_TEST(testFillAuto); CPPUNIT_TEST(testFillSeries); + // XSheetOperation + CPPUNIT_TEST(testComputeFunction); + CPPUNIT_TEST(testClearContents); + // XSheetPageBreak CPPUNIT_TEST(testGetColumnPageBreaks); CPPUNIT_TEST(testGetRowPageBreaks); |