summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-09-06 16:46:16 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-15 15:27:06 +0200
commit6df6c300ea499b260af0daa4d9a97f320e3e161e (patch)
treeeb3702cd9d9628e0667eb67eed13ac96a1f4052a
parentbb83c782bcb3e9320dcad35e8aff99cc76dc7d55 (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> (cherry picked from commit 7b4b1cb7c753fadbc20892ef8cc961b7a61e8d19) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102648 Tested-by: Jenkins
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf133490.odtbin0 -> 9606 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx88
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
new file mode 100644
index 000000000000..98050b58fe46
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf133490.odt
Binary files 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");