on xenial help sign in
Try to make test more robust
388cba7Michael Terry
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+1−1
@@ -170,6 +170,7 @@ class ApplicationLifecycleTests(UnityTestCase):
170 def test_greeter_hides_on_app_focus(self):
170 def test_greeter_hides_on_app_focus(self):
171 """Greeter should hide when an app is re-focused"""
171 """Greeter should hide when an app is re-focused"""
172 unity_proxy = self.launch_unity()
172 unity_proxy = self.launch_unity()
173+ greeter = self.main_window.get_greeter()
173 unlock_unity(unity_proxy)
174 unlock_unity(unity_proxy)
174
175
175 self._launch_app("messaging-app")
176 self._launch_app("messaging-app")
@@ -185,7 +186,6 @@ class ApplicationLifecycleTests(UnityTestCase):
185 )
186 )
186
187
187 lock_unity()
188 lock_unity()
188− greeter = self.main_window.get_greeter()
189 self.assertThat(greeter.created, Eventually(Equals(True)))
189 self.assertThat(greeter.created, Eventually(Equals(True)))
190
190
191 self._launch_app("messaging-app")
191 self._launch_app("messaging-app")
tests/autopilot/unity8/process_helpers.py+2−1
@@ -90,13 +90,14 @@ def unlock_unity(unity_proxy_obj=None):
90
90
91
91
92def lock_unity():
92def lock_unity():
93− import evdev
93+ import evdev, time
94 uinput = evdev.UInput(name='unity8-autopilot-power-button',
94 uinput = evdev.UInput(name='unity8-autopilot-power-button',
95 devnode='/dev/autopilot-uinput')
95 devnode='/dev/autopilot-uinput')
96 # One press and release to turn screen off (locking unity)
96 # One press and release to turn screen off (locking unity)
97 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
97 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
98 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
98 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
99 uinput.syn()
99 uinput.syn()
100+ time.sleep(1)
100 # And another press and release to turn screen back on
101 # And another press and release to turn screen back on
101 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
102 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
102 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
103 uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)