@@ -69,7 +69,7 @@ def _get_device_emulation_scenarios(devices='All'):
69 elif devices == 'Nexus10':
69 elif devices == 'Nexus10':
70 return [nexus10]
70 return [nexus10]
72− raise RuntimeException('Unrecognized device-option "%s" passed.' % devices)
72+ raise RuntimeError('Unrecognized device-option "%s" passed.' % devices)
74 return [native]
74 return [native]
@@ -77,6 +77,32 @@ class UnityTestCase(AutopilotTestCase):
78 """A test case base class for the Unity shell tests."""
78 """A test case base class for the Unity shell tests."""
80+ __unity_was_running_before_tests = False
84+ output = subprocess.check_output([
90+ if "start/" in output:
91+ UnityTestCase.__unity_was_running_before_tests = True
92+ logger.info("Stopping existing Unity")
94+ subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
95+ except subprocess.CalledProcessError as e:
96+ logger.warning("Unable to stop unity8")
97+ e.args += ("Failed to stop existing unity8 process", )
101+ def tearDownClass(cls):
102+ if UnityTestCase.__unity_was_running_before_tests:
103+ logger.info("Starting unity again with original env")
104+ subprocess.check_call(["/sbin/initctl", "start", "unity8"])
80 def setUp(self):
106 def setUp(self):
81 super(UnityTestCase, self).setUp()
107 super(UnityTestCase, self).setUp()
82 if Gio is not None and UNITYSHELL_GSETTINGS_SCHEMA in Gio.Settings.list_relocatable_schemas():
108 if Gio is not None and UNITYSHELL_GSETTINGS_SCHEMA in Gio.Settings.list_relocatable_schemas():
@@ -89,6 +115,12 @@ class UnityTestCase(AutopilotTestCase):
89 self._proxy = None
115 self._proxy = None
90 self._lightdm_mock_type = None
116 self._lightdm_mock_type = None
91 self._qml_mock_enabled = True
117 self._qml_mock_enabled = True
119+ #### This is a work around re: lp:1238417 ####
120+ from autopilot.input import _uinput
121+ _uinput._touch_device = _uinput.create_touch_device()
92 self.touch = Touch.create()
124 self.touch = Touch.create()
93 self._setup_display_details()
125 self._setup_display_details()
@@ -164,7 +196,7 @@ class UnityTestCase(AutopilotTestCase):
164 "/sbin/initctl",
196 "/sbin/initctl",
165 "get-env",
197 "get-env",
168 except subprocess.CalledProcessError:
200 except subprocess.CalledProcessError:
169 current_value = None
201 current_value = None
@@ -237,30 +269,12 @@ class UnityTestCase(AutopilotTestCase):
237 return app_proxy
269 return app_proxy
239 def _launch_unity_with_upstart(self):
271 def _launch_unity_with_upstart(self):
240− subprocess.call(["/sbin/initctl", "set-env", "QT_LOAD_TESTABILITY=1"])
242− output = subprocess.check_output([
248− unity_already_started = False
249− if "start/" in output:
250− unity_already_started = True
252− subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
273+ subprocess.call(["/sbin/initctl", "set-env", "QT_LOAD_TESTABILITY=1"])
253− except subprocess.CalledProcessError as e:
254− logger.warning("Unable to stop unity8")
255− e.args += ("Failed to stop existing unity8 process", )
258 output = subprocess.check_output(["/sbin/initctl", "start", "unity8"])
275 output = subprocess.check_output(["/sbin/initctl", "start", "unity8"])
261− self._cleanup_launching_upstart_unity,
277+ self.addCleanup(self._cleanup_launching_upstart_unity)
262− unity_already_started
265 pid = int(output.split()[-1])
279 pid = int(output.split()[-1])
@@ -269,20 +283,15 @@ class UnityTestCase(AutopilotTestCase):
269 emulator_base=UnityEmulatorBase,
283 emulator_base=UnityEmulatorBase,
272− def _cleanup_launching_upstart_unity(self, restart_unity):
286+ def _cleanup_launching_upstart_unity(self):
273− logger.info("Cleaning up launching unity, unsetting env")
287+ logger.info("Cleaning up launching unity")
274 subprocess.call(["/sbin/initctl", "unset-env", "QT_LOAD_TESTABILITY"])
288 subprocess.call(["/sbin/initctl", "unset-env", "QT_LOAD_TESTABILITY"])
277− logger.info("Stopping existing unity")
291+ logger.info("Stopping unity")
278 subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
292 subprocess.check_call(["/sbin/initctl", "stop", "unity8"])
279 except subprocess.CalledProcessError:
293 except subprocess.CalledProcessError:
280− logger.warning("Appears unity was already stopped")
294+ logger.warning("Appears unity was already stopped!")
282− # Actually, the previous env stuff will be still here right?
284− logger.info("Starting unity again with original env")
285− subprocess.check_call(["/sbin/initctl", "start", "unity8"])
287 def patch_lightdm_mock(self, mock_type='single'):
296 def patch_lightdm_mock(self, mock_type='single'):
288 self._lightdm_mock_type = mock_type
297 self._lightdm_mock_type = mock_type