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

New commits:
commit 2bf59e3b60a0d5c6ebcd4498f5038d6d2e86db62
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Feb 15 14:52:52 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Feb 15 20:52:23 2022 +0100

    tdf#146848: sw_uiwriter3: Add unittest
    
    Change-Id: I6460a99ce31cbbcba0498a6caaaac3b304a5134e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129966
    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 84e65489f325..f0a76ebc97f1 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -97,6 +97,38 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139843)
     CPPUNIT_ASSERT_EQUAL(nPages, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146848)
+{
+    // Reuse existing document
+    createSwDoc(DATA_DIRECTORY, "tdf77014.odt");
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:Cut", {});
+    Scheduler::ProcessEventsToIdle();
+
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(
+        xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    CPPUNIT_ASSERT(!xFields->hasMoreElements());
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    xFields = xFieldsAccess->createEnumeration();
+
+    int nFieldsCount = 0;
+    while (xFields->hasMoreElements())
+    {
+        xFields->nextElement();
+        nFieldsCount++;
+    }
+    CPPUNIT_ASSERT_EQUAL(4, nFieldsCount);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf145321)
 {
     createSwDoc(DATA_DIRECTORY, "tdf145321.odt");

Reply via email to