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

New commits:
commit abab2d24b31f0857502d2fa527b433bd4ff0a0f5
Author:     Kira Tubo <kira.t...@gmail.com>
AuthorDate: Fri Apr 5 20:12:47 2024 -0700
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Apr 18 12:20:54 2024 +0200

    tdf#156546: sw unit test: freeze redo insert table
    
    Unit test checks if writer freezes when the user performs redo on
    table inserted into a new document.
    
    Change-Id: I9d48f32a1ef27deb01c8042a68c21b0be20f2d05
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165919
    Tested-by: Jenkins
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index ab820a9dfc79..91d4ad34d4f7 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1135,6 +1135,43 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf131771)
                          getProperty<OUString>(xTextTable2, 
"TableTemplateName"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf156546)
+{
+    createSwDoc();
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Rows", uno::Any(sal_Int32(2)) }, { "Columns", 
uno::Any(sal_Int32(2)) } }));
+
+    dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+
+    uno::Reference<text::XTextTablesSupplier> xTableSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xTables(xTableSupplier->getTextTables(),
+                                                    uno::UNO_QUERY);
+
+    // check that table was created and inserted into the document
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    // create another document
+    createSwDoc();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    uno::Reference<text::XTextTablesSupplier> xTableSupplier2(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xTables2(xTableSupplier2->getTextTables(),
+                                                     uno::UNO_QUERY);
+
+    // check table exists after paste/undo
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables2->getCount());
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables2->getCount());
+
+    // without the test, writer freezes on redo table paste into new doc
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables2->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf80663)
 {
     createSwDoc();

Reply via email to