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/.
11 from org
.libreoffice
.unotest
import UnoInProcess
14 class CheckSidebar(unittest
.TestCase
):
18 cls
._uno
= UnoInProcess()
22 def tearDownClass(cls
):
25 def test_check_sidebar(self
):
27 xDoc
= self
.__class
__._uno
.openEmptyDoc( url
= "private:factory/scalc", bHidden
= False, bReadOnly
= False)
28 xController
= xDoc
.getCurrentController()
30 xSidebar
= xController
.getSidebar()
33 xSidebar
.setVisible(True)
34 self
.assertTrue ( xSidebar
.isVisible() )
36 # TODO: does not work in unit test context
37 # xSidebar.setVisible(False)
38 # isVisible = xSidebar.isVisible()
39 # assert( not isVisible )
40 # xSidebar.setVisible(True)
42 xSidebar
.showDecks(False)
43 xSidebar
.showDecks(True)
45 xDecks
= xSidebar
.getDecks()
47 first_deck_name
= "PropertyDeck"
49 deck_element_names
= xDecks
.getElementNames()
50 assert ( first_deck_name
in deck_element_names
)
51 assert ( xDecks
.hasByName(first_deck_name
) )
53 decks_count
= len(xDecks
)
54 self
.assertEqual ( 5, decks_count
)
56 xDeck
= xDecks
[first_deck_name
]
58 assert ( xDeck
.getId() == first_deck_name
)
60 new_deck_title
= "New title"
61 xDeck
.setTitle(new_deck_title
)
62 assert ( xDeck
.getTitle() == new_deck_title
)
65 initial_index
= xDeck
.getOrderIndex()
66 self
.assertEqual(100, initial_index
)
69 assert ( xDeck
.getOrderIndex() > initial_index
)
71 initial_index
= xDeck
.getOrderIndex()
73 assert ( xDeck
.getOrderIndex() < initial_index
)
75 initial_index
= xDeck
.getOrderIndex()
77 assert ( xDeck
.getOrderIndex() > initial_index
)
79 initial_index
= xDeck
.getOrderIndex()
81 assert ( xDeck
.getOrderIndex() < initial_index
)
83 xPanels
= xDeck
.getPanels()
85 panels_count
= len(xPanels
)
86 self
.assertEqual ( panels_count
, 5 )
88 first_panel_name
= self
.getFirstPanel(xPanels
)
90 panel_element_names
= xPanels
.getElementNames()
91 assert ( first_panel_name
in panel_element_names
)
92 assert ( xPanels
.hasByName(first_panel_name
) )
94 xPanel
= xPanels
[first_panel_name
]
96 assert ( xPanel
.getId() == first_panel_name
)
98 new_title
= "New title"
99 xPanel
.setTitle(new_title
)
100 assert ( xPanel
.getTitle() == new_title
)
102 initial_index
= xPanel
.getOrderIndex()
104 assert ( xPanel
.getOrderIndex() > initial_index
)
106 initial_index
= xPanel
.getOrderIndex()
108 assert ( xPanel
.getOrderIndex() < initial_index
)
110 initial_index
= xPanel
.getOrderIndex()
112 assert ( xPanel
.getOrderIndex() > initial_index
)
114 initial_index
= xPanel
.getOrderIndex()
116 assert ( xPanel
.getOrderIndex() < initial_index
)
119 assert( not xPanel
.isExpanded() )
121 last_panel_name
= self
.getLastPanel(xPanels
)
123 other_panel
= xPanels
[last_panel_name
]
124 other_panel
.expand(False)
125 assert( other_panel
.isExpanded() )
128 assert( xPanel
.isExpanded() )
129 assert( not other_panel
.isExpanded() )
134 def getFirstPanel(self
, xPanels
):
139 for panel
in xPanels
:
140 if panel
.getOrderIndex() < cur_index
:
141 panel_name
= panel
.getId()
142 cur_index
= panel
.getOrderIndex()
146 def getLastPanel(self
, xPanels
):
151 for panel
in xPanels
:
152 if panel
.getOrderIndex() > cur_index
:
153 panel_name
= panel
.getId()
154 cur_index
= panel
.getOrderIndex()
158 if __name__
== "__main__":
161 # vim: set shiftwidth=4 softtabstop=4 expandtab: