Merge lp:~veebers/unity8/adding_unlock_emulator into lp:unity8

Proposed by Christopher Lee
Status: Merged
Approved by: Michał Sawicz
Approved revision: 471
Merged at revision: 486
Proposed branch: lp:~veebers/unity8/adding_unlock_emulator
Merge into: lp:unity8
Diff against target: 120 lines (+116/-0)
1 file modified
tests/autopilot/unity8/process_helpers.py (+116/-0)
To merge this branch: bzr merge lp:~veebers/unity8/adding_unlock_emulator
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Lee (community) Approve
Michał Sawicz Approve
Thomi Richards (community) Approve
Review via email: mp+191328@code.launchpad.net

Commit message

Adds an easy to consume function that attempts to unlock the unity greeter.

Description of the change

Adds an easy to consume function that attempts to unlock the unity greeter.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:471
http://jenkins.qa.ubuntu.com/job/unity8-ci/1418/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/5039
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/2976
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/441
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1418
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1418/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1417
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1209
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/914
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/914/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2978
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2978/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2484
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2528

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1418/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Hey, unity8 tests should be using this, to make sure we know ASAP that things break and fix it for ourselves. WDYT?

review: Needs Information
Revision history for this message
Christopher Lee (veebers) wrote :

Sounds like a good idea.

I want get this merged now so that in the interim it can be consumed by the CI/testing scripts and I'll start work on updating the unity tests etc.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

Looks good - and works.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:471
http://jenkins.qa.ubuntu.com/job/unity8-ci/1465/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/5123
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3130/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2337
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/488
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1469
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1469/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1464
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1287
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/998
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/998/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3132
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3132/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2611/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2662/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/253
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/252

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1465/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Lee (veebers) wrote :

The CI is currently failing due to this bug: https://bugs.launchpad.net/ubuntu/+source/lxc-android-config/+bug/1243432

Once this bug is fixed the CI should pass with flying colours and this should be merged.

Revision history for this message
Christopher Lee (veebers) wrote :

Get CI running.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:471
http://jenkins.qa.ubuntu.com/job/unity8-ci/1513/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/145
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/139/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/40
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/37
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/37
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/37/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/37
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/136
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/145
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/145/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/139
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/139/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2766/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2817/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/571
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/572

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1513/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/autopilot/unity8/process_helpers.py'
2--- tests/autopilot/unity8/process_helpers.py 1970-01-01 00:00:00 +0000
3+++ tests/autopilot/unity8/process_helpers.py 2013-10-16 04:09:14 +0000
4@@ -0,0 +1,116 @@
5+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6+#
7+# Unity Autopilot Utilities
8+# Copyright (C) 2013 Canonical
9+#
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation, either version 3 of the License, or
13+# (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+#
23+
24+from autopilot.introspection import (
25+ get_proxy_object_for_existing_process,
26+ ProcessSearchError,
27+)
28+import subprocess
29+from unity8.shell.emulators import UnityEmulatorBase
30+from unity8.shell.emulators.main_window import MainWindow
31+
32+
33+class CannotAccessUnity(Exception):
34+ pass
35+
36+
37+def unlock_unity():
38+ """Helper function that attempts to unlock the unity greeter.
39+
40+ :raises RuntimeError: if the greeter attempts and fails to be unlocked.
41+
42+ :raises RuntimeWarning: when the greeter cannot be found because it is
43+ already unlocked.
44+ :raises CannotAccessUnity: if unity is not introspectable or cannot be
45+ found on dbus.
46+ :raises CannotAccessUnity: if unity's upstart status is not "start" or the
47+ upstart job cannot be found at all.
48+
49+ """
50+ pid = _get_unity_pid()
51+ try:
52+ unity = get_proxy_object_for_existing_process(
53+ pid=pid,
54+ emulator_base=UnityEmulatorBase,
55+ )
56+ main_window = MainWindow(unity)
57+
58+ greeter = main_window.get_greeter()
59+ if greeter is None:
60+ raise RuntimeWarning("Greeter appears to be already unlocked.")
61+ greeter.swipe()
62+ except ProcessSearchError as e:
63+ raise CannotAccessUnity(
64+ "Cannot introspect unity, make sure that it has been started "
65+ "with testability. Perhaps use the function "
66+ "'restart_unity_with_testability' this module provides."
67+ "(%s)"
68+ % str(e)
69+ )
70+
71+
72+def restart_unity_with_testability():
73+ """Restarts (or just starts) unity8 with the testability driver loaded
74+
75+ :raises subprocess.CalledProcessError: if unable to stop or start the
76+ unity8 upstart job.
77+
78+ """
79+ status = _get_unity_status()
80+ if "start/" in status:
81+ try:
82+ print("Stopping unity.")
83+ subprocess.check_call([
84+ 'initctl',
85+ 'stop',
86+ 'unity8',
87+ ])
88+ except subprocess.CalledProcessError as e:
89+ e.args += ("Failed to stop running instance of unity8", )
90+ raise
91+
92+ try:
93+ print("Starting unity with testability.")
94+ subprocess.check_call([
95+ 'initctl',
96+ 'start',
97+ 'unity8',
98+ 'QT_LOAD_TESTABILITY=1',
99+ ])
100+ except subprocess.CalledProcessError as e:
101+ e.args += ("Failed to start unity8 with testability ", )
102+ raise
103+
104+
105+def _get_unity_status():
106+ try:
107+ return subprocess.check_output([
108+ 'initctl',
109+ 'status',
110+ 'unity8'
111+ ])
112+ except subprocess.CalledProcessError as e:
113+ raise CannotAccessUnity("Unable to get unity's status: %s" % str(e))
114+
115+
116+def _get_unity_pid():
117+ status = _get_unity_status()
118+ if not "start/" in status:
119+ raise CannotAccessUnity("Unity is not in the running state.")
120+ return int(status.split()[-1])

Subscribers

People subscribed via source and target branches