Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / writer_tests3 / pageDialog.py
blob7e95e08d8570634394e148145e3148be3c69c964
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()
27 if btn == 'btnnone':
28 self.assertEqual(
29 document.StyleFamilies.PageStyles.Standard.BackColor, -1)
30 elif btn == 'btncolor':
31 self.assertEqual(
32 hex(document.StyleFamilies.PageStyles.Standard.BackColor), '0x729fcf')
33 self.assertEqual(
34 hex(document.StyleFamilies.PageStyles.Standard.FillColor), '0x729fcf')
35 self.assertEqual(
36 hex(document.StyleFamilies.PageStyles.Standard.FillColor), '0x729fcf')
37 elif btn == 'btngradient':
38 self.assertEqual(
39 document.StyleFamilies.PageStyles.Standard.FillGradient.Style, LINEAR)
40 self.assertEqual(
41 hex(document.StyleFamilies.PageStyles.Standard.FillGradient.StartColor), '0xdde8cb')
42 self.assertEqual(
43 document.StyleFamilies.PageStyles.Standard.FillGradient.Angle, 300)
44 self.assertEqual(
45 document.StyleFamilies.PageStyles.Standard.FillGradient.Border, 0)
46 self.assertEqual(
47 document.StyleFamilies.PageStyles.Standard.FillGradient.XOffset, 0)
48 self.assertEqual(
49 document.StyleFamilies.PageStyles.Standard.FillGradient.YOffset, 0)
50 self.assertEqual(
51 document.StyleFamilies.PageStyles.Standard.FillGradient.StartIntensity, 100)
52 self.assertEqual(
53 document.StyleFamilies.PageStyles.Standard.FillGradient.EndIntensity, 100)
54 self.assertEqual(
55 document.StyleFamilies.PageStyles.Standard.FillGradientName, 'Pastel Bouquet')
56 elif btn == 'btnhatch':
57 self.assertEqual(
58 document.StyleFamilies.PageStyles.Standard.FillHatch.Style, SINGLE )
59 self.assertEqual(
60 document.StyleFamilies.PageStyles.Standard.FillHatch.Color, 0)
61 self.assertEqual(
62 document.StyleFamilies.PageStyles.Standard.FillHatch.Distance, 102)
63 self.assertEqual(
64 document.StyleFamilies.PageStyles.Standard.FillHatch.Angle, 0)
65 self.assertEqual(
66 document.StyleFamilies.PageStyles.Standard.FillHatchName, 'Black 0 Degrees')
67 elif btn == 'btnbitmap':
68 self.assertEqual(
69 document.StyleFamilies.PageStyles.Standard.FillBitmapMode, REPEAT)
70 self.assertEqual(
71 document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetX, 0)
72 self.assertEqual(
73 document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetY, 0)
74 self.assertEqual(
75 document.StyleFamilies.PageStyles.Standard.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
76 self.assertEqual(
77 document.StyleFamilies.PageStyles.Standard.FillBitmapStretch, False)
78 self.assertEqual(
79 document.StyleFamilies.PageStyles.Standard.FillBitmapTile, True)
80 self.assertEqual(
81 document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetX, 0)
82 self.assertEqual(
83 document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetY, 0)
84 self.assertEqual(
85 document.StyleFamilies.PageStyles.Standard.FillBitmapLogicalSize, True)
86 self.assertEqual(
87 document.StyleFamilies.PageStyles.Standard.FillBitmapSizeX, 1000)
88 self.assertEqual(
89 document.StyleFamilies.PageStyles.Standard.FillBitmapSizeY, 1000)
90 self.assertEqual(
91 document.StyleFamilies.PageStyles.Standard.FillBitmapName, 'Painted White')
92 elif btn == 'btnpattern':
93 self.assertEqual(
94 document.StyleFamilies.PageStyles.Standard.FillBitmapMode, REPEAT)
95 self.assertEqual(
96 document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetX, 0)
97 self.assertEqual(
98 document.StyleFamilies.PageStyles.Standard.FillBitmapPositionOffsetY, 0)
99 self.assertEqual(
100 document.StyleFamilies.PageStyles.Standard.FillBitmapRectanglePoint, MIDDLE_MIDDLE)
101 self.assertEqual(
102 document.StyleFamilies.PageStyles.Standard.FillBitmapStretch, False)
103 self.assertEqual(
104 document.StyleFamilies.PageStyles.Standard.FillBitmapTile, True)
105 self.assertEqual(
106 document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetX, 0)
107 self.assertEqual(
108 document.StyleFamilies.PageStyles.Standard.FillBitmapOffsetY, 0)
109 self.assertEqual(
110 document.StyleFamilies.PageStyles.Standard.FillBitmapLogicalSize, True)
111 self.assertEqual(
112 document.StyleFamilies.PageStyles.Standard.FillBitmapSizeX, 1000)
113 self.assertEqual(
114 document.StyleFamilies.PageStyles.Standard.FillBitmapSizeY, 1000)
115 self.assertEqual(
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"):
153 for i in range(30):
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))
161 self.assertEqual(
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:
169 self.assertEqual(
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')
177 self.assertEqual(
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')
185 self.assertEqual(
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:
196 for i in range(4):
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))
205 self.assertEqual(
206 get_state_as_dict(xTextDirectionList)["SelectEntryText"], lTextDirection[i])
208 self.assertEqual(
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"):
216 pass
219 # vim: set shiftwidth=4 softtabstop=4 expandtab: