@@ -121,17 +121,14 @@ class UnityTestCase(AutopilotTestCase):
121121 self._qml_mock_enabled = True
122122
123123 #### This is a work around re: lp:1238417 ####
124− from autopilot.input import _uinput
125− _uinput._touch_device = _uinput.create_touch_device()
124+ if model() != "Desktop":
125+ from autopilot.input import _uinput
126+ _uinput._touch_device = _uinput.create_touch_device()
126127 ####
127128
128129 self.touch = Touch.create()
129130 self._setup_display_details()
130131
131− self._using_upstart = False
132− if model() != "Desktop": # or check env
133− self._using_upstart = True
134−
135132 def _reset_launcher(self):
136133 """Reset Unity launcher hide mode"""
137134 self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, self._launcher_hide_mode)
@@ -194,24 +191,22 @@ class UnityTestCase(AutopilotTestCase):
194191 environments.
195192
196193 """
197− if self._using_upstart:
198− try:
199− current_value = subprocess.check_output([
200− "/sbin/initctl",
201− "get-env",
202− key
203− ]).rstrip()
204− except subprocess.CalledProcessError:
205− current_value = None
206−
207− subprocess.call([
194+ try:
195+ current_value = subprocess.check_output([
208196 "/sbin/initctl",
209− "set-env",
210− "%s=%s" % (key, value)
211− ])
212− self.addCleanup(self._upstart_reset_env, key, current_value)
213− else:
214− self.patch_environment(key, value)
197+ "get-env",
198+ key
199+ ]).rstrip()
200+ except subprocess.CalledProcessError:
201+ current_value = None
202+
203+ subprocess.call([
204+ "/sbin/initctl",
205+ "set-env",
206+ "-g",
207+ "%s=%s" % (key, value)
208+ ])
209+ self.addCleanup(self._upstart_reset_env, key, current_value)
215210
216211 def _upstart_reset_env(self, key, value):
217212 logger.info("Resetting upstart env %s to %s", key, value)
@@ -252,16 +247,10 @@ class UnityTestCase(AutopilotTestCase):
252247 except OSError:
253248 pass
254249
255− if self._using_upstart:
256− app_proxy = self._launch_unity_with_upstart()
257− else:
258− app_proxy = self.launch_test_application(
259− binary_path,
260− *self.unity_geometry_args,
261− app_type='qt',
262− emulator_base=UnityEmulatorBase,
263− **kwargs
264− )
250+ app_proxy = self._launch_unity_with_upstart(
251+ binary_path,
252+ self.unity_geometry_args
253+ )
265254
266255 self._set_proxy(app_proxy)
267256
@@ -272,11 +261,24 @@ class UnityTestCase(AutopilotTestCase):
272261
273262 return app_proxy
274263
275− def _launch_unity_with_upstart(self):
264+ def _launch_unity_with_upstart(self, binary_path, args):
265+ subprocess.call([
266+ "/sbin/initctl",
267+ "set-env",
268+ "-g",
269+ "QT_LOAD_TESTABILITY=1"
270+ ])
276271
277− subprocess.call(["/sbin/initctl", "set-env", "QT_LOAD_TESTABILITY=1"])
272+ binary_arg = "BINARY=%s" % binary_path
273+ extra_args = "ARGS=%s" % " ".join(args)
278274
279− output = subprocess.check_output(["/sbin/initctl", "start", "unity8"])
275+ output = subprocess.check_output([
276+ "/sbin/initctl",
277+ "start",
278+ "unity8",
279+ binary_arg,
280+ extra_args,
281+ ])
280282
281283 self.addCleanup(self._cleanup_launching_upstart_unity)
282284