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

New commits:
commit d6c4ec7b00f3fe7b60f6155de4e7564a4dc72c28
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Mar 14 10:41:35 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 14 13:33:58 2022 +0100

    tdf#147961: sw_uiwriter3: Add unittest
    
    Change-Id: I49f4f98d77f0c5e8caa6471e9c938a472a9aaf96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131526
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 28fbddc1147f..4eea50a6529b 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -801,6 +801,27 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139737)
     Scheduler::ProcessEventsToIdle();
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147961)
+{
+    SwDoc* pDoc = createSwDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xIndexAccess(xTextTablesSupplier->getTextTables(),
+                                                         uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
+
+    pWrtShell->Insert("++");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+
+    // Without the fix in place, this test would have crashed here
+    pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147206)
 {
     SwDoc* pDoc = createSwDoc();

Reply via email to