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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 23 05:36:31 UTC 2017


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   45 ++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

New commits:
commit f6c0e851eff8c22c0ab427245c5eb78e9f396b62
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Jan 20 19:11:47 2017 -0500

    Lok: unittest batch API
    
    Change-Id: I33bc59756f46b51a69efd91b89813ba17eca6218
    Reviewed-on: https://gerrit.libreoffice.org/33403
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-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 59bf620..666deb4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -95,6 +95,7 @@ public:
     void testContextMenuImpress();
     void testNotificationCompression();
     void testTileInvalidationCompression();
+    void testBatching();
     void testPartInInvalidation();
     void testRedlineWriter();
     void testTrackChanges();
@@ -129,6 +130,7 @@ public:
     CPPUNIT_TEST(testContextMenuImpress);
     CPPUNIT_TEST(testNotificationCompression);
     CPPUNIT_TEST(testTileInvalidationCompression);
+    CPPUNIT_TEST(testBatching);
     CPPUNIT_TEST(testPartInInvalidation);
     CPPUNIT_TEST(testRedlineWriter);
     CPPUNIT_TEST(testTrackChanges);
@@ -1580,6 +1582,49 @@ void DesktopLOKTest::testPartInInvalidation()
     }
 }
 
+void DesktopLOKTest::testBatching()
+{
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+
+    comphelper::LibreOfficeKit::setPartInInvalidation(true);
+    comphelper::ScopeGuard aGuard([]()
+    {
+        comphelper::LibreOfficeKit::setPartInInvalidation(false);
+    });
+
+    std::vector<std::tuple<int, std::string>> notifs;
+    std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
+
+    // Enable Batch mode.
+    handler->setEventLatch(true);
+
+    handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 239, 0");
+    handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "EMPTY, 0");
+
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), notifs.size());
+
+    handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, 239, 240, 0");
+    handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "-121, -121, 300, 300, 0");
+    handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "0, 0, -32767, -32767, 0");
+
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), notifs.size());
+
+    // Disable Batch mode.
+    handler->setEventLatch(false);
+
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
+
+    size_t i = 0;
+    CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[i]));
+    CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1000000000, 1000000000, 0"), std::get<1>(notifs[i++]));
+}
+
 void DesktopLOKTest::testRedlineWriter()
 {
     // Load a Writer document, enable change recording and press a key.


More information about the Libreoffice-commits mailing list