summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-08-31 16:57:13 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-01 13:16:09 +0200
commit0fc96ac585520884e3509d574d162ffdae7698c9 (patch)
tree4afa08f339cf00790c25e173cb034a8ff8260e44
parent2bb8636ea51e552a20a4253a6c5c97898129d523 (diff)
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 <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf135412.docxbin0 -> 22923 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx29
2 files changed, 29 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf135412.docx
Binary files 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<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ CPPUNIT_ASSERT_EQUAL(4, getShapes());
+ uno::Reference<text::XTextRange> 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");