include/test/sheet/xddelink.hxx | 6 ++++++ sc/CppunitTest_sc_ddelinkobj.mk | 1 + sc/qa/extras/scddelinkobj.cxx | 32 +++++++++++++++++++++++++++----- test/source/sheet/xddelink.cxx | 3 +-- 4 files changed, 35 insertions(+), 7 deletions(-)
New commits: commit 3cacdf5b0f1a6285370d5b06ddec9bce770ea603 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Jan 29 13:40:21 2019 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Jan 29 17:02:17 2019 +0100 sc: fix CppunitTest_sc_ddelinkobj to copy its test document XRefreshable::testRefreshListener() fails on read-only filesystem because the ScDDELinksObj.ods cannot be loaded read-write. It is loaded read-write since commit 5b2794e27a81f8078cc251580ca59cc47807c7a0. Change-Id: I27b954b216acd3d138ade0d3f1b21fedd2f74fb1 Reviewed-on: https://gerrit.libreoffice.org/67071 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/include/test/sheet/xddelink.hxx b/include/test/sheet/xddelink.hxx index fa974ea321d8..854462a0dc1c 100644 --- a/include/test/sheet/xddelink.hxx +++ b/include/test/sheet/xddelink.hxx @@ -27,7 +27,13 @@ public: void testGetTopic(); protected: + explicit XDDELink(OUString const& rURL) + : m_URL(rURL) + { + } ~XDDELink() {} + + OUString const m_URL; }; } // namespace apitest diff --git a/sc/CppunitTest_sc_ddelinkobj.mk b/sc/CppunitTest_sc_ddelinkobj.mk index c59cf6e96360..60ab216aaca4 100644 --- a/sc/CppunitTest_sc_ddelinkobj.mk +++ b/sc/CppunitTest_sc_ddelinkobj.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ddelinkobj, \ subsequenttest \ test \ unotest \ + utl \ vcl \ )) diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx index 0aa2e968c58e..4d1838a3b321 100644 --- a/sc/qa/extras/scddelinkobj.cxx +++ b/sc/qa/extras/scddelinkobj.cxx @@ -12,6 +12,7 @@ #include <test/sheet/xddelink.hxx> #include <test/util/xrefreshable.hxx> +#include <unotools/tempfile.hxx> #include <sfx2/app.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -33,7 +34,29 @@ using namespace com::sun::star; namespace sc_apitest { +static utl::TempFile createTempCopy(OUString const& url) +{ + utl::TempFile tmp; + tmp.EnableKillingFile(); + auto const e = osl::File::copy(url, tmp.GetURL()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + (OUStringToOString("<" + url + "> -> <" + tmp.GetURL() + ">", RTL_TEXTENCODING_UTF8) + .getStr()), + osl::FileBase::E_None, e); + return tmp; +} + +struct TempFileBase +{ + utl::TempFile m_TempFile; + explicit TempFileBase(OUString const& url) + : m_TempFile(createTempCopy(url)) + { + } +}; + class ScDDELinkObj : public CalcUnoApiTest, + public TempFileBase, public apitest::XDDELink, public apitest::XNamed, public apitest::XRefreshable @@ -67,9 +90,9 @@ private: ScDDELinkObj::ScDDELinkObj() : CalcUnoApiTest("/sc/qa/extras/testdocuments") - , XNamed("soffice|" - + m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods") - + "!Sheet1.A1") + , TempFileBase(m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods")) + , XDDELink(m_TempFile.GetURL()) + , XNamed("soffice|" + m_TempFile.GetURL() + "!Sheet1.A1") { } @@ -81,8 +104,7 @@ uno::Reference<uno::XInterface> ScDDELinkObj::init() uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW); - const OUString testdoc - = m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods"); + const OUString testdoc = m_TempFile.GetURL(); xSheet->getCellByPosition(5, 5)->setFormula("=DDE(\"soffice\";\"" + testdoc + "\";\"Sheet1.A1\")"); diff --git a/test/source/sheet/xddelink.cxx b/test/source/sheet/xddelink.cxx index b166275d5367..4227c3b4c9a4 100644 --- a/test/source/sheet/xddelink.cxx +++ b/test/source/sheet/xddelink.cxx @@ -37,8 +37,7 @@ void XDDELink::testGetTopic() { uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW); - CPPUNIT_ASSERT_MESSAGE("Unable to execute getTopic()", - xLink->getTopic().endsWith("ScDDELinksObj.ods")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getTopic()", m_URL, xLink->getTopic()); } } // namespace apitest _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits