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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 16 19:48:31 UTC 2020


 sw/qa/extras/uiwriter/uiwriter.cxx |   44 +++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

New commits:
commit 254c26f1c69e2eb23f66a79349b0ea78a5d467d3
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Oct 16 18:32:32 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Oct 16 21:47:49 2020 +0200

    tdf#127635: sw_uiwriter: Add unittest
    
    Change-Id: Ib25d5723057b79f49876df816bff5971ee3fa7c3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104444
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 3ca0e97850ae..b1f93e1b8422 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -265,6 +265,7 @@ public:
     void testUnicodeNotationToggle();
     void testTextTableCellNames();
     void testShapeAnchorUndo();
+    void testTdf127635();
     void testDde();
     void testDocModState();
     void testTdf94804();
@@ -491,6 +492,7 @@ public:
     CPPUNIT_TEST(testUnicodeNotationToggle);
     CPPUNIT_TEST(testTextTableCellNames);
     CPPUNIT_TEST(testShapeAnchorUndo);
+    CPPUNIT_TEST(testTdf127635);
     CPPUNIT_TEST(testDde);
     CPPUNIT_TEST(testDocModState);
     CPPUNIT_TEST(testTdf94804);
@@ -4350,6 +4352,48 @@ void SwUiWriterTest::testShapeAnchorUndo()
     CPPUNIT_ASSERT_EQUAL(pObject->GetLogicRect(), aOrigLogicRect);
 }
 
+void SwUiWriterTest::testTdf127635()
+{
+    SwDoc* pDoc = createDoc();
+
+    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();
+
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false);
+
+    //Select 'a'
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+
+    // enable redlining
+    dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    // hide
+    dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+
+    CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+                           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();
+
+    SwEditShell* const pEditShell(pDoc->GetEditShell());
+    // accept all redlines
+    while(pEditShell->GetRedlineCount())
+        pEditShell->AcceptRedline(0);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: C d b
+    // - Actual  : Cd  b
+    CPPUNIT_ASSERT_EQUAL(OUString("C d b"), getParagraph(1)->getString());
+}
+
 void SwUiWriterTest::testDde()
 {
 #if HAVE_FEATURE_UI


More information about the Libreoffice-commits mailing list