diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-09-06 16:46:16 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-09-06 18:28:34 +0200 |
commit | 7b4b1cb7c753fadbc20892ef8cc961b7a61e8d19 (patch) | |
tree | 9520cb6c2cde7458d8837a064574910348483337 /sw/qa/extras | |
parent | 1d67beea593fa43f0bd782c0ce15b6a85042e33c (diff) |
tdf#133490: sw_uiwriter: Add unittest
Change-Id: I8a0660922e29d0dfaf8b859d396b88997a46bc92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102108
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/uiwriter/data3/tdf133490.odt | bin | 0 -> 9606 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 88 |
2 files changed, 88 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data3/tdf133490.odt b/sw/qa/extras/uiwriter/data3/tdf133490.odt Binary files differnew file mode 100644 index 000000000000..98050b58fe46 --- /dev/null +++ b/sw/qa/extras/uiwriter/data3/tdf133490.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 6e02006ea3c0..928711466229 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1313,6 +1313,94 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128782) CPPUNIT_ASSERT_EQUAL(aPos[1].Y, xShape2->getPosition().Y); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133490) +{ + load(DATA_DIRECTORY, "tdf133490.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(2, getShapes()); + + uno::Reference<drawing::XShape> xShape1 = getShape(1); + uno::Reference<drawing::XShape> xShape2 = getShape(2); + + awt::Point aPos[2]; + aPos[0] = xShape1->getPosition(); + aPos[1] = xShape2->getPosition(); + + //select shape 2 and move it to the right + dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); + Scheduler::ProcessEventsToIdle(); + + for (sal_Int32 i = 0; i < 5; ++i) + { + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RIGHT); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(aPos[0].X, xShape1->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[0].Y, xShape1->getPosition().Y); + //X position in shape 2 has changed + CPPUNIT_ASSERT(aPos[1].X < xShape2->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[1].Y, xShape2->getPosition().Y); + + for (sal_Int32 i = 0; i < 4; ++i) + { + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, undo action would have changed shape1's position + // and this test would have failed with + // - Expected: -139 + // - Actual : 1194 + CPPUNIT_ASSERT_EQUAL(aPos[0].X, xShape1->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[0].Y, xShape1->getPosition().Y); + CPPUNIT_ASSERT(aPos[1].X < xShape2->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[1].Y, xShape2->getPosition().Y); + } + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(aPos[0].X, xShape1->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[0].Y, xShape1->getPosition().Y); + // Shape 2 has come back to the original position + CPPUNIT_ASSERT_EQUAL(aPos[1].X, xShape2->getPosition().X); + CPPUNIT_ASSERT_EQUAL(aPos[1].Y, xShape2->getPosition().Y); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(1, getShapes()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132637_protectTrackChanges) { load(DATA_DIRECTORY, "tdf132637_protectTrackChanges.doc"); |