tdf#134227: sw_uiwriter: Add unittest
Change-Id: I473ab1ea5ccc603c6086189075db49c224d33743
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103149
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/data3/tdf134227.docx b/sw/qa/extras/uiwriter/data3/tdf134227.docx
new file mode 100644
index 0000000..e5228e6
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf134227.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index dca99f9..b3eda55 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -73,6 +73,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382)
CPPUNIT_ASSERT_EQUAL(8, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf134227)
{
load(DATA_DIRECTORY, "tdf134227.docx");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
CPPUNIT_ASSERT_EQUAL(4, getShapes());
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:SelectAll", {});
// Without the fix in place, it would have crashed here
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
xTransfer->Cut();
CPPUNIT_ASSERT_EQUAL(0, getShapes());
TransferableDataHelper aHelper(xTransfer.get());
SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(4, getShapes());
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(0, getShapes());
dispatchCommand(mxComponent, ".uno:Undo", {});
CPPUNIT_ASSERT_EQUAL(4, getShapes());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412)
{
load(DATA_DIRECTORY, "tdf135412.docx");