1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
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/.
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
14 class tdf154212(UITestCase
):
16 def test_tdf154212(self
):
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')
22 self
.xUITest
.executeCommand('.uno:Sidebar')
23 xWriterEdit
.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'}))
25 # wait until the navigator panel is available
26 xNavigatorPanel
= self
.ui_test
.wait_until_child_is_available('NavigatorPanel')
28 xNavigatorPanelContentTree
= xNavigatorPanel
.getChild("contenttree")
30 xNavigatorPanelContentTreeHeadings
= xNavigatorPanelContentTree
.getChild('0')
31 xNavigatorPanelContentTreeHeadings
.executeAction("EXPAND", tuple())
33 xHeadingsChild0
= xNavigatorPanelContentTreeHeadings
.getChild('0')
34 xHeadingsChild0
.executeAction("EXPAND", tuple())
36 xHeadingsChild0Child2
= xHeadingsChild0
.getChild('2')
37 self
.assertEqual(get_state_as_dict(xHeadingsChild0Child2
)["Text"], "MOVE THIS Heading level 2")
39 # double click on the entry to select and set focus
40 xHeadingsChild0Child2
.executeAction("DOUBLECLICK", tuple())
42 # click on the 'move chapter down' button in the Navigator tool box
43 xNavigatorPanel
= xWriterEdit
.getChild("NavigatorPanel")
44 xToolBarContent6
= xNavigatorPanel
.getChild("content6")
45 xToolBarContent6
.executeAction("CLICK", mkPropertyValues({"POS": "5"}))
47 self
.ui_test
.wait_until_property_is_updated(xNavigatorPanelContentTree
, "SelectEntryText", "MOVE THIS Heading level 2")
49 xNavigatorPanelContentTreeHeadings
= xNavigatorPanelContentTree
.getChild('0')
51 xHeadingsChild0
= xNavigatorPanelContentTreeHeadings
.getChild('0')
53 xHeadingsChild0Child4
= xHeadingsChild0
.getChild('4')
54 self
.assertEqual(get_state_as_dict(xHeadingsChild0Child4
)["Text"], "MOVE THIS Heading level 2")
56 # click on the 'move chapter up' button in the Navigator tool box
57 xNavigatorPanel
= xWriterEdit
.getChild("NavigatorPanel")
58 xToolBarContent6
= xNavigatorPanel
.getChild("content6")
59 xToolBarContent6
.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
61 self
.ui_test
.wait_until_property_is_updated(xNavigatorPanelContentTree
, "SelectEntryText", "MOVE THIS Heading level 2")
63 xNavigatorPanelContentTreeHeadings
= xNavigatorPanelContentTree
.getChild('0')
65 xHeadingsChild0
= xNavigatorPanelContentTreeHeadings
.getChild('0')
67 # Without the fix in place, this test would have failed with
68 # AssertionError: 'MOVE THIS Heading level 2' != 'Heading level 1'
69 self
.assertEqual(get_state_as_dict(xHeadingsChild0
)["Text"], "Heading level 1")
71 xHeadingsChild0Child2
= xHeadingsChild0
.getChild('2')
72 self
.assertEqual(get_state_as_dict(xHeadingsChild0Child2
)["Text"], "MOVE THIS Heading level 2")
74 self
.xUITest
.executeCommand('.uno:Sidebar')
76 # vim: set shiftwidth=4 softtabstop=4 expandtab: