sc/CppunitTest_sc_functions_test.mk | 114 ++++++++++++++++++++++++++++++++++++ sc/Module_sc.mk | 1 sc/qa/unit/functions_test.cxx | 100 +++++++++++++++++++++++++++++++ sc/qa/unit/helper/qahelper.cxx | 3 sc/qa/unit/helper/qahelper.hxx | 2 5 files changed, 219 insertions(+), 1 deletion(-)
New commits: commit e4127e4cd7bd27b9a616e1550cc9845096a66114 Author: Markus Mohrhard <[email protected]> Date: Sat May 14 17:08:46 2016 +0200 add framework for new calc function tests Change-Id: I65aa84d1fa7537ea180232e5c7308a76c3919870 Reviewed-on: https://gerrit.libreoffice.org/24996 Tested-by: Jenkins <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> diff --git a/sc/CppunitTest_sc_functions_test.mk b/sc/CppunitTest_sc_functions_test.mk new file mode 100644 index 0000000..5ee8725 --- /dev/null +++ b/sc/CppunitTest_sc_functions_test.mk @@ -0,0 +1,114 @@ +# -*- 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_functions_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_functions_test, \ + sc/qa/unit/functions_test \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sc_functions_test, \ + boost_headers \ + mdds_headers \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_functions_test, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sc \ + scqahelper \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tk \ + tl \ + ucbhelper \ + unotest \ + utl \ + vcl \ + xo \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_functions_test,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_functions_test,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_functions_test)) + +$(eval $(call gb_CppunitTest_use_vcl,sc_functions_test)) + +$(eval $(call gb_CppunitTest_use_components,sc_functions_test,\ + basic/util/sb \ + chart2/source/chartcore \ + chart2/source/controller/chartcontroller \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + connectivity/source/manager/sdbc2 \ + dbaccess/util/dba \ + embeddedobj/util/embobj \ + eventattacher/source/evtatt \ + filter/source/config/cache/filterconfig1 \ + filter/source/odfflatxml/odfflatxml \ + filter/source/xmlfilteradaptor/xmlfa \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scaddins/source/analysis/analysis \ + scaddins/source/datefunc/date \ + sc/util/sc \ + sc/util/scfilt \ + sfx2/util/sfx \ + sot/util/sot \ + svl/util/svl \ + svtools/util/svt \ + svx/util/svx \ + svx/util/svxcore \ + 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 \ + xmloff/util/xo \ + xmlscript/util/xmlscript \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_functions_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 3586019..0f6b29f 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -58,6 +58,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \ CppunitTest_sc_html_export_test \ CppunitTest_sc_opencl_test \ CppunitTest_sc_copypaste \ + CppunitTest_sc_functions_test \ )) # Disabled to allow the check tinderbox execute the sd tests diff --git a/sc/qa/unit/functions_test.cxx b/sc/qa/unit/functions_test.cxx new file mode 100644 index 0000000..3362dfd --- /dev/null +++ b/sc/qa/unit/functions_test.cxx @@ -0,0 +1,100 @@ +/* -*- 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 <sal/config.h> + +#include <unotest/filters-test.hxx> +#include "scdll.hxx" +#include "helper/qahelper.hxx" + +#include "document.hxx" + +class FunctionsTest : public ScBootstrapFixture, public test::FiltersTest +{ +public: + + FunctionsTest(); + + virtual void setUp() override; + + virtual void tearDown() override; + + virtual bool load( + const OUString &rFilter, + const OUString &rURL, + const OUString &rUserData, + SfxFilterFlags nFilterFlags, + SotClipboardFormatId nClipboardID, + unsigned int nFilterVersion) override; + + void testFormulasFODS(); + + CPPUNIT_TEST_SUITE(FunctionsTest); + CPPUNIT_TEST(testFormulasFODS); + CPPUNIT_TEST_SUITE_END(); + +private: + uno::Reference<uno::XInterface> m_xCalcComponent; +}; + +FunctionsTest::FunctionsTest(): + ScBootstrapFixture("sc/qa/unit/data/functions/fods") +{ +} + +void FunctionsTest::setUp() +{ + ScBootstrapFixture::setUp(); + + // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure, + // which is a private symbol to us, gets called + m_xCalcComponent = + getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument"); + CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); +} + +void FunctionsTest::tearDown() +{ + ScBootstrapFixture::tearDown(); +} + +bool FunctionsTest::load(const OUString& rFilter, const OUString& rURL, + const OUString& rUserData, SfxFilterFlags nFilterFlags, + SotClipboardFormatId nClipboardID, + unsigned int nFilterVersion) +{ + ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData, + OUString(), nFilterFlags, nClipboardID, nFilterVersion ); + CPPUNIT_ASSERT(xDocShRef.Is()); + + xDocShRef->DoHardRecalc(true); + + ScDocument& rDoc = xDocShRef->GetDocument(); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rDoc.GetValue(1, 2, 0), 1e-14); + + xDocShRef->DoClose(); + + return true; +} + +void FunctionsTest::testFormulasFODS() +{ + OUString aDirectoryURL = m_directories.getURLFromSrc("/sc/qa/unit/data/functions/fods/"); + recursiveScan(test::pass, "OpenDocument Spreadsheet Flat XML", aDirectoryURL, + "com.sun.star.comp.filter.OdfFlatXml,,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter,,,true", + FODS_FORMAT_TYPE, SotClipboardFormatId::NONE, 0, false); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(FunctionsTest); + + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index b59beb0..ac61dc2 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -85,7 +85,8 @@ const FileFormat ScBootstrapFixture::aFileFormats[] = { { "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE }, { "dif", "DIF", "calc_DIF", DIF_FORMAT_TYPE }, { "xml", "MS Excel 2003 XML", "calc_MS_Excel_2003_XML", XLS_XML_FORMAT_TYPE }, - { "xlsb", "Calc MS Excel 2007 Binary", "MS Excel 2007 Binary", XLSB_XML_FORMAT_TYPE } + { "xlsb", "Calc MS Excel 2007 Binary", "MS Excel 2007 Binary", XLSB_XML_FORMAT_TYPE }, + { "fods", "OpenDocument Spreadsheet Flat XML", "calc_ODS_FlatXML", FODS_FORMAT_TYPE } }; bool testEqualsWithTolerance( long nVal1, long nVal2, long nTol ) diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 0d089ce..101df14 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -51,6 +51,7 @@ #define DIF_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN ) #define XLS_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN) #define XLSB_XML_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED) +#define FODS_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::OWN, SfxFilterFlags::STARONEFILTER ) #define FORMAT_ODS 0 #define FORMAT_XLS 1 @@ -62,6 +63,7 @@ #define FORMAT_DIF 7 #define FORMAT_XLS_XML 8 #define FORMAT_XLSB 9 +#define FORMAT_FODS 10 enum StringType { PureString, FormulaValue, StringValue }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
