tdf#131684: Add unittest
Change-Id: Ic59d922700b4046a1ec94be5365b46dc8a021a00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92226
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/data3/tdf131684.docx b/sw/qa/extras/uiwriter/data3/tdf131684.docx
new file mode 100644
index 0000000..7d3397d
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf131684.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 2bafcd2..2dc50a0 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -374,6 +374,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680)
//CPPUNIT_ASSERT_EQUAL(sal_Int32(23), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131684)
{
load(DATA_DIRECTORY, "tdf131684.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(1), xIndexAccess->getCount());
//Use selectAll 3 times in a row
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:Cut", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:Paste", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
// without the fix, it crashes
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf80663)
{
mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");