[Libreoffice-commits] core.git: vcl/qa

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Sep 6 12:05:21 UTC 2020


 vcl/qa/cppunit/PDFiumLibraryTest.cxx                         |   42 +++++++++++
 vcl/qa/cppunit/data/PangramWithMultipleTypeOfAnnotations.pdf |binary
 2 files changed, 42 insertions(+)

New commits:
commit e12ac66a15b61d25105dce8fac82ed80d918a511
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Sep 3 20:15:36 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Sep 6 14:04:36 2020 +0200

    vcl: add testcase for reading different type of annotations
    
    add "FreeText" and "Line" annotations
    
    Change-Id: I00e4ac3e446dbec4fcd29a103d6cf8014137179d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102094
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 7e60ab92ec2a..dd18d9809b8d 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -38,6 +38,7 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
     void testPageObjects();
     void testAnnotationsMadeInEvince();
     void testAnnotationsMadeInAcrobat();
+    void testAnnotationsDifferentTypes();
     void testTools();
 
     CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
@@ -46,6 +47,7 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
     CPPUNIT_TEST(testPageObjects);
     CPPUNIT_TEST(testAnnotationsMadeInEvince);
     CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
+    CPPUNIT_TEST(testAnnotationsDifferentTypes);
     CPPUNIT_TEST(testTools);
     CPPUNIT_TEST_SUITE_END();
 };
@@ -289,6 +291,46 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
     }
 }
 
+void PDFiumLibraryTest::testAnnotationsDifferentTypes()
+{
+    OUString aURL = getFullUrl("PangramWithMultipleTypeOfAnnotations.pdf");
+    SvFileStream aStream(aURL, StreamMode::READ);
+    GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+    Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+    aGraphic.makeAvailable();
+
+    auto pVectorGraphicData = aGraphic.getVectorGraphicData();
+    CPPUNIT_ASSERT(pVectorGraphicData);
+    CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+                         pVectorGraphicData->getVectorGraphicDataType());
+
+    const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
+    int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    auto pDocument = pPdfium->openDocument(pData, nLength);
+    CPPUNIT_ASSERT(pDocument);
+
+    CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
+
+    auto pPage = pDocument->openPage(0);
+    CPPUNIT_ASSERT(pPage);
+
+    CPPUNIT_ASSERT_EQUAL(2, pPage->getAnnotationCount());
+
+    {
+        auto pAnnotation = pPage->getAnnotation(0);
+        CPPUNIT_ASSERT(pAnnotation);
+        CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::FreeText, pAnnotation->getSubType());
+    }
+
+    {
+        auto pAnnotation = pPage->getAnnotation(1);
+        CPPUNIT_ASSERT(pAnnotation);
+        CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Line, pAnnotation->getSubType());
+    }
+}
+
 void PDFiumLibraryTest::testTools()
 {
     OUString sConverted = vcl::pdf::convertPdfDateToISO8601("D:20200612201322+02'00");
diff --git a/vcl/qa/cppunit/data/PangramWithMultipleTypeOfAnnotations.pdf b/vcl/qa/cppunit/data/PangramWithMultipleTypeOfAnnotations.pdf
new file mode 100644
index 000000000000..281cf264a6ee
Binary files /dev/null and b/vcl/qa/cppunit/data/PangramWithMultipleTypeOfAnnotations.pdf differ


More information about the Libreoffice-commits mailing list