diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-23 11:51:57 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-23 14:43:56 +0100 |
commit | 6c3cebd5aaec641807f5efed814fc5d1c64df149 (patch) | |
tree | dc5333838c1a973afc5b72190e0be28dfcdc6e76 /sc | |
parent | 139d1aa610d19ab200deff1e3cd2c787f5c87d89 (diff) |
UnoApiTest: factor out createTempFile
Change-Id: I8d7bb4593839d3660b6609d836b09d50b68f5712
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143141
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/scddelinkobj.cxx | 35 | ||||
-rw-r--r-- | sc/qa/extras/scddelinksobj.cxx | 9 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/ScDDELinksObj.ods (renamed from sc/qa/unoapi/testdocuments/ScDDELinksObj.ods) | bin | 7812 -> 7812 bytes |
3 files changed, 8 insertions, 36 deletions
diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx index 9be1a660d867..8f798beedd98 100644 --- a/sc/qa/extras/scddelinkobj.cxx +++ b/sc/qa/extras/scddelinkobj.cxx @@ -33,33 +33,7 @@ using namespace com::sun::star; namespace sc_apitest { -static utl::TempFileNamed createTempCopy(OUString const& url) -{ - utl::TempFileNamed tmp; - tmp.EnableKillingFile(); - auto const e = osl::File::copy(url, tmp.GetURL()); - CPPUNIT_ASSERT_EQUAL_MESSAGE( - (OString("<" + OUStringToOString(url, RTL_TEXTENCODING_UTF8) + "> -> <" - + OUStringToOString(tmp.GetURL(), RTL_TEXTENCODING_UTF8) + ">") - .getStr()), - osl::FileBase::E_None, e); - return tmp; -} - -namespace -{ -struct TempFileBase -{ - utl::TempFileNamed m_TempFile; - explicit TempFileBase(OUString const& url) - : m_TempFile(createTempCopy(url)) - { - } -}; -} - class ScDDELinkObj : public UnoApiTest, - public TempFileBase, public apitest::XDDELink, public apitest::XNamed, public apitest::XRefreshable @@ -89,9 +63,8 @@ public: ScDDELinkObj::ScDDELinkObj() : UnoApiTest("/sc/qa/extras/testdocuments") - , TempFileBase(m_directories.getURLFromSrc(u"/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods")) - , XDDELink(m_TempFile.GetURL()) - , XNamed("soffice|" + m_TempFile.GetURL() + "!Sheet1.A1") + , XDDELink(maTempFile.GetURL()) + , XNamed("soffice|" + maTempFile.GetURL() + "!Sheet1.A1") { } @@ -103,7 +76,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_TempFile.GetURL(); + const OUString testdoc = maTempFile.GetURL(); xSheet->getCellByPosition(5, 5)->setFormula("=DDE(\"soffice\";\"" + testdoc + "\";\"Sheet1.A1\")"); @@ -124,6 +97,8 @@ void ScDDELinkObj::setUp() UnoApiTest::setUp(); // create a calc document mxComponent = loadFromDesktop("private:factory/scalc"); + + createTempCopy(u"ScDDELinksObj.ods"); } CPPUNIT_TEST_SUITE_REGISTRATION(ScDDELinkObj); diff --git a/sc/qa/extras/scddelinksobj.cxx b/sc/qa/extras/scddelinksobj.cxx index bb92a5a5151a..6a3a843ca9a1 100644 --- a/sc/qa/extras/scddelinksobj.cxx +++ b/sc/qa/extras/scddelinksobj.cxx @@ -81,12 +81,10 @@ public: ScDDELinksObj::ScDDELinksObj() : UnoApiTest("/sc/qa/extras/testdocuments") - , XDDELinks(m_directories.getURLFromSrc(u"/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods")) + , XDDELinks(createFileURL(u"ScDDELinksObj.ods")) , XElementAccess(cppu::UnoType<sheet::XDDELink>::get()) , XIndexAccess(1) - , XNameAccess("soffice|" - + m_directories.getURLFromSrc(u"/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods") - + "!Sheet1.A1") + , XNameAccess("soffice|" + createFileURL(u"ScDDELinksObj.ods") + "!Sheet1.A1") , XServiceInfo("ScDDELinksObj", "com.sun.star.sheet.DDELinks") { } @@ -99,8 +97,7 @@ uno::Reference<uno::XInterface> ScDDELinksObj::init() uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), uno::UNO_QUERY_THROW); - const OUString testdoc - = m_directories.getURLFromSrc(u"/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods"); + const OUString testdoc = createFileURL(u"ScDDELinksObj.ods"); xSheet->getCellByPosition(5, 5)->setFormula("=DDE(\"soffice\";\"" + testdoc + "\";\"Sheet1.A1\")"); diff --git a/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods b/sc/qa/extras/testdocuments/ScDDELinksObj.ods Binary files differindex 01c11e339a68..01c11e339a68 100644 --- a/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods +++ b/sc/qa/extras/testdocuments/ScDDELinksObj.ods |