summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-05-18 11:49:33 +0200
committerXisco FaulĂ­ <xiscofauli@libreoffice.org>2020-05-18 14:01:12 +0200
commitd08d42fd7f10f2d2c1bb42dc2aed11693bd882be (patch)
tree3a84e7c6fe0f4e03c3d847bc91e1b8bf2c56e0b9
parent18dc598a6e0017df375369a81c8df3bbd41ed8ab (diff)
tdf#128782: move UItest to CppunitTest
Change-Id: I98319183a7bd9abb9ed6b1dd9f85cf00ee701fc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94405 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf128782.odt (renamed from sw/qa/uitest/writer_tests/data/tdf128782.odt)bin8817 -> 8817 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx39
-rw-r--r--sw/qa/uitest/writer_tests7/tdf128782.py45
3 files changed, 39 insertions, 45 deletions
diff --git a/sw/qa/uitest/writer_tests/data/tdf128782.odt b/sw/qa/extras/uiwriter/data3/tdf128782.odt
index bb4a7d7f67c9..bb4a7d7f67c9 100644
--- a/sw/qa/uitest/writer_tests/data/tdf128782.odt
+++ b/sw/qa/extras/uiwriter/data3/tdf128782.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index ec33238f407e..3b67a6fde7ca 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -685,6 +685,45 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf117601)
CPPUNIT_ASSERT(xCellB1->getString().endsWith("test1"));
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128782)
+{
+ load(DATA_DIRECTORY, "tdf128782.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ 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 down
+ dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {});
+ dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {});
+ Scheduler::ProcessEventsToIdle();
+
+ pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(aPos[0].X, xShape1->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(aPos[0].Y, xShape1->getPosition().Y);
+ CPPUNIT_ASSERT_EQUAL(aPos[1].X, xShape2->getPosition().X);
+ //Y position in shape 2 has changed
+ CPPUNIT_ASSERT(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);
+ CPPUNIT_ASSERT_EQUAL(aPos[1].X, xShape2->getPosition().X);
+ // Shape2 has come back to the original position
+ // without the fix in place, it would have failed
+ CPPUNIT_ASSERT_EQUAL(aPos[1].Y, xShape2->getPosition().Y);
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132637_protectTrackChanges)
{
load(DATA_DIRECTORY, "tdf132637_protectTrackChanges.doc");
diff --git a/sw/qa/uitest/writer_tests7/tdf128782.py b/sw/qa/uitest/writer_tests7/tdf128782.py
deleted file mode 100644
index 13104c4bed29..000000000000
--- a/sw/qa/uitest/writer_tests7/tdf128782.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from uitest.framework import UITestCase
-from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.path import get_srcdir_url
-
-def get_url_for_data_file(file_name):
- return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
-
-class tdf128782(UITestCase):
-
- def test_tdf128782_move_textbox_undo(self):
- self.ui_test.load_file(get_url_for_data_file("tdf128782.odt"))
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
-
- oldX1 = document.getDrawPage()[0].Position.X
- oldY1 = document.getDrawPage()[0].Position.Y
- oldX2 = document.getDrawPage()[1].Position.X
- oldY2 = document.getDrawPage()[1].Position.Y
-
- #select shape 2 and move it down
- document.getCurrentController().select(document.getDrawPage()[1])
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
-
- #Only the Y value of shape 2 changes
- self.assertEqual(oldX1, document.getDrawPage()[0].Position.X)
- self.assertEqual(oldY1, document.getDrawPage()[0].Position.Y)
- self.assertEqual(oldX2, document.getDrawPage()[1].Position.X)
- self.assertNotEqual(oldY2, document.getDrawPage()[1].Position.Y)
-
- self.xUITest.executeCommand(".uno:Undo")
-
- #Both shapes should have the same position as before
- self.assertEqual(oldX1, document.getDrawPage()[0].Position.X)
- self.assertEqual(oldY1, document.getDrawPage()[0].Position.Y)
- self.assertEqual(oldX2, document.getDrawPage()[1].Position.X)
- self.assertEqual(oldY2, document.getDrawPage()[1].Position.Y)
-
- self.ui_test.close_doc()
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab: