From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/qa/uitest/navigator/movechapterupdown.py | 504 ++++++++++++++++++++++++++++ sw/qa/uitest/navigator/tdf114724.py | 56 ++++ sw/qa/uitest/navigator/tdf134960.py | 94 ++++++ sw/qa/uitest/navigator/tdf137274.py | 88 +++++ sw/qa/uitest/navigator/tdf140257.py | 112 +++++++ sw/qa/uitest/navigator/tdf140661.py | 70 ++++ sw/qa/uitest/navigator/tdf143569.py | 69 ++++ sw/qa/uitest/navigator/tdf144672.py | 68 ++++ sw/qa/uitest/navigator/tdf148198.py | 67 ++++ sw/qa/uitest/navigator/tdf149268.py | 49 +++ sw/qa/uitest/navigator/tdf149916.py | 48 +++ sw/qa/uitest/navigator/tdf151051.py | 59 ++++ sw/qa/uitest/navigator/tdf154212.py | 83 +++++ sw/qa/uitest/navigator/tdf154521.py | 203 +++++++++++ sw/qa/uitest/navigator/tdf154545.py | 97 ++++++ sw/qa/uitest/navigator/tdf40427.py | 97 ++++++ 16 files changed, 1764 insertions(+) create mode 100644 sw/qa/uitest/navigator/movechapterupdown.py create mode 100644 sw/qa/uitest/navigator/tdf114724.py create mode 100644 sw/qa/uitest/navigator/tdf134960.py create mode 100644 sw/qa/uitest/navigator/tdf137274.py create mode 100644 sw/qa/uitest/navigator/tdf140257.py create mode 100644 sw/qa/uitest/navigator/tdf140661.py create mode 100644 sw/qa/uitest/navigator/tdf143569.py create mode 100644 sw/qa/uitest/navigator/tdf144672.py create mode 100644 sw/qa/uitest/navigator/tdf148198.py create mode 100644 sw/qa/uitest/navigator/tdf149268.py create mode 100644 sw/qa/uitest/navigator/tdf149916.py create mode 100644 sw/qa/uitest/navigator/tdf151051.py create mode 100644 sw/qa/uitest/navigator/tdf154212.py create mode 100644 sw/qa/uitest/navigator/tdf154521.py create mode 100644 sw/qa/uitest/navigator/tdf154545.py create mode 100644 sw/qa/uitest/navigator/tdf40427.py (limited to 'sw/qa/uitest/navigator') diff --git a/sw/qa/uitest/navigator/movechapterupdown.py b/sw/qa/uitest/navigator/movechapterupdown.py new file mode 100644 index 0000000000..0b4c7ef5f5 --- /dev/null +++ b/sw/qa/uitest/navigator/movechapterupdown.py @@ -0,0 +1,504 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class movechapterupdown(UITestCase): + + def test_movechapterupdown(self): + + with self.ui_test.load_file(get_url_for_data_file('MoveChapterUpDown.odt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') + + self.xUITest.executeCommand('.uno:Sidebar') + xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + # Given the document chapter structure: + # 1. One H1 + # 1.1. one_A (H2) + # 1.2. one_B (H2) + # 2. Two (H1) + # A heading of level 3 + # 2.1. Two_A (H2) + # 2.1. Two_B (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree") + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple()) + + # + # test a level 1 chapter move up then move down + # + + # Double click on the "2. Two (H1)" entry to select and set focus + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2. Two (H1)") + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Expected chapter order: + # 2. Two (H1) + # A heading of level 3 + # 2.1. Two_A (H2) + # 2.1. Two_B (H2) + # 1. One (H1) + # 1.1. One_A (H2) + # 1.2. One_B (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "2. Two (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "A heading of level 3") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "1. One (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # Click on the 'Move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + # Expected chapter order is the original order + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # + # test a level 1 chapter move down then move up + # + + # Double click on the "2. Two (H1)" entry to select and set focus + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2. Two (H1)") + + # Click on the 'Move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + # Expected chapter order: + # 1. One (H1) + # 1.1. One_A (H2) + # 1.2. One_B (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + # 2. Two (H1) + # A heading of level 3 + # 2.1. Two_A (H2) + # 2.1. Two_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "3. Three (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "3.2. Three_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "2. Two (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "A heading of level 3") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild2Child2 = xHeadingsChild2.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child2)["Text"], "2.1. Two_B (H2)") + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Expected chapter order is the original order + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # + # test a sub chapter move chapter up then move down + # + + # Double click on the "2.1. Two_A (H2)" entry to select and set focus + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child1.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_A (H2)") + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Expected chapter order: + # 1. One H1 + # 1.1. one_A (H2) + # 1.2. one_B (H2) + # 2. Two (H1) + # 2.1. Two_A (H2) + # A heading of level 3 + # 2.1. Two_B (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child0Child0 = xHeadingsChild1Child0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_A (H2)") + + # Click on the 'Move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + # Expected chapter order: + # 1. One H1 + # 1.1. one_A (H2) + # 1.2. one_B (H2) + # 2. Two (H1) + # 2.1. Two_B (H2) + # 2.1. Two_A (H2) + # A heading of level 3 + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "2.1. Two_B (H2)") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child1Child0 = xHeadingsChild1Child1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1Child0)["Text"], "A heading of level 3") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # Move "A heading of level 3" to its original position + + # Double click on the "A heading of level 3" entry to select and set focus + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + xHeadingsChild1Child1Child0 = xHeadingsChild1Child1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1Child0.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "A heading of level 3") + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Expected chapter order: + # 1. One H1 + # 1.1. one_A (H2) + # 1.2. one_B (H2) + # 2. Two (H1) + # A heading of level 3 + # 2.1. Two_B (H2) + # 2.1. Two_A (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") + xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_A (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # Move "2.1. Two_B (H2)" to its original position + + # Double click on the "2.1. Two_B (H2)" entry to select and set focus + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") + xHeadingsChild1Child1.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_B (H2)") + + # Click on the 'Move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + # Expected chapter order is the original order + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + # + # test moving a sub chapter out of and then back into its parent + # + + # Double click on the "1.1. One_A (H2)" entry to select and set focus + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child0.executeAction("DOUBLECLICK", tuple()) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "1.1. One_A (H2)") + + # Click on the 'Move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + # Expected chapter order: + # 1.1. One_A (H2) + # 1. One H1 + # 1.2. One_B (H2) + # 2. Two (H1) + # A heading of level 3 + # 2.1. Two_A (H2) + # 2.1. Two_B (H2) + # 3. Three (H1) + # 3.1. Three_A (H2) + # 3.2. Three_B (H2) + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1.1. One_A (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "1. One (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "1.2. One_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "2. Two (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "A heading of level 3") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild2Child2 = xHeadingsChild2.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild3 = xNavigatorPanelContentTreeHeadings.getChild('3') + self.assertEqual(get_state_as_dict(xHeadingsChild3)["Text"], "3. Three (H1)") + xHeadingsChild3Child0 = xHeadingsChild3.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild3Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild3Child1 = xHeadingsChild3.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild3Child1)["Text"], "3.2. Three_B (H2)") + + # Click on the 'Move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + # Expected chapter order is the original order + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") + xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") + xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") + + xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") + xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") + xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") + xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") + + xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") + xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") + xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') + self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") + + self.xUITest.executeCommand('.uno:Sidebar') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf114724.py b/sw/qa/uitest/navigator/tdf114724.py new file mode 100644 index 0000000000..0ddc9fa11d --- /dev/null +++ b/sw/qa/uitest/navigator/tdf114724.py @@ -0,0 +1,56 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf114724(UITestCase): + + def test_track_headings_outline(self): + with self.ui_test.load_file(get_url_for_data_file("tdf114724.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content5") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + + xWriterEdit.executeAction("FOCUS", tuple()) + + xContentTree = xNavigatorPanel.getChild("contenttree") + + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + for _ in range(0,3): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 4") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 4") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + for _ in range(0,3): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + # tdf#124456 makes the sidebar navigator consistent with the floating navigator's use + # of the stored root mode setting. This requires the root mode button to be clicked + # here to change the content navigation view back to all categories view for subsequent + # tests that expect the navigator tree to not be in root mode. + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf134960.py b/sw/qa/uitest/navigator/tdf134960.py new file mode 100644 index 0000000000..d60cc677bc --- /dev/null +++ b/sw/qa/uitest/navigator/tdf134960.py @@ -0,0 +1,94 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf134960_hyperlinks(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def launch_sidebar(self, xWriterEdit): + + self.xUITest.executeCommand(".uno:Sidebar") + + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + xContentTree = xNavigatorPanel.getChild("contenttree") + xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') + self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) + + xHyperlinks.executeAction("EXPAND", tuple()) + + expectedHyperlinksOrder = [1, 2, 8, 9, 7, 10, 11, 3, 12, 4, 5, 6] + for i in range(12): + self.assertEqual('Hyperlink ' + str(expectedHyperlinksOrder[i]), get_state_as_dict(xHyperlinks.getChild(str(i)))['Text']) + + xHyperlinks.executeAction("COLLAPSE", tuple()) + + self.xUITest.executeCommand(".uno:Sidebar") + + def test_tdf134960_hyperlinks(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf134960.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + # Without the fix in place, this test would have failed with + # AssertionError: 'Hyperlink 2' != 'Hyperlink 6' + self.launch_sidebar(xWriterEdit) + + def test_tdf134960_hyperlinks_with_multiple_pages(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf134960.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + # Insert a page break so we have different links in different pages + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.xUITest.executeCommand(".uno:InsertPagebreak") + self.assertEqual("3", get_state_as_dict(xWriterEdit)["Pages"]) + + # Change view to 20% and 2 columns + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + variable = xDialog.getChild("variable") + variable.executeAction("CLICK", tuple()) + + zoomsb = xDialog.getChild("zoomsb") + zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + zoomsb.executeAction("TYPE", mkPropertyValues({"TEXT":"20"})) + + columns = xDialog.getChild("columns") + columns.executeAction("CLICK", tuple()) + + columnssb = xDialog.getChild("columnssb") + columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + columnssb.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + + # Without the fix in place, this test would have failed with + # AssertionError: 'Hyperlink 2' != 'Hyperlink 8' + self.launch_sidebar(xWriterEdit) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf137274.py b/sw/qa/uitest/navigator/tdf137274.py new file mode 100644 index 0000000000..711e813343 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf137274.py @@ -0,0 +1,88 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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 +import time + +class tdf137274(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def test_tdf137274(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") + + xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"})) + + # Insert first comment + xArgs = mkPropertyValues({"Text": "C1"}) + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + + # wait until the comment is available + self.ui_test.wait_until_child_is_available('Comment1') + + self.xUITest.executeCommand(".uno:Sidebar") + + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + xContentTree = xNavigatorPanel.getChild("contenttree") + xComments = self.get_item(xContentTree, 'Comments') + self.assertEqual('Comments', get_state_as_dict(xComments)['Text']) + + xComments.executeAction("EXPAND", tuple()) + + self.assertEqual(1, len(xComments.getChildren())) + self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text']) + + xComments.executeAction("COLLAPSE", tuple()) + + xArgs = mkPropertyValues({"Text": "C2"}) + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + + # wait until the second comment is available + self.ui_test.wait_until_child_is_available('Comment2') + + # xComments needs reassigned after content tree change + while True: + xComments = self.get_item(xContentTree, 'Comments') + if '1' in xComments.getChildren(): + break + time.sleep(self.ui_test.get_default_sleep()) + self.assertEqual('Comments', get_state_as_dict(xComments)['Text']) + + xComments.executeAction("EXPAND", tuple()) + + # Without the fix in place, this test would have failed with AssertionError: 2 != 0 + self.assertEqual(2, len(xComments.getChildren())) + self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text']) + + xComments.executeAction("COLLAPSE", tuple()) + + self.xUITest.executeCommand(".uno:Sidebar") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf140257.py b/sw/qa/uitest/navigator/tdf140257.py new file mode 100644 index 0000000000..fc2787bf0d --- /dev/null +++ b/sw/qa/uitest/navigator/tdf140257.py @@ -0,0 +1,112 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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 +from uitest.uihelper.common import select_by_text + +class Tdf140257(UITestCase): + + def change_outline_level(self, sText): + + with self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + + xOutline = xDialog.getChild("comboLB_OUTLINE_LEVEL") + + select_by_text(xOutline, sText) + + + def test_tdf140257(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + 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 + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + 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") + + 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 + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + 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") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf140661.py b/sw/qa/uitest/navigator/tdf140661.py new file mode 100644 index 0000000000..c3689f51cf --- /dev/null +++ b/sw/qa/uitest/navigator/tdf140661.py @@ -0,0 +1,70 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf140661(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def launch_navigator(self, bIsBeforeUngroup): + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild("contenttree") + xDrawings = self.get_item(xContentTree, 'Drawing objects') + self.assertEqual('Drawing objects', get_state_as_dict(xDrawings)['Text']) + + xDrawings.executeAction("EXPAND", tuple()) + + if bIsBeforeUngroup: + self.assertEqual(1, len(xDrawings.getChildren())) + self.assertEqual('DrawObject1', get_state_as_dict(xDrawings.getChild('0'))['Text']) + else: + self.assertEqual(12, len(xDrawings.getChildren())) + + # tdf#134960 + expectedShapeOrder = [1, 2, 8, 9, 7, 10, 11, 3, 12, 4, 5, 6] + for i in range(12): + self.assertEqual('Shape' + str(expectedShapeOrder[i]), get_state_as_dict(xDrawings.getChild(str(i)))['Text']) + + xDrawings.executeAction("COLLAPSE", tuple()) + + self.xUITest.executeCommand(".uno:Sidebar") + + def test_tdf140661(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf140661.odt")): + + self.launch_navigator(True) + + # Select the shape and ungroup it + self.xUITest.executeCommand(".uno:JumpToNextFrame") + + self.ui_test.wait_until_child_is_available('metricfield') + + self.xUITest.executeCommand(".uno:FormatUngroup") + + # Without the fix in place, this test would have failed with + # AssertionError: 12 != 0 + self.launch_navigator(False) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf143569.py b/sw/qa/uitest/navigator/tdf143569.py new file mode 100644 index 0000000000..e41a1c6805 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf143569.py @@ -0,0 +1,69 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf143569(UITestCase): + + def test_Tdf143569(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf143569.odt")): + + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild("contenttree") + + xHeadings = xContentTree.getChild('0') + self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text']) + self.assertEqual("1", get_state_as_dict(xHeadings)['Children']) + + xHeadings.executeAction("EXPAND", tuple()) + + xChild = xHeadings.getChild('0') + + # Without the fix in place, this test would have failed with + # AssertionError: 'Introduction' != 'Anchored to Paragraph' + self.assertEqual('Introduction', get_state_as_dict(xChild)['Text']) + self.assertEqual("1", get_state_as_dict(xChild)['Children']) + + xChild.executeAction("EXPAND", tuple()) + + xChild = xChild.getChild('0') + self.assertEqual('Problem', get_state_as_dict(xChild)['Text']) + self.assertEqual("1", get_state_as_dict(xChild)['Children']) + + xChild.executeAction("EXPAND", tuple()) + + xChild = xChild.getChild('0') + self.assertEqual('Discussion Agenda', get_state_as_dict(xChild)['Text']) + self.assertEqual("2", get_state_as_dict(xChild)['Children']) + + xChild.executeAction("EXPAND", tuple()) + + xChild1 = xChild.getChild('0') + self.assertEqual('Anchored to Paragraph', get_state_as_dict(xChild1)['Text']) + self.assertEqual("0", get_state_as_dict(xChild1)['Children']) + + xChild2 = xChild.getChild('1') + self.assertEqual('Anchored as Character', get_state_as_dict(xChild2)['Text']) + self.assertEqual("0", get_state_as_dict(xChild2)['Children']) + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf144672.py b/sw/qa/uitest/navigator/tdf144672.py new file mode 100644 index 0000000000..edbafb616b --- /dev/null +++ b/sw/qa/uitest/navigator/tdf144672.py @@ -0,0 +1,68 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf144672(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def test_Tdf144672(self): + with self.ui_test.load_file(get_url_for_data_file("tdf144672.odt")): + + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + xContentTree = xNavigatorPanel.getChild("contenttree") + + xReferences = self.get_item(xContentTree, 'References') + self.assertEqual('References', get_state_as_dict(xReferences)['Text']) + + # tdf#129625: Without the fix in place, this test would have failed with + # AssertionError: 'true' != 'false' + self.assertEqual('true', get_state_as_dict(xReferences)['IsSemiTransparent']) + + xIndexes = self.get_item(xContentTree, 'Indexes') + self.assertEqual('Indexes', get_state_as_dict(xIndexes)['Text']) + self.assertEqual('false', get_state_as_dict(xIndexes)['IsSemiTransparent']) + + xIndexes.executeAction("EXPAND", tuple()) + + self.assertEqual('3', get_state_as_dict(xIndexes)['Children']) + + for i in range(3): + # Without the fix in place, this test would have failed here with + # AssertionError: 'false' != 'true' + self.assertEqual('false', get_state_as_dict(xIndexes.getChild(i))['IsSemiTransparent']) + + xIndexes.executeAction("COLLAPSE", tuple()) + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf148198.py b/sw/qa/uitest/navigator/tdf148198.py new file mode 100644 index 0000000000..3e7b00e7d5 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf148198.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf148198(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def test_tdf148198(self): + sHyperlink0 = 'a hyperlink with an anchor, different character styles, a footnote1, a field This is a bookmark, and a rsid' + sHyperlink1 = 'another hyperlink' + + with self.ui_test.load_file(get_url_for_data_file('hyperlink_multiple_spans.fodt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') + + self.xUITest.executeCommand('.uno:Sidebar') + xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild('contenttree') + xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') + self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) + + xHyperlinks.executeAction('EXPAND', tuple()) + + self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children']) + self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text']) + self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text']) + + # save and reload: the first hyperlink must be kept in one piece + self.xUITest.executeCommand('.uno:Save') + self.xUITest.executeCommand('.uno:Reload') + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild('contenttree') + xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') + self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) + + xHyperlinks.executeAction('EXPAND', tuple()) + + # without the fix in place, this would fail: + # AssertionError: '2' != '11' + self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children']) + self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text']) + self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text']) + + self.xUITest.executeCommand('.uno:Sidebar') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf149268.py b/sw/qa/uitest/navigator/tdf149268.py new file mode 100644 index 0000000000..38b42c376e --- /dev/null +++ b/sw/qa/uitest/navigator/tdf149268.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf149268(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def test_tdf149268(self): + with self.ui_test.load_file(get_url_for_data_file("tdf149268.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + + # Without the fix in place, this test would have crashed here + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild("contenttree") + xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') + self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) + + xHyperlinks.executeAction("EXPAND", tuple()) + + self.assertEqual("4", get_state_as_dict(xHyperlinks)['Children']) + self.assertEqual('Internet', get_state_as_dict(xHyperlinks.getChild('0'))['Text']) + self.assertEqual('1234567', get_state_as_dict(xHyperlinks.getChild('1'))['Text']) + self.assertEqual('yyyy', get_state_as_dict(xHyperlinks.getChild('2'))['Text']) + self.assertEqual('zzz', get_state_as_dict(xHyperlinks.getChild('3'))['Text']) + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf149916.py b/sw/qa/uitest/navigator/tdf149916.py new file mode 100644 index 0000000000..cce7b8a122 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf149916.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf149916(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def test_tdf149916(self): + + with self.ui_test.load_file(get_url_for_data_file('tdf149916.odt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') + + self.xUITest.executeCommand('.uno:Sidebar') + xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild('contenttree') + xFields = self.get_item(xContentTree, 'Fields') + self.assertEqual('Fields', get_state_as_dict(xFields)['Text']) + + xFields.executeAction('EXPAND', tuple()) + + self.assertEqual('1', get_state_as_dict(xFields)['Children']) + + # Without the fix in place, this test would have failed with + # AssertionError: 'cross-reference - First - 1' != 'cross-reference - __RefHeading___Toc45_480138666 - 1' + self.assertEqual('cross-reference - First - 1', get_state_as_dict(xFields.getChild('0'))['Text']) + + self.xUITest.executeCommand('.uno:Sidebar') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf151051.py b/sw/qa/uitest/navigator/tdf151051.py new file mode 100644 index 0000000000..03889c7f49 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf151051.py @@ -0,0 +1,59 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf151051(UITestCase): + + def test_tdf151051(self): + + with self.ui_test.load_file(get_url_for_data_file('tdf151051.odt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') + + self.xUITest.executeCommand('.uno:Sidebar') + xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + xContentTree = xNavigatorPanel.getChild("contenttree") + + xHeadings = xContentTree.getChild('0') + xHeadings.executeAction("EXPAND", tuple()) + + xChild = xHeadings.getChild('0') + self.assertEqual('0', get_state_as_dict(xChild)['Children']) + + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content6") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) # 'promote' button + + xHeadings = xContentTree.getChild('0') + xHeadings.executeAction("EXPAND", tuple()) + + xChild = xHeadings.getChild('0') + xChild.executeAction("EXPAND", tuple()) + + # Without the fix in place, this test would have failed with + # AssertionError: '1' != '0' + self.assertEqual('1', get_state_as_dict(xChild)['Children']) + + self.xUITest.executeCommand('.uno:Sidebar') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf154212.py b/sw/qa/uitest/navigator/tdf154212.py new file mode 100644 index 0000000000..00a39a73b9 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf154212.py @@ -0,0 +1,83 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf154212(UITestCase): + + def test_tdf154212(self): + + with self.ui_test.load_file(get_url_for_data_file('tdf154212.odt')): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') + + self.xUITest.executeCommand('.uno:Sidebar') + xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") + # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that + # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the + # xInsert click above. + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.waitUntilAllIdlesDispatched() + + xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree") + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple()) + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + xHeadingsChild0.executeAction("EXPAND", tuple()) + + xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2") + + # double click on the entry to select and set focus + xHeadingsChild0Child2.executeAction("DOUBLECLICK", tuple()) + + # click on the 'move chapter down' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2") + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + + xHeadingsChild0Child4 = xHeadingsChild0.getChild('4') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child4)["Text"], "MOVE THIS Heading level 2") + + # click on the 'move chapter up' button in the Navigator tool box + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBarContent6 = xNavigatorPanel.getChild("content6") + xToolBarContent6.executeAction("CLICK", mkPropertyValues({"POS": "4"})) + + self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2") + + xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') + + xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') + + # Without the fix in place, this test would have failed with + # AssertionError: 'MOVE THIS Heading level 2' != 'Heading level 1' + self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "Heading level 1") + + xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') + self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2") + + self.xUITest.executeCommand('.uno:Sidebar') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf154521.py b/sw/qa/uitest/navigator/tdf154521.py new file mode 100644 index 0000000000..048efb0212 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf154521.py @@ -0,0 +1,203 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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 +from com.sun.star.view import XSelectionChangeListener +import unohelper + +selectionChangedResult = 0 + +class XSelectionChangeListenerExtended(unohelper.Base, XSelectionChangeListener): + # is invoked when a text selected, e.g. by selecting a bookmark in the Navigator + @classmethod + def selectionChanged(self, event): + global selectionChangedResult + selection = event.Source.getSelection() + if selection.supportsService("com.sun.star.text.TextRanges"): + textRange = selection.getByIndex(0) + if textRange.getString() == "foo": + selectionChangedResult = 1 + else: + selectionChangedResult = -1 + + @classmethod + def disposing(self, event): + pass + +class tdf154521(UITestCase): + + def test_tdf154521(self): + global selectionChangedResult + with self.ui_test.create_doc_in_start_center("writer") as xDoc: + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content5") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + + # type "foo", and create a bookmark on it + + self.xUITest.executeCommand(".uno:Escape") + + xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): + pass + + xWriterEdit.executeAction("FOCUS", tuple()) + + # add XSelectionChangeListener + + xListener = XSelectionChangeListenerExtended() + self.assertIsNotNone(xListener) + xDoc.CurrentController.addSelectionChangeListener(xListener) + + xContentTree = xNavigatorPanel.getChild("contenttree") + + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + # select bookmark to trigger selectionChanged event + + xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # wait for handling the selectionChanged event + while selectionChangedResult == 0: + pass + + # This was -1 (missing selection because of early broadcasting) + self.assertEqual(selectionChangedResult, 1) + + self.xUITest.executeCommand(".uno:Sidebar") + + def getTitle(self, document): + xController = document.getCurrentController() + xSidebar = xController.getSidebar() + xDecks = xSidebar.getDecks() + xNavigator = xDecks['NavigatorDeck'] + xPanels = xNavigator.getPanels() + xPanel = xPanels['SwNavigatorPanel'] + title = xPanel.getTitle() + # empty title of SwNavigatorPanel to allow to query the name of the selected bookmark + xPanel.setTitle("") + return title + + def test_query_selected_bookmark(self): + global selectionChangedResult + with self.ui_test.create_doc_in_start_center("writer") as xDoc: + + # click on the bookmark name in the Navigator + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content5") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + + # type "foo", and create 3 bookmarks on it + + self.xUITest.executeCommand(".uno:Escape") + + xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) + self.xUITest.executeCommand(".uno:SelectAll") + + for i in range(3): + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): + pass + + # check selected bookmarks in Navigator + + xWriterEdit.executeAction("FOCUS", tuple()) + + xContentTree = xNavigatorPanel.getChild("contenttree") + +# disable flakey UITest +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +## self.xUITest.executeCommand(".uno:Escape") + +# # get the title of SwNavigatorPanel with emptying it to access to the selected bookmark +# self.assertEqual(self.getTitle(xDoc), "Navigator") +# # title was emptied +# self.assertEqual(self.getTitle(xDoc), "") + +# # Select nested bookmark in Navigator + +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + +# # This jumped to Bookmark 1 after selection +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +# # This was "Navigator" +# self.assertEqual(self.getTitle(xDoc), "Bookmark 1") + +# # Try the same selection with Bookmark 2 +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +# # This was "Navigator" +# self.assertEqual(self.getTitle(xDoc), "Bookmark 2") + +# # Try the same selection with Bookmark 3 + +# # why we need this extra UP? +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2") +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 3") + +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 3") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 3") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 3") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +# # This was "Navigator" +# self.assertEqual(self.getTitle(xDoc), "Bookmark 3") + +# # go to the previous item + +# # why we need this extra UP? +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 3") +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmarks") +# self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmarks") +# xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + +# # This was "Navigator" +# self.assertEqual(self.getTitle(xDoc), "") + +# self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf154545.py b/sw/qa/uitest/navigator/tdf154545.py new file mode 100644 index 0000000000..ac034af930 --- /dev/null +++ b/sw/qa/uitest/navigator/tdf154545.py @@ -0,0 +1,97 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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 + +class tdf154545(UITestCase): + + def test_tdf154545(self): + global selectionChangedResult + with self.ui_test.create_doc_in_start_center("writer") as xDoc: + + # click on the bookmark name in the Navigator + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content5") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + + # type "foo", and create a bookmark on it + + xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): + pass + + # check selected bookmark in Navigator + + xWriterEdit.executeAction("FOCUS", tuple()) + + xContentTree = xNavigatorPanel.getChild("contenttree") + + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + self.xUITest.executeCommand(".uno:Escape") + + # create a nested bookmark on the last "o" + + cursor = xDoc.getCurrentController().getViewCursor() + cursor.goLeft(1, True) + + with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): + pass + + self.xUITest.executeCommand(".uno:Escape") + + # check selected nested bookmark in Navigator + + # This never occurred: Navigator didn't track nested bookmarks + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2") + # This was Bookmark 1 + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + # Select nested bookmark in Navigator + + xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # This jumped to Bookmark 1 after selection + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2") + # This was Bookmark 1 + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + # Try the same selection with Bookmark 1 + xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + + # go to the previous item + xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmarks") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmarks") + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf40427.py b/sw/qa/uitest/navigator/tdf40427.py new file mode 100644 index 0000000000..aaab63ffdd --- /dev/null +++ b/sw/qa/uitest/navigator/tdf40427.py @@ -0,0 +1,97 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +class tdf40427(UITestCase): + + def get_item(self, xTree, name): + for i in xTree.getChildren(): + xItem = xTree.getChild(i) + if name == get_state_as_dict(xItem)['Text']: + return xItem + + def expand_all(self, xTreeItem): + count = len(xTreeItem.getChildren()) + for i in xTreeItem.getChildren(): + xTreeItem.getChild(i).executeAction("EXPAND", ()) + count += self.expand_all(xTreeItem.getChild(i)) + return count + + def get_names(self, xTreeItem): + names = [] + for i in xTreeItem.getChildren(): + names.append(get_state_as_dict(xTreeItem.getChild(str(i)))['Text']) + names += self.get_names(xTreeItem.getChild(i)) + return names + + def test_tdf40427(self): + with self.ui_test.load_file(get_url_for_data_file("tdf40427_SectionPositions.odt")) as document: + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") + + self.assertEqual(2, document.CurrentController.PageCount) + + # Make sure that the view is 2 pages side-by-side - look at dialog View-Zoom-Zoom + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + + columnssb = xDialog.getChild("columnssb") + columns = xDialog.getChild("columns") + bookmode = xDialog.getChild("bookmode") + self.assertEqual("true", get_state_as_dict(columns)["Checked"]) + self.assertEqual("2", get_state_as_dict(columnssb)["Text"]) + self.assertEqual("false", get_state_as_dict(bookmode)["Selected"]) + + + # In this view, the sections "SectionB" and "SectionC" on second page are positioned on screen + # higher than "SectionY" and "SectionA" respectively; there are nested and anchored sections. + # Make sure that order in Navigator follows their relative position in document, not vertical + # position on screen, nor sorted alphabetically. Sections in flying frames are sorted by their + # anchor position in the document. + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + + xContentTree = xNavigatorPanel.getChild("contenttree") + xSections = self.get_item(xContentTree, 'Sections') + self.assertEqual('Sections', get_state_as_dict(xSections)['Text']) + xSections.executeAction("EXPAND", ()) + totalSectionsCount = self.expand_all(xSections) + + refSectionNames = [ + 'SectionZ', + 'SectionY', # SectionB should not get before this, despite its Y position on screen is higher + 'SectionT3', # Sections in tables go in rows, then across rows + 'SectionT1', + 'SectionT2', + 'SectionT0', + 'SectionF2', # Goes before SectionF1, because their fly anchors go in that order + 'SectionF3', # Same as SectionF1, but anchor section is in fly itself + 'SectionFinF3', # Check order of nested sections inside fly + 'SectionA', + 'SectionF1', # Section in fly anchored in a section goes immediately after its anchor section + 'SectionB', # High on screen, but late in list because it's on second page + 'SectionC', + ] + self.assertEqual(len(refSectionNames), totalSectionsCount) + + actSectionNames = self.get_names(xSections) + + # Without the fix in place, this would fail with + # AssertionError: Lists differ: ['SectionZ', 'SectionY', 'SectionT3', 'SectionT1', 'SectionT2'[100 chars]onC'] != ['SectionZ', 'SectionB', 'SectionF3', 'SectionFinF3', 'Section[100 chars]onA'] + self.assertEqual(refSectionNames, actSectionNames) + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit v1.2.3