@@ -71,7 +71,7 @@ class ApplicationLifecycleTests(UnityTestCase):
71 def _get_current_focused_app_id(self):
71 def _get_current_focused_app_id(self):
72 return self._proxy.select_single("Shell").currentFocusedAppId
72 return self._proxy.select_single("Shell").currentFocusedAppId
74− def _launch_app(self, app_name):
74+ def _launch_app_directly(self, app_name):
75 """Launches the application *app_name*
75 """Launches the application *app_name*
77 Assumes that the desktop file resides at:
77 Assumes that the desktop file resides at:
@@ -89,15 +89,22 @@ class ApplicationLifecycleTests(UnityTestCase):
89 app_type='qt'
89 app_type='qt'
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)
98+ command = ['pkill', '-f', '-9', app_name]
99+ self.addCleanup(subprocess.call, command)
92 @disable_qml_mocking
101 @disable_qml_mocking
93 def test_can_launch_application(self):
102 def test_can_launch_application(self):
94 """Must be able to launch an application."""
103 """Must be able to launch an application."""
95 unity_proxy = self.launch_unity()
104 unity_proxy = self.launch_unity()
96 unlock_unity(unity_proxy)
105 unlock_unity(unity_proxy)
98− app = self._launch_app("messaging-app")
107+ self._launch_app("messaging-app")
100− self.assertThat(app, NotEquals(None))
101 self.assertThat(
108 self.assertThat(
102 self._get_current_focused_app_id(),
109 self._get_current_focused_app_id(),
103 Eventually(Equals("messaging-app"))
110 Eventually(Equals("messaging-app"))
@@ -136,7 +143,8 @@ class ApplicationLifecycleTests(UnityTestCase):
136 Eventually(Equals("messaging-app"))
143 Eventually(Equals("messaging-app"))
146+ # FIXME: this should be able to launch via upstart. Bug #1273844
139− self._launch_app("address-book-app")
147+ self._launch_app_directly("address-book-app")
140 self.assertThat(
148 self.assertThat(
141 self._get_current_focused_app_id(),
149 self._get_current_focused_app_id(),
142 Eventually(Equals("address-book-app"))
150 Eventually(Equals("address-book-app"))
@@ -156,7 +164,7 @@ class ApplicationLifecycleTests(UnityTestCase):
156 greeter = self.main_window.get_greeter()
164 greeter = self.main_window.get_greeter()
157 self.assertThat(greeter.created, Eventually(Equals(True)))
165 self.assertThat(greeter.created, Eventually(Equals(True)))
159− app = self._launch_app("messaging-app")
167+ self._launch_app("messaging-app")
160 self.assertThat(greeter.created, Eventually(Equals(False)))
168 self.assertThat(greeter.created, Eventually(Equals(False)))
161 self.assertThat(
169 self.assertThat(
162 self._get_current_focused_app_id(),
170 self._get_current_focused_app_id(),
@@ -164,12 +172,12 @@ class ApplicationLifecycleTests(UnityTestCase):
166 @disable_qml_mocking
174 @disable_qml_mocking
167− def test_greeter_hides_on_app_focus_via_upstart(self):
175+ def test_greeter_hides_on_app_focus(self):
168− """Greeter should hide when an app is re-focused with upstart"""
176+ """Greeter should hide when an app is re-focused"""
169 unity_proxy = self.launch_unity()
177 unity_proxy = self.launch_unity()
170 unlock_unity(unity_proxy)
178 unlock_unity(unity_proxy)
172− app = self._launch_app("messaging-app")
180+ self._launch_app("messaging-app")
173 self.assertThat(
181 self.assertThat(
174 self._get_current_focused_app_id(),
182 self._get_current_focused_app_id(),
175 Eventually(Equals("messaging-app"))
183 Eventually(Equals("messaging-app"))
@@ -185,8 +193,7 @@ class ApplicationLifecycleTests(UnityTestCase):
185 greeter = self.main_window.get_greeter()
193 greeter = self.main_window.get_greeter()
186 self.assertThat(greeter.created, Eventually(Equals(True)))
194 self.assertThat(greeter.created, Eventually(Equals(True)))
188− command = ['initctl', 'start', 'application', 'APP_ID=messaging-app']
196+ self._launch_app("messaging-app")
189− subprocess.check_call(command)
190 self.assertThat(greeter.created, Eventually(Equals(False)))
197 self.assertThat(greeter.created, Eventually(Equals(False)))
191 self.assertThat(
198 self.assertThat(
192 self._get_current_focused_app_id(),
199 self._get_current_focused_app_id(),