From b8563d46a03567df0780216173b10156e158b64e Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Fri, 9 Mar 2018 07:32:31 +0000 Subject: tdf#45904 Move _SheetLink Java tests to C++ Change-Id: I33813be65bcb44c11a35bc97d963057418a28d9e Reviewed-on: https://gerrit.libreoffice.org/50984 Tested-by: Jenkins Reviewed-by: Jens Carl --- sc/CppunitTest_sc_sheetlinkobj.mk | 105 ++++++++++++++++++++++++++++++++++++++ sc/Module_sc.mk | 1 + sc/qa/extras/scsheetlinkobj.cxx | 103 +++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 sc/CppunitTest_sc_sheetlinkobj.mk create mode 100644 sc/qa/extras/scsheetlinkobj.cxx (limited to 'sc') diff --git a/sc/CppunitTest_sc_sheetlinkobj.mk b/sc/CppunitTest_sc_sheetlinkobj.mk new file mode 100644 index 000000000000..34e1e8c326b0 --- /dev/null +++ b/sc/CppunitTest_sc_sheetlinkobj.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_sheetlinkobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_sheetlinkobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_sheetlinkobj, \ + sc/qa/extras/scsheetlinkobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_sheetlinkobj, \ + 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_sheetlinkobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_sheetlinkobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_sheetlinkobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_sheetlinkobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_sheetlinkobj,\ + 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/util/i18npool \ + linguistic/source/lng \ + 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_sheetlinkobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 482b77e4e93e..808ce932152a 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -153,6 +153,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_documentconfigurationobj \ CppunitTest_sc_spreadsheetsettingsobj \ CppunitTest_sc_shapeobj \ + CppunitTest_sc_sheetlinkobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/scsheetlinkobj.cxx b/sc/qa/extras/scsheetlinkobj.cxx new file mode 100644 index 000000000000..57a85cc8009e --- /dev/null +++ b/sc/qa/extras/scsheetlinkobj.cxx @@ -0,0 +1,103 @@ +/* -*- 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 +#include + +#include + +using namespace css; +using namespace css::uno; +using namespace com::sun::star; + +namespace sc_apitest +{ +class ScSheetLinkObj : public CalcUnoApiTest, public apitest::SheetLink +{ +public: + ScSheetLinkObj(); + + virtual uno::Reference init() override; + + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScSheetLinkObj); + + // SheetLink + CPPUNIT_TEST(testSheetLinkProperties); + + CPPUNIT_TEST_SUITE_END(); + +private: + uno::Reference mxComponent; + OUString maUrl; +}; + +ScSheetLinkObj::ScSheetLinkObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference ScSheetLinkObj::init() +{ + uno::Reference xDoc(mxComponent, UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + + uno::Reference xSheets(xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference xIA(xSheets, UNO_QUERY_THROW); + uno::Reference xSheet(xIA->getByIndex(0), UNO_QUERY_THROW); + + uno::Reference xSL(xSheet, UNO_QUERY_THROW); + OUString aFileURL; + createFileURL("ScSheetLinkObj.ods", aFileURL); + xSL->link(aFileURL, "Sheet1", "", "", sheet::SheetLinkMode_VALUE); + + uno::Reference xPropSet(xDoc, UNO_QUERY_THROW); + uno::Reference sheetLinks; + CPPUNIT_ASSERT(xPropSet->getPropertyValue("SheetLinks") >>= sheetLinks); + CPPUNIT_ASSERT(sheetLinks.is()); + + uno::Any aAny = sheetLinks->getByName(sheetLinks->getElementNames()[0]); + uno::Reference sheetLink; + aAny >>= sheetLink; + return sheetLink; +} + +void ScSheetLinkObj::setUp() +{ + CalcUnoApiTest::setUp(); + // create a calc document + mxComponent = loadFromDesktop("private:factory/scalc"); +} + +void ScSheetLinkObj::tearDown() +{ + closeDocument(mxComponent); + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinkObj); + +} // end namespace + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit