Merge lp:~nick-dedekind/unity8/autopilot_test_failures into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1710
Merged at revision: 1725
Proposed branch: lp:~nick-dedekind/unity8/autopilot_test_failures
Merge into: lp:unity8
Diff against target: 101 lines (+51/-20)
2 files modified
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py (+4/-6)
tests/autopilot/unity8/process_helpers.py (+47/-14)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/autopilot_test_failures
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+254118@code.launchpad.net

Commit message

Fixed autopilot test failures related to udev input failure for power button.

Description of the change

Fixed autopilot test failures related to udev input failure for power button.

mir is not catching uinput keypresses when used immediately after being created. This causes the power button not to be triggered (or worse, only triggered once resulting in the screen turning off).
Fixed by using the greeter dbus interface rather than engaging the power switch to lock unity8.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

This does indeed seem to improve the general autopilot stability, there's still a few failures that need fixing, some of them are fixed by https://code.launchpad.net/~aacid/autopilot/dbus_search_no_seen_connections/+merge/254109 and https://code.launchpad.net/~aacid/autopilot/precreate_keyboard/+merge/254095

Other failures may also be related to https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1421009

But this defenitely seems a step forward :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py'
2--- tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2015-02-23 17:29:04 +0000
3+++ tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2015-04-02 08:16:46 +0000
4@@ -91,10 +91,9 @@
5 def test_greeter_hides_on_app_open(self):
6 """Greeter should hide when an app is opened"""
7 process_helpers.lock_unity()
8+
9+ application_name = self.launch_fake_app()
10 greeter = self.main_window.get_greeter()
11- self.assertThat(greeter.created, Eventually(Equals(True)))
12-
13- application_name = self.launch_fake_app()
14 greeter.wait_swiped_away()
15 process_helpers.unlock_unity()
16 self.assert_current_focused_application(application_name)
17@@ -108,10 +107,9 @@
18 self.assert_current_focused_application('unity8-dash')
19
20 process_helpers.lock_unity()
21+
22+ self.launch_upstart_application(application_name)
23 greeter = self.main_window.get_greeter()
24- self.assertThat(greeter.created, Eventually(Equals(True)))
25-
26- self.launch_upstart_application(application_name)
27 greeter.wait_swiped_away()
28 process_helpers.unlock_unity()
29 self.assert_current_focused_application(application_name)
30
31=== modified file 'tests/autopilot/unity8/process_helpers.py'
32--- tests/autopilot/unity8/process_helpers.py 2015-02-23 17:29:04 +0000
33+++ tests/autopilot/unity8/process_helpers.py 2015-04-02 08:16:46 +0000
34@@ -89,20 +89,53 @@
35
36
37 def lock_unity(unity_proxy_obj=None):
38- """Helper function that attempts to lock the unity greeter."""
39- import evdev
40- import time
41- uinput = evdev.UInput(name='unity8-autopilot-power-button',
42- devnode='/dev/autopilot-uinput')
43- # One press and release to turn screen off (locking unity)
44- uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
45- uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
46- uinput.syn()
47- time.sleep(1)
48- # And another press and release to turn screen back on
49- uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 1)
50- uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_POWER, 0)
51- uinput.syn()
52+ """Helper function that attempts to lock unity greeter.
53+
54+ If unity_proxy_object is None create a proxy object by querying for the
55+ running unity process.
56+ Otherwise re-use the passed proxy object.
57+
58+ :raises RuntimeError: if the greeter attempts and fails to be locked.
59+
60+ :raises RuntimeWarning: when the greeter is found because it is
61+ already locked.
62+ :raises CannotAccessUnity: if unity is not introspectable or cannot be
63+ found on dbus.
64+ :raises CannotAccessUnity: if unity's upstart status is not "start" or the
65+ upstart job cannot be found at all.
66+
67+ """
68+ if unity_proxy_obj is None:
69+ try:
70+ pid = _get_unity_pid()
71+ unity = _get_unity_proxy_object(pid)
72+ main_window = unity.select_single(main_window_emulator.QQuickView)
73+ except ProcessSearchError as e:
74+ raise CannotAccessUnity(
75+ "Cannot introspect unity, make sure that it has been started "
76+ "with testability. Perhaps use the function "
77+ "'restart_unity_with_testability' this module provides."
78+ "(%s)"
79+ % str(e)
80+ )
81+ else:
82+ main_window = unity_proxy_obj.select_single(
83+ main_window_emulator.QQuickView)
84+
85+ greeter = main_window.get_greeter()
86+ if greeter.created is True:
87+ raise RuntimeWarning("Greeter appears to be already locked.")
88+
89+ bus = dbus.SessionBus()
90+ dbus_proxy = bus.get_object("com.canonical.UnityGreeter", "/")
91+ try:
92+ dbus_proxy.ShowGreeter()
93+ except dbus.DBusException:
94+ logger.info("Failed to lock greeter")
95+ raise
96+ else:
97+ greeter.created.wait_for(True)
98+ logger.info("Greeter locked, continuing.")
99
100
101 def restart_unity_with_testability(*args):

Subscribers

People subscribed via source and target branches