on xenial help sign in
Added function that restarts unity with testability
6f1473aChristopher Lee
tests/autopilot/unity8/shell/emulators/unlock.py+36−5
@@ -44,15 +44,46 @@ def unlock_unity():
44 )
44 )
45
45
46
46
47−def _get_unity_pid():
47+def restart_unity_with_testability():
48+ status = _get_unity_status()
49+ if "start/" in status:
50+ try:
51+ print "Stopping unity."
52+ subprocess.check_call([
53+ 'initctl',
54+ 'stop',
55+ 'unity8',
56+ ])
57+ except subprocess.CalledProcessError as e:
58+ e.args += ("Failed to stop running instance of unity8", )
59+ raise
60+
48 try:
61 try:
62+ print "Stopping unity with testability."
63+ subprocess.check_call([
64+ 'initctl',
65+ 'start',
66+ 'unity8',
67+ 'QT_LOAD_TESTABILITY=1',
68+ ])
69+ except subprocess.CalledProcessError as e:
70+ e.args += ("Failed to start unity8 with testability ", )
71+ raise
72+
73+
74+def _get_unity_status():
75+ try:
49− status = subprocess.check_output([
76+ return subprocess.check_output([
50 'initctl',
77 'initctl',
51 'status',
78 'status',
52 'unity8'
79 'unity8'
53 ])
80 ])
54− if not "start/" in status:
55− raise CannotAccessUnity("Unity is not in the running state.")
56− return int(status.split()[-1])
57 except subprocess.CalledProcessError as e:
81 except subprocess.CalledProcessError as e:
58 raise CannotAccessUnity("Unable to get unity's status: %s" % e.message)
82 raise CannotAccessUnity("Unable to get unity's status: %s" % e.message)
83+
84+
85+def _get_unity_pid():
86+ status = _get_unity_status()
87+ if not "start/" in status:
88+ raise CannotAccessUnity("Unity is not in the running state.")
89+ return int(status.split()[-1])