tdf#146848: sw_uiwriter3: Add unittest
Change-Id: I6460a99ce31cbbcba0498a6caaaac3b304a5134e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129966
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 84e6548..f0a76eb 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -97,6 +97,38 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf139843)
CPPUNIT_ASSERT_EQUAL(nPages, getPages());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146848)
{
// Reuse existing document
createSwDoc(DATA_DIRECTORY, "tdf77014.odt");
dispatchCommand(mxComponent, ".uno:SelectAll", {});
Scheduler::ProcessEventsToIdle();
dispatchCommand(mxComponent, ".uno:Cut", {});
Scheduler::ProcessEventsToIdle();
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(
xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_ASSERT(!xFields->hasMoreElements());
// Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, ".uno:Paste", {});
Scheduler::ProcessEventsToIdle();
xFields = xFieldsAccess->createEnumeration();
int nFieldsCount = 0;
while (xFields->hasMoreElements())
{
xFields->nextElement();
nFieldsCount++;
}
CPPUNIT_ASSERT_EQUAL(4, nFieldsCount);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf145321)
{
createSwDoc(DATA_DIRECTORY, "tdf145321.odt");