sw/qa/extras/uiwriter/data/hello-world.pdf |binary sw/qa/extras/uiwriter/uiwriter.cxx | 38 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
New commits: commit 2218612b66483f98596492f17ac5195bdd87c69d Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Thu Mar 12 19:01:36 2020 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Jun 6 19:25:12 2020 +0200 pdfium: Test insertion of PDF into a document. Change-Id: Ide2643349fbf5cdf79e68c2c504d1cd486c09d7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90996 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <ke...@collabora.com> (cherry picked from commit efff12770fb16df8f8b405a08d28339e2a82a4b1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95630 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/qa/extras/uiwriter/data/hello-world.pdf b/sw/qa/extras/uiwriter/data/hello-world.pdf new file mode 100644 index 000000000000..ae2fa81b9841 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/hello-world.pdf differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 2f22be303d35..cad062c0c01c 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -367,6 +367,9 @@ public: void testTdf38394(); void testTdf59666(); void testInconsistentBookmark(); +#if HAVE_FEATURE_PDFIUM + void testInsertPdf(); +#endif CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -575,6 +578,9 @@ public: CPPUNIT_TEST(testTdf54409); CPPUNIT_TEST(testTdf38394); CPPUNIT_TEST(testTdf59666); +#if HAVE_FEATURE_PDFIUM + CPPUNIT_TEST(testInsertPdf); +#endif CPPUNIT_TEST_SUITE_END(); private: @@ -7100,6 +7106,38 @@ void SwUiWriterTest::testTdf59666() CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); } +#if HAVE_FEATURE_PDFIUM +void SwUiWriterTest::testInsertPdf() +{ + createDoc(); + SwXTextDocument *pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // insert the PDF into the document + uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence({ + {"FileName", uno::Any(m_directories.getURLFromSrc(DATA_DIRECTORY) + "hello-world.pdf")} + })); + lcl_dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs); + + // Save and load cycle + utl::TempFile aTempFile; + save("writer8", aTempFile); + loadURL(aTempFile.GetURL(), nullptr); + pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<drawing::XShape> xShape = getShape(1); + // Assert that we have a replacement graphics + auto xReplacementGraphic = getProperty<uno::Reference<graphic::XGraphic>>(xShape, "ReplacementGraphic"); + CPPUNIT_ASSERT(xReplacementGraphic.is()); + + auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(xShape, "Graphic"); + CPPUNIT_ASSERT(xGraphic.is()); + // Assert that the graphic is a PDF + CPPUNIT_ASSERT_EQUAL(OUString("application/pdf"), getProperty<OUString>(xGraphic, "MimeType")); +} +#endif + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits