on xenial help sign in
test adding the with_lightdm_mock wrapper.
commit89538896800f01ad1ffc9dfa3d36896bd59a162f authorThomi Richards <thomi.richards@canonical.com> dateMon 15 Jul 2013, 10:42 (13 years ago) parent3f5d08f
2 files changed+16−2
tests/autopilot/unity8/shell/tests/helpers.py+14−1 tests/autopilot/unity8/shell/tests/test_lock_screen.py+2−1
tests/autopilot/unity8/shell/tests/helpers.py+14−1
@@ -5,13 +5,26 @@
55# under the terms of the GNU General Public License version 3, as published
66# by the Free Software Foundation.
77
8−from testtools.matchers import Equals, NotEquals
98from autopilot.matchers import Eventually
9+from testtools.matchers import Equals, NotEquals
10+from functools import wraps
1011
1112import logging
1213
1314logger = logging.getLogger(__name__)
1415
16+
17+def with_lightdm_mock(fn, mock_type):
18+ """A simple decorator that sets up the LightDM mock for a single test."""
19+ @wraps(fn)
20+ def wrapper(*args, **kwargs):
21+ logger.info("Setting up LightDM mock type '%s'", mock_type)
22+ return fn(*args, **kwargs)
23+ return wrapper
24+
25+
26+# TODO: Mixing classes like these are ikky. Remove them, and replace with
27+# something better!
1528class TestShellHelpers(object):
1629 """Helpers for testing the Shell"""
1730
tests/autopilot/unity8/shell/tests/test_lock_screen.py+2−1
@@ -26,7 +26,7 @@
2626from __future__ import absolute_import
2727
2828from unity8.shell.tests import Unity8TestCase
29−from unity8.shell.tests.helpers import TestShellHelpers
29+from unity8.shell.tests.helpers import with_lightdm_mock
3030
3131from autopilot.input import Mouse, Touch, Pointer
3232from testtools.matchers import Equals, NotEquals, GreaterThan, MismatchError
@@ -62,6 +62,7 @@ class TestLockscreen(Unity8TestCase):
6262 # dash = self.main_window.get_dash()
6363 # self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
6464
65+ @with_lightdm_mock("single_pin")
6566 def test_can_unlock_screen(self):
6667 """Must be able to unlock the screen."""
6768 self.lightdm_mock = "single_pin"