sw/qa/extras/uiwriter/data/tdf147199.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx       |   41 ++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

New commits:
commit 1d84ac1cd25022be13bd0c3f831f24b8edfee75d
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Jun 30 17:45:35 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 30 21:31:50 2022 +0200

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

diff --git a/sw/qa/extras/uiwriter/data/tdf147199.docx 
b/sw/qa/extras/uiwriter/data/tdf147199.docx
new file mode 100644
index 000000000000..f28894cadc90
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf147199.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 619e5c032549..e3127c2e3d1f 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -78,6 +78,47 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf145731)
     CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147199)
+{
+    createSwDoc(DATA_DIRECTORY, "tdf147199.docx");
+
+    CPPUNIT_ASSERT_EQUAL(7, getShapes());
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:Cut", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(0, getShapes());
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(7, getShapes());
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(14, getShapes());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(7, getShapes());
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(0, getShapes());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(7, getShapes());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139843)
 {
     createSwDoc(DATA_DIRECTORY, "tdf139843.odt");

Reply via email to