@@ -21,27 +21,23 @@
22from __future__ import absolute_import
22from __future__ import absolute_import
24−from unity8.process_helpers import unlock_unity
24+import logging
25−from unity8.shell import disable_qml_mocking
25+import os
26−from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
28−from autopilot.matchers import Eventually
29from autopilot.platform import model
27from autopilot.platform import model
30−from testtools.matchers import Equals, NotEquals
32−import logging
29+from unity8.application_lifecycle import tests
34−logger = logging.getLogger(__name__)
32+logger = logging.getLogger(__name__)
37−class ApplicationLifecycleTests(UnityTestCase):
39− scenarios = _get_device_emulation_scenarios()
35+class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
41 def setUp(self):
37 def setUp(self):
38+ if model() == 'Desktop':
39+ self.skipTest('Test cannot be run on the desktop.')
42 super(ApplicationLifecycleTests, self).setUp()
40 super(ApplicationLifecycleTests, self).setUp()
43− if model() == "Desktop":
44− self.skipTest("Test cannot be run on the desktop.")
46 def swipe_screen_from_right(self):
42 def swipe_screen_from_right(self):
47 width = self.main_window.width
43 width = self.main_window.width
@@ -54,80 +50,39 @@ class ApplicationLifecycleTests(UnityTestCase):
54 logger.info("Swiping screen from the right edge")
50 logger.info("Swiping screen from the right edge")
55 self.touch.drag(start_x, start_y, end_x, end_y)
51 self.touch.drag(start_x, start_y, end_x, end_y)
57− def _launch_app(self, app_name):
53+ def launch_fake_app(self):
58− """Launches the application *app_name*
54+ _, desktop_file_path = self.create_test_application()
59−
55+ desktop_file_name = os.path.basename(desktop_file_path)
60− Assumes that the desktop file resides at:
56+ application_name, _ = os.path.splitext(desktop_file_name)
61− /usr/share/applications/{app_name}.desktop
57+ self.launch_upstart_application(application_name)
58+ return application_name
64− desktop_file = "--desktop_file_hint="\
65− "/usr/share/applications/{app_name}.desktop".format(
68− return self.launch_test_application(
71− "--stage_hint=main_stage",
76 def test_can_launch_application(self):
60 def test_can_launch_application(self):
77 """Must be able to launch an application."""
61 """Must be able to launch an application."""
78− unity_proxy = self.launch_unity()
62+ application_name = self.launch_fake_app()
79− unlock_unity(unity_proxy)
63+ self.assert_current_focused_application(application_name)
81− app = self._launch_app("messaging-app")
83− self.assertThat(app, NotEquals(None))
85− self.main_window.get_current_focused_app_id(),
86− Eventually(Equals("messaging-app"))
90 def test_can_launch_multiple_applications(self):
65 def test_can_launch_multiple_applications(self):
91 """A second application launched must be focused."""
66 """A second application launched must be focused."""
92− unity_proxy = self.launch_unity()
67+ application1_name = self.launch_fake_app()
93− unlock_unity(unity_proxy)
68+ self.assert_current_focused_application(application1_name)
95− self._launch_app("messaging-app")
70+ application2_name = self.launch_fake_app()
96− self.assertThat(
71+ self.assertFalse(application1_name == application2_name)
97− self.main_window.get_current_focused_app_id(),
72+ self.assert_current_focused_application(application2_name)
98− Eventually(Equals("messaging-app"))
73+
101− self._launch_app("address-book-app")
103− self.main_window.get_current_focused_app_id(),
104− Eventually(Equals("address-book-app"))
107− @disable_qml_mocking
108 def test_app_moves_from_unfocused_to_focused(self):
74 def test_app_moves_from_unfocused_to_focused(self):
109 """An application that is in the unfocused state must be able to be
75 """An application that is in the unfocused state must be able to be
110 brought back to the focused state.
76 brought back to the focused state.
113− unity_proxy = self.launch_unity()
79+ application1_name = self.launch_fake_app()
114− unlock_unity(unity_proxy)
80+ self.assert_current_focused_application(application1_name)
116− self._launch_app("messaging-app")
118− self.main_window.get_current_focused_app_id(),
119− Eventually(Equals("messaging-app"))
122− self._launch_app("address-book-app")
82+ application2_name = self.launch_fake_app()
123− self.assertThat(
83+ self.assertFalse(application1_name == application2_name)
124− self.main_window.get_current_focused_app_id(),
84+ self.assert_current_focused_application(application2_name)
125− Eventually(Equals("address-book-app"))
128 self.swipe_screen_from_right()
86 self.swipe_screen_from_right()
130− self.assertThat(
88+ self.assert_current_focused_application(application1_name)
131− self.main_window.get_current_focused_app_id(),
132− Eventually(Equals("messaging-app"))