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
|
#
# 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 uitest.uihelper.common import select_pos, get_state_as_dict
from com.sun.star.uno import RuntimeException
from com.sun.star.awt.GradientStyle import LINEAR
from com.sun.star.drawing.HatchStyle import SINGLE
from com.sun.star.drawing.BitmapMode import REPEAT
from com.sun.star.drawing.RectanglePoint import MIDDLE_MIDDLE
from libreoffice.uno.propertyvalue import mkPropertyValues
class WriterPageDialog(UITestCase):
def launch_dialog_and_select_tab(self, tab):
self.ui_test.execute_dialog_through_command(".uno:PageDialog")
xDialog = self.xUITest.getTopFocusWindow()
tabcontrol = xDialog.getChild("tabcontrol")
select_pos(tabcontrol, str(tab))
return xDialog
def click_button(self, dialog, button):
xButton = dialog.getChild(button)
xButton.executeAction("CLICK", tuple())
def check_default_area(self, btn):
document = self.ui_test.get_component()
if btn == 'btnnone':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.BackColor, -1)
elif btn == 'btncolor':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.BackColor, 7512015)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillColor, 7512015)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillColor, 7512015)
elif btn == 'btngradient':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.Style, LINEAR)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.StartColor, 9101876)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.Angle, 300)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.Border, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.XOffset, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.YOffset, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.StartIntensity, 100)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradient.EndIntensity, 100)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillGradientName, 'Tango Green')
elif btn == 'btnhatch':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillHatch.Style, SINGLE )
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillHatch.Color, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillHatch.Distance, 102)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillHatch.Angle, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillHatchName, 'Black 0 Degrees')
elif btn == 'btnbitmap':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapMode, REPEAT)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapStretch, False)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapTile, True)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapLogicalSize, True)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapSizeX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapSizeY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapName, 'Sky')
elif btn == 'btnpattern':
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapMode, REPEAT)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapStretch, False)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapTile, True)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapLogicalSize, True)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapSizeX, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapSizeY, 0)
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.FillBitmapName, '5 Percent')
def test_area_tab(self):
self.ui_test.create_doc_in_start_center("writer")
buttons = ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
for index, button in enumerate(buttons):
xDialog = self.launch_dialog_and_select_tab(2)
self.click_button(xDialog, button)
self.click_button(xDialog, 'ok')
self.check_default_area(button)
xDialog = self.launch_dialog_and_select_tab(2)
self.click_button(xDialog, 'btnnone')
self.click_button(xDialog, 'ok')
self.check_default_area('btnnone')
self.ui_test.close_doc()
def test_paper_format(self):
lPaperFormat = ["A6", "A5", "A4", "A3", "B6 (ISO)", "B5 (ISO)", "B4 (ISO)", "Letter",
"Legal", "Long Bond", "Tabloid", "B6 (JIS)", "B5 (JIS)", "B4 (JIS)", "16 Kai",
"32 Kai", "Big 32 Kai", "User", "DL Envelope", "C6 Envelope", "C6/5 Envelope",
"C5 Envelope", "C4 Envelope", "#6¾ Envelope", "#7¾ (Monarch) Envelope",
"#9 Envelope", "#10 Envelope", "#11 Envelope", "#12 Envelope", "Japanese Postcard"]
self.ui_test.create_doc_in_start_center("writer")
for i in range(30):
with self.subTest(i=i):
xDialog = self.launch_dialog_and_select_tab(1)
xFormatList = xDialog.getChild("comboPageFormat")
select_pos(xFormatList, str(i))
self.assertEqual(
get_state_as_dict(xFormatList)["SelectEntryText"], lPaperFormat[i])
self.click_button(xDialog, 'ok')
self.ui_test.close_doc()
def test_orientation(self):
self.ui_test.create_doc_in_start_center("writer")
document = self.ui_test.get_component()
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.IsLandscape, False)
xDialog = self.launch_dialog_and_select_tab(1)
self.click_button(xDialog, 'radiobuttonLandscape')
self.click_button(xDialog, 'ok')
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.IsLandscape, True)
xDialog = self.launch_dialog_and_select_tab(1)
self.click_button(xDialog, 'radiobuttonPortrait')
self.click_button(xDialog, 'ok')
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.IsLandscape, False)
self.ui_test.close_doc()
def test_text_direction(self):
lTextDirection = ['Left-to-right (horizontal)', 'Right-to-left (horizontal)',
'Right-to-left (vertical)', 'Left-to-right (vertical)']
self.ui_test.create_doc_in_start_center("writer")
document = self.ui_test.get_component()
for i in range(4):
with self.subTest(i=i):
xDialog = self.launch_dialog_and_select_tab(1)
xTextDirectionList = xDialog.getChild("comboTextFlowBox")
select_pos(xTextDirectionList, str(i))
self.assertEqual(
get_state_as_dict(xTextDirectionList)["SelectEntryText"], lTextDirection[i])
self.click_button(xDialog, 'ok')
self.assertEqual(
document.StyleFamilies.PageStyles.Standard.WritingMode, i)
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|