tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / sfx2 / qa / python / check_sidebar.py
blob3ea8542d2e03e0f616bbfca3d1bd0e91b5cb6a1e
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 import unittest
11 from org.libreoffice.unotest import UnoInProcess
14 class CheckSidebar(unittest.TestCase):
16 @classmethod
17 def setUpClass(cls):
18 cls._uno = UnoInProcess()
19 cls._uno.setUp()
21 @classmethod
22 def tearDownClass(cls):
23 cls._uno.tearDown()
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()
31 assert(xSidebar)
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]
57 assert ( xDeck )
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 )
64 xDeck.moveFirst()
65 initial_index = xDeck.getOrderIndex()
66 self.assertEqual(100, initial_index)
68 xDeck.moveLast()
69 assert ( xDeck.getOrderIndex() > initial_index )
71 initial_index = xDeck.getOrderIndex()
72 xDeck.moveFirst()
73 assert ( xDeck.getOrderIndex() < initial_index )
75 initial_index = xDeck.getOrderIndex()
76 xDeck.moveDown()
77 assert ( xDeck.getOrderIndex() > initial_index )
79 initial_index = xDeck.getOrderIndex()
80 xDeck.moveUp()
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]
95 assert ( xPanel )
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()
103 xPanel.moveLast()
104 assert ( xPanel.getOrderIndex() > initial_index )
106 initial_index = xPanel.getOrderIndex()
107 xPanel.moveFirst()
108 assert ( xPanel.getOrderIndex() < initial_index )
110 initial_index = xPanel.getOrderIndex()
111 xPanel.moveDown()
112 assert ( xPanel.getOrderIndex() > initial_index )
114 initial_index = xPanel.getOrderIndex()
115 xPanel.moveUp()
116 assert ( xPanel.getOrderIndex() < initial_index )
118 xPanel.collapse()
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() )
127 xPanel.expand(True)
128 assert( xPanel.isExpanded() )
129 assert( not other_panel.isExpanded() )
131 # close the document
132 xDoc.dispose()
134 def getFirstPanel(self, xPanels):
136 panel_name = ""
137 cur_index = 10000
139 for panel in xPanels:
140 if panel.getOrderIndex() < cur_index:
141 panel_name = panel.getId()
142 cur_index = panel.getOrderIndex()
144 return panel_name
146 def getLastPanel(self, xPanels):
148 panel_name = ""
149 cur_index = 0
151 for panel in xPanels:
152 if panel.getOrderIndex() > cur_index:
153 panel_name = panel.getId()
154 cur_index = panel.getOrderIndex()
156 return panel_name
158 if __name__ == "__main__":
159 unittest.main()
161 # vim: set shiftwidth=4 softtabstop=4 expandtab: