Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / uitest / writer_tests / formatCharacter.py
blob6cd06ad965660b04a992a5ccf64d92b5ff14d4e2
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 formatCharacter(UITestCase):
18 def test_format_character_tab_font(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:FontDialog")
25 xDialog = self.xUITest.getTopFocusWindow()
26 xTabs = xDialog.getChild("tabcontrol")
27 select_pos(xTabs, "0")
29 xSizeFont = xDialog.getChild("westsizelb-cjk")
30 xSizeFontEast = xDialog.getChild("eastsizelb")
31 xSizeFontCTL = xDialog.getChild("ctlsizelb")
32 xLangFont = xDialog.getChild("westlanglb-cjk")
33 xLangFontEast = xDialog.getChild("eastlanglb")
34 xLangFontCTL = xDialog.getChild("ctllanglb")
36 xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
37 xSizeFont.executeAction("BACKSPACE", tuple())
38 xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18
39 xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
40 xSizeFontEast.executeAction("BACKSPACE", tuple())
41 xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18
42 xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
43 xSizeFontCTL.executeAction("BACKSPACE", tuple())
44 xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18
45 select_pos(xLangFont, "0")
46 select_pos(xLangFontEast, "0")
47 select_pos(xLangFontCTL, "0")
48 xOK = xDialog.getChild("ok")
49 xOK.executeAction("CLICK", tuple())
51 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
52 xDialog = self.xUITest.getTopFocusWindow()
53 xSizeFont = xDialog.getChild("westsizelb-cjk")
54 xSizeFontEast = xDialog.getChild("eastsizelb")
55 xSizeFontCTL = xDialog.getChild("ctlsizelb")
56 xLangFont = xDialog.getChild("westlanglb-cjk")
57 xLangFontEast = xDialog.getChild("eastlanglb")
58 xLangFontCTL = xDialog.getChild("ctllanglb")
60 self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18")
61 self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18")
62 self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18") #check font size
63 self.assertEqual(get_state_as_dict(xLangFont)["Text"], "\u202a[None]\u202c")
64 self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "\u202a[None]\u202c")
65 self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "\u202a[None]\u202c")
67 xCanc = xDialog.getChild("cancel")
68 self.ui_test.close_dialog_through_button(xCanc)
70 self.ui_test.close_doc()
72 def test_format_character_tab_font_effects(self):
73 self.ui_test.create_doc_in_start_center("writer")
74 document = self.ui_test.get_component()
75 xWriterDoc = self.xUITest.getTopFocusWindow()
76 xWriterEdit = xWriterDoc.getChild("writer_edit")
78 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
79 xDialog = self.xUITest.getTopFocusWindow()
80 xTabs = xDialog.getChild("tabcontrol")
81 select_pos(xTabs, "1")
83 xEffects = xDialog.getChild("effectslb")
84 xRelief = xDialog.getChild("relieflb")
85 xBlinking = xDialog.getChild("blinkingcb")
86 xHidden = xDialog.getChild("hiddencb")
87 xOverline = xDialog.getChild("overlinelb")
88 xStrikeout = xDialog.getChild("strikeoutlb")
89 xUnderline = xDialog.getChild("underlinelb")
90 xEmphasis = xDialog.getChild("emphasislb")
91 xPosition = xDialog.getChild("positionlb")
93 select_pos(xEffects, "1")
94 select_pos(xRelief, "1")
95 xBlinking.executeAction("CLICK", tuple())
96 xHidden.executeAction("CLICK", tuple())
97 select_pos(xOverline, "1")
98 select_pos(xStrikeout, "1")
99 select_pos(xUnderline, "1")
100 select_pos(xEmphasis, "1")
101 select_pos(xPosition, "1")
103 xOK = xDialog.getChild("ok")
104 xOK.executeAction("CLICK", tuple())
106 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
107 xDialog = self.xUITest.getTopFocusWindow()
108 xTabs = xDialog.getChild("tabcontrol")
109 select_pos(xTabs, "1")
111 xEffects = xDialog.getChild("effectslb")
112 xRelief = xDialog.getChild("relieflb")
113 xBlinking = xDialog.getChild("blinkingcb")
114 xHidden = xDialog.getChild("hiddencb")
115 xOverline = xDialog.getChild("overlinelb")
116 xStrikeout = xDialog.getChild("strikeoutlb")
117 xUnderline = xDialog.getChild("underlinelb")
118 xEmphasis = xDialog.getChild("emphasislb")
119 xPosition = xDialog.getChild("positionlb")
121 self.assertEqual(get_state_as_dict(xEffects)["SelectEntryText"], "Capitals")
122 self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed")
123 self.assertEqual(get_state_as_dict(xBlinking)["Selected"], "true")
124 self.assertEqual(get_state_as_dict(xHidden)["Selected"], "true")
125 self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single")
126 self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single")
127 self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single")
128 self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot")
129 self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text")
131 xCanc = xDialog.getChild("cancel")
132 self.ui_test.close_dialog_through_button(xCanc)
134 self.ui_test.close_doc()
136 def test_format_character_tab_hyperlink(self):
137 self.ui_test.create_doc_in_start_center("writer")
138 document = self.ui_test.get_component()
139 xWriterDoc = self.xUITest.getTopFocusWindow()
140 xWriterEdit = xWriterDoc.getChild("writer_edit")
142 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
143 xDialog = self.xUITest.getTopFocusWindow()
144 xTabs = xDialog.getChild("tabcontrol")
145 select_pos(xTabs, "4")
147 xURL = xDialog.getChild("urled")
148 xURL.executeAction("TYPE", mkPropertyValues({"TEXT":"libreoffice.org"}))
149 xTexted = xDialog.getChild("texted")
150 xTexted.executeAction("TYPE", mkPropertyValues({"TEXT":"LibreOffice"}))
151 xName = xDialog.getChild("nameed")
152 xName.executeAction("TYPE", mkPropertyValues({"TEXT":"hyperlink"}))
154 xVisited = xDialog.getChild("visitedlb")
155 props = {"TEXT": "Bullets"}
156 actionProps = mkPropertyValues(props)
157 xVisited.executeAction("SELECT", actionProps)
158 xUnVisited = xDialog.getChild("unvisitedlb")
159 props = {"TEXT": "Bullets"}
160 actionProps = mkPropertyValues(props)
161 xUnVisited.executeAction("SELECT", actionProps)
163 xOK = xDialog.getChild("ok")
164 self.ui_test.close_dialog_through_button(xOK)
166 self.xUITest.executeCommand(".uno:GoLeft")
167 self.assertEqual(document.Text.String[0:11], "LibreOffice")
169 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
170 xDialog = self.xUITest.getTopFocusWindow()
171 xTabs = xDialog.getChild("tabcontrol")
172 select_pos(xTabs, "4")
173 xURL = xDialog.getChild("urled")
174 xTexted = xDialog.getChild("texted")
175 xName = xDialog.getChild("nameed")
176 xVisited = xDialog.getChild("visitedlb")
177 xUnVisited = xDialog.getChild("unvisitedlb")
179 self.assertEqual(get_state_as_dict(xURL)["Text"], "http://libreoffice.org/")
180 self.assertEqual(get_state_as_dict(xTexted)["Text"], "LibreOffice")
181 self.assertEqual(get_state_as_dict(xName)["Text"], "hyperlink")
182 self.assertEqual(get_state_as_dict(xVisited)["SelectEntryText"], "Bullets")
183 self.assertEqual(get_state_as_dict(xUnVisited)["SelectEntryText"], "Bullets")
185 xCanc = xDialog.getChild("cancel")
186 self.ui_test.close_dialog_through_button(xCanc)
187 self.ui_test.close_doc()
189 def test_format_character_tab_asian_layout(self):
190 self.ui_test.create_doc_in_start_center("writer")
191 document = self.ui_test.get_component()
192 xWriterDoc = self.xUITest.getTopFocusWindow()
193 xWriterEdit = xWriterDoc.getChild("writer_edit")
195 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
196 xDialog = self.xUITest.getTopFocusWindow()
197 xTabs = xDialog.getChild("tabcontrol")
198 select_pos(xTabs, "3")
200 xTwolines = xDialog.getChild("twolines")
201 xTwolines.executeAction("CLICK", tuple())
203 xOK = xDialog.getChild("ok")
204 self.ui_test.close_dialog_through_button(xOK)
206 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
207 xDialog = self.xUITest.getTopFocusWindow()
208 xTabs = xDialog.getChild("tabcontrol")
209 select_pos(xTabs, "3")
210 xTwolines = xDialog.getChild("twolines")
212 self.assertEqual(get_state_as_dict(xTwolines)["Selected"], "true")
213 xCanc = xDialog.getChild("cancel")
214 self.ui_test.close_dialog_through_button(xCanc)
215 self.ui_test.close_doc()
217 def test_format_character_tab_position(self):
218 self.ui_test.create_doc_in_start_center("writer")
219 document = self.ui_test.get_component()
220 xWriterDoc = self.xUITest.getTopFocusWindow()
221 xWriterEdit = xWriterDoc.getChild("writer_edit")
223 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
224 xDialog = self.xUITest.getTopFocusWindow()
225 xTabs = xDialog.getChild("tabcontrol")
226 select_pos(xTabs, "2")
228 xSuperscript = xDialog.getChild("superscript")
229 xRelFontSize = xDialog.getChild("fontsizesb")
230 x90deg = xDialog.getChild("90deg")
231 xScalewidth = xDialog.getChild("scalewidthsb")
232 xKerning = xDialog.getChild("kerningsb")
233 xPairKerning = xDialog.getChild("pairkerning")
234 xFitToLine = xDialog.getChild("fittoline")
236 xSuperscript.executeAction("CLICK", tuple())
237 xRelFontSize.executeAction("UP", tuple())
238 x90deg.executeAction("CLICK", tuple())
239 xScalewidth.executeAction("UP", tuple())
240 xKerning.executeAction("UP", tuple())
241 xPairKerning.executeAction("CLICK", tuple())
242 xFitToLine.executeAction("CLICK", tuple())
244 xOK = xDialog.getChild("ok")
245 self.ui_test.close_dialog_through_button(xOK)
247 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
248 xDialog = self.xUITest.getTopFocusWindow()
249 xTabs = xDialog.getChild("tabcontrol")
250 select_pos(xTabs, "2")
251 xSuperscript = xDialog.getChild("superscript")
252 xRelFontSize = xDialog.getChild("fontsizesb")
253 x90deg = xDialog.getChild("90deg")
254 xScalewidth = xDialog.getChild("scalewidthsb")
255 xKerning = xDialog.getChild("kerningsb")
256 xPairKerning = xDialog.getChild("pairkerning")
257 xFitToLine = xDialog.getChild("fittoline")
259 self.assertEqual(get_state_as_dict(xSuperscript)["Checked"], "true")
260 self.assertEqual(get_state_as_dict(x90deg)["Checked"], "true")
261 self.assertEqual(get_state_as_dict(xScalewidth)["Text"], "100%")
262 self.assertEqual(get_state_as_dict(xKerning)["Text"], "0.1 pt")
263 self.assertEqual(get_state_as_dict(xPairKerning)["Selected"], "false")
264 self.assertEqual(get_state_as_dict(xFitToLine)["Selected"], "true")
266 xCanc = xDialog.getChild("cancel")
267 self.ui_test.close_dialog_through_button(xCanc)
269 self.ui_test.close_doc()
271 def test_format_character_tab_position_scalewidthsb(self):
272 self.ui_test.create_doc_in_start_center("writer")
273 document = self.ui_test.get_component()
274 xWriterDoc = self.xUITest.getTopFocusWindow()
275 xWriterEdit = xWriterDoc.getChild("writer_edit")
277 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
278 xDialog = self.xUITest.getTopFocusWindow()
279 xTabs = xDialog.getChild("tabcontrol")
280 select_pos(xTabs, "2")
282 xScalewidth = xDialog.getChild("scalewidthsb")
283 xScalewidth.executeAction("UP", tuple())
285 xOK = xDialog.getChild("ok")
286 self.ui_test.close_dialog_through_button(xOK)
288 self.ui_test.execute_dialog_through_command(".uno:FontDialog")
289 xDialog = self.xUITest.getTopFocusWindow()
290 xTabs = xDialog.getChild("tabcontrol")
291 select_pos(xTabs, "2")
292 xScalewidth = xDialog.getChild("scalewidthsb")
293 self.assertEqual(get_state_as_dict(xScalewidth)["Text"], "101%")
295 xCanc = xDialog.getChild("cancel")
296 self.ui_test.close_dialog_through_button(xCanc)
298 self.ui_test.close_doc()
300 # vim: set shiftwidth=4 softtabstop=4 expandtab: