on xenial help sign in
Update autopilot tests
commitcec081773990a6f0a6de69ef4fcadf157d15ccfa authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 21 Jan 2015, 11:50 (12 years ago) parent030e5dd
4 files changed+14−30
tests/autopilot/unity8/shell/__init__.py−13 tests/autopilot/unity8/shell/tests/__init__.py+8−11 tests/autopilot/unity8/shell/tests/test_edges_demo.py−1 tests/autopilot/unity8/shell/tests/test_lock_screen.py+6−5
tests/autopilot/unity8/shell/__init__.py−13
@@ -27,19 +27,6 @@ import logging
2727
2828logger = logging.getLogger(__name__)
2929
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−
4330def disable_qml_mocking(fn):
4431 """Simple decorator that disables the QML mocks from being loaded."""
4532 @wraps(fn)
tests/autopilot/unity8/shell/tests/__init__.py+8−11
@@ -153,7 +153,6 @@ class UnityTestCase(AutopilotTestCase):
153153 self.useFixture(toolkit_fixtures.HideUnity7Launcher())
154154
155155 self._proxy = None
156− self._lightdm_mock_type = None
157156 self._qml_mock_enabled = True
158157 self._data_dirs_mock_enabled = True
159158 self._environment = {}
@@ -265,8 +264,7 @@ class UnityTestCase(AutopilotTestCase):
265264 binary_path
266265 )
267266
268− if self._lightdm_mock_type is None:
269− self.patch_lightdm_mock()
267+ self.patch_lightdm_mock()
270268
271269 if self._qml_mock_enabled:
272270 self._environment['QML2_IMPORT_PATH'] = (
@@ -338,12 +336,11 @@ class UnityTestCase(AutopilotTestCase):
338336 if data_dirs is not None:
339337 self._environment['XDG_DATA_DIRS'] = data_dirs
340338
341− def patch_lightdm_mock(self, mock_type='single'):
342− self._lightdm_mock_type = mock_type
343− logger.info("Setting up LightDM mock type '%s'", mock_type)
339+ def patch_lightdm_mock(self):
340+ logger.info("Setting up LightDM mock lib")
344341 new_ld_library_path = [
345342 get_default_extra_mock_libraries(),
346− self._get_lightdm_mock_path(mock_type)
343+ self._get_lightdm_mock_path()
347344 ]
348345 if os.getenv('LD_LIBRARY_PATH') is not None:
349346 new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH'))
@@ -353,16 +350,16 @@ class UnityTestCase(AutopilotTestCase):
353350
354351 self._environment['LD_LIBRARY_PATH'] = new_ld_library_path
355352
356− def _get_lightdm_mock_path(self, mock_type):
353+ def _get_lightdm_mock_path(self):
357354 lib_path = get_mocks_library_path()
358355 lightdm_mock_path = os.path.abspath(
359− os.path.join(lib_path, "LightDM", mock_type)
356+ os.path.join(lib_path, "LightDM", "liblightdm")
360357 )
361358
362359 if not os.path.exists(lightdm_mock_path):
363360 raise RuntimeError(
364− "LightDM mock '%s' does not exist at path '%s'."
365− % (mock_type, lightdm_mock_path)
361+ "LightDM mock does not exist at path '%s'."
362+ % (lightdm_mock_path)
366363 )
367364 return lightdm_mock_path
368365
tests/autopilot/unity8/shell/tests/test_edges_demo.py−1
@@ -34,7 +34,6 @@ class EdgesDemoTestCase(tests.UnityTestCase):
3434 super(EdgesDemoTestCase, self).setUp()
3535 self._qml_mock_enabled = False
3636 self._data_dirs_mock_enabled = False
37− self._lightdm_mock_type = False
3837
3938 self.useFixture(fixture_setup.EdgesDemo(True))
4039 self.unity = self.launch_unity()
tests/autopilot/unity8/shell/tests/test_lock_screen.py+6−5
@@ -20,7 +20,6 @@
2020
2121from __future__ import absolute_import
2222
23−from unity8.shell import with_lightdm_mock
2423from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2524
2625from autopilot.matchers import Eventually
@@ -41,9 +40,10 @@ class TestLockscreen(UnityTestCase):
4140
4241 scenarios = _get_device_emulation_scenarios()
4342
44− @with_lightdm_mock("single-pin")
4543 def test_can_unlock_pin_screen(self):
4644 """Must be able to unlock the PIN entry lock screen."""
45+
46+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
4747 self.launch_unity()
4848 greeter = self.main_window.get_greeter()
4949
@@ -56,9 +56,10 @@ class TestLockscreen(UnityTestCase):
5656 self._enter_prompt_passphrase("1234\n")
5757 self.assertThat(greeter.shown, Eventually(Equals(False)))
5858
59− @with_lightdm_mock("single-passphrase")
6059 def test_can_unlock_passphrase_screen(self):
6160 """Must be able to unlock the passphrase entry screen."""
61+
62+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
6263 self.launch_unity()
6364 greeter = self.main_window.get_greeter()
6465
@@ -71,9 +72,9 @@ class TestLockscreen(UnityTestCase):
7172 self._enter_prompt_passphrase("password")
7273 self.assertThat(greeter.shown, Eventually(Equals(False)))
7374
74− @with_lightdm_mock("single-pin")
7575 def test_pin_screen_wrong_code(self):
7676 """Entering the wrong pin code must not dismiss the lock screen."""
77+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
7778 self.launch_unity()
7879 greeter = self.main_window.get_greeter()
7980
@@ -90,9 +91,9 @@ class TestLockscreen(UnityTestCase):
9091 self.assertThat(prompt.text, Eventually(Equals("")))
9192 self.assertThat(greeter.shown, Eventually(Equals(True)))
9293
93− @with_lightdm_mock("single-passphrase")
9494 def test_passphrase_screen_wrong_password(self):
9595 """Entering the wrong password must not dismiss the lock screen."""
96+ self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
9697 self.launch_unity()
9798 greeter = self.main_window.get_greeter()
9899