Blame SOURCES/0274-CppunitTest_desktop_lib-test-absolute-positions-for-.patch

135360
From 8cef5dbaf83e049e929d6319acb785bdaac447a5 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Wed, 4 Nov 2015 10:59:08 +0100
135360
Subject: [PATCH 274/398] CppunitTest_desktop_lib: test absolute positions for
135360
 row/column headers
135360
135360
Change-Id: If2526647221fef2c6b18b21b589192239d8a89ad
135360
(cherry picked from commit 2bed1867531fc91d1bd20da226d3fa012356125d)
135360
---
135360
 desktop/qa/desktop_lib/test_desktop_lib.cxx | 54 ++++++++++++++++++++++++++---
135360
 1 file changed, 49 insertions(+), 5 deletions(-)
135360
135360
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
index 4c23ecb50b73..8c622a577231 100644
135360
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
@@ -363,6 +363,35 @@ void DesktopLOKTest::testPasteWriter()
135360
 
135360
 void DesktopLOKTest::testRowColumnHeaders()
135360
 {
135360
+    /*
135360
+     * Payload example:
135360
+     *
135360
+     * {
135360
+     *     "rows": [
135360
+     *         {
135360
+     *             "size": "254.987250637468",
135360
+     *             "text": "1"
135360
+     *         },
135360
+     *         {
135360
+     *             "size": "509.974501274936",
135360
+     *             "text": "2"
135360
+     *         }
135360
+     *     ],
135360
+     *     "columns": [
135360
+     *         {
135360
+     *             "size": "1274.93625318734",
135360
+     *             "text": "A"
135360
+     *         },
135360
+     *         {
135360
+     *             "size": "2549.87250637468",
135360
+     *             "text": "B"
135360
+     *         }
135360
+     *     ]
135360
+     * }
135360
+     *
135360
+     * "size" defines the bottom/right boundary of a row/column in twips (size between 0 and boundary)
135360
+     * "text" has the header label in UTF-8
135360
+     */
135360
     LibLODocument_Impl* pDocument = loadDoc("search.ods");
135360
     boost::property_tree::ptree aTree;
135360
     char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
135360
@@ -371,23 +400,38 @@ void DesktopLOKTest::testRowColumnHeaders()
135360
     CPPUNIT_ASSERT(!aStream.str().empty());
135360
 
135360
     boost::property_tree::read_json(aStream, aTree);
135360
+    sal_Int32 nPrevious = 0;
135360
     for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
135360
     {
135360
         sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
135360
         CPPUNIT_ASSERT(nSize > 0);
135360
         OString aText(rValue.second.get<std::string>("text").c_str());
135360
-        // This failed, as the first item did not contain the text of the first row.
135360
-        CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
135360
-        break;
135360
+        if (!nPrevious)
135360
+            // This failed, as the first item did not contain the text of the first row.
135360
+            CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
135360
+        else
135360
+        {
135360
+            // Make sure that size is absolute: the first two items have the same relative size.
135360
+            CPPUNIT_ASSERT(nPrevious < nSize);
135360
+            break;
135360
+        }
135360
+        nPrevious = nSize;
135360
     }
135360
 
135360
+    nPrevious = 0;
135360
     for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
135360
     {
135360
         sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
135360
         CPPUNIT_ASSERT(nSize > 0);
135360
         OString aText(rValue.second.get<std::string>("text").c_str());
135360
-        CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
135360
-        break;
135360
+        if (!nPrevious)
135360
+            CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
135360
+        else
135360
+        {
135360
+            CPPUNIT_ASSERT(nPrevious < nSize);
135360
+            break;
135360
+        }
135360
+        nPrevious = nSize;
135360
     }
135360
 }
135360
 
135360
-- 
135360
2.12.0
135360