Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / uitest / writer_tests / formatBulletsNumbering.py
blob7e6026b01414df699a422ca8ddb714aefdbfc87f
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 libreoffice.uno.propertyvalue import mkPropertyValues
9 from uitest.uihelper.common import get_state_as_dict, type_text
11 import time
12 from uitest.debug import sleep
13 from libreoffice.uno.propertyvalue import mkPropertyValues
14 from uitest.uihelper.common import select_pos
16 class formatBulletsNumbering(UITestCase):
18 def test_bullets_and_numbering_dialog_tab_position(self):
19 self.ui_test.create_doc_in_start_center("writer")
20 document = self.ui_test.get_component()
21 xWriterDoc = self.xUITest.getTopFocusWindow()
22 xWriterEdit = xWriterDoc.getChild("writer_edit")
24 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
25 xDialog = self.xUITest.getTopFocusWindow()
26 xPages = xDialog.getChild("pages")
27 xWriterEntry = xPages.getChild('3') # Writer
28 xWriterEntry.executeAction("EXPAND", tuple())
29 xWriterGeneralEntry = xWriterEntry.getChild('0')
30 xWriterGeneralEntry.executeAction("SELECT", tuple()) #General - set millimeters
31 xMetric = xDialog.getChild("metric")
32 props = {"TEXT": "Millimeter"}
33 actionProps = mkPropertyValues(props)
34 xMetric.executeAction("SELECT", actionProps)
35 xOKBtn = xDialog.getChild("ok")
36 self.ui_test.close_dialog_through_button(xOKBtn)
38 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
39 xDialog = self.xUITest.getTopFocusWindow()
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")
46 xokbtn = xDialog.getChild("ok")
48 xalignedatmf.executeAction("UP", tuple())
49 props = {"TEXT": "Centered"}
50 actionProps = mkPropertyValues(props)
51 xnum2alignlb.executeAction("SELECT", actionProps)
52 xatmf.executeAction("UP", tuple())
53 xindentatmf.executeAction("UP", tuple())
55 self.ui_test.close_dialog_through_button(xokbtn)
57 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
58 xDialog = self.xUITest.getTopFocusWindow()
59 xTabs = xDialog.getChild("tabcontrol")
60 select_pos(xTabs, "4")
61 xalignedatmf = xDialog.getChild("alignedatmf")
62 xnum2alignlb = xDialog.getChild("num2alignlb")
63 xatmf = xDialog.getChild("atmf")
64 xindentatmf = xDialog.getChild("indentatmf")
66 self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "6.5 mm")
67 self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
68 self.assertEqual(get_state_as_dict(xatmf)["Text"], "12.8 mm")
69 self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "12.8 mm")
71 xcancbtn = xDialog.getChild("cancel")
72 self.ui_test.close_dialog_through_button(xcancbtn)
74 self.ui_test.close_doc()
76 def test_bullets_and_numbering_dialog_tab_position2(self):
77 self.ui_test.create_doc_in_start_center("writer")
78 document = self.ui_test.get_component()
79 xWriterDoc = self.xUITest.getTopFocusWindow()
80 xWriterEdit = xWriterDoc.getChild("writer_edit")
82 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
83 xDialog = self.xUITest.getTopFocusWindow()
84 xTabs = xDialog.getChild("tabcontrol")
85 select_pos(xTabs, "4")
86 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
87 props = {"TEXT": "Space"}
88 actionProps = mkPropertyValues(props)
89 xnumfollowedbylb.executeAction("SELECT", actionProps)
91 xokbtn = xDialog.getChild("ok")
92 self.ui_test.close_dialog_through_button(xokbtn)
94 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
95 xDialog = self.xUITest.getTopFocusWindow()
96 xTabs = xDialog.getChild("tabcontrol")
97 select_pos(xTabs, "4")
98 xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
99 self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Space")
101 xcancbtn = xDialog.getChild("cancel")
102 self.ui_test.close_dialog_through_button(xcancbtn)
104 self.ui_test.close_doc()
106 def test_bullets_and_numbering_dialog_tab_customize(self):
107 self.ui_test.create_doc_in_start_center("writer")
108 document = self.ui_test.get_component()
109 xWriterDoc = self.xUITest.getTopFocusWindow()
110 xWriterEdit = xWriterDoc.getChild("writer_edit")
112 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
113 xDialog = self.xUITest.getTopFocusWindow()
114 xTabs = xDialog.getChild("tabcontrol")
115 select_pos(xTabs, "5")
116 xnumfmtlb = xDialog.getChild("numfmtlb")
117 xstartat = xDialog.getChild("startat")
118 xcharstyle = xDialog.getChild("charstyle")
119 xprefix = xDialog.getChild("prefix")
120 xsuffix = xDialog.getChild("suffix")
121 xallsame = xDialog.getChild("allsame")
123 props = {"TEXT": "A, B, C, ..."}
124 actionProps = mkPropertyValues(props)
125 xnumfmtlb.executeAction("SELECT", actionProps)
126 xstartat.executeAction("UP", tuple())
127 props2 = {"TEXT": "Bullets"}
128 actionProps2 = mkPropertyValues(props2)
129 xcharstyle.executeAction("SELECT", actionProps2)
130 xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"o"}))
131 xsuffix.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
132 xsuffix.executeAction("BACKSPACE", tuple())
133 xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
134 xallsame.executeAction("CLICK", tuple())
136 xokbtn = xDialog.getChild("ok")
137 self.ui_test.close_dialog_through_button(xokbtn)
139 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
140 xDialog = self.xUITest.getTopFocusWindow()
141 xTabs = xDialog.getChild("tabcontrol")
142 select_pos(xTabs, "5")
143 xnumfmtlb = xDialog.getChild("numfmtlb")
144 xstartat = xDialog.getChild("startat")
145 xcharstyle = xDialog.getChild("charstyle")
146 xprefix = xDialog.getChild("prefix")
147 xsuffix = xDialog.getChild("suffix")
148 xallsame = xDialog.getChild("allsame")
150 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "A, B, C, ...")
151 self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
152 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
153 self.assertEqual(get_state_as_dict(xprefix)["Text"], "o")
154 self.assertEqual(get_state_as_dict(xsuffix)["Text"], "a")
155 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "true")
157 xcancbtn = xDialog.getChild("cancel")
158 self.ui_test.close_dialog_through_button(xcancbtn)
160 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
161 xDialog = self.xUITest.getTopFocusWindow()
162 xTabs = xDialog.getChild("tabcontrol")
163 select_pos(xTabs, "5")
165 xremovebtn = xDialog.getChild("user")
166 self.ui_test.close_dialog_through_button(xremovebtn) #remove new settings, back to default
168 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
169 xDialog = self.xUITest.getTopFocusWindow()
170 xTabs = xDialog.getChild("tabcontrol")
171 select_pos(xTabs, "5")
172 xnumfmtlb = xDialog.getChild("numfmtlb")
173 xstartat = xDialog.getChild("startat")
174 xcharstyle = xDialog.getChild("charstyle")
175 xprefix = xDialog.getChild("prefix")
176 xsuffix = xDialog.getChild("suffix")
177 xallsame = xDialog.getChild("allsame")
179 self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "1, 2, 3, ...")
180 self.assertEqual(get_state_as_dict(xstartat)["Text"], "1")
181 self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "None")
182 self.assertEqual(get_state_as_dict(xprefix)["Text"], "")
183 self.assertEqual(get_state_as_dict(xsuffix)["Text"], ".")
184 self.assertEqual(get_state_as_dict(xallsame)["Selected"], "false")
186 xcancbtn = xDialog.getChild("cancel")
187 self.ui_test.close_dialog_through_button(xcancbtn)
189 self.ui_test.close_doc()
191 def test_bullets_and_numbering_tab_move(self):
192 self.ui_test.create_doc_in_start_center("writer")
193 document = self.ui_test.get_component()
194 xWriterDoc = self.xUITest.getTopFocusWindow()
195 xWriterEdit = xWriterDoc.getChild("writer_edit")
197 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
198 xDialog = self.xUITest.getTopFocusWindow()
199 xPages = xDialog.getChild("pages")
200 xWriterEntry = xPages.getChild('3') # Writer
201 xWriterEntry.executeAction("EXPAND", tuple())
202 xWriterGeneralEntry = xWriterEntry.getChild('0')
203 xWriterGeneralEntry.executeAction("SELECT", tuple()) #General - set millimeters
204 xMetric = xDialog.getChild("metric")
205 props = {"TEXT": "Millimeter"}
206 actionProps = mkPropertyValues(props)
207 xMetric.executeAction("SELECT", actionProps)
208 xOKBtn = xDialog.getChild("ok")
209 self.ui_test.close_dialog_through_button(xOKBtn)
211 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
212 xDialog = self.xUITest.getTopFocusWindow()
213 xTabs = xDialog.getChild("tabcontrol")
214 select_pos(xTabs, "4")
215 xindentatmf = xDialog.getChild("indentatmf")
216 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
218 xokbtn = xDialog.getChild("ok")
219 self.ui_test.close_dialog_through_button(xokbtn) #create bullets
221 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #TAB to move indent right
222 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
223 xDialog = self.xUITest.getTopFocusWindow()
224 xTabs = xDialog.getChild("tabcontrol")
225 select_pos(xTabs, "4")
226 xindentatmf = xDialog.getChild("indentatmf")
227 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
228 self.assertEqual(indentValue < indentValue2 , True)
229 xcancbtn = xDialog.getChild("cancel")
230 self.ui_test.close_dialog_through_button(xcancbtn)
232 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
233 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
234 xDialog = self.xUITest.getTopFocusWindow()
235 xTabs = xDialog.getChild("tabcontrol")
236 select_pos(xTabs, "4")
237 xindentatmf = xDialog.getChild("indentatmf")
238 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
239 self.assertEqual(indentValue == indentValue3 , True)
240 xcancbtn = xDialog.getChild("cancel")
241 self.ui_test.close_dialog_through_button(xcancbtn)
243 self.ui_test.close_doc()
245 def test_bullets_and_numbering_button_move(self):
246 self.ui_test.create_doc_in_start_center("writer")
247 document = self.ui_test.get_component()
248 xWriterDoc = self.xUITest.getTopFocusWindow()
249 xWriterEdit = xWriterDoc.getChild("writer_edit")
251 self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
252 xDialog = self.xUITest.getTopFocusWindow()
253 xPages = xDialog.getChild("pages")
254 xWriterEntry = xPages.getChild('3') # Writer
255 xWriterEntry.executeAction("EXPAND", tuple())
256 xWriterGeneralEntry = xWriterEntry.getChild('0')
257 xWriterGeneralEntry.executeAction("SELECT", tuple()) #General - set millimeters
258 xMetric = xDialog.getChild("metric")
259 props = {"TEXT": "Millimeter"}
260 actionProps = mkPropertyValues(props)
261 xMetric.executeAction("SELECT", actionProps)
262 xOKBtn = xDialog.getChild("ok")
263 self.ui_test.close_dialog_through_button(xOKBtn)
265 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
266 xDialog = self.xUITest.getTopFocusWindow()
267 xTabs = xDialog.getChild("tabcontrol")
268 select_pos(xTabs, "4")
269 xindentatmf = xDialog.getChild("indentatmf")
270 indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
272 xokbtn = xDialog.getChild("ok")
273 self.ui_test.close_dialog_through_button(xokbtn) #create bullets
275 self.xUITest.executeCommand(".uno:DecrementSubLevels")
276 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
277 xDialog = self.xUITest.getTopFocusWindow()
278 xTabs = xDialog.getChild("tabcontrol")
279 select_pos(xTabs, "4")
280 xindentatmf = xDialog.getChild("indentatmf")
281 indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
282 self.assertEqual(indentValue < indentValue2 , True)
283 xcancbtn = xDialog.getChild("cancel")
284 self.ui_test.close_dialog_through_button(xcancbtn)
286 self.xUITest.executeCommand(".uno:IncrementLevel")
287 self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
288 xDialog = self.xUITest.getTopFocusWindow()
289 xTabs = xDialog.getChild("tabcontrol")
290 select_pos(xTabs, "4")
291 xindentatmf = xDialog.getChild("indentatmf")
292 indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
293 self.assertEqual(indentValue == indentValue3 , True)
294 xcancbtn = xDialog.getChild("cancel")
295 self.ui_test.close_dialog_through_button(xcancbtn)
297 self.ui_test.close_doc()
298 # vim: set shiftwidth=4 softtabstop=4 expandtab: