From 0fc96ac585520884e3509d574d162ffdae7698c9 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 31 Aug 2020 16:57:13 +0200 Subject: tdf#135412: sw_uiwriter: Add unittest Change-Id: I091f5e40161119fcc07c43deaede6bc49049bf87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101745 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/extras/uiwriter/data3/tdf135412.docx | Bin 0 -> 22923 bytes sw/qa/extras/uiwriter/uiwriter3.cxx | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sw/qa/extras/uiwriter/data3/tdf135412.docx diff --git a/sw/qa/extras/uiwriter/data3/tdf135412.docx b/sw/qa/extras/uiwriter/data3/tdf135412.docx new file mode 100644 index 000000000000..b420fa5ce2d1 Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf135412.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index cd8c7ac359bc..b8972d19f7e2 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -64,6 +64,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf129382) CPPUNIT_ASSERT_EQUAL(8, getShapes()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135412) +{ + load(DATA_DIRECTORY, "tdf135412.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + uno::Reference xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("X"), xShape->getString()); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + dispatchCommand(mxComponent, ".uno:Paste", {}); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + // Without the fix in place, the text in the shape wouldn't be pasted + xShape.set(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("X"), xShape->getString()); + + //Without the fix in place, it would have crashed here + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + xShape.set(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("X"), xShape->getString()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132911) { load(DATA_DIRECTORY, "tdf132911.odt"); -- cgit