5
path = os.path.expanduser("~/.config/ubuntu-ui-toolkit/theme.ini")
5
#: Specify the name of a custom visual theme for Ubuntu UI
6
custom_theme = os.path.expanduser("~/.config/ubuntu-ui-toolkit/theme.ini")
7
#: Relative XDG path to location of custom theme files. This is an example only.
8
themedir = 'themes/Ubuntu/Custom'
6
9
themestring = "theme=themes.Ubuntu.Custom"
7
themedir = 'themes/Ubuntu/Custom'
8
data_dirs = subprocess.check_output(['initctl', 'get-env', 'XDG_DATA_DIRS']).split(':')
10
11
class ThemeCustomizationTests(AutopilotTestCase):
13
Downstreams may customize the visual color scheme of Ubuntu Touch,
14
including the overall color palatte as well as individual UI widgets.
16
The mechanism for doing so is two-fold:
18
* create the elements of a new visual theme
19
* configure the Unity shell to use the custom theme
21
Downstreams *may* create new visual themes.
23
If a new visual theme is created, downstreams *must* specify the new
24
theme by modifying the contents of the theme.ini file.
12
27
def test_for_presence_of_theme_customization_file(self):
13
"""Check to see if the dconf file contains entry for disabled scopes"""
14
dconffile = open(path, "r")
29
The presence of this file controls the visual theme of the Unity
32
~/.config/ubuntu-ui-toolkit/theme.ini
34
Downstreams *must* modify the contents of this file to point to
35
the name of the new theme.
37
Downstreams *must not* change the name of this file.
39
dconffile = open(custom_theme, "r")
15
40
customk = dconffile.read()
17
42
if "%s" % (themestring) in customk.splitlines():
18
43
self.assertTrue(True)
20
print "Error reading theme.ini at %s" % (path)
45
print "Error reading theme.ini at %s" % (custom_theme)
21
46
self.assertTrue(False)
24
49
def test_theme_dir_in_datadirs(self):
25
'''Check to see if the themedir exists somewhere in XDG_DATA_DIRS'''
51
If a downstream creates a custom visual theme, the theme's files
52
will be shipped in a subdirectory of:
56
This test verifies the custom visual theme files are present in
59
Downstreams *must* modify the value of `themedir` to search for
60
the specific subdirectory containing the custome theme files.
26
62
themedirfound = False
63
data_dirs = subprocess.check_output(['initctl', 'get-env',
64
'XDG_DATA_DIRS']).split(':')
27
65
for dir in data_dirs:
28
#initctl get-env adds a \n to the end of the output, we need to strip() it out
66
# We use a relative path in `themedir` because we don't
67
# necessarily know the full path to the custom XDG data
68
# directory. Currently, the path is set to /custom/xdg/data
69
# in ubuntu-touch-customization-hooks, but that could
70
# theoretically change. So use the relative path, and glom
71
# it together with every XDG_DATA_DIR path we discover in
72
# the environment and test for its presence. Not spectacular
75
# Note that initctl get-env adds a \n to the end of the
76
# output so we need to strip() it out
29
77
if os.path.isdir(os.path.join(dir.strip(), themedir)):
30
78
themedirfound = True
31
79
self.assertTrue(themedirfound)