Update git submodules
[LibreOffice.git] / sc / qa / uitest / calc_tests8 / navigator.py
blob3c4eb1fe1dffd10d8b585c35600720355d44ac80
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
13 from uitest.uihelper.calc import enter_text_to_cell
15 class navigator(UITestCase):
17 def test_rename_sheet(self):
18 with self.ui_test.load_file(get_url_for_data_file("navigator.ods")):
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 xGridWin = xCalcDoc.getChild("grid_window")
22 self.xUITest.executeCommand(".uno:Sidebar")
23 xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
25 xCalcDoc = self.xUITest.getTopFocusWindow()
26 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
27 xContentBox = xNavigatorPanel.getChild('contentbox')
28 xSheets = xContentBox.getChild("0")
29 self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
30 self.assertEqual(len(xSheets.getChildren()), 2)
31 self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1')
32 self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
33 xRangeNames = xContentBox.getChild("1")
34 self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
35 self.assertEqual(len(xRangeNames.getChildren()), 2)
36 self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)')
37 self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)')
39 #The document has one comment too
40 xComments = xContentBox.getChild("6")
41 self.assertEqual(get_state_as_dict(xComments)['Text'], 'Comments')
42 self.assertEqual(len(xComments.getChildren()), 1)
43 self.assertEqual(get_state_as_dict(xComments.getChild('0'))['Text'], 'Test Comment')
45 with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog:
46 xname_entry = xDialog.getChild("name_entry")
47 xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"}))
49 xCalcDoc = self.xUITest.getTopFocusWindow()
50 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
51 xContentBox = xNavigatorPanel.getChild('contentbox')
52 xSheets = xContentBox.getChild("0")
53 self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
54 self.assertEqual(len(xSheets.getChildren()), 2)
55 self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'S1')
56 self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
57 xRangeNames = xContentBox.getChild("1")
58 self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
59 self.assertEqual(len(xRangeNames.getChildren()), 2)
60 self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (S1)')
61 self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (S1)')
63 self.xUITest.executeCommand(".uno:Undo")
65 xCalcDoc = self.xUITest.getTopFocusWindow()
66 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
67 xContentBox = xNavigatorPanel.getChild('contentbox')
68 xSheets = xContentBox.getChild("0")
69 self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
70 self.assertEqual(len(xSheets.getChildren()), 2)
71 self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1')
72 self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
73 xRangeNames = xContentBox.getChild("1")
74 self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
75 self.assertEqual(len(xRangeNames.getChildren()), 2)
76 #FIXME: tdf#133082
77 #self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)')
78 #self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)')
80 self.xUITest.executeCommand(".uno:Sidebar")
82 def test_tdf98493(self):
84 with self.ui_test.load_file(get_url_for_data_file("tdf98493.ods")):
85 xCalcDoc = self.xUITest.getTopFocusWindow()
86 xGridWin = xCalcDoc.getChild("grid_window")
88 self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], "2")
90 self.xUITest.executeCommand(".uno:Sidebar")
91 xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
93 xCalcDoc = self.xUITest.getTopFocusWindow()
94 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
95 xToolBar = xNavigatorPanel.getChild("toolbox2")
96 xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button
98 xContentBox = xNavigatorPanel.getChild('contentbox')
100 # tdf#133079, without the fix in place, it would be 8
101 self.assertEqual(len(xContentBox.getChildren()), 1)
103 xSheets = xContentBox.getChild('0')
104 self.assertEqual(len(xSheets.getChildren()), 12)
106 #key=item position, value=sheet ( there are hidden sheets )
107 results = { '1': '0', '5': '4', '6': '4', '11': '10'}
109 for k, v in results.items():
110 xChild = xSheets.getChild(k)
111 xChild.executeAction("DOUBLECLICK", tuple())
113 self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], v)
115 self.xUITest.executeCommand(".uno:Sidebar")
118 def test_tdf134390(self):
119 with self.ui_test.create_doc_in_start_center("calc"):
120 xCalcDoc = self.xUITest.getTopFocusWindow()
121 xGridWin = xCalcDoc.getChild("grid_window")
123 self.xUITest.executeCommand(".uno:Sidebar")
124 xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
126 xCalcDoc = self.xUITest.getTopFocusWindow()
127 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
128 xToolBar = xNavigatorPanel.getChild("toolbox2")
129 xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button
131 xRow = xNavigatorPanel.getChild('row')
132 xColumn = xNavigatorPanel.getChild('column')
134 self.assertEqual(get_state_as_dict(xColumn)['Value'], '1')
135 self.assertEqual(get_state_as_dict(xRow)['Value'], '1')
136 self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "0")
137 self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "0")
139 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
141 xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
142 xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
143 xColumn.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
144 xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
145 xToolkit.processEventsToIdle()
146 # disable flakey UITest
147 # self.assertEqual(get_state_as_dict(xColumn)['Value'], '2')
149 xRow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
150 xRow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
151 xRow.executeAction("TYPE", mkPropertyValues({"TEXT":"2"}))
152 xRow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
153 xToolkit.processEventsToIdle()
154 self.assertEqual(get_state_as_dict(xRow)['Value'], '2')
156 # Without the fix in place, this test would have failed with
157 # AssertionError: '0' != '1'
158 self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1")
159 # disable flaky test
160 # self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "1")
162 self.xUITest.executeCommand(".uno:Sidebar")
165 def test_tdf141973(self):
166 with self.ui_test.load_file(get_url_for_data_file("tdf141973.ods")):
167 xCalcDoc = self.xUITest.getTopFocusWindow()
168 xGridWin = xCalcDoc.getChild("grid_window")
170 self.xUITest.executeCommand(".uno:Sidebar")
172 # Without the fix in place, this test would have crashed here
173 xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
175 xCalcDoc = self.xUITest.getTopFocusWindow()
176 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
177 xContentBox = xNavigatorPanel.getChild('contentbox')
178 xDrawings = xContentBox.getChild("7")
179 self.assertEqual('Drawing objects', get_state_as_dict(xDrawings)['Text'])
180 self.assertEqual(len(xDrawings.getChildren()), 1)
181 self.assertEqual('withname', get_state_as_dict(xDrawings.getChild('0'))['Text'])
183 self.xUITest.executeCommand(".uno:Sidebar")
186 def test_tdf158652(self):
187 with self.ui_test.create_doc_in_start_center("calc"):
188 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
189 xCalcDoc = self.xUITest.getTopFocusWindow()
190 xGridWin = xCalcDoc.getChild("grid_window")
192 self.xUITest.executeCommand(".uno:Sidebar")
194 xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
196 xCalcDoc = self.xUITest.getTopFocusWindow()
197 xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
198 xContentBox = xNavigatorPanel.getChild('contentbox')
199 enter_text_to_cell(xGridWin, "A1", "1")
201 commentText = mkPropertyValues({"Text":"CommentText"})
202 self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", commentText)
203 xToolkit.waitUntilAllIdlesDispatched()
204 xComments = xContentBox.getChild("6")
205 self.assertEqual(len(xComments.getChildren()), 1)
207 self.xUITest.executeCommand(".uno:DeleteNote")
208 xToolkit.waitUntilAllIdlesDispatched()
209 xComments = xContentBox.getChild("6")
210 self.assertEqual(len(xComments.getChildren()), 0)
212 self.xUITest.executeCommand(".uno:Sidebar")
214 # vim: set shiftwidth=4 softtabstop=4 expandtab: