diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-04 17:31:55 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-08 11:54:22 +0100 |
commit | 248be1fe7d31499fe7e237bb15ec67b55962c1a7 (patch) | |
tree | d2a3693af5d555f5c6cca31b625a9001af21e869 /test | |
parent | 444bf8710d5da7b584fbcb94693e4ed8d2e29297 (diff) |
UnoApiTest: simplify code by using tempfile member
SwModelTestBase does the same. this will help to make
SwModelTestBase inherit from UnoApiTest
Change-Id: If1c824cf92f0e8b70253e4d5fdeddcaa521d4632
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142287
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/unoapi_test.cxx | 45 | ||||
-rw-r--r-- | test/source/unoapixml_test.cxx | 4 |
2 files changed, 21 insertions, 28 deletions
diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index 93b55eef440c..a0c41da78ec5 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -26,6 +26,7 @@ UnoApiTest::UnoApiTest(OUString path) : mbSkipValidation(false) , m_aBaseString(std::move(path)) { + maTempFile.EnableKillingFile(); } void UnoApiTest::setUp() @@ -81,63 +82,55 @@ uno::Any UnoApiTest::executeMacro(const OUString& rScriptURL, return aRet; } -utl::TempFileNamed UnoApiTest::save(const OUString& rFilter) +void UnoApiTest::save(const OUString& rFilter) { - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); utl::MediaDescriptor aMediaDescriptor; aMediaDescriptor["FilterName"] <<= rFilter; if (!maFilterOptions.isEmpty()) aMediaDescriptor["FilterOptions"] <<= maFilterOptions; css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW); - xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); if (!mbSkipValidation) { if (rFilter == "Office Open XML Text") - validate(aTempFile.GetFileName(), test::OOXML); + validate(maTempFile.GetFileName(), test::OOXML); else if (rFilter == "Calc Office Open XML") - validate(aTempFile.GetFileName(), test::OOXML); + validate(maTempFile.GetFileName(), test::OOXML); else if (rFilter == "Impress Office Open XML") - validate(aTempFile.GetFileName(), test::OOXML); + validate(maTempFile.GetFileName(), test::OOXML); else if (rFilter == "writer8") - validate(aTempFile.GetFileName(), test::ODF); + validate(maTempFile.GetFileName(), test::ODF); else if (rFilter == "calc8") - validate(aTempFile.GetFileName(), test::ODF); + validate(maTempFile.GetFileName(), test::ODF); else if (rFilter == "impress8") - validate(aTempFile.GetFileName(), test::ODF); + validate(maTempFile.GetFileName(), test::ODF); else if (rFilter == "draw8") - validate(aTempFile.GetFileName(), test::ODF); + validate(maTempFile.GetFileName(), test::ODF); else if (rFilter == "OpenDocument Text Flat XML") - validate(aTempFile.GetFileName(), test::ODF); + validate(maTempFile.GetFileName(), test::ODF); else if (rFilter == "MS Word 97") - validate(aTempFile.GetFileName(), test::MSBINARY); + validate(maTempFile.GetFileName(), test::MSBINARY); else if (rFilter == "MS Excel 97") - validate(aTempFile.GetFileName(), test::MSBINARY); + validate(maTempFile.GetFileName(), test::MSBINARY); else if (rFilter == "MS PowerPoint 97") - validate(aTempFile.GetFileName(), test::MSBINARY); + validate(maTempFile.GetFileName(), test::MSBINARY); } - - return aTempFile; } -utl::TempFileNamed UnoApiTest::saveAndClose(const OUString& rFilter) +void UnoApiTest::saveAndClose(const OUString& rFilter) { - utl::TempFileNamed aTempFile = save(rFilter); + save(rFilter); mxComponent->dispose(); mxComponent.clear(); - - return aTempFile; } -utl::TempFileNamed UnoApiTest::saveAndReload(const OUString& rFilter) +void UnoApiTest::saveAndReload(const OUString& rFilter) { - utl::TempFileNamed aTempFile = saveAndClose(rFilter); - - mxComponent = loadFromDesktop(aTempFile.GetURL()); + saveAndClose(rFilter); - return aTempFile; + mxComponent = loadFromDesktop(maTempFile.GetURL()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/source/unoapixml_test.cxx b/test/source/unoapixml_test.cxx index b2b3848ab937..23dc826cbc97 100644 --- a/test/source/unoapixml_test.cxx +++ b/test/source/unoapixml_test.cxx @@ -26,9 +26,9 @@ UnoApiXmlTest::UnoApiXmlTest(OUString path) { } -xmlDocUniquePtr UnoApiXmlTest::parseExport(OUString const& url, OUString const& rStreamName) +xmlDocUniquePtr UnoApiXmlTest::parseExport(OUString const& rStreamName) { - std::unique_ptr<SvStream> const pStream(parseExportStream(url, rStreamName)); + std::unique_ptr<SvStream> const pStream(parseExportStream(maTempFile.GetURL(), rStreamName)); xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); return pXmlDoc; } |