filter/CppunitTest_filter_pdf.mk |    1 
 filter/qa/pdf.cxx                |   41 ++++++++++++++++-----------------------
 2 files changed, 18 insertions(+), 24 deletions(-)

New commits:
commit 7f6fd2bc9157c1f72ff04507986aee75ff6a1969
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Nov 9 14:10:59 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Nov 9 15:24:00 2022 +0100

    CppunitTest_filter_pdf: inherit from UnoApiTest
    
    Change-Id: I9c1565a68393ed775c42e2e972f9c54475e6bd62
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142487
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/filter/CppunitTest_filter_pdf.mk b/filter/CppunitTest_filter_pdf.mk
index b85bbf45437c..e551ae6b9d07 100644
--- a/filter/CppunitTest_filter_pdf.mk
+++ b/filter/CppunitTest_filter_pdf.mk
@@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,filter_pdf, \
     cppu \
     cppuhelper \
     sal \
+    subsequenttest \
     test \
     tl \
     unotest \
diff --git a/filter/qa/pdf.cxx b/filter/qa/pdf.cxx
index 29129f2b08f2..601f62a16bdb 100644
--- a/filter/qa/pdf.cxx
+++ b/filter/qa/pdf.cxx
@@ -7,8 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
+#include <test/unoapi_test.hxx>
 
 #include <com/sun/star/document/XExporter.hpp>
 #include <com/sun/star/document/XFilter.hpp>
@@ -28,35 +27,32 @@ using namespace ::com::sun::star;
 namespace
 {
 /// Covers filter/source/pdf/ fixes.
-class Test : public test::BootstrapFixture, public unotest::MacrosTest
+class Test : public UnoApiTest
 {
-private:
-    uno::Reference<lang::XComponent> mxComponent;
-
 public:
+    Test()
+        : UnoApiTest("/filter/qa/data/")
+    {
+    }
+
     void setUp() override;
     void tearDown() override;
-    uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
 };
 
 void Test::setUp()
 {
-    test::BootstrapFixture::setUp();
-    MacrosTest::setUpNssGpg(m_directories, "filter_pdf");
+    UnoApiTest::setUp();
 
-    mxDesktop.set(frame::Desktop::create(mxComponentContext));
+    MacrosTest::setUpNssGpg(m_directories, "filter_pdf");
 }
 
 void Test::tearDown()
 {
-    if (mxComponent.is())
-        mxComponent->dispose();
+    MacrosTest::tearDownNssGpg();
 
-    test::BootstrapFixture::tearDown();
+    UnoApiTest::tearDown();
 }
 
-constexpr OUStringLiteral DATA_DIRECTORY = u"/filter/qa/data/";
-
 CPPUNIT_TEST_FIXTURE(Test, testSignCertificateSubjectName)
 {
     std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
@@ -83,15 +79,14 @@ CPPUNIT_TEST_FIXTURE(Test, testSignCertificateSubjectName)
     }
 
     // Given an empty document:
-    getComponent().set(
-        loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument"));
+    mxComponent.set(loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument"));
 
     // When exporting to PDF, and referring to a certificate using a subject 
name:
     uno::Reference<css::lang::XMultiServiceFactory> xFactory = 
getMultiServiceFactory();
     uno::Reference<document::XFilter> xFilter(
         xFactory->createInstance("com.sun.star.document.PDFFilter"), 
uno::UNO_QUERY);
     uno::Reference<document::XExporter> xExporter(xFilter, uno::UNO_QUERY);
-    xExporter->setSourceDocument(getComponent());
+    xExporter->setSourceDocument(mxComponent);
     SvMemoryStream aStream;
     uno::Reference<io::XOutputStream> xOutputStream(new 
utl::OStreamWrapper(aStream));
 
@@ -118,18 +113,16 @@ CPPUNIT_TEST_FIXTURE(Test, testPdfDecompositionSize)
         return;
 
     // Given an empty Writer document:
-    getComponent().set(
-        loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument"));
+    mxComponent.set(loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument"));
 
     // When inserting a 267 points wide PDF image into the document:
     uno::Sequence<beans::PropertyValue> aArgs = {
-        comphelper::makePropertyValue("FileName",
-                                      
m_directories.getURLFromSrc(DATA_DIRECTORY) + "picture.pdf"),
+        comphelper::makePropertyValue("FileName", 
createFileURL(u"picture.pdf")),
     };
-    dispatchCommand(getComponent(), ".uno:InsertGraphic", aArgs);
+    dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs);
 
     // Then make sure that its size is correct:
-    uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> xDrawPage = 
xDrawPageSupplier->getDrawPage();
     uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
     auto xGraphic = 
xShape->getPropertyValue("Graphic").get<uno::Reference<graphic::XGraphic>>();

Reply via email to