1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 from uitest
.uihelper
.common
import get_state_as_dict
9 from uitest
.uihelper
.common
import select_pos
10 from uitest
.uihelper
.common
import change_measurement_unit
11 from uitest
.uihelper
.calc
import enter_text_to_cell
12 from libreoffice
.calc
.document
import get_cell_by_position
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 from uitest
.uihelper
.common
import get_state_as_dict
, type_text
15 from uitest
.debug
import sleep
16 import org
.libreoffice
.unotest
19 def get_url_for_data_file(file_name
):
20 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
23 #Bug 98390 - Crash when modifying minor grid
25 class chartGrid(UITestCase
):
26 def test_tdf98390_chart_grid_dialog(self
):
27 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("tdf98390.ods"))
28 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
29 gridwin
= xCalcDoc
.getChild("grid_window")
30 document
= self
.ui_test
.get_component()
32 change_measurement_unit(self
, "Centimeter")
35 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
36 gridwin
.executeAction("ACTIVATE", tuple())
37 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
38 xChartMain
= xChartMainTop
.getChild("chart_window")
39 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
40 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"}))
41 xDialog
= self
.xUITest
.getTopFocusWindow()
43 tabcontrol
= xDialog
.getChild("tabcontrol")
44 select_pos(tabcontrol
, "0")
46 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
47 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
49 xWidth
.executeAction("UP", tuple())
50 transparency
.executeAction("UP", tuple())
52 xOKBtn
= xDialog
.getChild("ok")
53 self
.ui_test
.close_dialog_through_button(xOKBtn
)
55 #reopen and verify X Axis Major Grid
56 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
57 gridwin
.executeAction("ACTIVATE", tuple())
58 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
59 xChartMain
= xChartMainTop
.getChild("chart_window")
60 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
61 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"}))
62 xDialog
= self
.xUITest
.getTopFocusWindow()
64 tabcontrol
= xDialog
.getChild("tabcontrol")
65 select_pos(tabcontrol
, "0")
66 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
67 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
69 self
.assertEqual(get_state_as_dict(xWidth
)["Text"], "0.10 cm")
70 self
.assertEqual(get_state_as_dict(transparency
)["Text"], "5%")
71 xOKBtn
= xDialog
.getChild("ok")
72 self
.ui_test
.close_dialog_through_button(xOKBtn
)
75 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
76 gridwin
.executeAction("ACTIVATE", tuple())
77 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
78 xChartMain
= xChartMainTop
.getChild("chart_window")
79 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
80 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"}))
81 xDialog
= self
.xUITest
.getTopFocusWindow()
83 tabcontrol
= xDialog
.getChild("tabcontrol")
84 select_pos(tabcontrol
, "0")
86 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
87 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
89 xWidth
.executeAction("UP", tuple())
90 transparency
.executeAction("UP", tuple())
92 xOKBtn
= xDialog
.getChild("ok")
93 self
.ui_test
.close_dialog_through_button(xOKBtn
)
95 #reopen and verify Y Axis Major Grid
96 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
97 gridwin
.executeAction("ACTIVATE", tuple())
98 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
99 xChartMain
= xChartMainTop
.getChild("chart_window")
100 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
101 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"}))
102 xDialog
= self
.xUITest
.getTopFocusWindow()
104 tabcontrol
= xDialog
.getChild("tabcontrol")
105 select_pos(tabcontrol
, "0")
107 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
108 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
110 self
.assertEqual(get_state_as_dict(xWidth
)["Text"], "0.10 cm")
111 self
.assertEqual(get_state_as_dict(transparency
)["Text"], "5%")
113 xOKBtn
= xDialog
.getChild("ok")
114 self
.ui_test
.close_dialog_through_button(xOKBtn
)
117 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
118 gridwin
.executeAction("ACTIVATE", tuple())
119 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
120 xChartMain
= xChartMainTop
.getChild("chart_window")
121 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
122 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"}))
123 xDialog
= self
.xUITest
.getTopFocusWindow()
125 tabcontrol
= xDialog
.getChild("tabcontrol")
126 select_pos(tabcontrol
, "0")
128 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
129 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
131 xWidth
.executeAction("UP", tuple())
132 transparency
.executeAction("UP", tuple())
134 xOKBtn
= xDialog
.getChild("ok")
135 self
.ui_test
.close_dialog_through_button(xOKBtn
)
137 #reopen and verify Y Axis Minor Grid
138 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
139 gridwin
.executeAction("ACTIVATE", tuple())
140 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
141 xChartMain
= xChartMainTop
.getChild("chart_window")
142 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
143 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"}))
144 xDialog
= self
.xUITest
.getTopFocusWindow()
146 tabcontrol
= xDialog
.getChild("tabcontrol")
147 select_pos(tabcontrol
, "0")
148 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
149 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
151 self
.assertEqual(get_state_as_dict(xWidth
)["Text"], "0.10 cm")
152 self
.assertEqual(get_state_as_dict(transparency
)["Text"], "5%")
154 xOKBtn
= xDialog
.getChild("ok")
155 self
.ui_test
.close_dialog_through_button(xOKBtn
)
158 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
159 gridwin
.executeAction("ACTIVATE", tuple())
160 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
161 xChartMain
= xChartMainTop
.getChild("chart_window")
162 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
163 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
164 xDialog
= self
.xUITest
.getTopFocusWindow()
166 tabcontrol
= xDialog
.getChild("tabcontrol")
167 select_pos(tabcontrol
, "0")
169 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
170 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
172 xWidth
.executeAction("UP", tuple())
173 transparency
.executeAction("UP", tuple())
175 xOKBtn
= xDialog
.getChild("ok")
176 self
.ui_test
.close_dialog_through_button(xOKBtn
)
178 #reopen and verify X Axis Minor Grid
179 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
180 gridwin
.executeAction("ACTIVATE", tuple())
181 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
182 xChartMain
= xChartMainTop
.getChild("chart_window")
183 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
184 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
185 xDialog
= self
.xUITest
.getTopFocusWindow()
187 tabcontrol
= xDialog
.getChild("tabcontrol")
188 select_pos(tabcontrol
, "0")
189 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
190 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
192 self
.assertEqual(get_state_as_dict(xWidth
)["Text"], "0.10 cm")
193 self
.assertEqual(get_state_as_dict(transparency
)["Text"], "5%")
195 xOKBtn
= xDialog
.getChild("ok")
196 self
.ui_test
.close_dialog_through_button(xOKBtn
)
199 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
200 gridwin
.executeAction("ACTIVATE", tuple())
201 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
202 xChartMain
= xChartMainTop
.getChild("chart_window")
203 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
204 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridAll"}))
205 xDialog
= self
.xUITest
.getTopFocusWindow()
207 tabcontrol
= xDialog
.getChild("tabcontrol")
208 select_pos(tabcontrol
, "0")
210 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
211 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
213 xWidth
.executeAction("UP", tuple())
214 transparency
.executeAction("UP", tuple())
216 xOKBtn
= xDialog
.getChild("ok")
217 self
.ui_test
.close_dialog_through_button(xOKBtn
)
219 #reopen and verify X Axis Minor Grid (changed in All Grids)
220 gridwin
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
221 gridwin
.executeAction("ACTIVATE", tuple())
222 xChartMainTop
= self
.xUITest
.getTopFocusWindow()
223 xChartMain
= xChartMainTop
.getChild("chart_window")
224 xSeriesObj
= xChartMain
.getChild("CID/D=0:CS=0:CT=0:Series=0")
225 self
.ui_test
.execute_dialog_through_action(xSeriesObj
, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
226 xDialog
= self
.xUITest
.getTopFocusWindow()
228 tabcontrol
= xDialog
.getChild("tabcontrol")
229 select_pos(tabcontrol
, "0")
230 xWidth
= xDialog
.getChild("MTR_FLD_LINE_WIDTH")
231 transparency
= xDialog
.getChild("MTR_LINE_TRANSPARENT")
233 self
.assertEqual(get_state_as_dict(xWidth
)["Text"], "0.20 cm")
234 self
.assertEqual(get_state_as_dict(transparency
)["Text"], "10%")
236 xOKBtn
= xDialog
.getChild("ok")
237 self
.ui_test
.close_dialog_through_button(xOKBtn
)
239 self
.ui_test
.close_doc()
240 # vim: set shiftwidth=4 softtabstop=4 expandtab: