Merge lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script into lp:~canonical-ci-engineering/jenkins-launchpad-plugin/autopilot-testrunner-touch-saucy

Proposed by Omer Akram
Status: Needs review
Proposed branch: lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script
Merge into: lp:~canonical-ci-engineering/jenkins-launchpad-plugin/autopilot-testrunner-touch-saucy
Diff against target: 152 lines (+42/-96)
1 file modified
unlock_screen.py (+42/-96)
To merge this branch: bzr merge lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script
Reviewer Review Type Date Requested Status
Canonical CI Engineering Pending
Review via email: mp+209773@code.launchpad.net

Commit message

use unity helpers to unlock screen

Description of the change

unity is removing the bottom bar so the interface that we were relying on is going away, now using unity helpers to unlock the screen.

depends on unity8-autopilot

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

On 03/06/2014 02:13 PM, Omer Akram wrote:
> Omer Akram has proposed merging lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script into lp:~canonical-ci-engineering/jenkins-launchpad-plugin/autopilot-testrunner-touch-saucy.
>
> Commit message:
> use unity helpers to unlock screen
>
> Requested reviews:
> Canonical CI Engineering (canonical-ci-engineering)
>
> For more details, see:
> https://code.launchpad.net/~om26er/jenkins-launchpad-plugin/fix_unlock_script/+merge/209773
>
> unity is removing the bottom bar so the interface that we were relying on is going away, now using unity helpers to unlock the screen.
>

Omer - are we going to need a similar patch to:

<http://bazaar.launchpad.net/~ubuntu-test-case-dev/ubuntu-test-cases/touch/view/head:/utils/target/unlock_screen.py>

?

Revision history for this message
Omer Akram (om26er) wrote :

On it.

On Fri, Mar 7, 2014 at 2:45 AM, Andy Doan <email address hidden>wrote:

> On 03/06/2014 02:13 PM, Omer Akram wrote:
> > Omer Akram has proposed merging
> lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script into
> lp:~canonical-ci-engineering/jenkins-launchpad-plugin/autopilot-testrunner-touch-saucy.
> >
> > Commit message:
> > use unity helpers to unlock screen
> >
> > Requested reviews:
> > Canonical CI Engineering (canonical-ci-engineering)
> >
> > For more details, see:
> >
> https://code.launchpad.net/~om26er/jenkins-launchpad-plugin/fix_unlock_script/+merge/209773
> >
> > unity is removing the bottom bar so the interface that we were relying
> on is going away, now using unity helpers to unlock the screen.
> >
>
> Omer - are we going to need a similar patch to:
>
>
> <
> http://bazaar.launchpad.net/~ubuntu-test-case-dev/ubuntu-test-cases/touch/view/head:/utils/target/unlock_screen.py
> >
>
> ?
>
> --
>
> https://code.launchpad.net/~om26er/jenkins-launchpad-plugin/fix_unlock_script/+merge/209773
> You are the owner of lp:~om26er/jenkins-launchpad-plugin/fix_unlock_script.
>

125. By Omer Akram

restart_with_testability is private

126. By Omer Akram

add link to the bug

Unmerged revisions

126. By Omer Akram

add link to the bug

125. By Omer Akram

restart_with_testability is private

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unlock_screen.py'
2--- unlock_screen.py 2013-10-17 19:40:43 +0000
3+++ unlock_screen.py 2014-03-06 22:31:45 +0000
4@@ -1,106 +1,52 @@
5 #!/usr/bin/env python
6
7-from autopilot import introspection
8-from autopilot.display import Display
9-from autopilot.input import Pointer, Touch
10+import logging
11+import sys
12+
13+from unity8 import process_helpers as helpers
14+
15 import dbus
16-import os
17-import sys
18-import time
19+
20+logging.basicConfig(level=logging.INFO)
21+
22+
23+def unlock_screen():
24+ _restart_with_testability()
25+ helpers.unlock_unity()
26+
27+
28+def _restart_with_testability():
29+ powerd = _get_powerd_interface()
30+ powerd_cookie = _take_powerd_screen_lock(powerd)
31+ helpers.restart_unity_with_testability()
32+ _release_powerd_screen_lock(powerd, powerd_cookie)
33+
34+
35+def _get_powerd_interface():
36+ bus = dbus.SystemBus()
37+ return bus.get_object('com.canonical.powerd', '/com/canonical/powerd')
38+
39+
40+def _take_powerd_screen_lock(powerd):
41+ logging.info('Taking screen lock (http://pad.lv/1236525).')
42+ return powerd.requestSysState(
43+ "autopilot-lock", 1, dbus_interface='com.canonical.powerd'
44+ )
45+
46+
47+def _release_powerd_screen_lock(powerd, powerd_cookie):
48+ logging.info('Releasing screen lock (http://pad.lv/1236525)')
49+ powerd.clearSysState(
50+ powerd_cookie, dbus_interface='com.canonical.powerd'
51+ )
52
53
54 def help():
55 print "Usage:"
56- print "Run the script without any argument to unlock with assertion"
57- print ""
58- print "option -q:"
59- print "Execute with parameter -q to unlock the screen quickly without introspection"
60-
61-
62-def start_unity_in_testability():
63- override_file = "~/.config/upstart/unity8.override"
64-
65- os.system('echo "exec unity8 -testability" > ~/.config/upstart/unity8.override')
66-
67- print "----------------------------------------------------------------------"
68- print "Stopping Unity"
69- os.system('/sbin/stop unity8')
70- print "Unity stopped"
71- os.system('rm -f /tmp/mir_socket')
72-
73- print "----------------------------------------------------------------------"
74- print "Taking screen lock (#1235000)"
75- bus = dbus.SystemBus()
76- powerd = bus.get_object('com.canonical.powerd', '/com/canonical/powerd')
77- powerd_cookie = powerd.requestSysState("autopilot-lock", 1, dbus_interface='com.canonical.powerd')
78- print "----------------------------------------------------------------------"
79- print "Starting Unity with testability"
80- os.system('/sbin/start unity8')
81- print "Unity started"
82- print "----------------------------------------------------------------------"
83- print "Releasing screen lock (#1235000)"
84- powerd.clearSysState(powerd_cookie, dbus_interface='com.canonical.powerd')
85-
86- print "----------------------------------------------------------------------"
87- if os.path.exists(override_file):
88- os.remove(override_file)
89- print "Cleaned up upstart override"
90- print "----------------------------------------------------------------------"
91-
92- print "Turning on the screen"
93- print ""
94-
95-
96-def unlock_screen():
97- print "----------------------------------------------------------------------"
98- print "Executing Swipe"
99- input_device = Touch.create()
100- pointing_device = Pointer(input_device)
101- conn = "com.canonical.Shell.BottomBarVisibilityCommunicator"
102- unity8 = introspection.get_proxy_object_for_existing_process(connection_name=conn)
103- greeter = unity8.select_single("Greeter")
104- x, y, w, h = greeter.globalRect
105- tx = x + w
106- ty = y + (h / 2)
107-
108- pointing_device.drag(tx, ty, tx / 2, ty)
109- try:
110- greeter.shown.wait_for(False)
111- print "----------------------------------------------------------------------"
112- print "THE SCREEN UNLOCKED (normal)"
113- except:
114- print "----------------------------------------------------------------------"
115- print "THE SCREEN DIDN'T UNLOCK THE FIRST TRY, NOW ATTEMPTING A BLIND SWIPE"
116- unlock_screen_blind(greeter)
117-
118-
119-def unlock_screen_blind(greeter=None):
120- input_device = Touch.create()
121- pointing_device = Pointer(input_device)
122- x, y, w, h = Display.create(preferred_backend='UPA').get_screen_geometry(0)
123- tx = x + w
124- ty = y + (h / 2)
125-
126- pointing_device.drag(tx, ty, tx / 2, ty)
127- if greeter is not None:
128- try:
129- greeter.shown.wait_for(False)
130- if greeter.shown is False:
131- print ""
132- print "THE SCREEN UNLOCKED (blind)"
133- except:
134- print "----------------------------------------------------------------------"
135- "THE SCREEN DIDN'T UNLOCK, RESTART THE DEVICE AND RUN THE SCRIPT AGAIN"
136-
137-
138-if len(sys.argv) >= 2 and sys.argv[1] == '-q':
139- # Blind unlock only
140- unlock_screen_blind()
141-elif len(sys.argv) >= 2 and sys.argv[1] == '-r':
142- # Restart only
143- start_unity_in_testability()
144-elif len(sys.argv) >= 2 and sys.argv[1] == '-h':
145+ print "Run the script without any argument to unlock with assertion."
146+
147+
148+if len(sys.argv) >= 2 and sys.argv[1] == '-h':
149 help()
150 else:
151- start_unity_in_testability()
152 unlock_screen()

Subscribers

People subscribed via source and target branches