sw/qa/extras/tiledrendering/tiledrendering.cxx |  131 ++++++-------------------
 sw/qa/extras/uiwriter/uiwriter4.cxx            |    6 -
 sw/qa/extras/uiwriter/uiwriter6.cxx            |   10 -
 sw/qa/extras/uiwriter/uiwriter7.cxx            |   17 ---
 sw/qa/extras/uiwriter/uiwriter8.cxx            |   13 --
 sw/qa/inc/swmodeltestbase.hxx                  |    2 
 sw/qa/unit/swmodeltestbase.cxx                 |   12 ++
 7 files changed, 52 insertions(+), 139 deletions(-)

New commits:
commit 797938b7bb897617a078fc7e57de27759a00ed07
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Mar 15 14:38:46 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Mar 15 19:44:03 2023 +0000

    SwModelTestBase: factor out common code
    
    Change-Id: Iab415dadd3bc465d31bf14cbe2f384b9588466a1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148929
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 31eb9b267fba..fd5c469c4f3b 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -322,9 +322,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPostKeyEvent)
     // Did we manage to go after the first character?
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
pShellCursor->GetPoint()->GetContentIndex());
 
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     // Did we manage to insert the character after the first one?
     CPPUNIT_ASSERT_EQUAL(OUString("Axaa bbb."), 
pShellCursor->GetPoint()->GetNode().GetTextNode()->GetText());
 }
@@ -1028,9 +1026,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeViewCursors)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell2->GetDrawView();
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell2->GetWin());
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     // Press a key in the second view, while the first one observes this.
     aView1.m_bViewCursorInvalidated = false;
     aView2.m_bOwnCursorInvalidated = false;
@@ -1039,9 +1035,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeViewCursors)
     const tools::Rectangle aLastOwnCursor2 = aView2.m_aOwnCursor;
     const tools::Rectangle aLastViewCursor2 = aView2.m_aViewCursor;
 
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"y");
     // Make sure that aView1 gets a view-only cursor notification, while
     // aView2 gets a real cursor notification.
     CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor, aLastOwnCursor1);
@@ -1146,15 +1140,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTextEditViewInvalidations)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
 
     // Assert that both views are invalidated when pressing a key while in 
text edit.
     aView1.m_bTilesInvalidated = false;
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"y");
 
     CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
 
@@ -1175,9 +1165,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoInvalidations)
     // Insert a character the end of the document.
     SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
     pWrtShell->EndOfSection();
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"c");
     // ProcessEventsToIdle resets the view; set it again
     SfxLokHelper::setView(nView1);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
@@ -1206,9 +1194,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoLimiting)
     // Insert a character the end of the document in the second view.
     SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
     pWrtShell2->EndOfSection();
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"c");
     SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
     CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), 
pShellCursor->GetPoint()->GetNode().GetTextNode()->GetText());
 
@@ -1236,16 +1222,12 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReordering)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'z', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'z', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"z");
     CPPUNIT_ASSERT_EQUAL(OUString("a"), pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(OUString("z"), pTextNode2->GetText());
 
@@ -1280,21 +1262,15 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingRedo)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph, twice.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'f', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'f', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"f");
     // Go to the start of the paragraph, to avoid grouping.
     pWrtShell1->SttEndDoc(/*bStt=*/true);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 's', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 's', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"s");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'z', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'z', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"z");
     CPPUNIT_ASSERT_EQUAL(OUString("sf"), pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(OUString("z"), pTextNode2->GetText());
 
@@ -1332,21 +1308,15 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoReorderingMulti)
     pWrtShell1->SttEndDoc(/*bStt=*/true);
     SwTextNode* pTextNode1 = 
pWrtShell1->GetCursor()->GetPointNode().GetTextNode();
     // View 1 types into the first paragraph.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
     SfxLokHelper::setView(nView2);
     pWrtShell2->SttEndDoc(/*bStt=*/false);
     SwTextNode* pTextNode2 = 
pWrtShell2->GetCursor()->GetPointNode().GetTextNode();
     // View 2 types into the second paragraph, twice.
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     // Go to the start of the paragraph, to avoid grouping.
     pWrtShell2->SttPara();
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"y");
     CPPUNIT_ASSERT_EQUAL(OUString("a"), pTextNode1->GetText());
     CPPUNIT_ASSERT_EQUAL(OUString("yx"), pTextNode2->GetText());
 
@@ -1382,9 +1352,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoShapeLimiting)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell2->GetDrawView();
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell2->GetWin());
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     pWrtShell2->EndTextEdit();
 
     // Assert that the first view can't and the second view can undo the 
insertion.
@@ -1415,9 +1383,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoDispatch)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"c");
 
     // Click before the first word in the second view.
     SfxLokHelper::setView(nView2);
@@ -1454,9 +1420,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairDispatch)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"c");
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -1497,9 +1461,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoShells)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     pWrtShell->EndTextEdit();
 
     // Make sure that the undo item remembers who created it.
@@ -1525,8 +1487,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
     SdrObject* pObject = pPage->GetObj(0);
     SdrView* pView = pWrtShell->GetDrawView();
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), 
pWrtShell->GetWin());
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    emulateTyping(*pXTextDocument, u"x");
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 
awt::Key::BACKSPACE);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE);
     Scheduler::ProcessEventsToIdle();
@@ -1547,9 +1508,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testShapeTextUndoGroupShells)
 
     // Create an editeng text selection in the first view.
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     // 0th para, 0th char -> 0th para, 1st char.
     ESelection aWordSelection(0, 0, 0, 1);
     rEditView.SetSelection(aWordSelection);
@@ -1808,18 +1767,14 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testCommentEndTextEdit)
     // Create a document, type a character and remember the cursor position.
     SwXTextDocument* pXTextDocument = createDoc();
     ViewCallback aView1;
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     tools::Rectangle aBodyCursor = aView1.m_aOwnCursor;
 
     // Create a comment and type a character there as well.
     const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
     // End comment text edit by clicking in the body text area, and assert that
     // no unexpected cursor callbacks are emitted at origin (top left corner of
     // the document).
@@ -1921,15 +1876,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testUndoRepairResult)
 
     // Insert a character in the second view.
     SfxLokHelper::setView(nView2);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"b");
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -1955,15 +1906,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedoRepairResult)
 
     // Insert a character in the second view.
     SfxLokHelper::setView(nView2);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"b");
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
 
     comphelper::dispatchCommand(".uno:Undo", {}, pResult2);
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), pResult2->m_nDocRepair);
@@ -2026,16 +1973,12 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDisableUndoRepair)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'k', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'k', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"k");
     checkUndoRepairStates(pXTextDocument, pView1, pView2);
 
     // Insert a character in the second view.
     SfxLokHelper::setView(nView2);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'u', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"u");
     {
         SfxItemSet 
aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
         SfxItemSet 
aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), 
svl::Items<SID_UNDO, SID_UNDO>);
@@ -2054,9 +1997,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDisableUndoRepair)
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'l', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'l', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"l");
     checkUndoRepairStates(pXTextDocument, pView1, pView2);
 }
 
@@ -2160,9 +2101,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDocumentRepair)
 
     // Insert a character in the second view.
     SfxLokHelper::setView(nView2);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'u', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"u");
     {
         std::unique_ptr<SfxBoolItem> pItem1;
         std::unique_ptr<SfxBoolItem> pItem2;
@@ -2662,9 +2601,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testVisCursorInvalidation)
     aView2.m_bOwnCursorInvalidated = false;
     aView2.m_bViewCursorInvalidated = false;
 
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
 
     CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
     CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
@@ -2688,9 +2625,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testVisCursorInvalidation)
     aView2.m_bOwnCursorInvalidated = false;
     aView2.m_bViewCursorInvalidated = false;
 
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"x");
 
     CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
     CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index d8e24dfc6f9d..327d493c8c35 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1077,8 +1077,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf84695)
     SwXTextDocument* pXTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pXTextDocument);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
 
     uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
     // This was empty, Enter did not start the fly frame edit mode.
@@ -1102,8 +1101,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, 
testTdf84695NormalChar)
     // Now pressing 'a' should add a character.
     SwXTextDocument* pXTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pXTextDocument);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a");
 
     uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
     // This was empty, pressing a normal character did not start the fly frame 
edit mode.
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 13979f0d7234..8a90c395a570 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -86,16 +86,6 @@ sal_Int32 lcl_getAttributeIDFromHints(const SwpHints& hints)
     return -1;
 }
 
-void emulateTyping(SwXTextDocument& rTextDoc, const std::u16string_view& rStr)
-{
-    for (const char16_t c : rStr)
-    {
-        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0);
-        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0);
-        Scheduler::ProcessEventsToIdle();
-    }
-}
-
 uno::Reference<XLinguServiceManager2> GetLngSvcMgr_Impl()
 {
     uno::Reference<XComponentContext> 
xContext(comphelper::getProcessComponentContext());
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index cd6f9f240be3..392a57ed8962 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -2215,10 +2215,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf127635)
 
     SwXTextDocument* pXTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pXTextDocument);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, ' ', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"a b");
 
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, 
/*bBasicCall=*/false);
@@ -2235,10 +2232,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf127635)
                            pDoc->getIDocumentRedlineAccess().IsRedlineOn());
     CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
 
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, ' ', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'd', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"c d");
 
     SwEditShell* const pEditShell(pDoc->GetEditShell());
     // accept all redlines
@@ -2414,12 +2408,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf89954)
     pWrtShell->EndPara();
     SwXTextDocument* pXTextDocument = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pXTextDocument);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 't', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'e', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 's', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 't', 0);
-    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, '.', 0);
-    Scheduler::ProcessEventsToIdle();
+    emulateTyping(*pXTextDocument, u"test.");
 
     SwNodeIndex aNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1);
     // Placeholder character for the comment anchor was ^A 
(CH_TXTATR_BREAKWORD), not <fff9> (CH_TXTATR_INWORD).
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 45d76fd76771..e6a362484cf4 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -40,19 +40,6 @@
 #include <officecfg/Office/Common.hxx>
 
 /// 8th set of tests asserting the behavior of Writer user interface shells.
-namespace
-{
-void emulateTyping(SwXTextDocument& rTextDoc, const std::u16string_view& rStr)
-{
-    for (const char16_t c : rStr)
-    {
-        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0);
-        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0);
-        Scheduler::ProcessEventsToIdle();
-    }
-}
-} //namespace
-
 class SwUiWriterTest8 : public SwModelTestBase
 {
 public:
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index ca235e722f83..bb9791e81315 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -348,6 +348,8 @@ protected:
 
     bool isExported(){ return mbExported; }
 
+    void emulateTyping(SwXTextDocument& rTextDoc, const std::u16string_view& 
rStr);
+
 private:
     void loadURL(OUString const& rURL, const char* pName, const char* 
pPassword);
 
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index 2a47327287a3..29867b0d8103 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -22,9 +22,11 @@
 #include <rtl/ustrbuf.hxx>
 #include <unotools/streamwrap.hxx>
 #include <unotools/ucbstreamhelper.hxx>
+#include <vcl/scheduler.hxx>
 
 #include <IDocumentLayoutAccess.hxx>
 #include <docsh.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <rootfrm.hxx>
 #include <unotxdoc.hxx>
 #include <view.hxx>
@@ -627,4 +629,14 @@ void SwModelTestBase::WrapFromTempFile(SvMemoryStream& 
rStream)
     rStream.Seek(0);
 }
 
+void SwModelTestBase::emulateTyping(SwXTextDocument& rTextDoc, const 
std::u16string_view& rStr)
+{
+    for (const char16_t c : rStr)
+    {
+        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0);
+        rTextDoc.postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0);
+        Scheduler::ProcessEventsToIdle();
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to