[Libreoffice-commits] core.git: desktop/inc desktop/qa

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon May 9 02:41:04 UTC 2016


 desktop/inc/lib/init.hxx                    |    9 +++++++++
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   28 +++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 3d27afd26f7b85c46a7c7d08498000b9dbcea1c8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Apr 23 14:06:22 2016 -0400

    Desktop compresses text selection start/end notifications
    
    Change-Id: Ia85ded04d0eaf9d9b846fab6d86a44a758fccb69
    Reviewed-on: https://gerrit.libreoffice.org/24320
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 45037438d84485356a5ceb820ecc3e0bae4b112e)
    Reviewed-on: https://gerrit.libreoffice.org/24380
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index df065d7..7cf81e3 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -39,6 +39,8 @@ namespace desktop {
 
             // Add the states that are safe to skip duplicates on,
             // even when not consequent.
+            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_START, "NIL");
+            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_END, "NIL");
             m_states.emplace(LOK_CALLBACK_TEXT_SELECTION, "NIL");
             m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "NIL");
             m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL");
@@ -94,6 +96,13 @@ namespace desktop {
                 return;
             }
 
+            if (type == LOK_CALLBACK_TEXT_SELECTION && payload.empty())
+            {
+                // Removing text selection invalidates the start and end as well.
+                m_states[LOK_CALLBACK_TEXT_SELECTION_START] = "";
+                m_states[LOK_CALLBACK_TEXT_SELECTION_END] = "";
+            }
+
             m_queue.emplace_back(type, payload);
 
             lock.unlock();
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index f6e3d91..86ca392 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1289,10 +1289,18 @@ void DesktopLOKTest::testNotificationCompression()
     handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 8
     handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Should be dropped.
     handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // Should be dropped.
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 9
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 10
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // 11
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // Should be dropped.
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // Should be dropped.
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 12
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 13
+    handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 14
 
     Scheduler::ProcessEventsToIdle();
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(9), notifs.size());
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(15), notifs.size());
 
     CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[0]));
     CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[0]));
@@ -1320,6 +1328,24 @@ void DesktopLOKTest::testNotificationCompression()
 
     CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[8]));
     CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[8]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[9]));
+    CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[9]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[10]));
+    CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[10]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[11]));
+    CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[11]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[12]));
+    CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[12]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[13]));
+    CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[13]));
+
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[14]));
+    CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[14]));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);


More information about the Libreoffice-commits mailing list