Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / navigator / tdf154212.py
blob0aaa8e04b23f4448199d2da3bb8e1c6ad3a321fe
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 # 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()
35 xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree")
37 xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0')
38 xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple())
40 xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0')
41 xHeadingsChild0.executeAction("EXPAND", tuple())
43 xHeadingsChild0Child2 = xHeadingsChild0.getChild('2')
44 self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2")
46 # double click on the entry to select and set focus
47 xHeadingsChild0Child2.executeAction("DOUBLECLICK", tuple())
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"}))
54 self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2")
56 xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0')
58 xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0')
60 xHeadingsChild0Child4 = xHeadingsChild0.getChild('4')
61 self.assertEqual(get_state_as_dict(xHeadingsChild0Child4)["Text"], "MOVE THIS Heading level 2")
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"}))
68 self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "MOVE THIS Heading level 2")
70 xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0')
72 xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0')
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")
78 xHeadingsChild0Child2 = xHeadingsChild0.getChild('2')
79 self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "MOVE THIS Heading level 2")
81 self.xUITest.executeCommand('.uno:Sidebar')
83 # vim: set shiftwidth=4 softtabstop=4 expandtab: