tdf#124397: sw: Add unittest
Change-Id: Idd98980625e246dea432346f3d7c12c942132aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93223
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/data3/tdf124397.docx b/sw/qa/extras/uiwriter/data3/tdf124397.docx
new file mode 100644
index 0000000..65e2d25
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf124397.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index ebecdde..362a016 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -223,6 +223,27 @@
CPPUNIT_ASSERT_EQUAL(OUString("foo"), getParagraph(1)->getString());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf124397)
{
load(DATA_DIRECTORY, "tdf124397.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:Delete", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
// Without the fix in place, it would crash here
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf107975)
{
// This test also covers tdf#117185 tdf#110442