From d10c2d772fbf376772f836933f85c548cb66cac8 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 24 Oct 2022 13:01:24 +0200 Subject: [PATCH] CppunitTest_filter_svg: inherit from UnoApiTest Change-Id: I6edf5254a8ec0caae317526cf9d6bac21aaed6f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141731 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- filter/CppunitTest_filter_svg.mk | 1 + filter/qa/unit/svg.cxx | 71 +++++++++++--------------------- 2 files changed, 24 insertions(+), 48 deletions(-) diff --git a/filter/CppunitTest_filter_svg.mk b/filter/CppunitTest_filter_svg.mk index ec0841929f3f..96147625e4b3 100644 --- a/filter/CppunitTest_filter_svg.mk +++ b/filter/CppunitTest_filter_svg.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,filter_svg, \ cppu \ cppuhelper \ sal \ + subsequenttest \ test \ unotest \ utl \ diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index a3bc29143ab3..fc932d80793e 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -11,8 +11,7 @@ #include -#include -#include +#include #include #include @@ -28,41 +27,17 @@ using namespace ::com::sun::star; -constexpr OUStringLiteral DATA_DIRECTORY = u"/filter/qa/unit/data/"; - /// SVG filter tests. -class SvgFilterTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SvgFilterTest : public UnoApiTest, public XmlTestTools { -private: - uno::Reference mxComponent; - public: - void setUp() override; - void tearDown() override; + SvgFilterTest(); void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; - uno::Reference& getComponent() { return mxComponent; } - void load(std::u16string_view rURL); }; -void SvgFilterTest::setUp() +SvgFilterTest::SvgFilterTest() + : UnoApiTest("/filter/qa/unit/data/") { - test::BootstrapFixture::setUp(); - - mxDesktop.set(frame::Desktop::create(mxComponentContext)); -} - -void SvgFilterTest::tearDown() -{ - if (mxComponent.is()) - mxComponent->dispose(); - - test::BootstrapFixture::tearDown(); -} - -void SvgFilterTest::load(std::u16string_view rFileName) -{ - OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + rFileName; - mxComponent = loadFromDesktop(aURL); } void SvgFilterTest::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) @@ -74,13 +49,13 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) { #if !defined(MACOSX) // Load a document with a jpeg image in it. - load(u"preserve-jpg.odt"); + loadFromURL(u"preserve-jpg.odt"); // Select the image. - dispatchCommand(getComponent(), ".uno:JumpToNextFrame", {}); + dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); // Export the selection to SVG. - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor; @@ -105,10 +80,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentLine) { // Load a document with a semi-transparent line shape. - load(u"semi-transparent-line.odg"); + loadFromURL(u"semi-transparent-line.odg"); // Export it to SVG. - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor; @@ -136,10 +111,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentText) // correct transparency factor applied for the first shape. // Load draw document with transparent text in one box - load(u"TransparentText.odg"); + loadFromURL(u"TransparentText.odg"); // Export to SVG. - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); @@ -170,10 +145,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentText) CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic) { // Load a document containing a 3D shape. - load(u"shape-nographic.odp"); + loadFromURL(u"shape-nographic.odp"); // Export to SVG. - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor; @@ -189,10 +164,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic) CPPUNIT_TEST_FIXTURE(SvgFilterTest, testCustomBullet) { // Given a presentation with a custom bullet: - load(u"custom-bullet.fodp"); + loadFromURL(u"custom-bullet.fodp"); // When exporting that to SVG: - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor; @@ -216,10 +191,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testCustomBullet) CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest) { // Load document containing empty paragraphs with ids. - load(u"attributeRedefinedTest.odp"); + loadFromURL(u"attributeRedefinedTest.odp"); // Export to SVG. - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor; @@ -258,12 +233,12 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest) CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTab) { // Given a shape with "A\tB" text: - getComponent() = loadFromDesktop("private:factory/simpress", - "com.sun.star.presentation.PresentationDocument"); - uno::Reference xFactory(getComponent(), uno::UNO_QUERY); + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + uno::Reference xFactory(mxComponent, uno::UNO_QUERY); uno::Reference xShape( xFactory->createInstance("com.sun.star.drawing.TextShape"), uno::UNO_QUERY); - uno::Reference xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); xDrawPage->add(xShape); @@ -272,7 +247,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTab) xShapeText->setString("A\tB"); // When exporting that document to SVG: - uno::Reference xStorable(getComponent(), uno::UNO_QUERY_THROW); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference xOut = new utl::OOutputStreamWrapper(aStream); utl::MediaDescriptor aMediaDescriptor;