@@ -33,7 +33,12 @@ import logging
3333import os.path
3434from testtools.matchers import Equals, NotEquals
3535
36−from unity8 import get_lib_path, get_binary_path, get_mocks_library_path
36+from unity8 import (
37+ get_lib_path,
38+ get_binary_path,
39+ get_mocks_library_path,
40+ get_default_extra_mock_libraries,
41+)
3742from unity8.shell.emulators import UnityEmulatorBase
3843from unity8.shell.emulators.dash import Dash
3944from unity8.shell.emulators.main_window import MainWindow
@@ -81,6 +86,7 @@ class UnityTestCase(AutopilotTestCase):
8186 self.addCleanup(self._reset_launcher)
8287
8388 self._proxy = None
89+ self._lightdm_mock_type = None
8490 self.touch = Touch.create()
8591 self._setup_display_details()
8692
@@ -153,6 +159,8 @@ class UnityTestCase(AutopilotTestCase):
153159 binary_path
154160 )
155161
162+ if self._lightdm_mock_type is None:
163+ self.patch_lightdm_mock()
156164 self._setup_extra_mock_environment_patch()
157165
158166 app_proxy = self.launch_test_application(
@@ -170,6 +178,30 @@ class UnityTestCase(AutopilotTestCase):
170178
171179 return app_proxy
172180
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)
187+ )
188+ logger.info("New library path: %s", new_ld_library_path)
189+
190+ self.patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
191+
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)
196+ )
197+
198+ if not os.path.exists(lightdm_mock_path):
199+ raise RuntimeError(
200+ "LightDM mock '%s' does not exist at path '%s'."
201+ % (mock_type, lightdm_mock_path)
202+ )
203+ return lightdm_mock_path
204+
173205 def _setup_extra_mock_environment_patch(self):
174206 mocks_library_path = get_mocks_library_path()
175207 self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)