on xenial help sign in
Move the duplicated assertion to the base test case.
4916d87Leo Arias
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+7
@@ -17,6 +17,8 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
18#
19
19
20+from autopilot.matchers import Eventually
21+from testtools.matchers import Equals
20from ubuntuuitoolkit import fixture_setup
22from ubuntuuitoolkit import fixture_setup
21
23
22from unity8.shell import tests
24from unity8.shell import tests
@@ -29,3 +31,8 @@ class ApplicationLifeCycleTestCase(tests.UnityTestCase):
29 self.useFixture(fake_application)
31 self.useFixture(fake_application)
30 return (
32 return (
31 fake_application.qml_file_path, fake_application.desktop_file_path)
33 fake_application.qml_file_path, fake_application.desktop_file_path)
34+
35+ def assert_current_focused_application(self, application_name):
36+ self.assertThat(
37+ self.main_window.get_current_focused_app_id,
38+ Eventually(Equals(application_name)))
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+5−8
@@ -26,21 +26,22 @@ import os
26
26
27from autopilot.matchers import Eventually
27from autopilot.matchers import Eventually
28from autopilot.platform import model
28from autopilot.platform import model
29−from testtools.matchers import Equals, NotEquals
29+from testtools.matchers import Equals
30from ubuntuuitoolkit import (
30from ubuntuuitoolkit import (
31 base,
31 base,
32 emulators as toolkit_emulators,
32 emulators as toolkit_emulators,
33)
33)
34
34
35+from unity8.application_lifecycle import tests
35from unity8.process_helpers import unlock_unity
36from unity8.process_helpers import unlock_unity
36from unity8.shell import disable_qml_mocking
37from unity8.shell import disable_qml_mocking
37−from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
38+from unity8.shell.tests import _get_device_emulation_scenarios
38
39
39
40
40logger = logging.getLogger(__name__)
41logger = logging.getLogger(__name__)
41
42
42
43
43−class ApplicationLifecycleTests(UnityTestCase):
44+class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
44
45
45 scenarios = _get_device_emulation_scenarios()
46 scenarios = _get_device_emulation_scenarios()
46
47
@@ -98,11 +99,7 @@ class ApplicationLifecycleTests(UnityTestCase):
98 unlock_unity(unity_proxy)
99 unlock_unity(unity_proxy)
99
100
100 application_name = self.launch_fake_app()
101 application_name = self.launch_fake_app()
101−
102+ self.assert_current_focused_application(application_name)
102− self.assertThat(
103− self.main_window.get_current_focused_app_id(),
104− Eventually(Equals(application_name))
105− )
106
103
107 @disable_qml_mocking
104 @disable_qml_mocking
108 def test_can_launch_multiple_applications(self):
105 def test_can_launch_multiple_applications(self):
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+2−8
@@ -22,8 +22,6 @@
22import os
22import os
23
23
24from autopilot import platform
24from autopilot import platform
25−from autopilot.matchers import Eventually
26−from testtools.matchers import Equals
27
25
28from unity8 import process_helpers
26from unity8 import process_helpers
29from unity8.application_lifecycle import tests
27from unity8.application_lifecycle import tests
@@ -64,11 +62,7 @@ MainView {
64 self.assertEqual('', self.main_window.get_current_focused_app_id())
62 self.assertEqual('', self.main_window.get_current_focused_app_id())
65 self.addCleanup(os.system, 'pkill qmlscene')
63 self.addCleanup(os.system, 'pkill qmlscene')
66 os.system('url-dispatcher application:///{}'.format(desktop_file_name))
64 os.system('url-dispatcher application:///{}'.format(desktop_file_name))
67− self.assertThat(
65+ self.assert_current_focused_application(application_name)
68− self.main_window.get_current_focused_app_id,
69− Eventually(Equals(application_name)))
70
66
71 self.main_window.show_dash_swiping()
67 self.main_window.show_dash_swiping()
72− self.assertThat(
68+ self.assert_current_focused_application('')
73− self.main_window.get_current_focused_app_id,
74− Eventually(Equals('')))