[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/qa
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sat Apr 23 13:27:05 UTC 2016
desktop/qa/desktop_lib/test_desktop_lib.cxx | 54 ++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
New commits:
commit bb52a54aa49cbb75820f8ddbfc8e9e94b63281cd
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Apr 23 09:21:00 2016 -0400
Test desktop notification compression
Change-Id: Ibb9a62bb5e1500a068c24346d6d433012a1bc7dd
Reviewed-on: https://gerrit.libreoffice.org/24314
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 89b1ebb..1ad168f 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();
More information about the Libreoffice-commits
mailing list