[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 15 13:27:47 UTC 2020
sw/qa/extras/uiwriter/data3/tdf133490.odt |binary
sw/qa/extras/uiwriter/uiwriter3.cxx | 88 ++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
New commits:
commit 6df6c300ea499b260af0daa4d9a97f320e3e161e
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Sun Sep 6 16:46:16 2020 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Sep 15 15:27:06 2020 +0200
tdf#133490: sw_uiwriter: Add unittest
Change-Id: I8a0660922e29d0dfaf8b859d396b88997a46bc92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102108
Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
(cherry picked from commit 7b4b1cb7c753fadbc20892ef8cc961b7a61e8d19)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102648
Tested-by: Jenkins
diff --git a/sw/qa/extras/uiwriter/data3/tdf133490.odt b/sw/qa/extras/uiwriter/data3/tdf133490.odt
new file mode 100644
index 000000000000..98050b58fe46
Binary files /dev/null and b/sw/qa/extras/uiwriter/data3/tdf133490.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index fe637456f517..669122e62ebb 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -833,6 +833,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");
More information about the Libreoffice-commits
mailing list