[Libreoffice-commits] core.git: sw/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 11 18:43:59 UTC 2021


 sw/qa/uitest/navigator/tdf140257.py |  120 ++++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)

New commits:
commit 0c262229337c43f125d8931cba40ab432f51a851
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Feb 11 15:11:32 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Feb 11 19:43:15 2021 +0100

    tdf#140257: sw: Add UItest
    
    Change-Id: I4de5287a523c9f1006c8511bc2effe4e6f4e4c6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110766
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/qa/uitest/navigator/tdf140257.py b/sw/qa/uitest/navigator/tdf140257.py
new file mode 100644
index 000000000000..8982b7d2901f
--- /dev/null
+++ b/sw/qa/uitest/navigator/tdf140257.py
@@ -0,0 +1,120 @@
+# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.uihelper.common import select_pos
+
+class Tdf140257(UITestCase):
+
+  def change_outline_level(self, sText):
+
+    self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog")
+    xDialog = self.xUITest.getTopFocusWindow()
+    xTabs = xDialog.getChild("tabcontrol")
+    select_pos(xTabs, "4")
+
+    xOutline = xDialog.getChild("comboLB_OUTLINE_LEVEL")
+
+    props = {"TEXT": sText}
+    actionProps = mkPropertyValues(props)
+    xOutline.executeAction("SELECT", actionProps)
+
+    xOKBtn = xDialog.getChild("ok")
+    self.ui_test.close_dialog_through_button(xOKBtn)
+
+  def test_tdf140257(self):
+    self.ui_test.create_doc_in_start_center("writer")
+    xMainWindow = self.xUITest.getTopFocusWindow()
+    xWriterEdit = xMainWindow.getChild("writer_edit")
+
+    self.change_outline_level("Level 1")
+
+    for i in range(4):
+        type_text(xWriterEdit, 'P' + str(i + 1))
+        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+
+    type_text(xWriterEdit, 'P5')
+
+    self.xUITest.executeCommand(".uno:Sidebar")
+
+    xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
+
+    # wait until the navigator panel is available
+    self.ui_test.wait_until_child_is_available(xMainWindow, 'NavigatorPanelParent')
+
+    xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
+
+    xContentTree = xNavigatorPanel.getChild("contenttree")
+    xHeadings = xContentTree.getChild('0')
+    self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
+
+    xHeadings.executeAction("EXPAND", tuple())
+
+    self.assertEqual(5, len(xHeadings.getChildren()))
+
+    for i in range(5):
+        self.assertEqual('P' + str(i + 1), get_state_as_dict(xHeadings.getChild(str(i)))['Text'])
+
+    self.xUITest.executeCommand(".uno:Sidebar")
+
+    document = self.ui_test.get_component()
+    cursor = document.getCurrentController().getViewCursor()
+
+    # Use Adding Selection
+    selectionProperty = mkPropertyValues({"SelectionMode": 2})
+    self.xUITest.executeCommandWithParameters(".uno:SelectionMode", selectionProperty)
+
+    # Go to P2 and select it
+    cursor.goUp(3, False)
+    cursor.gotoStartOfLine(False)
+    cursor.gotoEndOfLine(True)
+
+    # Go to P4 and select it
+    cursor.goDown(2, False)
+    cursor.gotoStartOfLine(False)
+    cursor.gotoEndOfLine(True)
+
+    self.change_outline_level("Level 2")
+
+    self.xUITest.executeCommand(".uno:Sidebar")
+
+    xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
+
+    # wait until the navigator panel is available
+    self.ui_test.wait_until_child_is_available(xMainWindow, 'NavigatorPanelParent')
+
+    xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
+
+    xContentTree = xNavigatorPanel.getChild("contenttree")
+    xHeadings = xContentTree.getChild('0')
+    self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
+
+    xHeadings.executeAction("EXPAND", tuple())
+
+    # Without the fix in place, this test would have failed with
+    # AssertionError: 3 != 4
+    self.assertEqual(3, len(xHeadings.getChildren()))
+    xChild1 = xHeadings.getChild('0')
+    self.assertEqual('P1', get_state_as_dict(xChild1)['Text'])
+    xChild1.executeAction("EXPAND", tuple())
+    self.assertEqual(1, len(xChild1.getChildren()))
+    self.assertEqual('P2', get_state_as_dict(xChild1.getChild('0'))['Text'])
+
+    xChild2 = xHeadings.getChild('1')
+    self.assertEqual('P3', get_state_as_dict(xChild2)['Text'])
+    xChild2.executeAction("EXPAND", tuple())
+    self.assertEqual(1, len(xChild2.getChildren()))
+    self.assertEqual('P4', get_state_as_dict(xChild2.getChild('0'))['Text'])
+
+    self.assertEqual('P5', get_state_as_dict(xHeadings.getChild('2'))['Text'])
+
+    self.xUITest.executeCommand(".uno:Sidebar")
+
+    self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list