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

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