diff options
-rw-r--r-- | desktop/inc/lib/init.hxx | 9 | ||||
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 28 |
2 files changed, 36 insertions, 1 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index fdcb54fd264b..c9e0ff53b9f5 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 b9d59692d084..1199fe7066c6 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -701,10 +701,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 flushTimers(); - 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])); @@ -732,6 +740,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); |