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 /vcl/qa | |
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 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/filter/ipdf/ipdf.cxx | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx index cdb09b7e858b..1c143a1b8319 100644 --- a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx +++ b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx @@ -72,16 +72,12 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testPDFAddVisibleSignatureLastPage) if (!IsDefaultDPI()) return; // Given: copy the test document to a temporary file, as it'll be modified. - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - OUString aSourceURL = createFileURL(u"add-visible-signature-last-page.pdf"); - OUString aURL = aTempFile.GetURL(); - osl::File::RC eRet = osl::File::copy(aSourceURL, aURL); - CPPUNIT_ASSERT_EQUAL(osl::File::RC::E_None, eRet); + createTempCopy(u"add-visible-signature-last-page.pdf"); // Open it. uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue("ReadOnly", true) }; - mxComponent = loadFromDesktop(aURL, "com.sun.star.drawing.DrawingDocument", aArgs); + mxComponent + = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.drawing.DrawingDocument", aArgs); SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); CPPUNIT_ASSERT(pBaseModel); SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); @@ -120,15 +116,10 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testPDFAddVisibleSignatureLastPage) pObjectShell->SignDocumentContentUsingCertificate(xCert); // Then: count the # of shapes on the signature widget/annotation. - std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); - if (!pPDFium) + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); + if (!pPdfDocument) return; - SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ); - SvMemoryStream aMemory; - aMemory.WriteStream(aFile); // Last page. - std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument - = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), OString()); std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/1); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 |