on xenial help sign in
And add another autopilot test for re-focusing an app while in greeter
commit7f71e9d1084ace039895296d65af03237f09eee6 authorMichael Terry <michael.terry@canonical.com> dateWed 22 Jan 2014, 12:03 (13 years ago) parent05e99dc
2 files changed+56−1
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+42−1 tests/autopilot/unity8/process_helpers.py+14
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+42−1
@@ -21,7 +21,7 @@
2121
2222from __future__ import absolute_import
2323
24−from unity8.process_helpers import unlock_unity
24+from unity8.process_helpers import lock_unity, unlock_unity
2525from unity8.shell import disable_qml_mocking
2626from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2727
@@ -55,6 +55,18 @@ class ApplicationLifecycleTests(UnityTestCase):
5555 logger.info("Swiping screen from the right edge")
5656 self.touch.drag(start_x, start_y, end_x, end_y)
5757
58+ def swipe_screen_from_left(self):
59+ qml_view = self.main_window.get_qml_view()
60+ width = qml_view.width
61+ height = qml_view.height
62+ start_x = 0
63+ start_y = int(height/2)
64+ end_x = width
65+ end_y = start_y
66+
67+ logger.info("Swiping screen from the left edge")
68+ self.touch.drag(start_x, start_y, end_x, end_y)
69+
5870 def _get_current_focused_app_id(self):
5971 return self._proxy.select_single("Shell").currentFocusedAppId
6072
@@ -149,3 +161,32 @@ class ApplicationLifecycleTests(UnityTestCase):
149161 self._get_current_focused_app_id(),
150162 Eventually(Equals("messaging-app"))
151163 )
164+
165+ @disable_qml_mocking
166+ def test_greeter_hides_on_app_focus(self):
167+ """Greeter should hide when an app is re-focused"""
168+ unity_proxy = self.launch_unity()
169+ unlock_unity(unity_proxy)
170+
171+ app = self._launch_app("messaging-app")
172+ self.assertThat(
173+ self._get_current_focused_app_id(),
174+ Eventually(Equals("messaging-app"))
175+ )
176+
177+ self.swipe_screen_from_left()
178+ self.assertThat(
179+ self._get_current_focused_app_id(),
180+ Eventually(Equals(''))
181+ )
182+
183+ lock_unity()
184+ greeter = self.main_window.get_greeter()
185+ self.assertThat(greeter.created, Eventually(Equals(True)))
186+
187+ app = self._launch_app("messaging-app")
188+ self.assertThat(greeter.created, Eventually(Equals(False)))
189+ self.assertThat(
190+ self._get_current_focused_app_id(),
191+ Eventually(Equals("messaging-app"))
192+ )
tests/autopilot/unity8/process_helpers.py+14
@@ -88,6 +88,20 @@ def unlock_unity(unity_proxy_obj=None):
8888 break
8989
9090
91+def lock_unity():
92+ import evdev
93+ uinput = evdev.UInput(name='unity8-autopilot-power-button',
94+ devnode='/dev/autopilot-uinput')
95+ # One press and release to turn screen off (locking unity)
96+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
97+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
98+ uinput.syn()
99+ # And another press and release to turn screen back on
100+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
101+ uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
102+ uinput.syn()
103+
104+
91105def restart_unity_with_testability(*args):
92106 """Restarts (or starts) unity with testability enabled.
93107