summaryrefslogtreecommitdiffstats
path: root/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py
blob: 0d245b858174e6ef0621e283e2111e653a382614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict, type_text

import time
from uitest.debug import sleep
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import select_pos

class formatBulletsNumbering(UITestCase):

   def test_bullets_and_numbering_dialog_tab_position(self):
        self.ui_test.create_doc_in_start_center("writer")
        document = self.ui_test.get_component()
        xWriterDoc = self.xUITest.getTopFocusWindow()

        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
        xDialog = self.xUITest.getTopFocusWindow()
        xPages = xDialog.getChild("pages")
        xWriterEntry = xPages.getChild('3')                 # Writer
        xWriterEntry.executeAction("EXPAND", tuple())
        xWriterGeneralEntry = xWriterEntry.getChild('0')
        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General - set millimeters
        xMetric = xDialog.getChild("metric")
        props = {"TEXT": "Millimeter"}
        actionProps = mkPropertyValues(props)
        xMetric.executeAction("SELECT", actionProps)
        xOKBtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xOKBtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xalignedatmf = xDialog.getChild("alignedatmf")
        xnum2alignlb = xDialog.getChild("num2alignlb")
        xatmf = xDialog.getChild("atmf")
        xindentatmf = xDialog.getChild("indentatmf")
        xokbtn = xDialog.getChild("ok")

        xalignedatmf.executeAction("UP", tuple())
        props = {"TEXT": "Centered"}
        actionProps = mkPropertyValues(props)
        xnum2alignlb.executeAction("SELECT", actionProps)
        xatmf.executeAction("UP", tuple())
        xindentatmf.executeAction("UP", tuple())

        self.ui_test.close_dialog_through_button(xokbtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xalignedatmf = xDialog.getChild("alignedatmf")
        xnum2alignlb = xDialog.getChild("num2alignlb")
        xatmf = xDialog.getChild("atmf")
        xindentatmf = xDialog.getChild("indentatmf")

        self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "6.5 mm")
        self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
        self.assertEqual(get_state_as_dict(xatmf)["Text"], "12.8 mm")
        self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "12.8 mm")

        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.close_doc()

   def test_bullets_and_numbering_dialog_tab_position2(self):
        self.ui_test.create_doc_in_start_center("writer")
        document = self.ui_test.get_component()
        xWriterDoc = self.xUITest.getTopFocusWindow()

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
        props = {"TEXT": "Space"}
        actionProps = mkPropertyValues(props)
        xnumfollowedbylb.executeAction("SELECT", actionProps)

        xokbtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xokbtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
        self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Space")

        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.close_doc()

   def test_bullets_and_numbering_dialog_tab_customize(self):
        self.ui_test.create_doc_in_start_center("writer")
        document = self.ui_test.get_component()
        xWriterDoc = self.xUITest.getTopFocusWindow()

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "5")
        xnumfmtlb = xDialog.getChild("numfmtlb")
        xstartat = xDialog.getChild("startat")
        xcharstyle = xDialog.getChild("charstyle")
        xprefix = xDialog.getChild("prefix")
        xsuffix = xDialog.getChild("suffix")
        xallsame = xDialog.getChild("allsame")

        props = {"TEXT": "A, B, C, ..."}
        actionProps = mkPropertyValues(props)
        xnumfmtlb.executeAction("SELECT", actionProps)
        xstartat.executeAction("UP", tuple())
        props2 = {"TEXT": "Bullets"}
        actionProps2 = mkPropertyValues(props2)
        xcharstyle.executeAction("SELECT", actionProps2)
        xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"o"}))
        xsuffix.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
        xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
        xallsame.executeAction("CLICK", tuple())

        xokbtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xokbtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "5")
        xnumfmtlb = xDialog.getChild("numfmtlb")
        xstartat = xDialog.getChild("startat")
        xcharstyle = xDialog.getChild("charstyle")
        xprefix = xDialog.getChild("prefix")
        xsuffix = xDialog.getChild("suffix")
        xallsame = xDialog.getChild("allsame")

        self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "A, B, C, ...")
        self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
        self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
        self.assertEqual(get_state_as_dict(xprefix)["Text"], "o")
        self.assertEqual(get_state_as_dict(xsuffix)["Text"], "a")
        self.assertEqual(get_state_as_dict(xallsame)["Selected"], "true")

        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "5")

        xremovebtn = xDialog.getChild("user")
        self.ui_test.close_dialog_through_button(xremovebtn)  #remove new settings, back to default

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "5")
        xnumfmtlb = xDialog.getChild("numfmtlb")
        xstartat = xDialog.getChild("startat")
        xcharstyle = xDialog.getChild("charstyle")
        xprefix = xDialog.getChild("prefix")
        xsuffix = xDialog.getChild("suffix")
        xallsame = xDialog.getChild("allsame")

        self.assertEqual(get_state_as_dict(xnumfmtlb)["SelectEntryText"], "1, 2, 3, ...")
        self.assertEqual(get_state_as_dict(xstartat)["Text"], "1")
        self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "None")
        self.assertEqual(get_state_as_dict(xprefix)["Text"], "")
        self.assertEqual(get_state_as_dict(xsuffix)["Text"], ".")
        self.assertEqual(get_state_as_dict(xallsame)["Selected"], "false")

        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.close_doc()

   def test_bullets_and_numbering_tab_move(self):
        self.ui_test.create_doc_in_start_center("writer")
        document = self.ui_test.get_component()
        xWriterDoc = self.xUITest.getTopFocusWindow()
        xWriterEdit = xWriterDoc.getChild("writer_edit")

        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
        xDialog = self.xUITest.getTopFocusWindow()
        xPages = xDialog.getChild("pages")
        xWriterEntry = xPages.getChild('3')                 # Writer
        xWriterEntry.executeAction("EXPAND", tuple())
        xWriterGeneralEntry = xWriterEntry.getChild('0')
        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General - set millimeters
        xMetric = xDialog.getChild("metric")
        props = {"TEXT": "Millimeter"}
        actionProps = mkPropertyValues(props)
        xMetric.executeAction("SELECT", actionProps)
        xOKBtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xOKBtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]

        xokbtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xokbtn)  #create bullets

        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) #TAB to move indent right
        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
        self.assertEqual(indentValue < indentValue2 , True)
        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
        self.assertEqual(indentValue == indentValue3 , True)
        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.close_doc()

   def test_bullets_and_numbering_button_move(self):
        self.ui_test.create_doc_in_start_center("writer")
        document = self.ui_test.get_component()
        xWriterDoc = self.xUITest.getTopFocusWindow()

        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
        xDialog = self.xUITest.getTopFocusWindow()
        xPages = xDialog.getChild("pages")
        xWriterEntry = xPages.getChild('3')                 # Writer
        xWriterEntry.executeAction("EXPAND", tuple())
        xWriterGeneralEntry = xWriterEntry.getChild('0')
        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General - set millimeters
        xMetric = xDialog.getChild("metric")
        props = {"TEXT": "Millimeter"}
        actionProps = mkPropertyValues(props)
        xMetric.executeAction("SELECT", actionProps)
        xOKBtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xOKBtn)

        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]

        xokbtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xokbtn)  #create bullets

        self.xUITest.executeCommand(".uno:DecrementSubLevels")
        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue2 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
        self.assertEqual(indentValue < indentValue2 , True)
        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.xUITest.executeCommand(".uno:IncrementLevel")
        self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog")
        xDialog = self.xUITest.getTopFocusWindow()
        xTabs = xDialog.getChild("tabcontrol")
        select_pos(xTabs, "4")
        xindentatmf = xDialog.getChild("indentatmf")
        indentValue3 = get_state_as_dict(xindentatmf)["Text"][0:len(get_state_as_dict(xindentatmf)["Text"])-3]
        self.assertEqual(indentValue == indentValue3 , True)
        xcancbtn = xDialog.getChild("cancel")
        self.ui_test.close_dialog_through_button(xcancbtn)

        self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab: