diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-04-23 09:21:00 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2016-04-23 13:26:41 +0000 |
commit | bb52a54aa49cbb75820f8ddbfc8e9e94b63281cd (patch) | |
tree | 95dc7331c1869697ae8bfc8edb9239be3f789719 | |
parent | 548faf728cf097d93c3f6478ceea5f8747e789c6 (diff) |
Test desktop notification compression
Change-Id: Ibb9a62bb5e1500a068c24346d6d433012a1bc7dd
Reviewed-on: https://gerrit.libreoffice.org/24314
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 89b1ebbe20d7..1ad168f99f86 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -99,6 +99,7 @@ public: void testCommandResult(); void testWriterComments(); void testSheetOperations(); + void testNotificationCompression(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -118,6 +119,7 @@ public: CPPUNIT_TEST(testCommandResult); CPPUNIT_TEST(testWriterComments); CPPUNIT_TEST(testSheetOperations); + CPPUNIT_TEST(testNotificationCompression); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; @@ -675,6 +677,58 @@ void DesktopLOKTest::testSheetOperations() comphelper::LibreOfficeKit::setActive(false); } +static void callbackCompressionTest(const int type, const char* payload, void* data) +{ + std::vector<std::tuple<int, std::string>>* notifs = reinterpret_cast<std::vector<std::tuple<int, std::string>>*>(data); + notifs->emplace_back(type, std::string(payload ? payload : "(nil)")); +} + +void DesktopLOKTest::testNotificationCompression() +{ + std::vector<std::tuple<int, std::string>> notifs; + std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(callbackCompressionTest, ¬ifs)); + + handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // 1 + handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // Should be dropped. + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 2 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Should be dropped. + handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 3 + handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 4 + handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:Bold"); // 5 + handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 6 + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 7 + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Should be dropped. + + flushTimers(); + + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(8), 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])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[1])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[1])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[2])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[2])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[3])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[3])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[4])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[4])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[5])); + CPPUNIT_ASSERT_EQUAL(std::string(".uno:Bold"), std::get<1>(notifs[5])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[6])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[6])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[7])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[7])); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); |