on xenial help sign in
Use the greeter dbus method in process_helpers.unlock_unity
7ba2cb5Michał Sawicz
tests/autopilot/unity8/process_helpers.py+11−16
@@ -20,6 +20,7 @@
20import logging
20import logging
21import subprocess
21import subprocess
22import sys
22import sys
23+import dbus
23
24
24# This has to work in both python 3 (ap 1.5) and py2 (ap legacy 1.4.1) so we
25# This has to work in both python 3 (ap 1.5) and py2 (ap legacy 1.4.1) so we
25# pick the correct location in each case. Remove the py2 branch once we no
26# pick the correct location in each case. Remove the py2 branch once we no
@@ -82,22 +83,16 @@ def unlock_unity(unity_proxy_obj=None):
82 if greeter.created is False:
83 if greeter.created is False:
83 raise RuntimeWarning("Greeter appears to be already unlocked.")
84 raise RuntimeWarning("Greeter appears to be already unlocked.")
84
85
85− # Because of potential input jerkiness under heavy load,
86+ bus = dbus.SessionBus()
86− # retry unlocking the greeter two times.
87+ dbus_proxy = bus.get_object("com.canonical.UnityGreeter", "/")
87− # https://bugs.launchpad.net/ubuntu/+bug/1260113
88−
89− retries = 3
90− while retries > 0:
91− try:
88+ try:
92− greeter.swipe()
89+ dbus_proxy.HideGreeter()
93− except AssertionError:
90+ except dbus.DBusException:
94− retries -= 1
95− if retries == 0:
96− raise
97− logger.info("Failed to unlock greeter, trying again...")
91+ logger.info("Failed to unlock greeter")
92+ raise
98− else:
93+ else:
94+ greeter.wait_unlocked()
99− logger.info("Greeter unlocked, continuing.")
95+ logger.info("Greeter unlocked, continuing.")
100− break
101
96
102
97
103def lock_unity(unity_proxy_obj=None):
98def lock_unity(unity_proxy_obj=None):
tests/autopilot/unity8/shell/emulators/greeter.py+4−1
@@ -25,6 +25,9 @@ from unity8.shell.emulators import UnityEmulatorBase
25class Greeter(UnityEmulatorBase):
25class Greeter(UnityEmulatorBase):
26 """An emulator that understands the greeter screen."""
26 """An emulator that understands the greeter screen."""
27
27
28+ def wait_unlocked(self):
29+ self.showProgress.wait_for(0)
30+
28 def swipe(self):
31 def swipe(self):
29 """Swipe the greeter screen away."""
32 """Swipe the greeter screen away."""
30 self.created.wait_for(True)
33 self.created.wait_for(True)
@@ -37,7 +40,7 @@ class Greeter(UnityEmulatorBase):
37 stop_y = start_y
40 stop_y = start_y
38 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
41 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
39
42
40− self.showProgress.wait_for(0)
43+ self.wait_unlocked()
41
44
42 def get_prompt(self):
45 def get_prompt(self):
43 return self.select_single(
46 return self.select_single(