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/.
13 from org
.libreoffice
.unotest
import UnoInProcess
15 from com
.sun
.star
.ui
import XSidebarProvider
16 from com
.sun
.star
.ui
import XDecks
17 from com
.sun
.star
.ui
import XDeck
18 from com
.sun
.star
.ui
import XPanels
19 from com
.sun
.star
.ui
import XPanel
21 class CheckSidebar(unittest
.TestCase
):
25 cls
._uno
= UnoInProcess()
29 def tearDownClass(cls
):
32 def test_check_sidebar(self
):
34 xDoc
= self
.__class
__._uno
.openEmptyDoc( url
= "private:factory/scalc", bHidden
= False, bReadOnly
= False)
35 xController
= xDoc
.getCurrentController()
37 xSidebar
= xController
.getSidebar()
40 xSidebar
.setVisible(True)
41 isVisible
= xSidebar
.isVisible()
42 self
.assertTrue ( xSidebar
.isVisible() )
44 # TODO: does not work in unit test context
45 # xSidebar.setVisible(False)
46 # isVisible = xSidebar.isVisible()
47 # assert( not isVisible )
48 # xSidebar.setVisible(True)
50 xSidebar
.showDecks(False)
51 xSidebar
.showDecks(True)
53 xDecks
= xSidebar
.getDecks()
55 first_deck_name
= "PropertyDeck";
57 deck_element_names
= xDecks
.getElementNames()
58 assert ( first_deck_name
in deck_element_names
)
59 assert ( xDecks
.hasByName(first_deck_name
) )
61 decks_count
= len(xDecks
)
62 self
.assertEqual ( 5, decks_count
)
64 xDeck
= xDecks
[first_deck_name
]
66 assert ( xDeck
.getId() == first_deck_name
)
68 new_deck_title
= "New title"
69 xDeck
.setTitle(new_deck_title
)
70 assert ( xDeck
.getTitle() == new_deck_title
)
73 initial_index
= xDeck
.getOrderIndex()
74 self
.assertEqual(100, initial_index
)
77 assert ( xDeck
.getOrderIndex() > initial_index
)
79 initial_index
= xDeck
.getOrderIndex()
81 assert ( xDeck
.getOrderIndex() < initial_index
)
83 initial_index
= xDeck
.getOrderIndex()
85 assert ( xDeck
.getOrderIndex() > initial_index
)
87 initial_index
= xDeck
.getOrderIndex()
89 assert ( xDeck
.getOrderIndex() < initial_index
)
91 xPanels
= xDeck
.getPanels()
93 panels_count
= len(xPanels
)
94 self
.assertEqual ( panels_count
, 5 )
96 first_panel_name
= self
.getFirstPanel(xPanels
)
98 panel_element_names
= xPanels
.getElementNames()
99 assert ( first_panel_name
in panel_element_names
)
100 assert ( xPanels
.hasByName(first_panel_name
) )
102 xPanel
= xPanels
[first_panel_name
]
104 assert ( xPanel
.getId() == first_panel_name
)
106 new_title
= "New title"
107 xPanel
.setTitle(new_title
)
108 assert ( xPanel
.getTitle() == new_title
)
110 initial_index
= xPanel
.getOrderIndex()
112 assert ( xPanel
.getOrderIndex() > initial_index
)
114 initial_index
= xPanel
.getOrderIndex()
116 assert ( xPanel
.getOrderIndex() < initial_index
)
118 initial_index
= xPanel
.getOrderIndex()
120 assert ( xPanel
.getOrderIndex() > initial_index
)
122 initial_index
= xPanel
.getOrderIndex()
124 assert ( xPanel
.getOrderIndex() < initial_index
)
127 assert( not xPanel
.isExpanded() )
129 last_panel_name
= self
.getLastPanel(xPanels
)
131 other_panel
= xPanels
[last_panel_name
]
132 other_panel
.expand(False)
133 assert( other_panel
.isExpanded() )
136 assert( xPanel
.isExpanded() )
137 assert( not other_panel
.isExpanded() )
142 def getFirstPanel(self
, xPanels
):
147 for panel
in xPanels
:
148 if panel
.getOrderIndex() < cur_index
:
149 panel_name
= panel
.getId()
150 cur_index
= panel
.getOrderIndex()
154 def getLastPanel(self
, xPanels
):
159 for panel
in xPanels
:
160 if panel
.getOrderIndex() > cur_index
:
161 panel_name
= panel
.getId()
162 cur_index
= panel
.getOrderIndex()
166 if __name__
== "__main__":
169 # vim: set shiftwidth=4 softtabstop=4 expandtab: