on xenial help sign in
Update autopilot tests
cec0817Daniel d'Andrada
tests/autopilot/unity8/shell/__init__.py−13
@@ -27,19 +27,6 @@ import logging
27
27
28logger = logging.getLogger(__name__)
28logger = logging.getLogger(__name__)
29
29
30−
31−def with_lightdm_mock(mock_type):
32− """A simple decorator that sets up the LightDM mock for a single test."""
33− def with_lightdm_mock_internal(fn):
34− @wraps(fn)
35− def wrapper(*args, **kwargs):
36− tests_self = args[0]
37− tests_self.patch_lightdm_mock(mock_type)
38− return fn(*args, **kwargs)
39− return wrapper
40− return with_lightdm_mock_internal
41−
42−
43def disable_qml_mocking(fn):
30def disable_qml_mocking(fn):
44 """Simple decorator that disables the QML mocks from being loaded."""
31 """Simple decorator that disables the QML mocks from being loaded."""
45 @wraps(fn)
32 @wraps(fn)
tests/autopilot/unity8/shell/tests/__init__.py+8−11
@@ -153,7 +153,6 @@ class UnityTestCase(AutopilotTestCase):
153 self.useFixture(toolkit_fixtures.HideUnity7Launcher())
153 self.useFixture(toolkit_fixtures.HideUnity7Launcher())
154
154
155 self._proxy = None
155 self._proxy = None
156− self._lightdm_mock_type = None
157 self._qml_mock_enabled = True
156 self._qml_mock_enabled = True
158 self._data_dirs_mock_enabled = True
157 self._data_dirs_mock_enabled = True
159 self._environment = {}
158 self._environment = {}
@@ -265,8 +264,7 @@ class UnityTestCase(AutopilotTestCase):
265 binary_path
264 binary_path
266 )
265 )
267
266
268− if self._lightdm_mock_type is None:
269− self.patch_lightdm_mock()
267+ self.patch_lightdm_mock()
270
268
271 if self._qml_mock_enabled:
269 if self._qml_mock_enabled:
272 self._environment['QML2_IMPORT_PATH'] = (
270 self._environment['QML2_IMPORT_PATH'] = (
@@ -338,12 +336,11 @@ class UnityTestCase(AutopilotTestCase):
338 if data_dirs is not None:
336 if data_dirs is not None:
339 self._environment['XDG_DATA_DIRS'] = data_dirs
337 self._environment['XDG_DATA_DIRS'] = data_dirs
340
338
341− def patch_lightdm_mock(self, mock_type='single'):
339+ def patch_lightdm_mock(self):
342− self._lightdm_mock_type = mock_type
343− logger.info("Setting up LightDM mock type '%s'", mock_type)
340+ logger.info("Setting up LightDM mock lib")
344 new_ld_library_path = [
341 new_ld_library_path = [
345 get_default_extra_mock_libraries(),
342 get_default_extra_mock_libraries(),
346− self._get_lightdm_mock_path(mock_type)
343+ self._get_lightdm_mock_path()
347 ]
344 ]
348 if os.getenv('LD_LIBRARY_PATH') is not None:
345 if os.getenv('LD_LIBRARY_PATH') is not None:
349 new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH'))
346 new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH'))
@@ -353,16 +350,16 @@ class UnityTestCase(AutopilotTestCase):
353
350
354 self._environment['LD_LIBRARY_PATH'] = new_ld_library_path
351 self._environment['LD_LIBRARY_PATH'] = new_ld_library_path
355
352
356− def _get_lightdm_mock_path(self, mock_type):
353+ def _get_lightdm_mock_path(self):
357 lib_path = get_mocks_library_path()
354 lib_path = get_mocks_library_path()
358 lightdm_mock_path = os.path.abspath(
355 lightdm_mock_path = os.path.abspath(
359− os.path.join(lib_path, "LightDM", mock_type)
356+ os.path.join(lib_path, "LightDM", "liblightdm")
360 )
357 )
361
358
362 if not os.path.exists(lightdm_mock_path):
359 if not os.path.exists(lightdm_mock_path):
363 raise RuntimeError(
360 raise RuntimeError(
364− "LightDM mock '%s' does not exist at path '%s'."
361+ "LightDM mock does not exist at path '%s'."
365− % (mock_type, lightdm_mock_path)
362+ % (lightdm_mock_path)
366 )
363 )
367 return lightdm_mock_path
364 return lightdm_mock_path
368
365
tests/autopilot/unity8/shell/tests/test_edges_demo.py−1
@@ -34,7 +34,6 @@ class EdgesDemoTestCase(tests.UnityTestCase):
34 super(EdgesDemoTestCase, self).setUp()
34 super(EdgesDemoTestCase, self).setUp()
35 self._qml_mock_enabled = False
35 self._qml_mock_enabled = False
36 self._data_dirs_mock_enabled = False
36 self._data_dirs_mock_enabled = False
37− self._lightdm_mock_type = False
38
37
39 self.useFixture(fixture_setup.EdgesDemo(True))
38 self.useFixture(fixture_setup.EdgesDemo(True))
40 self.unity = self.launch_unity()
39 self.unity = self.launch_unity()
tests/autopilot/unity8/shell/tests/test_lock_screen.py+6−5
@@ -20,7 +20,6 @@
20
20
21from __future__ import absolute_import
21from __future__ import absolute_import
22
22
23−from unity8.shell import with_lightdm_mock
24from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
23from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25
24
26from autopilot.matchers import Eventually
25from autopilot.matchers import Eventually
@@ -41,9 +40,10 @@ class TestLockscreen(UnityTestCase):
41
40
42 scenarios = _get_device_emulation_scenarios()
41 scenarios = _get_device_emulation_scenarios()
43
42
44− @with_lightdm_mock("single-pin")
45 def test_can_unlock_pin_screen(self):
43 def test_can_unlock_pin_screen(self):
46 """Must be able to unlock the PIN entry lock screen."""
44 """Must be able to unlock the PIN entry lock screen."""
45+
46+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
47 self.launch_unity()
47 self.launch_unity()
48 greeter = self.main_window.get_greeter()
48 greeter = self.main_window.get_greeter()
49
49
@@ -56,9 +56,10 @@ class TestLockscreen(UnityTestCase):
56 self._enter_prompt_passphrase("1234\n")
56 self._enter_prompt_passphrase("1234\n")
57 self.assertThat(greeter.shown, Eventually(Equals(False)))
57 self.assertThat(greeter.shown, Eventually(Equals(False)))
58
58
59− @with_lightdm_mock("single-passphrase")
60 def test_can_unlock_passphrase_screen(self):
59 def test_can_unlock_passphrase_screen(self):
61 """Must be able to unlock the passphrase entry screen."""
60 """Must be able to unlock the passphrase entry screen."""
61+
62+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
62 self.launch_unity()
63 self.launch_unity()
63 greeter = self.main_window.get_greeter()
64 greeter = self.main_window.get_greeter()
64
65
@@ -71,9 +72,9 @@ class TestLockscreen(UnityTestCase):
71 self._enter_prompt_passphrase("password")
72 self._enter_prompt_passphrase("password")
72 self.assertThat(greeter.shown, Eventually(Equals(False)))
73 self.assertThat(greeter.shown, Eventually(Equals(False)))
73
74
74− @with_lightdm_mock("single-pin")
75 def test_pin_screen_wrong_code(self):
75 def test_pin_screen_wrong_code(self):
76 """Entering the wrong pin code must not dismiss the lock screen."""
76 """Entering the wrong pin code must not dismiss the lock screen."""
77+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
77 self.launch_unity()
78 self.launch_unity()
78 greeter = self.main_window.get_greeter()
79 greeter = self.main_window.get_greeter()
79
80
@@ -90,9 +91,9 @@ class TestLockscreen(UnityTestCase):
90 self.assertThat(prompt.text, Eventually(Equals("")))
91 self.assertThat(prompt.text, Eventually(Equals("")))
91 self.assertThat(greeter.shown, Eventually(Equals(True)))
92 self.assertThat(greeter.shown, Eventually(Equals(True)))
92
93
93− @with_lightdm_mock("single-passphrase")
94 def test_passphrase_screen_wrong_password(self):
94 def test_passphrase_screen_wrong_password(self):
95 """Entering the wrong password must not dismiss the lock screen."""
95 """Entering the wrong password must not dismiss the lock screen."""
96+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
96 self.launch_unity()
97 self.launch_unity()
97 greeter = self.main_window.get_greeter()
98 greeter = self.main_window.get_greeter()
98
99