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
14 class tdf152921(UITestCase
):
16 def test_tdf152921(self
):
17 with self
.ui_test
.create_doc_in_start_center("writer"):
18 xWriterEdit
= self
.xUITest
.getTopFocusWindow().getChild("writer_edit")
20 # open the sidebar if need, it should already be open on a clean run
21 if 'TabBar' not in xWriterEdit
.Children
:
22 self
.xUITest
.executeCommand(".uno:Sidebar")
24 xTabBar
= xWriterEdit
.getChild('TabBar')
26 # make sure only the tabbar is visible, no deck
27 xDeckTitleToolBar
= xWriterEdit
.getChild('toolbar')
28 xDeckTitleToolBar
.executeAction("CLICK", mkPropertyValues({"POS": "1"}))
29 # tabbar is visible, deck is not
30 # without the patch this assert would fail, a tab would be highlighted
31 self
.assertFalse(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
33 # open a panel and assert that a tab is highlighted, also assert that only one tab is
34 # highlighted, only a single tab should ever be highlighted
35 xWriterEdit
.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"}))
36 self
.assertTrue(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
37 self
.assertEqual(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds'].split(",")), 1)
39 # click on the 'Close Sidebar Deck' button in the deck title tool bar
40 xDeckTitleToolBar
.executeAction("CLICK", mkPropertyValues({"POS": "1"}))
41 # without the patch this assert would fail, a tab would be highlighted
42 self
.assertFalse(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
44 # open a deck by simulating a click on a tab in the tabbar
45 xTabBar
.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
46 self
.assertTrue(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
47 self
.assertEqual(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds'].split(",")), 1)
49 # close it by clicking on the same tab
50 xTabBar
.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
51 # tabbar is visible, deck is not
52 # without the patch this assert would fail, a tab would be highlighted
53 self
.assertFalse(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
56 xTabBar
.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
57 self
.assertTrue(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
58 self
.assertEqual(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds'].split(",")), 1)
60 # open a different deck
61 xTabBar
.executeAction("CLICK", mkPropertyValues({"POS": "1"}))
62 self
.assertTrue(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
63 self
.assertEqual(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds'].split(",")), 1)
65 # click on the 'Close Sidebar Deck' button
66 xDeckTitleToolBar
.executeAction("CLICK", mkPropertyValues({"POS": "1"}))
67 # without the patch this assert would fail, a tab would be highlighted
68 self
.assertFalse(len(get_state_as_dict(xTabBar
)['HighlightedTabsIds']))
70 # vim: set shiftwidth=4 softtabstop=4 expandtab: