From 0692cd8d199c31f761a4c7b0c16a94d3e195b2dc Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 24 Oct 2022 21:05:09 +0200 Subject: [PATCH] CppunitTest_sd_svg_export_tests: inherit from UnoApiTest Change-Id: Ib630949127d7087cddbb92737528690cafe9be26 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141782 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sd/CppunitTest_sd_svg_export_tests.mk | 1 + sd/qa/unit/SVGExportTests.cxx | 93 +++++++-------------------- test/source/unoapi_test.cxx | 2 +- 3 files changed, 27 insertions(+), 69 deletions(-) diff --git a/sd/CppunitTest_sd_svg_export_tests.mk b/sd/CppunitTest_sd_svg_export_tests.mk index 728ab4000f33..3614e4b8f2ae 100644 --- a/sd/CppunitTest_sd_svg_export_tests.mk +++ b/sd/CppunitTest_sd_svg_export_tests.mk @@ -40,6 +40,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_svg_export_tests, \ sd \ sfx \ sot \ + subsequenttest \ svl \ svt \ svx \ diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx index 270c98dd53d8..64e3147710d0 100644 --- a/sd/qa/unit/SVGExportTests.cxx +++ b/sd/qa/unit/SVGExportTests.cxx @@ -10,12 +10,10 @@ #include #include - -#include +#include #include #include -#include #include #include #include @@ -70,7 +68,7 @@ bool isValidTiledBackgroundId(const OUString& sId) } -class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SdSVGFilterTest : public UnoApiTest, public XmlTestTools { class Resetter { @@ -95,68 +93,21 @@ class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTes } }; - uno::Reference mxComponent; - utl::TempFileNamed maTempFile; - -protected: - void load(std::u16string_view pDir, const char* pName) - { - return loadURL(m_directories.getURLFromSrc(pDir) + OUString::createFromAscii(pName), pName); - } - - void loadURL(OUString const& rURL, const char* pName) - { - if (mxComponent.is()) - mxComponent->dispose(); - // Output name early, so in the case of a hang, the name of the hanging input file is visible. - if (pName) - std::cout << pName << ","; - mxComponent = loadFromDesktop(rURL); - } - - void save() - { - uno::Reference xStorable(mxComponent, uno::UNO_QUERY); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); - xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - } - public: SdSVGFilterTest() + : UnoApiTest("/sd/qa/unit/data/odp/") { - maTempFile.EnableKillingFile(); - } - - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - - mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); - } - - virtual void tearDown() override - { - if (mxComponent.is()) - mxComponent->dispose(); - - test::BootstrapFixture::tearDown(); - } - - void executeExport(const char* pName) - { - load( u"/sd/qa/unit/data/odp/", pName ); - save(); } void testSVGExportTextDecorations() { - executeExport( "svg-export-text-decorations.odp" ); + loadFromURL(u"svg-export-text-decorations.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); - svgDoc->name = reinterpret_cast(xmlStrdup(reinterpret_cast(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr()))); + svgDoc->name = reinterpret_cast(xmlStrdup(reinterpret_cast(OUStringToOString(aTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr()))); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG ), 1); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_G[2] ), "class", "SlideGroup"); @@ -173,9 +124,10 @@ public: void testSVGExportJavascriptURL() { - executeExport("textbox-link-javascript.odp"); + loadFromURL(u"textbox-link-javascript.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); // There should be only one child (no link to javascript url) @@ -187,9 +139,10 @@ public: void testSVGExportSlideCustomBackground() { - executeExport("slide-custom-background.odp"); + loadFromURL(u"slide-custom-background.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G/SVG_DEFS ), "class", "SlideBackground"); @@ -197,9 +150,10 @@ public: void testSVGExportTextFieldsInMasterPage() { - executeExport("text-fields.odp"); + loadFromURL(u"text-fields.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_DEFS[9]/SVG_G[2] ), "class", "Master_Slide"); @@ -224,9 +178,10 @@ public: void testSVGExportSlideBitmapBackground() { - executeExport("slide-bitmap-background.odp"); + loadFromURL(u"slide-bitmap-background.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_DEFS[9] ), "class", "BackgroundBitmaps"); @@ -252,9 +207,10 @@ public: void testSVGExportSlideTileBitmapBackground() { - executeExport("slide-tile-background.odp"); + loadFromURL(u"slide-tile-background.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); // check the bitmap @@ -316,9 +272,10 @@ public: aSettings.SetLanguageTag(aLangISO, true); Application::SetSettings(aSettings); - executeExport("text-fields.odp"); + loadFromURL(u"text-fields.odp"); + utl::TempFileNamed aTempFile = save("impress_svg_Export"); - xmlDocUniquePtr svgDoc = parseXml(maTempFile); + xmlDocUniquePtr svgDoc = parseXml(aTempFile); CPPUNIT_ASSERT(svgDoc); assertXPath(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_DEFS[9]/SVG_G[2] ), "class", "Master_Slide"); diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index 4d06c47a9697..0cc8bf0e33cc 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -79,7 +79,7 @@ utl::TempFileNamed UnoApiTest::save(const OUString& rFilter) aTempFile.EnableKillingFile(); uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) }; css::uno::Reference xStorable(mxComponent, css::uno::UNO_QUERY_THROW); - xStorable->storeAsURL(aTempFile.GetURL(), aArgs); + xStorable->storeToURL(aTempFile.GetURL(), aArgs); mxComponent->dispose(); mxComponent.clear();