[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - 2 commits - sw/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 26 08:30:19 UTC 2020


 sw/qa/extras/uiwriter/data/tdf133982.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx        |   69 ++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

New commits:
commit c207a70dc1d42250b80d9bf63723fee11c9b0c2b
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Oct 16 18:32:32 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Mon Oct 26 09:29:52 2020 +0100

    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>
    (cherry picked from commit 254c26f1c69e2eb23f66a79349b0ea78a5d467d3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104745
    Tested-by: Michael Stahl <michael.stahl at cib.de>
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 1ace94e3d473..76e6b84445aa 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -260,6 +260,7 @@ public:
     void testUnicodeNotationToggle();
     void testTextTableCellNames();
     void testShapeAnchorUndo();
+    void testTdf127635();
     void testDde();
     void testDocModState();
     void testTdf94804();
@@ -474,6 +475,7 @@ public:
     CPPUNIT_TEST(testUnicodeNotationToggle);
     CPPUNIT_TEST(testTextTableCellNames);
     CPPUNIT_TEST(testShapeAnchorUndo);
+    CPPUNIT_TEST(testTdf127635);
     CPPUNIT_TEST(testDde);
     CPPUNIT_TEST(testDocModState);
     CPPUNIT_TEST(testTdf94804);
@@ -4238,6 +4240,48 @@ void SwUiWriterTest::testDde()
 #endif
 }
 
+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
+    lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    // hide
+    lcl_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());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf132160)
 {
     load(DATA_DIRECTORY, "tdf132160.odt");
commit 95554417cad0a6597d9f633f87081ab3d2d03c11
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Jun 18 11:08:38 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Mon Oct 26 09:29:36 2020 +0100

    tdf#133982: sw: Add unittest
    
    Change-Id: I1a9b0a1150f8e3e1832aaa15a09049622bd83afc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96592
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 9197a52c1bd79bbdc0756724c74fd2a679b9f626)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104744
    Tested-by: Michael Stahl <michael.stahl at cib.de>
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/qa/extras/uiwriter/data/tdf133982.docx b/sw/qa/extras/uiwriter/data/tdf133982.docx
new file mode 100644
index 000000000000..d2e8573d15ac
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf133982.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index cd8516d6c29e..1ace94e3d473 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -7356,6 +7356,31 @@ void SwUiWriterTest::testTdf38394()
     CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf133982)
+{
+    load(DATA_DIRECTORY, "tdf133982.docx");
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(),
+                                                         uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+
+    //Use selectAll 3 times in a row
+    lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+    //Without the fix in place, it would have crashed here
+    lcl_dispatchCommand(mxComponent, ".uno:Cut", {});
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
+
+    lcl_dispatchCommand(mxComponent, ".uno:Paste", {});
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+}
+
 void SwUiWriterTest::testTdf59666()
 {
     SwDoc* pDoc = createDoc();


More information about the Libreoffice-commits mailing list