on xenial help sign in
Ship a camera-app.desktop file and use a custom XDG_DATA_DIRS for testing.

Approved by Michal Hruby.

commit2f1d7f121a539f6b077d6d884be10cbc303e836b authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 17 Oct 2013, 00:18 (13 years ago) parent4bf4f04ce3c4b4
5 files changed+26−2
debian/unity8-fake-env.install+1 tests/autopilot/unity8/__init__.py+16−1 tests/autopilot/unity8/shell/tests/__init__.py+4−1 tests/mocks/CMakeLists.txt+5 tests/mocks/data/applications/camera-app.desktop
debian/unity8-fake-env.install+1
@@ -1 +1,2 @@
11usr/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():
5252 if running_installed_tests():
5353 mock_path = "qml/mocks/"
5454 else:
55− mock_path = "../lib/x86_64-linux-gnu/unity8/qml/mocks/"
55+ mock_path = os.path.join(
56+ "../lib/",
57+ sysconfig.get_config_var('MULTIARCH'),
58+ "/unity8/qml/mocks/"
59+ )
5660 lib_path = get_lib_path()
5761 ld_library_path = os.path.abspath(
5862 os.path.join(
@@ -83,6 +87,17 @@ def get_binary_path(binary="unity8"):
8387 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
8488 return binary_path
8589
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
86101
87102def get_grid_size():
88103 grid_size = os.getenv('GRID_UNIT_PX')
tests/autopilot/unity8/shell/tests/__init__.py+4−1
@@ -41,6 +41,7 @@ from unity8 import (
4141 get_binary_path,
4242 get_mocks_library_path,
4343 get_default_extra_mock_libraries,
44+ get_data_dirs
4445)
4546from unity8.shell.emulators import UnityEmulatorBase
4647from unity8.shell.emulators.dash import Dash
@@ -120,7 +121,9 @@ class UnityTestCase(AutopilotTestCase):
120121 self._proxy = None
121122 self._lightdm_mock_type = None
122123 self._qml_mock_enabled = True
123− self._environment = {}
124+ self._environment = {
125+ 'XDG_DATA_DIRS': get_data_dirs()
126+ }
124127
125128 #### FIXME: This is a work around re: lp:1238417 ####
126129 if model() != "Desktop":
tests/mocks/CMakeLists.txt+5
@@ -7,3 +7,8 @@ add_subdirectory(Powerd)
77add_subdirectory(QMenuModel)
88add_subdirectory(Ubuntu)
99add_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.