Debian Codegraph @

sw/qa/uitest/navigator/tdf151051.py

raw
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 tdf151051(UITestCase):
15
16 def test_tdf151051(self):
17
18 with self.ui_test.load_file(get_url_for_data_file('tdf151051.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 xContentTree = xNavigatorPanel.getChild("contenttree")
36
37 xHeadings = xContentTree.getChild('0')
38 xHeadings.executeAction("EXPAND", tuple())
39
40 xChild = xHeadings.getChild('0')
41 self.assertEqual('0', get_state_as_dict(xChild)['Children'])
42
43 xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel")
44 xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar")
45 xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'promote' button
46
47 xHeadings = xContentTree.getChild('0')
48 xHeadings.executeAction("EXPAND", tuple())
49
50 xChild = xHeadings.getChild('0')
51 xChild.executeAction("EXPAND", tuple())
52
53 # Without the fix in place, this test would have failed with
54 # AssertionError: '1' != '0'
55 self.assertEqual('1', get_state_as_dict(xChild)['Children'])
56
57 self.xUITest.executeCommand('.uno:Sidebar')
58
59 # vim: set shiftwidth=4 softtabstop=4 expandtab: