diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-07-16 15:23:54 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-10-02 17:02:39 +0200 |
commit | 62b337a3d6650b8b3045dd98f59a8c0188f0a6fa (patch) | |
tree | ad2a07dc300387cb034aef373de549e2db20b577 /desktop/qa/desktop_lib | |
parent | 42dd11c0a2c9e71e8163363afbfd14f448c65ef5 (diff) |
Unit test for removeTextContext.
Change-Id: Ib75259f1680fac41a84caeef57718203ec9c4b86
Reviewed-on: https://gerrit.libreoffice.org/79880
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop/qa/desktop_lib')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index e16bc91aecb7..5945a3bd378a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -121,6 +121,7 @@ public: void testNotificationCompression(); void testTileInvalidationCompression(); void testPartInInvalidation(); + void testInput(); void testRedlineWriter(); void testTrackChanges(); void testRedlineCalc(); @@ -174,6 +175,7 @@ public: CPPUNIT_TEST(testNotificationCompression); CPPUNIT_TEST(testTileInvalidationCompression); CPPUNIT_TEST(testPartInInvalidation); + CPPUNIT_TEST(testInput); CPPUNIT_TEST(testRedlineWriter); CPPUNIT_TEST(testTrackChanges); CPPUNIT_TEST(testRedlineCalc); @@ -1699,6 +1701,43 @@ void DesktopLOKTest::testPartInInvalidation() } } +void DesktopLOKTest::testInput() +{ + // Load a Writer document, enable change recording and press a key. + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); + uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); + + Scheduler::ProcessEventsToIdle(); // Get focus & other bits setup. + + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, "far"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, "far"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, " "); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, " "); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, "beyond"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, "beyond"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, " "); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, " "); + // Mis-spelled ... + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, "kovely"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, "kovely"); + // Remove it again + pDocument->pClass->removeTextContext(pDocument, 0, 6, 0); + // Replace it with lovely + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, "lovely"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, "lovely"); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT, " "); + pDocument->pClass->postWindowExtTextInputEvent(pDocument, 0, LOK_EXT_TEXTINPUT_END, " "); + + // get the text ... + pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false); + Scheduler::ProcessEventsToIdle(); + char* pText = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", nullptr); + CPPUNIT_ASSERT(pText != nullptr); + OString aLovely("far beyond lovely "); + CPPUNIT_ASSERT_EQUAL(aLovely, OString(pText)); + free(pText); +} + void DesktopLOKTest::testRedlineWriter() { // Load a Writer document, enable change recording and press a key. |