Merge lp:~chris.gagnon/unity8/autopilot-helper-to-background-and-signal-app into lp:unity8

Proposed by Chris Gagnon
Status: Work in progress
Proposed branch: lp:~chris.gagnon/unity8/autopilot-helper-to-background-and-signal-app
Merge into: lp:unity8
Diff against target: 75 lines (+35/-3)
1 file modified
tests/autopilot/unity8/process_helpers.py (+35/-3)
To merge this branch: bzr merge lp:~chris.gagnon/unity8/autopilot-helper-to-background-and-signal-app
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Leo Arias (community) Needs Fixing
Albert Astals Cid (community) Abstain
Review via email: mp+220438@code.launchpad.net

Commit message

add autopilot helpers to restart unity8 if it's not started with testability, put an app in the background and send a signal to an app

To post a comment you must log in.
914. By Chris Gagnon

moved signal to it's own function

915. By Chris Gagnon

get shell for restarted unity8

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/autopilot/unity8/process_helpers.py
1 conflicts encountered.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Interestingly seems it doesn't conflict anymore

review: Abstain
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

I was using currentFocusedAppID but that doesn't exist for the shell anymore

Revision history for this message
Leo Arias (elopio) wrote :

I'm more interested in this one than in the rest:
restart_unity_if_not_testable()

Can you put it in a Fixture? Something called like: UnityWithTestability.

About send_app_to_background, is it better to call the slots, or would it be better to tell autopilot to click the home button? I have a branch that opens the launcher and clicks, in case you prefer that.

Instead of currentFocusedAppID, use focusedApplicationId. Even better if you use the method from MainWindow: get_current_focused_app_id

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MichaƂ Sawicz (saviq) wrote :

Bump?

Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

some of the internals of the shell has changed, I need to rework this mp

Unmerged revisions

915. By Chris Gagnon

get shell for restarted unity8

914. By Chris Gagnon

moved signal to it's own function

913. By Chris Gagnon

add helpers to restart unity, background app, send a signal to an app.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity8/process_helpers.py'
2--- tests/autopilot/unity8/process_helpers.py 2014-05-14 22:48:45 +0000
3+++ tests/autopilot/unity8/process_helpers.py 2014-05-21 12:17:26 +0000
4@@ -29,6 +29,7 @@
5 else:
6 from autopilot.introspection import ProcessSearchError
7 from autopilot.introspection import get_proxy_object_for_existing_process
8+from testtools.matchers import NotEquals
9
10 from unity8.shell import emulators
11 from unity8.shell.emulators import main_window as main_window_emulator
12@@ -75,7 +76,7 @@
13 main_window_emulator.QQuickView)
14
15 greeter = main_window.get_greeter()
16- if greeter.created == False:
17+ if greeter.created is False:
18 raise RuntimeWarning("Greeter appears to be already unlocked.")
19
20 # Because of potential input jerkiness under heavy load,
21@@ -98,7 +99,8 @@
22
23 def lock_unity(unity_proxy_obj=None):
24 """Helper function that attempts to lock the unity greeter."""
25- import evdev, time
26+ import evdev
27+ import time
28 uinput = evdev.UInput(name='unity8-autopilot-power-button',
29 devnode='/dev/autopilot-uinput')
30 # One press and release to turn screen off (locking unity)
31@@ -113,7 +115,7 @@
32
33
34 def restart_unity_with_testability(*args):
35- """Restarts (or starts) unity with testability enabled.
36+ """Restart (or starts) unity with testability enabled.
37
38 Passes *args arguments to the launched process.
39
40@@ -122,6 +124,36 @@
41 return restart_unity(*args)
42
43
44+def restart_unity_if_not_testable():
45+ """Return unity shell, restart unity if needed."""
46+ try:
47+ pid = _get_unity_pid()
48+ unity8 = get_proxy_object_for_existing_process(pid)
49+ shell = unity8.select_single("Shell")
50+ except:
51+ pid = restart_unity_with_testability()
52+ unity8 = get_proxy_object_for_existing_process(pid)
53+ shell = unity8.select_single("Shell")
54+ return shell
55+
56+
57+def send_app_to_background(shell, app_name):
58+ """Put app in background app
59+ :param shell: The unity8 shell
60+ :param app_name: The name of the app to put in the background
61+ """
62+ shell.slots.showHome()
63+ shell.currentFocusedAppId.wait_for(NotEquals(app_name))
64+
65+
66+def signal_app(app_proxy_object, signal):
67+ """Send signal to app
68+ :param app_proxy_object: Proxy object of app you want to send a signal to
69+ :param signal: The signal to send the app
70+ """
71+ app_proxy_object.process.send_signal(signal)
72+
73+
74 def restart_unity(*args):
75 """Restarts (or starts) unity8 using the provided arguments.
76

Subscribers

People subscribed via source and target branches