summaryrefslogtreecommitdiff
path: root/desktop/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-29 12:49:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-29 13:01:40 +0200
commitdadbb11c16197ad80b96e11af5ddcb3c5e888f66 (patch)
treedce58535fc4658730ca72f977569c934b2533da4 /desktop/qa
parenteba87071c5004744603e5b423e956e56be61604c (diff)
LOK: conditionally include part number in invalidation payload
Since desktop/ code queues, compresses and only emits callbacks on idle, it's possible that two invalidations are in the queue, and there was a setPart() call between them. In this case it's impossible to tell what part the invalidation was sent for. Fix this by conditionally including the part number in the invalidation payload. It's off by default, a new feature flag is added to request this behavior. gtktiledviewer enables this feature flag by default, though just to show the part number in the debug output. Android doesn't enable it. (cherry picked from commit d5263c2c564c88e3dafe4c1ab8d3d9c1c48ede73) Conflicts: desktop/qa/desktop_lib/test_desktop_lib.cxx Change-Id: I73e6def848c0eb61d64e71026002c7a0e750aab4
Diffstat (limited to 'desktop/qa')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 18dbd122b463..bbf17d72c677 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -34,6 +34,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/scopeguard.hxx>
#include <lib/init.hxx>
@@ -97,6 +98,7 @@ public:
void testContextMenuWriter();
void testContextMenuImpress();
void testNotificationCompression();
+ void testPartInInvalidation();
void testRedlineWriter();
void testTrackChanges();
void testRedlineCalc();
@@ -129,6 +131,7 @@ public:
CPPUNIT_TEST(testContextMenuWriter);
CPPUNIT_TEST(testContextMenuImpress);
CPPUNIT_TEST(testNotificationCompression);
+ CPPUNIT_TEST(testPartInInvalidation);
CPPUNIT_TEST(testRedlineWriter);
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testRedlineCalc);
@@ -1196,6 +1199,77 @@ void DesktopLOKTest::testNotificationCompression()
CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++]));
}
+void DesktopLOKTest::testPartInInvalidation()
+{
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+ // No part in invalidation: merge.
+ {
+ std::vector<std::tuple<int, std::string>> notifs;
+ std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
+
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10");
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
+
+ CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[0]));
+ CPPUNIT_ASSERT_EQUAL(std::string("10, 10, 30, 10"), std::get<1>(notifs[0]));
+ }
+ // No part in invalidation: don't merge.
+ {
+ std::vector<std::tuple<int, std::string>> notifs;
+ std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
+
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10");
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "40, 10, 20, 10");
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size());
+ }
+
+ // Part in invalidation, intersection and parts match -> merge.
+ {
+ 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));
+
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 0");
+
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), notifs.size());
+ }
+ // Part in invalidation, intersection and parts don't match -> don't merge.
+ {
+ 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));
+
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "10, 10, 20, 10, 0");
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "20, 10, 20, 10, 1");
+
+ Scheduler::ProcessEventsToIdle();
+
+ // This failed as RectangleAndPart::Create() always assumed no part in
+ // payload, so this was merged -> it was 1.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size());
+ }
+}
+
void DesktopLOKTest::testRedlineWriter()
{
// Load a Writer document, enable change recording and press a key.