on xenial help sign in
Add fix so mocking isn't used when running applications, fixes lock_screen tests.
2d38203Christopher Lee
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+4
@@ -21,6 +21,7 @@
21
21
22from __future__ import absolute_import
22from __future__ import absolute_import
23
23
24+from unity8.shell import disable_qml_mocking
24from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25
26
26from autopilot.matchers import Eventually
27from autopilot.matchers import Eventually
@@ -74,6 +75,7 @@ class ApplicationLifecycleTests(UnityTestCase):
74 app_type='qt'
75 app_type='qt'
75 )
76 )
76
77
78+ @disable_qml_mocking
77 def test_can_launch_application(self):
79 def test_can_launch_application(self):
78 """Must be able to launch an application."""
80 """Must be able to launch an application."""
79 self.launch_unity()
81 self.launch_unity()
@@ -87,6 +89,7 @@ class ApplicationLifecycleTests(UnityTestCase):
87 Eventually(Equals("messaging-app"))
89 Eventually(Equals("messaging-app"))
88 )
90 )
89
91
92+ @disable_qml_mocking
90 def test_can_launch_multiple_applications(self):
93 def test_can_launch_multiple_applications(self):
91 """A second application launched must be focused."""
94 """A second application launched must be focused."""
92 self.launch_unity()
95 self.launch_unity()
@@ -104,6 +107,7 @@ class ApplicationLifecycleTests(UnityTestCase):
104 Eventually(Equals("address-book-app"))
107 Eventually(Equals("address-book-app"))
105 )
108 )
106
109
110+ @disable_qml_mocking
107 def test_app_moves_from_unfocused_to_focused(self):
111 def test_app_moves_from_unfocused_to_focused(self):
108 """An application that is in the unfocused state must be able to be
112 """An application that is in the unfocused state must be able to be
109 brought back to the focused state.
113 brought back to the focused state.
tests/autopilot/unity8/shell/__init__.py+10
@@ -36,3 +36,13 @@ def with_lightdm_mock(mock_type):
36 return fn(*args, **kwargs)
36 return fn(*args, **kwargs)
37 return wrapper
37 return wrapper
38 return with_lightdm_mock_internal
38 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):
86
86
87 self._proxy = None
87 self._proxy = None
88 self._lightdm_mock_type = None
88 self._lightdm_mock_type = None
89+ self._qml_mock_enabled = True
89 self.touch = Touch.create()
90 self.touch = Touch.create()
90 self._setup_display_details()
91 self._setup_display_details()
91
92
@@ -160,7 +161,9 @@ class UnityTestCase(AutopilotTestCase):
160
161
161 if self._lightdm_mock_type is None:
162 if self._lightdm_mock_type is None:
162 self.patch_lightdm_mock()
163 self.patch_lightdm_mock()
164+
165+ if self._qml_mock_enabled:
163− self._setup_extra_mock_environment_patch()
166+ self._setup_extra_mock_environment_patch()
164
167
165 app_proxy = self.launch_test_application(
168 app_proxy = self.launch_test_application(
166 binary_path,
169 binary_path,