on xenial help sign in
Add fix so mocking isn't used when running applications, fixes lock_screen tests.
commit2d382037638fa8411f586721ac08a6c84a158fd8 authorChristopher Lee <chris.lee@canonical.com> dateFri 13 Sep 2013, 14:09 (13 years ago) parent934ca9e
3 files changed+18−1
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+4 tests/autopilot/unity8/shell/__init__.py+10 tests/autopilot/unity8/shell/tests/__init__.py+4−1
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+4
@@ -21,6 +21,7 @@
2121
2222from __future__ import absolute_import
2323
24+from unity8.shell import disable_qml_mocking
2425from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2526
2627from autopilot.matchers import Eventually
@@ -74,6 +75,7 @@ class ApplicationLifecycleTests(UnityTestCase):
7475 app_type='qt'
7576 )
7677
78+ @disable_qml_mocking
7779 def test_can_launch_application(self):
7880 """Must be able to launch an application."""
7981 self.launch_unity()
@@ -87,6 +89,7 @@ class ApplicationLifecycleTests(UnityTestCase):
8789 Eventually(Equals("messaging-app"))
8890 )
8991
92+ @disable_qml_mocking
9093 def test_can_launch_multiple_applications(self):
9194 """A second application launched must be focused."""
9295 self.launch_unity()
@@ -104,6 +107,7 @@ class ApplicationLifecycleTests(UnityTestCase):
104107 Eventually(Equals("address-book-app"))
105108 )
106109
110+ @disable_qml_mocking
107111 def test_app_moves_from_unfocused_to_focused(self):
108112 """An application that is in the unfocused state must be able to be
109113 brought back to the focused state.
tests/autopilot/unity8/shell/__init__.py+10
@@ -36,3 +36,13 @@ def with_lightdm_mock(mock_type):
3636 return fn(*args, **kwargs)
3737 return wrapper
3838 return with_lightdm_mock_internal
39+
40+
41+def disable_qml_mocking(fn):
42+ """Simple decorator that disables the QML mocks from being loaded."""
43+ @wraps(fn)
44+ def wrapper(*args, **kwargs):
45+ tests_self = args[0]
46+ tests_self._qml_mock_enabled = False
47+ return fn(*args, **kwargs)
48+ return wrapper
tests/autopilot/unity8/shell/tests/__init__.py+4−1
@@ -86,6 +86,7 @@ class UnityTestCase(AutopilotTestCase):
8686
8787 self._proxy = None
8888 self._lightdm_mock_type = None
89+ self._qml_mock_enabled = True
8990 self.touch = Touch.create()
9091 self._setup_display_details()
9192
@@ -160,7 +161,9 @@ class UnityTestCase(AutopilotTestCase):
160161
161162 if self._lightdm_mock_type is None:
162163 self.patch_lightdm_mock()
163− self._setup_extra_mock_environment_patch()
164+
165+ if self._qml_mock_enabled:
166+ self._setup_extra_mock_environment_patch()
164167
165168 app_proxy = self.launch_test_application(
166169 binary_path,