summaryrefslogtreecommitdiff
path: root/libreofficekit/qa
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-01-25 22:55:20 +0000
committerMichael Meeks <michael.meeks@collabora.com>2019-02-13 14:14:17 +0100
commitf637b79e3517235883a65bd33a303642fb17fdee (patch)
treef4eb44b709b021045f033d43dbac094f5ae567ce /libreofficekit/qa
parentbf1a511f9c7b3ca8131601ab3b267b8e24891f9a (diff)
lok: keystroke attribution issue.
Change-Id: I7e5ed3c72fef12d31b5500acffff622b5f4129de Reviewed-on: https://gerrit.libreoffice.org/66931 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r--libreofficekit/qa/unit/tiledrendering.cxx56
1 files changed, 56 insertions, 0 deletions
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 69f7c5dbe6f8..7d605e7a5839 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -8,6 +8,7 @@
*/
#include <memory>
+#include <thread>
#include <boost/property_tree/json_parser.hpp>
#include <cppunit/TestFixture.h>
#include <cppunit/plugin/TestPlugIn.h>
@@ -108,6 +109,7 @@ public:
void testCalcSheetNames( Office* pOffice );
void testPaintPartTile( Office* pOffice );
void testDocumentLoadLanguage(Office* pOffice);
+ void testMultiKeyInput(Office *pOffice);
#if 0
void testOverlay( Office* pOffice );
#endif
@@ -132,6 +134,7 @@ void TiledRenderingTest::runAllTests()
testDocumentLoadFail( pOffice.get() );
testDocumentTypes( pOffice.get() );
+ testMultiKeyInput(pOffice.get());
testImpressSlideNames( pOffice.get() );
testCalcSheetNames( pOffice.get() );
testPaintPartTile( pOffice.get() );
@@ -394,6 +397,59 @@ void TiledRenderingTest::testOverlay( Office* /*pOffice*/ )
}
#endif
+void TiledRenderingTest::testMultiKeyInput(Office *pOffice)
+{
+ std::unique_ptr<Document> pDocument(loadDocument(pOffice, "blank_text.odt"));
+
+ CPPUNIT_ASSERT(pDocument.get());
+ CPPUNIT_ASSERT_EQUAL(LOK_DOCTYPE_TEXT, static_cast<LibreOfficeKitDocumentType>(pDocument->getDocumentType()));
+
+ // Create two views.
+ int nViewA = pDocument->getView();
+ pDocument->initializeForRendering("{\".uno:Author\":{\"type\":\"string\",\"value\":\"jill\"}}");
+
+ pDocument->createView();
+ int nViewB = pDocument->getView();
+ pDocument->initializeForRendering("{\".uno:Author\":{\"type\":\"string\",\"value\":\"jack\"}}");
+
+ // Enable change tracking
+ pDocument->postUnoCommand(".uno:TrackChanges");
+
+ // First a key-stroke from a
+ pDocument->setView(nViewA);
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 97, 0); // a
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 512); // 'a
+
+ // A space on 'a' - force commit
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 32, 0); // ' '
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1284); // '' '
+
+ // Another 'a'
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 97, 0); // a
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 512); // 'a
+
+ // FIXME: Wait for writer input handler to commit that.
+ // without this we fall foul of edtwin's KeyInputFlushTimer
+ std::this_thread::sleep_for(std::chrono::milliseconds(300));
+
+ // Quickly a new key-stroke from b
+ pDocument->setView(nViewB);
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 98, 0); // b
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 514); // 'b
+
+ // A space on 'b' - force commit
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 32, 0); // ' '
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1284); // '' '
+
+ // Wait for writer input handler to commit that.
+ std::this_thread::sleep_for(std::chrono::milliseconds(300));
+
+ // get track changes ?
+ char *values = pDocument->getCommandValues(".uno:AcceptTrackedChanges");
+ std::cerr << "Values: '" << values << "'\n";
+ CPPUNIT_ASSERT(0);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(TiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();