sd/qa/unit/data/odp/tdf146876.odp |binary
 sd/qa/unit/layout-tests.cxx       |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

New commits:
commit 71a737c5b81bdf9dce75f8f575da2f98e70f0418
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Sat Jan 29 13:55:05 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Jan 29 19:02:39 2022 +0100

    tdf#146876: sd_layout_tests: Add unittest
    
    Change-Id: I4df3b153750be8d650f2c3b0ea5bd840b4397c27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129134
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/qa/unit/data/odp/tdf146876.odp 
b/sd/qa/unit/data/odp/tdf146876.odp
new file mode 100644
index 000000000000..edb361fbab30
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf146876.odp differ
diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx
index 32a1d40f0191..25c70341ea1c 100644
--- a/sd/qa/unit/layout-tests.cxx
+++ b/sd/qa/unit/layout-tests.cxx
@@ -56,6 +56,41 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf135843)
     xDocShRef->DoClose();
 }
 
+CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf146876)
+{
+    sd::DrawDocShellRef xDocShRef
+        = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf146876.odp"), 
ODP);
+
+    std::shared_ptr<GDIMetaFile> xMetaFile = xDocShRef->GetPreviewMetaFile();
+    MetafileXmlDump dumper;
+
+    xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    // Check the shape is inside the (5000,8500) - (11500,12500) area
+    for (size_t i = 2; i < 4; ++i)
+    {
+        for (size_t j = 1; j < 6; ++j)
+        {
+            const OString xPath = "/metafile/push[1]/push[1]/push[" + 
OString::number(i)
+                                  + "]/polyline/point[" + OString::number(j) + 
"]";
+            const sal_Int32 nX = getXPath(pXmlDoc, xPath.getStr(), 
"x").toInt32();
+            const sal_Int32 nY = getXPath(pXmlDoc, xPath.getStr(), 
"y").toInt32();
+
+            // Without the fix in place, this test would have failed with
+            // - Expected greater or equal than: 5000
+            // - Actual  : 0
+            CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(5000), nX);
+            CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(11500), nX);
+
+            CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(8500), nY);
+            CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(12500), nY);
+        }
+    }
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf136949)
 {
     sd::DrawDocShellRef xDocShRef

Reply via email to