tdf#151375: sw_odfimport: Add unittest
Change-Id: I702059fcfc8e99b11412f959bc924af73780d351
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141284
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/odfimport/data/tdf151375.ott b/sw/qa/extras/odfimport/data/tdf151375.ott
new file mode 100644
index 0000000..1215cc7
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf151375.ott
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index c7d7209..4644bac 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1193,6 +1193,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf134971)
CPPUNIT_ASSERT_EQUAL(OUString("Arial"), sString);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf151375)
{
// Create a new document.
mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<document::XDocumentInsertable> xCursor(xText->createTextCursorByRange(xText->getStart()), uno::UNO_QUERY);
// Without the fix in place, this test would have crashed here
xCursor->insertDocumentFromURL(m_directories.getURLFromSrc(mpTestDocumentPath) + "tdf151375.ott", {});
uno::Reference<text::XTextFramesSupplier> const xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> const xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf138879)
{
// Create a new document.