diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-07-28 18:34:48 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-10-28 08:19:07 +0100 |
commit | b2faa46071ff4a00672b0699e524e7ae66915fc0 (patch) | |
tree | bc30dc856cc1c00463b921798ccf5931f9e9dd7e | |
parent | a780fd334a3a6d9a5a300f1b0ba0e067b500dcad (diff) |
tdf#132911: sw_uiwriter: Add unittest
Change-Id: I0ad6697d8dce814f20ea5f98e9c8f4b9c68f278d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99641
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit a206054ac048702d48077eea6f3d464c3d241ab3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104824
Tested-by: Michael Stahl <michael.stahl@cib.de>
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf132911.odt | bin | 0 -> 10980 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 74 |
2 files changed, 74 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf132911.odt b/sw/qa/extras/uiwriter/data/tdf132911.odt Binary files differnew file mode 100644 index 000000000000..3c311f3ed36b --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf132911.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d287894f94db..0bd769d2b121 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -5784,6 +5784,80 @@ void SwUiWriterTest::testRedlineViewAuthor() pDocShell->SetView(pView); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf132911) +{ + load(DATA_DIRECTORY, "tdf132911.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + auto getShapes = [&]() -> int + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); + return xDraws->getCount(); + }; + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + // Without the fix in place, it would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(8, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(8, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + //FIXME: tdf#135247 + //lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + //Scheduler::ProcessEventsToIdle(); + //CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + //CPPUNIT_ASSERT_EQUAL(4, getShapes()); +} + void SwUiWriterTest::testTdf91292() { createDoc("tdf91292_paraBackground.docx"); |