on xenial help sign in
Use upstart launching for more of the app focus tests; it is more realistic
commit6ced7b15973d5c9d20bd50deaf8bc88dd6c59ac7 authorMichael Terry <michael.terry@canonical.com> dateTue 28 Jan 2014, 15:52 (13 years ago) parent5ea1eca
1 file changed+18−11
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+18−11
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+18−11
@@ -71,7 +71,7 @@ class ApplicationLifecycleTests(UnityTestCase):
7171 def _get_current_focused_app_id(self):
7272 return self._proxy.select_single("Shell").currentFocusedAppId
7373
74− def _launch_app(self, app_name):
74+ def _launch_app_directly(self, app_name):
7575 """Launches the application *app_name*
7676
7777 Assumes that the desktop file resides at:
@@ -89,15 +89,22 @@ class ApplicationLifecycleTests(UnityTestCase):
8989 app_type='qt'
9090 )
9191
92+ def _launch_app(self, app_name):
93+ """Launches the application *app_name* via upstart."""
94+ command = ['initctl', '--quiet', 'start', 'application',
95+ 'APP_ID=%s' % app_name]
96+ subprocess.check_call(command)
97+
98+ command = ['pkill', '-f', '-9', app_name]
99+ self.addCleanup(subprocess.call, command)
100+
92101 @disable_qml_mocking
93102 def test_can_launch_application(self):
94103 """Must be able to launch an application."""
95104 unity_proxy = self.launch_unity()
96105 unlock_unity(unity_proxy)
97106
98− app = self._launch_app("messaging-app")
99−
100− self.assertThat(app, NotEquals(None))
107+ self._launch_app("messaging-app")
101108 self.assertThat(
102109 self._get_current_focused_app_id(),
103110 Eventually(Equals("messaging-app"))
@@ -136,7 +143,8 @@ class ApplicationLifecycleTests(UnityTestCase):
136143 Eventually(Equals("messaging-app"))
137144 )
138145
139− self._launch_app("address-book-app")
146+ # FIXME: this should be able to launch via upstart. Bug #1273844
147+ self._launch_app_directly("address-book-app")
140148 self.assertThat(
141149 self._get_current_focused_app_id(),
142150 Eventually(Equals("address-book-app"))
@@ -156,7 +164,7 @@ class ApplicationLifecycleTests(UnityTestCase):
156164 greeter = self.main_window.get_greeter()
157165 self.assertThat(greeter.created, Eventually(Equals(True)))
158166
159− app = self._launch_app("messaging-app")
167+ self._launch_app("messaging-app")
160168 self.assertThat(greeter.created, Eventually(Equals(False)))
161169 self.assertThat(
162170 self._get_current_focused_app_id(),
@@ -164,12 +172,12 @@ class ApplicationLifecycleTests(UnityTestCase):
164172 )
165173
166174 @disable_qml_mocking
167− def test_greeter_hides_on_app_focus_via_upstart(self):
168− """Greeter should hide when an app is re-focused with upstart"""
175+ def test_greeter_hides_on_app_focus(self):
176+ """Greeter should hide when an app is re-focused"""
169177 unity_proxy = self.launch_unity()
170178 unlock_unity(unity_proxy)
171179
172− app = self._launch_app("messaging-app")
180+ self._launch_app("messaging-app")
173181 self.assertThat(
174182 self._get_current_focused_app_id(),
175183 Eventually(Equals("messaging-app"))
@@ -185,8 +193,7 @@ class ApplicationLifecycleTests(UnityTestCase):
185193 greeter = self.main_window.get_greeter()
186194 self.assertThat(greeter.created, Eventually(Equals(True)))
187195
188− command = ['initctl', 'start', 'application', 'APP_ID=messaging-app']
189− subprocess.check_call(command)
196+ self._launch_app("messaging-app")
190197 self.assertThat(greeter.created, Eventually(Equals(False)))
191198 self.assertThat(
192199 self._get_current_focused_app_id(),