| 1 |
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 5 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
# |
| 9 |
|
| 10 |
from uitest.framework import UITestCase |
| 11 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 12 |
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file |
| 13 |
|
| 14 |
class tdf154212(UITestCase): |
| 15 |
|
| 16 |
def test_tdf154212(self): |
| 17 |
|
| 18 |
with self.ui_test.load_file(get_url_for_data_file('tdf154212.odt')): |
| 19 |
xWriterDoc = self.xUITest.getTopFocusWindow() |
| 20 |
xWriterEdit = xWriterDoc.getChild('writer_edit') |
| 21 |
|
| 22 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 23 |
xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) |
| 24 |
|
| 25 |
# wait until the navigator panel is available |
| 26 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 27 |
|
| 28 |
# See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") |
| 29 |
# in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that |
| 30 |
# m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the |
| 31 |
# xInsert click above. |
| 32 |
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') |
| 33 |
xToolkit.waitUntilAllIdlesDispatched() |
| 34 |
|
| 35 |
xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree") |
| 36 |
|
| 37 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 38 |
xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple()) |
| 39 |
|
| 40 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 41 |
xHeadingsChild0.executeAction("EXPAND", tuple()) |
| 42 |
|
| 43 |
xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') |
| 44 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2") |
| 45 |
|
| 46 |
# double click on the entry to select and set focus |
| 47 |
xHeadingsChild0Child2.executeAction("DOUBLECLICK", tuple()) |
| 48 |
|
| 49 |
# click on the 'move chapter down' button in the Navigator tool box |
| 50 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 51 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 52 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 53 |
|
| 54 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2") |
| 55 |
|
| 56 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 57 |
|
| 58 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 59 |
|
| 60 |
xHeadingsChild0Child4 = xHeadingsChild0.getChild('4') |
| 61 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child4)["Text"], "MOVE THIS Heading level 2") |
| 62 |
|
| 63 |
# click on the 'move chapter up' button in the Navigator tool box |
| 64 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 65 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 66 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 67 |
|
| 68 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2") |
| 69 |
|
| 70 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 71 |
|
| 72 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 73 |
|
| 74 |
# Without the fix in place, this test would have failed with |
| 75 |
# AssertionError: 'MOVE THIS Heading level 2' != 'Heading level 1' |
| 76 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "Heading level 1") |
| 77 |
|
| 78 |
xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') |
| 79 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2") |
| 80 |
|
| 81 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 82 |
|
| 83 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |