on xenial help sign in
Ship a camera-app.desktop file and use a custom XDG_DATA_DIRS for testing.
2f1d7f1Michał Sawicz
debian/unity8-fake-env.install+1
@@ -1 +1,2 @@
1usr/lib/*/unity8/qml/mocks
1usr/lib/*/unity8/qml/mocks
2+usr/share/unity8/mocks
tests/autopilot/unity8/__init__.py+16−1
@@ -52,7 +52,11 @@ def get_mocks_library_path():
52 if running_installed_tests():
52 if running_installed_tests():
53 mock_path = "qml/mocks/"
53 mock_path = "qml/mocks/"
54 else:
54 else:
55+ mock_path = os.path.join(
56+ "../lib/",
57+ sysconfig.get_config_var('MULTIARCH'),
55− mock_path = "../lib/x86_64-linux-gnu/unity8/qml/mocks/"
58+ "/unity8/qml/mocks/"
59+ )
56 lib_path = get_lib_path()
60 lib_path = get_lib_path()
57 ld_library_path = os.path.abspath(
61 ld_library_path = os.path.abspath(
58 os.path.join(
62 os.path.join(
@@ -83,6 +87,17 @@ def get_binary_path(binary="unity8"):
83 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
87 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
84 return binary_path
88 return binary_path
85
89
90+def get_data_dirs():
91+ """Prepend a mock data path to XDG_DATA_DIRS."""
92+ data_path = os.path.abspath(
93+ os.path.join(os.path.dirname(__file__),
94+ running_installed_tests() and "/usr/share/unity8/mocks/data" or "../../mocks/data"
95+ ))
96+ xdg_path = os.getenv("XDG_DATA_DIRS")
97+ if xdg_path:
98+ return "{0}:{1}".format(data_path, xdg_path)
99+ else:
100+ return data_path
86
101
87def get_grid_size():
102def get_grid_size():
88 grid_size = os.getenv('GRID_UNIT_PX')
103 grid_size = os.getenv('GRID_UNIT_PX')
tests/autopilot/unity8/shell/tests/__init__.py+4−1
@@ -41,6 +41,7 @@ from unity8 import (
41 get_binary_path,
41 get_binary_path,
42 get_mocks_library_path,
42 get_mocks_library_path,
43 get_default_extra_mock_libraries,
43 get_default_extra_mock_libraries,
44+ get_data_dirs
44)
45)
45from unity8.shell.emulators import UnityEmulatorBase
46from unity8.shell.emulators import UnityEmulatorBase
46from unity8.shell.emulators.dash import Dash
47from unity8.shell.emulators.dash import Dash
@@ -120,7 +121,9 @@ class UnityTestCase(AutopilotTestCase):
120 self._proxy = None
121 self._proxy = None
121 self._lightdm_mock_type = None
122 self._lightdm_mock_type = None
122 self._qml_mock_enabled = True
123 self._qml_mock_enabled = True
123− self._environment = {}
124+ self._environment = {
125+ 'XDG_DATA_DIRS': get_data_dirs()
126+ }
124
127
125 #### FIXME: This is a work around re: lp:1238417 ####
128 #### FIXME: This is a work around re: lp:1238417 ####
126 if model() != "Desktop":
129 if model() != "Desktop":
tests/mocks/CMakeLists.txt+5
@@ -7,3 +7,8 @@ add_subdirectory(Powerd)
7add_subdirectory(QMenuModel)
7add_subdirectory(QMenuModel)
8add_subdirectory(Ubuntu)
8add_subdirectory(Ubuntu)
9add_subdirectory(Unity)
9add_subdirectory(Unity)
10+
11+install(
12+ DIRECTORY data
13+ DESTINATION ${SHELL_APP_DIR}/mocks
14+)
tests/mocks/data/applications/camera-app.desktopnew file

No changes to the content.