Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / writer_tests2 / formatBulletsNumbering.py
blobc01ad801058729fa3b910dd24bdcec61fa213ddf
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_dialog_tab_position(self):
21 with self.ui_test.create_doc_in_start_center("writer"):
23 with change_measurement_unit(self, "Millimeter"):
25 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
26 xTabs = xDialog.getChild("tabcontrol")
27 select_pos(xTabs, "4")
28 xalignedatmf = xDialog.getChild("alignedatmf")
29 xnum2alignlb = xDialog.getChild("num2alignlb")
30 xatmf = xDialog.getChild("atmf")
31 xindentatmf = xDialog.getChild("indentatmf")
33 xalignedatmf.executeAction("UP", tuple())
34 select_by_text(xnum2alignlb, "Centered")
35 xatmf.executeAction("UP", tuple())
36 xindentatmf.executeAction("UP", tuple())
39 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
40 xTabs = xDialog.getChild("tabcontrol")
41 select_pos(xTabs, "4")
42 xalignedatmf = xDialog.getChild("alignedatmf")
43 xnum2alignlb = xDialog.getChild("num2alignlb")
44 xatmf = xDialog.getChild("atmf")
45 xindentatmf = xDialog.getChild("indentatmf")
47 self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "6.5 mm")
48 self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
49 self.assertEqual(get_state_as_dict(xatmf)["Text"], "12.8 mm")
50 self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "12.8 mm")
54 def test_bullets_and_numbering_dialog_tab_position2(self):
55 with self.ui_test.create_doc_in_start_center("writer"):
57 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
58 xTabs = xDialog.getChild("tabcontrol")
59 select_pos(xTabs, "4")
60 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
61 select_by_text(xnumfollowedbylb, "Space")
64 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
65 xTabs = xDialog.getChild("tabcontrol")
66 select_pos(xTabs, "4")
67 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
68 self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Space")
72 def test_bullets_and_numbering_dialog_tab_customize(self):
73 with self.ui_test.create_doc_in_start_center("writer"):
75 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
76 xTabs = xDialog.getChild("tabcontrol")
77 select_pos(xTabs, "5")
78 xnumfmtlb = xDialog.getChild("numfmtlb")
79 xstartat = xDialog.getChild("startat")
80 xcharstyle = xDialog.getChild("charstyle")
81 xprefix = xDialog.getChild("prefix")
82 xsuffix = xDialog.getChild("suffix")
83 xallsame = xDialog.getChild("allsame")
85 select_by_text(xnumfmtlb, "A, B, C, ...")
86 xstartat.executeAction("UP", tuple())
87 select_by_text(xcharstyle, "Bullets")
88 xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"o"}))
89 xsuffix.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
90 xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
91 xallsame.executeAction("CLICK", tuple())
94 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
95 xTabs = xDialog.getChild("tabcontrol")
96 select_pos(xTabs, "5")
97 xnumfmtlb = xDialog.getChild("numfmtlb")
98 xstartat = xDialog.getChild("startat")
99 xcharstyle = xDialog.getChild("charstyle")
100 xprefix = xDialog.getChild("prefix")
101 xsuffix = xDialog.getChild("suffix")
102 xallsame = xDialog.getChild("allsame")
104 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "A, B, C, ...")
105 self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
106 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
107 self.assertEqual(get_state_as_dict(xprefix)["Text"], "o")
108 self.assertEqual(get_state_as_dict(xsuffix)["Text"], "a")
109 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "true")
112 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="user") as xDialog:
113 pass
115 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
116 xTabs = xDialog.getChild("tabcontrol")
117 select_pos(xTabs, "5")
118 xnumfmtlb = xDialog.getChild("numfmtlb")
119 xstartat = xDialog.getChild("startat")
120 xcharstyle = xDialog.getChild("charstyle")
121 xprefix = xDialog.getChild("prefix")
122 xsuffix = xDialog.getChild("suffix")
123 xallsame = xDialog.getChild("allsame")
125 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "1, 2, 3, ...")
126 self.assertEqual(get_state_as_dict(xstartat)["Text"], "1")
127 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "None")
128 self.assertEqual(get_state_as_dict(xprefix)["Text"], "")
129 self.assertEqual(get_state_as_dict(xsuffix)["Text"], ".")
130 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "false")
134 def test_bullets_and_numbering_tab_move(self):
135 with self.ui_test.create_doc_in_start_center("writer"):
137 with change_measurement_unit(self, "Millimeter"):
138 xWriterDoc = self.xUITest.getTopFocusWindow()
139 xWriterEdit = xWriterDoc.getChild("writer_edit")
141 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
142 xTabs = xDialog.getChild("tabcontrol")
143 select_pos(xTabs, "4")
144 xindentatmf = xDialog.getChild("indentatmf")
145 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
148 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #TAB to move indent right
149 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
150 xTabs = xDialog.getChild("tabcontrol")
151 select_pos(xTabs, "4")
152 xindentatmf = xDialog.getChild("indentatmf")
153 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
154 self.assertEqual(indentValue < indentValue2 , True)
156 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
157 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
158 xTabs = xDialog.getChild("tabcontrol")
159 select_pos(xTabs, "4")
160 xindentatmf = xDialog.getChild("indentatmf")
161 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
162 self.assertEqual(indentValue == indentValue3 , True)
165 def test_bullets_and_numbering_button_move(self):
166 with self.ui_test.create_doc_in_start_center("writer"):
168 with change_measurement_unit(self, "Millimeter"):
170 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
171 xTabs = xDialog.getChild("tabcontrol")
172 select_pos(xTabs, "4")
173 xindentatmf = xDialog.getChild("indentatmf")
174 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
177 self.xUITest.executeCommand(".uno:DecrementSubLevels")
178 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
179 xTabs = xDialog.getChild("tabcontrol")
180 select_pos(xTabs, "4")
181 xindentatmf = xDialog.getChild("indentatmf")
182 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
183 self.assertEqual(indentValue < indentValue2 , True)
185 self.xUITest.executeCommand(".uno:IncrementLevel")
186 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog", close_button="cancel") as xDialog:
187 xTabs = xDialog.getChild("tabcontrol")
188 select_pos(xTabs, "4")
189 xindentatmf = xDialog.getChild("indentatmf")
190 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
191 self.assertEqual(indentValue == indentValue3 , True)
194 def test_bullets_and_numbering_selection(self):
195 with self.ui_test.create_doc_in_start_center("writer"):
197 # Test Bullet Page
198 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
200 # Select the BulletPage's Selector
201 xTabs = xDialog.getChild("tabcontrol")
202 select_pos(xTabs, "0")
203 xBulletPage = xDialog.getChild("PickBulletPage")
204 xselector = xBulletPage.getChild("valueset")
205 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
206 # Select element num 3
207 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
208 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "2")
209 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "3")
210 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Solid diamond bullets")
211 # Select element num 7
212 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "7"}))
213 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "6")
214 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "7")
215 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Cross mark bullets")
218 # Test other Pages
219 with self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") as xDialog:
220 # Select the NumberingPage's Selector
221 xTabs = xDialog.getChild("tabcontrol")
222 select_pos(xTabs, "1")
223 xNumberingPage = xDialog.getChild("PickNumberingPage")
224 xselector = xNumberingPage.getChild("valueset")
225 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
226 # Select element num 5
227 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"}))
228 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "4")
229 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "5")
230 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Uppercase letter A) B) C)")
231 # Select element num 8
232 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "8"}))
233 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "7")
234 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "8")
235 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Lowercase Roman number i. ii. iii.")
237 # Select the OutlinePage's Selector
238 xTabs = xDialog.getChild("tabcontrol")
239 select_pos(xTabs, "2")
240 xOutlinePage = xDialog.getChild("PickOutlinePage")
241 xselector = xOutlinePage.getChild("valueset")
242 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8")
243 # Select element num 1
244 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
245 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "0")
246 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "1")
247 self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Uppercase Roman, uppercase letters, numeric, lowercase letters, lowercase Roman, solid small circular bullet")
249 # Select the GraphicPage's Selector
250 xTabs = xDialog.getChild("tabcontrol")
251 select_pos(xTabs, "3")
252 xGraphicPage = xDialog.getChild("PickGraphicPage")
253 xselector = xGraphicPage.getChild("valueset")
254 self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "92")
255 # Select element num 22
256 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "22"}))
257 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "21")
258 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "22")
259 # Select element num 73
260 xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "73"}))
261 self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "72")
262 self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "73")
265 # vim: set shiftwidth=4 softtabstop=4 expandtab: