summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-12-03 23:23:06 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2020-12-04 11:43:03 +0100
commit44a3a3a53db57398efa2ec4db026e4ebda086dde (patch)
treee3ff664d700f00fa5970331e8dc8c355ee90d15b
parenteed5a105bf6338828ee6c973891c1d922b3fb08b (diff)
tdf#137802: sw: Add UITest
First, I tried to create this as a CppUnittest but I couldn't make it to work, so i'm using a UItest instead. At least we have a test Change-Id: I21d6b70e48b0e20cfd7f5ab3f819def721f434c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107177 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/uitest/data/tdf137802.odtbin0 -> 9780 bytes
-rw-r--r--sw/qa/uitest/writer_tests7/tdf137802.py84
2 files changed, 84 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/tdf137802.odt b/sw/qa/uitest/data/tdf137802.odt
new file mode 100644
index 000000000000..2d5ac8b04a96
--- /dev/null
+++ b/sw/qa/uitest/data/tdf137802.odt
Binary files differ
diff --git a/sw/qa/uitest/writer_tests7/tdf137802.py b/sw/qa/uitest/writer_tests7/tdf137802.py
new file mode 100644
index 000000000000..8f7a887e753c
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf137802.py
@@ -0,0 +1,84 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# 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 uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from com.sun.star.text.TextContentAnchorType import AT_PAGE, AT_PARAGRAPH
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class tdf137802(UITestCase):
+
+ def test_tdf137802(self):
+
+ self.ui_test.load_file(get_url_for_data_file("tdf137802.odt"))
+
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ document = self.ui_test.get_component()
+
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType)
+
+ self.xUITest.executeCommand(".uno:JumpToNextFrame")
+
+ self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
+
+ self.ui_test.execute_dialog_through_command(".uno:TransformDialog")
+
+ xDialog = self.xUITest.getTopFocusWindow()
+
+ xDialog.getChild('topage').executeAction("CLICK", tuple())
+
+ xOkBtn = xDialog.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
+
+ self.assertEqual(AT_PAGE, document.DrawPage.getByIndex(0).AnchorType)
+
+ self.assertEqual(document.DrawPage.getCount(), 2)
+
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ # When shape 1 is selected, esc key doesn't put the focus back to the document
+ # because the shape has a textbox. Move the focus to another shape with tab key
+ # and then use escape
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"}))
+
+ # Wait until the shape is deselected and the cursor is on the document
+ self.ui_test.wait_until_child_is_available(xWriterEdit, 'FontNameBox')
+
+ # Delete the second paragraph. Shape 2 is anchored to this paragraph
+ # so it should be deleted
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
+
+ self.assertEqual(document.DrawPage.getCount(), 1)
+
+ self.xUITest.executeCommand(".uno:JumpToNextFrame")
+ self.xUITest.executeCommand(".uno:Delete")
+
+ self.assertEqual(document.DrawPage.getCount(), 0)
+
+ self.xUITest.executeCommand(".uno:Undo")
+
+ self.assertEqual(document.DrawPage.getCount(), 1)
+
+ self.xUITest.executeCommand(".uno:Undo")
+
+ self.assertEqual(document.DrawPage.getCount(), 2)
+
+ self.xUITest.executeCommand(".uno:Undo")
+
+ self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType)
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: