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 get_state_as_dict
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 with self
.ui_test
.create_doc_in_start_center("writer"):
21 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog") as xDialog
:
22 xTabs
= xDialog
.getChild("tabcontrol")
23 select_pos(xTabs
, "0")
25 # xNoteBook = xDialog.getChild("nbWestern") //western notebook is always active
26 xSizeFont
= xDialog
.getChild("cbWestSize")
27 xLangFont
= xDialog
.getChild("cbWestLanguage")
28 xSizeFont
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
29 xSizeFont
.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))
31 select_pos(xLangFont
, "0")
33 xNoteBook
= xDialog
.getChild("nbCJKCTL")
34 select_pos(xNoteBook
, "0")
35 xSizeFontEast
= xDialog
.getChild("cbCJKSize")
36 xLangFontEast
= xDialog
.getChild("cbCJKLanguage")
37 xSizeFontEast
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
38 xSizeFontEast
.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18
39 select_pos(xLangFontEast
, "0")
41 select_pos(xNoteBook
, "1")
42 xSizeFontCTL
= xDialog
.getChild("cbCTLSize")
43 xLangFontCTL
= xDialog
.getChild("cbCTLLanguage")
44 xSizeFontCTL
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
45 xSizeFontCTL
.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18
46 select_pos(xLangFontCTL
, "0")
48 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog", close_button
="cancel") as xDialog
:
49 xSizeFont
= xDialog
.getChild("cbWestSize")
50 self
.assertEqual(get_state_as_dict(xSizeFont
)["Text"], "18 pt")
51 xLangFont
= xDialog
.getChild("cbWestLanguage")
52 self
.assertEqual(get_state_as_dict(xLangFont
)["Text"], "[None]")
54 xNoteBook
= xDialog
.getChild("nbCJKCTL")
55 select_pos(xNoteBook
, "0")
56 xSizeFontEast
= xDialog
.getChild("cbCJKSize")
57 self
.assertEqual(get_state_as_dict(xSizeFontEast
)["Text"], "18 pt")
58 xLangFontEast
= xDialog
.getChild("cbCJKLanguage")
59 self
.assertEqual(get_state_as_dict(xLangFontEast
)["Text"], "[None]")
61 select_pos(xNoteBook
, "1")
62 xSizeFontCTL
= xDialog
.getChild("cbCTLSize")
63 self
.assertEqual(get_state_as_dict(xSizeFontCTL
)["Text"], "18 pt")
64 xLangFontCTL
= xDialog
.getChild("cbCTLLanguage")
65 self
.assertEqual(get_state_as_dict(xLangFontCTL
)["Text"], "[None]")
67 def test_format_character_tab_font_effects(self
):
68 with self
.ui_test
.create_doc_in_start_center("writer"):
70 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog") as xDialog
:
71 xTabs
= xDialog
.getChild("tabcontrol")
72 select_pos(xTabs
, "1")
74 xEffects
= xDialog
.getChild("effectslb")
75 xRelief
= xDialog
.getChild("relieflb")
76 xHidden
= xDialog
.getChild("hiddencb")
77 xOverline
= xDialog
.getChild("overlinelb")
78 xStrikeout
= xDialog
.getChild("strikeoutlb")
79 xUnderline
= xDialog
.getChild("underlinelb")
80 xEmphasis
= xDialog
.getChild("emphasislb")
81 xPosition
= xDialog
.getChild("positionlb")
83 select_pos(xEffects
, "1")
84 select_pos(xRelief
, "1")
85 xHidden
.executeAction("CLICK", tuple())
86 select_pos(xOverline
, "1")
87 select_pos(xStrikeout
, "1")
88 select_pos(xUnderline
, "1")
89 select_pos(xEmphasis
, "1")
90 select_pos(xPosition
, "1")
93 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog", close_button
="cancel") as xDialog
:
94 xTabs
= xDialog
.getChild("tabcontrol")
95 select_pos(xTabs
, "1")
97 xEffects
= xDialog
.getChild("effectslb")
98 xRelief
= xDialog
.getChild("relieflb")
99 xHidden
= xDialog
.getChild("hiddencb")
100 xOverline
= xDialog
.getChild("overlinelb")
101 xStrikeout
= xDialog
.getChild("strikeoutlb")
102 xUnderline
= xDialog
.getChild("underlinelb")
103 xEmphasis
= xDialog
.getChild("emphasislb")
104 xPosition
= xDialog
.getChild("positionlb")
106 self
.assertEqual(get_state_as_dict(xEffects
)["SelectEntryText"], "UPPERCASE")
107 self
.assertEqual(get_state_as_dict(xRelief
)["SelectEntryText"], "Embossed")
108 self
.assertEqual(get_state_as_dict(xHidden
)["Selected"], "true")
109 self
.assertEqual(get_state_as_dict(xOverline
)["SelectEntryText"], "Single")
110 self
.assertEqual(get_state_as_dict(xStrikeout
)["SelectEntryText"], "Single")
111 self
.assertEqual(get_state_as_dict(xUnderline
)["SelectEntryText"], "Single")
112 self
.assertEqual(get_state_as_dict(xEmphasis
)["SelectEntryText"], "Dot")
113 self
.assertEqual(get_state_as_dict(xPosition
)["SelectEntryText"], "Below text")
115 def test_format_character_tab_asian_layout(self
):
116 with self
.ui_test
.create_doc_in_start_center("writer"):
118 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog") as xDialog
:
119 xTabs
= xDialog
.getChild("tabcontrol")
120 select_pos(xTabs
, "3")
122 xTwolines
= xDialog
.getChild("twolines")
123 xTwolines
.executeAction("CLICK", tuple())
126 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog", close_button
="cancel") as xDialog
:
127 xTabs
= xDialog
.getChild("tabcontrol")
128 select_pos(xTabs
, "3")
129 xTwolines
= xDialog
.getChild("twolines")
131 self
.assertEqual(get_state_as_dict(xTwolines
)["Selected"], "true")
133 def test_format_character_tab_position(self
):
134 with self
.ui_test
.create_doc_in_start_center("writer"):
136 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog") as xDialog
:
137 xTabs
= xDialog
.getChild("tabcontrol")
138 select_pos(xTabs
, "2")
140 xSuperscript
= xDialog
.getChild("superscript")
141 xRelFontSize
= xDialog
.getChild("fontsizesb")
142 x90deg
= xDialog
.getChild("90deg")
143 xScalewidth
= xDialog
.getChild("scalewidthsb")
144 xKerning
= xDialog
.getChild("kerningsb")
145 xPairKerning
= xDialog
.getChild("pairkerning")
146 xFitToLine
= xDialog
.getChild("fittoline")
147 xNoHyphenation
= xDialog
.getChild("nohyphenation")
148 self
.assertEqual(get_state_as_dict(xNoHyphenation
)["Selected"], "false")
150 xSuperscript
.executeAction("CLICK", tuple())
151 xRelFontSize
.executeAction("UP", tuple())
152 x90deg
.executeAction("CLICK", tuple())
153 xScalewidth
.executeAction("UP", tuple())
154 xKerning
.executeAction("UP", tuple())
155 xPairKerning
.executeAction("CLICK", tuple())
156 xFitToLine
.executeAction("CLICK", tuple())
157 xNoHyphenation
.executeAction("CLICK", tuple())
160 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog", close_button
="cancel") as xDialog
:
161 xTabs
= xDialog
.getChild("tabcontrol")
162 select_pos(xTabs
, "2")
163 xSuperscript
= xDialog
.getChild("superscript")
164 xRelFontSize
= xDialog
.getChild("fontsizesb")
165 x90deg
= xDialog
.getChild("90deg")
166 xScalewidth
= xDialog
.getChild("scalewidthsb")
167 xKerning
= xDialog
.getChild("kerningsb")
168 xPairKerning
= xDialog
.getChild("pairkerning")
169 xFitToLine
= xDialog
.getChild("fittoline")
170 xNoHyphenation
= xDialog
.getChild("nohyphenation")
172 self
.assertEqual(get_state_as_dict(xSuperscript
)["Checked"], "true")
173 self
.assertEqual(get_state_as_dict(x90deg
)["Checked"], "true")
174 self
.assertEqual(get_state_as_dict(xScalewidth
)["Text"], "100%")
175 self
.assertEqual(get_state_as_dict(xKerning
)["Text"], "0.1 pt")
176 self
.assertEqual(get_state_as_dict(xPairKerning
)["Selected"], "false")
177 self
.assertEqual(get_state_as_dict(xFitToLine
)["Selected"], "true")
178 self
.assertEqual(get_state_as_dict(xNoHyphenation
)["Selected"], "true")
180 def test_format_character_tab_position_scalewidthsb(self
):
181 with self
.ui_test
.create_doc_in_start_center("writer"):
183 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog") as xDialog
:
184 xTabs
= xDialog
.getChild("tabcontrol")
185 select_pos(xTabs
, "2")
187 xScalewidth
= xDialog
.getChild("scalewidthsb")
188 xScalewidth
.executeAction("UP", tuple())
191 with self
.ui_test
.execute_dialog_through_command(".uno:FontDialog", close_button
="cancel") as xDialog
:
192 xTabs
= xDialog
.getChild("tabcontrol")
193 select_pos(xTabs
, "2")
194 xScalewidth
= xDialog
.getChild("scalewidthsb")
195 self
.assertEqual(get_state_as_dict(xScalewidth
)["Text"], "101%")
197 # vim: set shiftwidth=4 softtabstop=4 expandtab: