@@ -33,7 +33,12 @@ import logging
33import os.path
33import os.path
34from testtools.matchers import Equals, NotEquals
34from testtools.matchers import Equals, NotEquals
36−from unity8 import get_lib_path, get_binary_path, get_mocks_library_path
39+ get_mocks_library_path,
40+ get_default_extra_mock_libraries,
37from unity8.shell.emulators import UnityEmulatorBase
42from unity8.shell.emulators import UnityEmulatorBase
38from unity8.shell.emulators.dash import Dash
43from unity8.shell.emulators.dash import Dash
39from unity8.shell.emulators.main_window import MainWindow
44from unity8.shell.emulators.main_window import MainWindow
@@ -81,6 +86,7 @@ class UnityTestCase(AutopilotTestCase):
81 self.addCleanup(self._reset_launcher)
86 self.addCleanup(self._reset_launcher)
83 self._proxy = None
88 self._proxy = None
89+ self._lightdm_mock_type = None
84 self.touch = Touch.create()
90 self.touch = Touch.create()
85 self._setup_display_details()
91 self._setup_display_details()
@@ -153,6 +159,8 @@ class UnityTestCase(AutopilotTestCase):
153 binary_path
159 binary_path
162+ if self._lightdm_mock_type is None:
163+ self.patch_lightdm_mock()
156 self._setup_extra_mock_environment_patch()
164 self._setup_extra_mock_environment_patch()
158 app_proxy = self.launch_test_application(
166 app_proxy = self.launch_test_application(
@@ -170,6 +178,30 @@ class UnityTestCase(AutopilotTestCase):
171 return app_proxy
179 return app_proxy
181+ def patch_lightdm_mock(self, mock_type='single'):
182+ self._lightdm_mock_type = mock_type
183+ logger.info("Setting up LightDM mock type '%s'", mock_type)
184+ new_ld_library_path = "%s:%s" % (
185+ get_default_extra_mock_libraries(),
186+ self._get_lightdm_mock_path(mock_type)
188+ logger.info("New library path: %s", new_ld_library_path)
190+ self.patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
192+ def _get_lightdm_mock_path(self, mock_type):
193+ lib_path = get_mocks_library_path()
194+ lightdm_mock_path = os.path.abspath(
195+ os.path.join(lib_path, "LightDM", mock_type)
198+ if not os.path.exists(lightdm_mock_path):
200+ "LightDM mock '%s' does not exist at path '%s'."
201+ % (mock_type, lightdm_mock_path)
203+ return lightdm_mock_path
173 def _setup_extra_mock_environment_patch(self):
205 def _setup_extra_mock_environment_patch(self):
174 mocks_library_path = get_mocks_library_path()
206 mocks_library_path = get_mocks_library_path()
175 self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)
207 self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)