Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / navigator / tdf144672.py
blobedbafb616bd7f9efa7b48a2afc99893d5d829084
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 tdf144672(UITestCase):
16 def get_item(self, xTree, name):
17 for i in xTree.getChildren():
18 xItem = xTree.getChild(i)
19 if name == get_state_as_dict(xItem)['Text']:
20 return xItem
22 def test_Tdf144672(self):
23 with self.ui_test.load_file(get_url_for_data_file("tdf144672.odt")):
25 xMainWindow = self.xUITest.getTopFocusWindow()
26 xWriterEdit = xMainWindow.getChild("writer_edit")
28 self.xUITest.executeCommand(".uno:Sidebar")
30 xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
32 # wait until the navigator panel is available
33 xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
35 # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons")
36 # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that
37 # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the
38 # xInsert click above.
39 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
40 xToolkit.waitUntilAllIdlesDispatched()
42 xContentTree = xNavigatorPanel.getChild("contenttree")
44 xReferences = self.get_item(xContentTree, 'References')
45 self.assertEqual('References', get_state_as_dict(xReferences)['Text'])
47 # tdf#129625: Without the fix in place, this test would have failed with
48 # AssertionError: 'true' != 'false'
49 self.assertEqual('true', get_state_as_dict(xReferences)['IsSemiTransparent'])
51 xIndexes = self.get_item(xContentTree, 'Indexes')
52 self.assertEqual('Indexes', get_state_as_dict(xIndexes)['Text'])
53 self.assertEqual('false', get_state_as_dict(xIndexes)['IsSemiTransparent'])
55 xIndexes.executeAction("EXPAND", tuple())
57 self.assertEqual('3', get_state_as_dict(xIndexes)['Children'])
59 for i in range(3):
60 # Without the fix in place, this test would have failed here with
61 # AssertionError: 'false' != 'true'
62 self.assertEqual('false', get_state_as_dict(xIndexes.getChild(i))['IsSemiTransparent'])
64 xIndexes.executeAction("COLLAPSE", tuple())
66 self.xUITest.executeCommand(".uno:Sidebar")
68 # vim: set shiftwidth=4 softtabstop=4 expandtab: