on xenial help sign in
Passing arguments to unity8
8fe8141Christopher Lee
tests/autopilot/unity8/shell/tests/__init__.py+38−36
@@ -121,17 +121,14 @@ class UnityTestCase(AutopilotTestCase):
121 self._qml_mock_enabled = True
121 self._qml_mock_enabled = True
122
122
123 #### This is a work around re: lp:1238417 ####
123 #### This is a work around re: lp:1238417 ####
124+ if model() != "Desktop":
124− from autopilot.input import _uinput
125+ from autopilot.input import _uinput
125− _uinput._touch_device = _uinput.create_touch_device()
126+ _uinput._touch_device = _uinput.create_touch_device()
126 ####
127 ####
127
128
128 self.touch = Touch.create()
129 self.touch = Touch.create()
129 self._setup_display_details()
130 self._setup_display_details()
130
131
131− self._using_upstart = False
132− if model() != "Desktop": # or check env
133− self._using_upstart = True
134−
135 def _reset_launcher(self):
132 def _reset_launcher(self):
136 """Reset Unity launcher hide mode"""
133 """Reset Unity launcher hide mode"""
137 self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, self._launcher_hide_mode)
134 self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, self._launcher_hide_mode)
@@ -194,24 +191,22 @@ class UnityTestCase(AutopilotTestCase):
194 environments.
191 environments.
195
192
196 """
193 """
197− if self._using_upstart:
198− try:
194+ try:
199− current_value = subprocess.check_output([
195+ 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([
208 "/sbin/initctl",
196 "/sbin/initctl",
197+ "get-env",
198+ key
199+ ]).rstrip()
200+ except subprocess.CalledProcessError:
201+ current_value = None
202+
203+ subprocess.call([
204+ "/sbin/initctl",
209− "set-env",
205+ "set-env",
206+ "-g",
210− "%s=%s" % (key, value)
207+ "%s=%s" % (key, value)
211− ])
208+ ])
212− self.addCleanup(self._upstart_reset_env, key, current_value)
209+ self.addCleanup(self._upstart_reset_env, key, current_value)
213− else:
214− self.patch_environment(key, value)
215
210
216 def _upstart_reset_env(self, key, value):
211 def _upstart_reset_env(self, key, value):
217 logger.info("Resetting upstart env %s to %s", key, value)
212 logger.info("Resetting upstart env %s to %s", key, value)
@@ -252,16 +247,10 @@ class UnityTestCase(AutopilotTestCase):
252 except OSError:
247 except OSError:
253 pass
248 pass
254
249
255− if self._using_upstart:
256− app_proxy = self._launch_unity_with_upstart()
250+ app_proxy = self._launch_unity_with_upstart(
257− else:
258− app_proxy = self.launch_test_application(
259− binary_path,
251+ binary_path,
260− *self.unity_geometry_args,
252+ self.unity_geometry_args
261− app_type='qt',
262− emulator_base=UnityEmulatorBase,
263− **kwargs
264− )
253+ )
265
254
266 self._set_proxy(app_proxy)
255 self._set_proxy(app_proxy)
267
256
@@ -272,11 +261,24 @@ class UnityTestCase(AutopilotTestCase):
272
261
273 return app_proxy
262 return app_proxy
274
263
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+ ])
276
271
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)
278
274
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+ ])
280
282
281 self.addCleanup(self._cleanup_launching_upstart_unity)
283 self.addCleanup(self._cleanup_launching_upstart_unity)
282
284
upstart-session/unity8.conf+2−2
@@ -11,7 +11,7 @@ post-start script
11 /usr/bin/ofono-setup
11 /usr/bin/ofono-setup
12end script
12end script
13
13
14−script
14+script
15 sleep 2
15 sleep 2
16− exec unity8
16+ exec unity8 ${BINARY:-unity8} $ARGS
17end script
17end script