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 select_pos
, get_state_as_dict
12 from uitest
.uihelper
.common
import change_measurement_unit
13 from com
.sun
.star
.awt
.GradientStyle
import LINEAR
14 from com
.sun
.star
.drawing
.HatchStyle
import SINGLE
15 from com
.sun
.star
.drawing
.BitmapMode
import REPEAT
16 from com
.sun
.star
.drawing
.RectanglePoint
import MIDDLE_MIDDLE
19 class WriterPageDialog(UITestCase
):
21 def click_button(self
, dialog
, button
):
22 xButton
= dialog
.getChild(button
)
23 xButton
.executeAction("CLICK", tuple())
25 def check_default_area(self
, btn
):
26 document
= self
.ui_test
.get_component()
29 document
.StyleFamilies
.PageStyles
.Standard
.BackColor
, -1)
30 elif btn
== 'btncolor':
32 hex(document
.StyleFamilies
.PageStyles
.Standard
.BackColor
), '0x729fcf')
34 hex(document
.StyleFamilies
.PageStyles
.Standard
.FillColor
), '0x729fcf')
36 hex(document
.StyleFamilies
.PageStyles
.Standard
.FillColor
), '0x729fcf')
37 elif btn
== 'btngradient':
39 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.Style
, LINEAR
)
41 hex(document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.StartColor
), '0xdde8cb')
43 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.Angle
, 300)
45 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.Border
, 0)
47 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.XOffset
, 0)
49 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.YOffset
, 0)
51 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.StartIntensity
, 100)
53 document
.StyleFamilies
.PageStyles
.Standard
.FillGradient
.EndIntensity
, 100)
55 document
.StyleFamilies
.PageStyles
.Standard
.FillGradientName
, 'Pastel Bouquet')
56 elif btn
== 'btnhatch':
58 document
.StyleFamilies
.PageStyles
.Standard
.FillHatch
.Style
, SINGLE
)
60 document
.StyleFamilies
.PageStyles
.Standard
.FillHatch
.Color
, 0)
62 document
.StyleFamilies
.PageStyles
.Standard
.FillHatch
.Distance
, 102)
64 document
.StyleFamilies
.PageStyles
.Standard
.FillHatch
.Angle
, 0)
66 document
.StyleFamilies
.PageStyles
.Standard
.FillHatchName
, 'Black 0 Degrees')
67 elif btn
== 'btnbitmap':
69 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapMode
, REPEAT
)
71 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapPositionOffsetX
, 0)
73 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapPositionOffsetY
, 0)
75 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
77 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapStretch
, False)
79 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapTile
, True)
81 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapOffsetX
, 0)
83 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapOffsetY
, 0)
85 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapLogicalSize
, True)
87 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapSizeX
, 1000)
89 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapSizeY
, 1000)
91 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapName
, 'Painted White')
92 elif btn
== 'btnpattern':
94 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapMode
, REPEAT
)
96 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapPositionOffsetX
, 0)
98 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapPositionOffsetY
, 0)
100 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapRectanglePoint
, MIDDLE_MIDDLE
)
102 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapStretch
, False)
104 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapTile
, True)
106 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapOffsetX
, 0)
108 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapOffsetY
, 0)
110 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapLogicalSize
, True)
112 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapSizeX
, 1000)
114 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapSizeY
, 1000)
116 document
.StyleFamilies
.PageStyles
.Standard
.FillBitmapName
, '5 Percent')
118 def test_area_tab(self
):
120 with self
.ui_test
.create_doc_in_start_center("writer"):
122 with
change_measurement_unit(self
, "Centimeter"):
124 buttons
= ['btnbitmap', 'btncolor', 'btngradient', 'btnhatch', 'btnpattern']
125 for index
, button
in enumerate(buttons
):
127 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
128 tabcontrol
= xDialog
.getChild("tabcontrol")
129 select_pos(tabcontrol
, "2")
130 self
.click_button(xDialog
, button
)
132 self
.check_default_area(button
)
134 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
135 tabcontrol
= xDialog
.getChild("tabcontrol")
136 select_pos(tabcontrol
, "2")
138 self
.click_button(xDialog
, 'btnnone')
140 self
.check_default_area('btnnone')
143 def test_paper_format(self
):
145 lPaperFormat
= ["A6", "A5", "A4", "A3", "B6 (ISO)", "B5 (ISO)", "B4 (ISO)", "Letter",
146 "Legal", "Long Bond", "Tabloid", "B6 (JIS)", "B5 (JIS)", "B4 (JIS)", "16 Kai",
147 "32 Kai", "Big 32 Kai", "User", "DL Envelope", "C6 Envelope", "C6/5 Envelope",
148 "C5 Envelope", "C4 Envelope", "#6¾ Envelope", "#7¾ (Monarch) Envelope",
149 "#9 Envelope", "#10 Envelope", "#11 Envelope", "#12 Envelope", "Japanese Postcard"]
151 with self
.ui_test
.create_doc_in_start_center("writer"):
154 with self
.subTest(i
=i
):
155 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
156 tabcontrol
= xDialog
.getChild("tabcontrol")
157 select_pos(tabcontrol
, "1")
158 xFormatList
= xDialog
.getChild("comboPageFormat")
159 select_pos(xFormatList
, str(i
))
162 get_state_as_dict(xFormatList
)["SelectEntryText"], lPaperFormat
[i
])
165 def test_orientation(self
):
167 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
170 document
.StyleFamilies
.PageStyles
.Standard
.IsLandscape
, False)
172 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
173 tabcontrol
= xDialog
.getChild("tabcontrol")
174 select_pos(tabcontrol
, "1")
175 self
.click_button(xDialog
, 'radiobuttonLandscape')
178 document
.StyleFamilies
.PageStyles
.Standard
.IsLandscape
, True)
180 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
181 tabcontrol
= xDialog
.getChild("tabcontrol")
182 select_pos(tabcontrol
, "1")
183 self
.click_button(xDialog
, 'radiobuttonPortrait')
186 document
.StyleFamilies
.PageStyles
.Standard
.IsLandscape
, False)
189 def test_text_direction(self
):
191 lTextDirection
= ['Left-to-right (horizontal)', 'Right-to-left (horizontal)',
192 'Right-to-left (vertical)', 'Left-to-right (vertical)']
194 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
197 with self
.subTest(i
=i
):
198 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as xDialog
:
199 tabcontrol
= xDialog
.getChild("tabcontrol")
200 select_pos(tabcontrol
, "1")
202 xTextDirectionList
= xDialog
.getChild("comboTextFlowBox")
203 select_pos(xTextDirectionList
, str(i
))
206 get_state_as_dict(xTextDirectionList
)["SelectEntryText"], lTextDirection
[i
])
209 document
.StyleFamilies
.PageStyles
.Standard
.WritingMode
, i
)
212 def test_cancel_button_page_dialog(self
):
213 with self
.ui_test
.create_doc_in_start_center("writer"):
215 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog", close_button
="cancel"):
219 # vim: set shiftwidth=4 softtabstop=4 expandtab: