Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / qa / uitest / dialogs / chardlg.py
blobd6ebffac3e1e57547f0b714788bc241615d01952
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from libreoffice.uno.propertyvalue import mkPropertyValues
8 from uitest.framework import UITestCase
9 from uitest.uihelper.common import select_pos
10 from uitest.uihelper.common import get_state_as_dict
11 from uitest.uihelper.common import select_by_text
13 # Test for cui/source/tabpages/chardlg.cxx.
14 class Test(UITestCase):
16 def testSvxCharEffectsPage(self):
17 # Start Impress.
18 with self.ui_test.create_doc_in_start_center("impress") as component:
19 template = self.xUITest.getTopFocusWindow()
20 self.ui_test.close_dialog_through_button(template.getChild("close"))
21 doc = self.xUITest.getTopFocusWindow()
22 editWin = doc.getChild("impress_win")
23 # Select the title shape.
24 editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
25 editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
26 self.xUITest.executeCommand(".uno:SelectAll")
28 # Now use Format -> Character.
29 with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
30 xTabs = xDialog.getChild("tabcontrol")
31 # Select RID_SVXPAGE_CHAR_EFFECTS.
32 select_pos(xTabs, "1")
33 xFontTransparency = xDialog.getChild("fonttransparencymtr")
34 for _ in range(5):
35 xFontTransparency.executeAction("UP", tuple())
37 # Verify the result.
38 drawPage = component.getDrawPages()[0]
39 shape = drawPage[0]
41 # Without the accompanying fix in place, this test would have failed with:
42 # AssertionError: 100 != 5
43 # i.e. the dialog did not set transparency to 5%, instead it left the character color at
44 # COL_AUTO.
45 self.assertEqual(shape.CharTransparence, 5)
47 def testSvxCharEffectsPageTheme(self):
48 # Given a document with a document theme:
49 # Start Impress.
50 with self.ui_test.create_doc_in_start_center("impress") as component:
51 template = self.xUITest.getTopFocusWindow()
52 self.ui_test.close_dialog_through_button(template.getChild("close"))
53 doc = self.xUITest.getTopFocusWindow()
54 editWin = doc.getChild("impress_win")
56 # Set theme colors.
57 drawPage = component.getDrawPages().getByIndex(0)
58 master = drawPage.MasterPage
59 theme = mkPropertyValues({
60 "Name": "nameA",
61 "ColorSchemeName": "colorSetA",
62 "ColorScheme": tuple([
63 0x000000, # dk1
64 0x000000, # lt1
65 0x000000, # dk2
66 0x000000, # lt2
67 0x000000, # accent1
68 0x000000, # accent2
69 0x000000, # accent3
70 0x000000, # accent4
71 0x000000, # accent5
72 0x000000, # accent6
73 0x000000, # hlink
74 0x000000, # folHlink
77 master.ThemeUnoRepresentation = theme
79 # Select the title shape.
80 editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
81 editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
82 self.xUITest.executeCommand(".uno:SelectAll")
84 # Now use Format -> Character.
85 with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
86 xTabs = xDialog.getChild("tabcontrol")
87 # Select RID_SVXPAGE_CHAR_EFFECTS.
88 select_pos(xTabs, "1")
90 # When setting the shape text color to accent 1:
91 accent1 = xDialog.getChild("fontcolorlb")
92 accent1.executeAction("OPENLIST", tuple())
93 floatWindow = self.xUITest.getFloatWindow()
94 paletteSelector = floatWindow.getChild("palette_listbox")
95 select_by_text(paletteSelector, "Theme colors")
96 colorSet = floatWindow.getChild("colorset")
97 # 4 would be accent1, +12 is the first from the effect variants.
98 colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": "16"}))
100 # Then make sure the doc model has the correct color theme index:
101 drawPage = component.getDrawPages().getByIndex(0)
102 shape = drawPage.getByIndex(0)
103 paragraphs = shape.createEnumeration()
104 paragraph = paragraphs.nextElement()
105 portions = paragraph.createEnumeration()
106 portion = portions.nextElement()
108 # Without the accompanying fix in place, this test would have failed with:
109 # AssertionError: -1 != 3
110 # i.e. no theme index was set, instead of accent1 (index into the above color scheme).
111 self.assertEqual(portion.CharColorTheme, 3)
113 # Then make sure that '80% lighter' is lum-mod=2000 and lum-off=8000:
114 # Without the accompanying fix in place, this test would have failed with:
115 # AssertionError: 10000 != 2000
116 # i.e. the effects where not applied, luminance modulation was the default instead of a
117 # custom value.
118 self.assertEqual(portion.CharColorLumMod, 5000)
119 self.assertEqual(portion.CharColorLumOff, 5000)
121 def testSvxCharEffectsPageWriter(self):
122 # Start Writer.
123 with self.ui_test.create_doc_in_start_center("writer") as component:
124 doc = self.xUITest.getTopFocusWindow()
125 editWin = doc.getChild("writer_edit")
126 # Type a character and select it.
127 editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
128 editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
129 self.xUITest.executeCommand(".uno:SelectAll")
131 # Now use Format -> Character.
132 with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
133 xTabs = xDialog.getChild("tabcontrol")
134 # Select RID_SVXPAGE_CHAR_EFFECTS.
135 select_pos(xTabs, "1")
136 xFontTransparency = xDialog.getChild("fonttransparencymtr")
137 # Without the accompanying fix in place, this test would have failed with:
138 # AssertionError: 'false' != 'true'
139 # i.e. the transparency widget was hidden.
140 self.assertEqual(get_state_as_dict(xFontTransparency)["Visible"], "true")
141 for _ in range(5):
142 xFontTransparency.executeAction("UP", tuple())
144 # Verify the result.
145 paragraph = component.Text.createEnumeration().nextElement()
147 self.assertEqual(paragraph.CharTransparence, 5)
149 def testSvxCharEffectsPageWriterAutomatic(self):
150 # Start Writer.
151 with self.ui_test.create_doc_in_start_center("writer"):
152 doc = self.xUITest.getTopFocusWindow()
153 editWin = doc.getChild("writer_edit")
155 # Use Format -> Character.
156 with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
157 xTabs = xDialog.getChild("tabcontrol")
158 # Select RID_SVXPAGE_CHAR_EFFECTS.
159 select_pos(xTabs, "1")
160 xFontColorLB = xDialog.getChild("fontcolorlb")
161 # Without the accompanying fix in place, this test would have failed with:
162 # AssertionError: 'White' != 'Automatic'
163 # i.e. the auto color lost its alpha component and appeared as white.
164 self.assertEqual(get_state_as_dict(xFontColorLB)["Text"], "Automatic")
167 # vim: set shiftwidth=4 softtabstop=4 expandtab: