tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sw / qa / uitest / writer_tests2 / formatBulletsNumbering.py
blobd0b78525c1c658aaba71297adfd67af5b6d4add8
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 uitest.uihelper.common import get_state_as_dict
13 from libreoffice.uno.propertyvalue import mkPropertyValues
14 from uitest.uihelper.common import select_pos
15 from uitest.uihelper.common import select_by_text
16 from uitest.uihelper.common import change_measurement_unit
18 class formatBulletsNumbering(UITestCase):
20 def test_bullets_and_numbering_change_bullet(self):
21 with self.ui_test.create_doc_in_start_center("writer"):
23 # Set the "black down-pointing triangle" bullet in the third item
24 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
25 # Select the BulletPage's selector
26 xTabs = xDialog.getChild("tabcontrol")
27 select_pos(xTabs, "0")
28 xBulletPage = xDialog.getChild("PickBulletPage")
29 xSelector = xBulletPage.getChild("valueset")
31 # Select element number 3
32 xSelector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
33 self.assertEqual(get_state_as_dict(xSelector)["SelectedItemId"], "3")
34 xChangeBulletBtn = xBulletPage.getChild("changeBulletBtn")
35 with self.ui_test.execute_blocking_action(xChangeBulletBtn.executeAction, args=('CLICK', ())) as xCharSetDialog:
36 xCharSet = xCharSetDialog.getChild("showcharset")
37 xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "21", "ROW": "1"}))
39 # Check that the "black down-pointing triangle" bullet is the third item
40 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
41 # Select the BulletPage's selector
42 xTabs = xDialog.getChild("tabcontrol")
43 select_pos(xTabs, "0")
44 xBulletPage = xDialog.getChild("PickBulletPage")
45 xSelector = xBulletPage.getChild("valueset")
47 # Select element number 3
48 xSelector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
49 self.assertEqual(get_state_as_dict(xSelector)["SelectedItemId"], "3")
50 xChangeBulletBtn = xBulletPage.getChild("changeBulletBtn")
51 with self.ui_test.execute_blocking_action(xChangeBulletBtn.executeAction, args=('CLICK', ())) as xCharSetDialog:
52 xHexText = xCharSetDialog.getChild("hexvalue")
53 xDecText = xCharSetDialog.getChild("decimalvalue")
54 # Check the "black down-pointing triangle" bullet Hex and Decimal value
55 self.assertEqual(get_state_as_dict(xHexText)["Text"], "25BC")
56 self.assertEqual(get_state_as_dict(xDecText)["Text"], "9660")
59 def test_bullets_and_numbering_dialog_tab_position(self):
60 with self.ui_test.create_doc_in_start_center("writer"):
62 with change_measurement_unit(self, "Millimeter"):
64 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
65 xTabs = xDialog.getChild("tabcontrol")
66 select_pos(xTabs, "4")
67 xalignedatmf = xDialog.getChild("alignedatmf")
68 xnum2alignlb = xDialog.getChild("num2alignlb")
69 xatmf = xDialog.getChild("atmf")
70 xindentatmf = xDialog.getChild("indentatmf")
72 xalignedatmf.executeAction("UP", tuple())
73 select_by_text(xnum2alignlb, "Centered")
74 xatmf.executeAction("UP", tuple())
75 xindentatmf.executeAction("UP", tuple())
78 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
79 xTabs = xDialog.getChild("tabcontrol")
80 select_pos(xTabs, "4")
81 xalignedatmf = xDialog.getChild("alignedatmf")
82 xnum2alignlb = xDialog.getChild("num2alignlb")
83 xatmf = xDialog.getChild("atmf")
84 xindentatmf = xDialog.getChild("indentatmf")
86 self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "6.5 mm")
87 self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
88 self.assertEqual(get_state_as_dict(xatmf)["Text"], "12.8 mm")
89 self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "12.8 mm")
93 def test_bullets_and_numbering_dialog_tab_position2(self):
94 with self.ui_test.create_doc_in_start_center("writer"):
96 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
97 xTabs = xDialog.getChild("tabcontrol")
98 select_pos(xTabs, "4")
99 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
100 select_by_text(xnumfollowedbylb, "Space")
103 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
104 xTabs = xDialog.getChild("tabcontrol")
105 select_pos(xTabs, "4")
106 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
107 self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Space")
111 def test_bullets_and_numbering_dialog_tab_customize(self):
112 with self.ui_test.create_doc_in_start_center("writer"):
114 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
115 xTabs = xDialog.getChild("tabcontrol")
116 select_pos(xTabs, "5")
117 xnumfmtlb = xDialog.getChild("numfmtlb")
118 xstartat = xDialog.getChild("startat")
119 xcharstyle = xDialog.getChild("charstyle")
120 xprefix = xDialog.getChild("prefix")
121 xsuffix = xDialog.getChild("suffix")
122 xallsame = xDialog.getChild("allsame")
124 select_by_text(xnumfmtlb, "A, B, C, ...")
125 xstartat.executeAction("UP", tuple())
126 select_by_text(xcharstyle, "Bullets")
127 xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"o"}))
128 xsuffix.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
129 xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
130 xallsame.executeAction("CLICK", tuple())
133 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
134 xTabs = xDialog.getChild("tabcontrol")
135 select_pos(xTabs, "5")
136 xnumfmtlb = xDialog.getChild("numfmtlb")
137 xstartat = xDialog.getChild("startat")
138 xcharstyle = xDialog.getChild("charstyle")
139 xprefix = xDialog.getChild("prefix")
140 xsuffix = xDialog.getChild("suffix")
141 xallsame = xDialog.getChild("allsame")
143 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "A, B, C, ...")
144 self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
145 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
146 self.assertEqual(get_state_as_dict(xprefix)["Text"], "o")
147 self.assertEqual(get_state_as_dict(xsuffix)["Text"], "a")
148 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "true")
151 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="user") as xDialog:
152 pass
154 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
155 xTabs = xDialog.getChild("tabcontrol")
156 select_pos(xTabs, "5")
157 xnumfmtlb = xDialog.getChild("numfmtlb")
158 xstartat = xDialog.getChild("startat")
159 xcharstyle = xDialog.getChild("charstyle")
160 xprefix = xDialog.getChild("prefix")
161 xsuffix = xDialog.getChild("suffix")
162 xallsame = xDialog.getChild("allsame")
164 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "1, 2, 3, ...")
165 self.assertEqual(get_state_as_dict(xstartat)["Text"], "1")
166 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "None")
167 self.assertEqual(get_state_as_dict(xprefix)["Text"], "")
168 self.assertEqual(get_state_as_dict(xsuffix)["Text"], ".")
169 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "false")
173 def test_bullets_and_numbering_tab_move(self):
174 with self.ui_test.create_doc_in_start_center("writer"):
176 with change_measurement_unit(self, "Millimeter"):
177 xWriterDoc = self.xUITest.getTopFocusWindow()
178 xWriterEdit = xWriterDoc.getChild("writer_edit")
180 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
181 xTabs = xDialog.getChild("tabcontrol")
182 select_pos(xTabs, "4")
183 xindentatmf = xDialog.getChild("indentatmf")
184 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
187 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #TAB to move indent right
188 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
189 xTabs = xDialog.getChild("tabcontrol")
190 select_pos(xTabs, "4")
191 xindentatmf = xDialog.getChild("indentatmf")
192 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
193 self.assertEqual(indentValue < indentValue2 , True)
195 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
196 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
197 xTabs = xDialog.getChild("tabcontrol")
198 select_pos(xTabs, "4")
199 xindentatmf = xDialog.getChild("indentatmf")
200 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
201 self.assertEqual(indentValue == indentValue3 , True)
204 def test_bullets_and_numbering_button_move(self):
205 with self.ui_test.create_doc_in_start_center("writer"):
207 with change_measurement_unit(self, "Millimeter"):
209 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
210 xTabs = xDialog.getChild("tabcontrol")
211 select_pos(xTabs, "4")
212 xindentatmf = xDialog.getChild("indentatmf")
213 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
216 self.xUITest.executeCommand(".uno:DecrementSubLevels")
217 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
218 xTabs = xDialog.getChild("tabcontrol")
219 select_pos(xTabs, "4")
220 xindentatmf = xDialog.getChild("indentatmf")
221 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
222 self.assertEqual(indentValue < indentValue2 , True)
224 self.xUITest.executeCommand(".uno:IncrementLevel")
225 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="ok") as xDialog:
226 xTabs = xDialog.getChild("tabcontrol")
227 select_pos(xTabs, "4")
228 xindentatmf = xDialog.getChild("indentatmf")
229 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
230 self.assertEqual(indentValue == indentValue3 , True)
233 def test_bullets_and_numbering_selection(self):
234 with self.ui_test.create_doc_in_start_center("writer"):
236 # Test Bullet Page
237 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
239 # Select the BulletPage's Selector
240 xTabs = xDialog.getChild("tabcontrol")
241 select_pos(xTabs, "0")
242 xBulletPage = xDialog.getChild("PickBulletPage")
243 xselector = xBulletPage.getChild("valueset")
244 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
245 # Select element num 3
246 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
247 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "2")
248 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "3")
249 # Select element num 7
250 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "7"}))
251 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "6")
252 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "7")
254 # Test other Pages
255 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
256 # Select the NumberingPage's Selector
257 xTabs = xDialog.getChild("tabcontrol")
258 select_pos(xTabs, "1")
259 xNumberingPage = xDialog.getChild("PickNumberingPage")
260 xselector = xNumberingPage.getChild("valueset")
261 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
262 # Select element num 5
263 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"}))
264 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "4")
265 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "5")
266 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Uppercase letter A) B) C)")
267 # Select element num 8
268 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "8"}))
269 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "7")
270 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "8")
271 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Lowercase Roman number i. ii. iii.")
273 # Select the OutlinePage's Selector
274 xTabs = xDialog.getChild("tabcontrol")
275 select_pos(xTabs, "2")
276 xOutlinePage = xDialog.getChild("PickOutlinePage")
277 xselector = xOutlinePage.getChild("valueset")
278 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
279 # Select element num 1
280 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
281 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "0")
282 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "1")
283 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Uppercase Roman, uppercase letters, numeric, lowercase letters, lowercase Roman, solid small circular bullet")
285 # Select the GraphicPage's Selector
286 xTabs = xDialog.getChild("tabcontrol")
287 select_pos(xTabs, "3")
288 xGraphicPage = xDialog.getChild("PickGraphicPage")
289 xselector = xGraphicPage.getChild("valueset")
290 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "92")
291 # Select element num 22
292 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "22"}))
293 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "21")
294 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "22")
295 # Select element num 73
296 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "73"}))
297 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "72")
298 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "73")
301 def test_bullets_and_numbering_document_bullet_list(self):
302 with self.ui_test.create_doc_in_start_center("writer"):
303 self.xUITest.executeCommand(".uno:DefaultBullet")
304 # Without the fix in place, this test would have crashed here
305 self.xUITest.executeCommand(".uno:DocumentBulletList")
308 # vim: set shiftwidth=4 softtabstop=4 expandtab: