[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/qa

Jan Holesovsky (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 26 11:43:32 UTC 2020


 sw/qa/extras/uiwriter/data/hello-world.pdf |binary
 sw/qa/extras/uiwriter/uiwriter.cxx         |   38 +++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

New commits:
commit f3dcc6692b15e152114b647235b3ddc19135adce
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Mar 12 19:01:36 2020 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Mar 26 12:42:59 2020 +0100

    pdfium: Test insertion of PDF into a document.
    
    Change-Id: Ide2643349fbf5cdf79e68c2c504d1cd486c09d7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90447
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.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 457785382f02..0100cd64f090 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -352,6 +352,9 @@ public:
     void testTdf51223();
     void testTdf108423();
     void testInconsistentBookmark();
+#if HAVE_FEATURE_PDFIUM
+    void testInsertPdf();
+#endif
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -555,6 +558,9 @@ public:
     CPPUNIT_TEST(testTdf51223);
     CPPUNIT_TEST(testInconsistentBookmark);
     CPPUNIT_TEST(testTdf108423);
+#if HAVE_FEATURE_PDFIUM
+    CPPUNIT_TEST(testInsertPdf);
+#endif
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -6595,6 +6601,38 @@ void SwUiWriterTest::testTdf108423()
     CPPUNIT_ASSERT_EQUAL(sText, 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();
 


More information about the Libreoffice-commits mailing list