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
5b2794e27a
.
Change-Id: I27b954b216acd3d138ade0d3f1b21fedd2f74fb1
Reviewed-on: https://gerrit.libreoffice.org/67071
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
This commit is contained in:
parent
55013f566d
commit
3cacdf5b0f
4 changed files with 35 additions and 7 deletions
|
@ -27,7 +27,13 @@ public:
|
|||
void testGetTopic();
|
||||
|
||||
protected:
|
||||
explicit XDDELink(OUString const& rURL)
|
||||
: m_URL(rURL)
|
||||
{
|
||||
}
|
||||
~XDDELink() {}
|
||||
|
||||
OUString const m_URL;
|
||||
};
|
||||
} // namespace apitest
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ddelinkobj, \
|
|||
subsequenttest \
|
||||
test \
|
||||
unotest \
|
||||
utl \
|
||||
vcl \
|
||||
))
|
||||
|
||||
|
|
|
@ -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\")");
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue