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 convert_property_values_to_dict
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.common
import get_state_as_dict
11 from uitest
.uihelper
.common
import select_pos
12 from uitest
.uihelper
.common
import select_by_text
14 # Test for cui/source/tabpages/themepage.cxx.
15 class Test(UITestCase
):
17 def testThemePage(self
):
18 # Given an Impress document with a master page that has a theme:
19 with self
.ui_test
.create_doc_in_start_center("impress") as component
:
20 template
= self
.xUITest
.getTopFocusWindow()
21 self
.ui_test
.close_dialog_through_button(template
.getChild("close"))
22 doc
= self
.xUITest
.getTopFocusWindow()
23 editWin
= doc
.getChild("impress_win")
24 drawPage
= component
.getDrawPages().getByIndex(0)
25 master
= drawPage
.MasterPage
26 theme
= mkPropertyValues({
28 "ColorSchemeName": "colorSetA",
29 "ColorScheme": tuple([
44 master
.ThemeUnoRepresentation
= theme
46 # When changing the name of the theme:
47 self
.xUITest
.executeCommand(".uno:SlideMasterPage")
48 with self
.ui_test
.execute_dialog_through_command(".uno:PageSetup") as xDialog
:
49 xTabs
= xDialog
.getChild("tabcontrol")
50 # Select RID_SVXPAGE_THEME.
51 select_pos(xTabs
, "3")
52 themeName
= xDialog
.getChild("themeName")
53 themeName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
54 themeName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
55 themeName
.executeAction("TYPE", mkPropertyValues({"TEXT": "nameB"}))
56 colorSetName
= xDialog
.getChild("colorSetName")
57 colorSetName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
58 colorSetName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
59 colorSetName
.executeAction("TYPE", mkPropertyValues({"TEXT": "colorSetB"}))
61 # Select a custom accent1 color.
62 accent1
= xDialog
.getChild("btnAccent1")
63 accent1
.executeAction("OPENLIST", tuple())
64 floatWindow
= self
.xUITest
.getFloatWindow()
65 paletteSelector
= floatWindow
.getChild("palette_listbox")
66 select_by_text(paletteSelector
, "chart-palettes")
67 colorSet
= floatWindow
.getChild("colorset")
68 colorSet
.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
70 # Then make sure the doc model is updated accordingly:
71 # Without the accompanying fix in place, this test would have failed with:
72 # AssertionError: 'nameA' != 'nameB'
73 # i.e. the UI didn't update the theme name.
74 theme
= convert_property_values_to_dict(master
.ThemeUnoRepresentation
)
75 self
.assertEqual(theme
["Name"], "nameB")
76 # Without the accompanying fix in place, this test would have failed with:
77 # AssertionError: 'colorSetA' != 'colorSetB'
78 # i.e. the UI didn't update the color scheme name.
79 self
.assertEqual(theme
["ColorSchemeName"], "colorSetB")
80 colorSet
= theme
["ColorScheme"]
81 # Without the accompanying fix in place, this test would have failed with:
82 # AssertionError: 0 != 16728590 (#ff420e)
83 # i.e. the UI didn't update the accent1 color from black to a custom value.
84 self
.assertEqual(colorSet
[4], 0xff420e)
87 # vim: set shiftwidth=4 softtabstop=4 expandtab: