on xenial help sign in
Move the duplicated assertion to the base test case.
commit4916d87be9b2a09c9dc3b8523c58888858794066 authorLeo Arias <leo.arias@canonical.com> dateMon 7 Apr 2014, 14:51 (13 years ago) parent5aebfad
3 files changed+14−16
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+7 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+5−8 tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+2−8
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+7
@@ -17,6 +17,8 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20+from autopilot.matchers import Eventually
21+from testtools.matchers import Equals
2022from ubuntuuitoolkit import fixture_setup
2123
2224from unity8.shell import tests
@@ -29,3 +31,8 @@ class ApplicationLifeCycleTestCase(tests.UnityTestCase):
2931 self.useFixture(fake_application)
3032 return (
3133 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
2626
2727from autopilot.matchers import Eventually
2828from autopilot.platform import model
29−from testtools.matchers import Equals, NotEquals
29+from testtools.matchers import Equals
3030from ubuntuuitoolkit import (
3131 base,
3232 emulators as toolkit_emulators,
3333)
3434
35+from unity8.application_lifecycle import tests
3536from unity8.process_helpers import unlock_unity
3637from 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
3839
3940
4041logger = logging.getLogger(__name__)
4142
4243
43−class ApplicationLifecycleTests(UnityTestCase):
44+class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
4445
4546 scenarios = _get_device_emulation_scenarios()
4647
@@ -98,11 +99,7 @@ class ApplicationLifecycleTests(UnityTestCase):
9899 unlock_unity(unity_proxy)
99100
100101 application_name = self.launch_fake_app()
101−
102− self.assertThat(
103− self.main_window.get_current_focused_app_id(),
104− Eventually(Equals(application_name))
105− )
102+ self.assert_current_focused_application(application_name)
106103
107104 @disable_qml_mocking
108105 def test_can_launch_multiple_applications(self):
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+2−8
@@ -22,8 +22,6 @@
2222import os
2323
2424from autopilot import platform
25−from autopilot.matchers import Eventually
26−from testtools.matchers import Equals
2725
2826from unity8 import process_helpers
2927from unity8.application_lifecycle import tests
@@ -64,11 +62,7 @@ MainView {
6462 self.assertEqual('', self.main_window.get_current_focused_app_id())
6563 self.addCleanup(os.system, 'pkill qmlscene')
6664 os.system('url-dispatcher application:///{}'.format(desktop_file_name))
67− self.assertThat(
68− self.main_window.get_current_focused_app_id,
69− Eventually(Equals(application_name)))
65+ self.assert_current_focused_application(application_name)
7066
7167 self.main_window.show_dash_swiping()
72− self.assertThat(
73− self.main_window.get_current_focused_app_id,
74− Eventually(Equals('')))
68+ self.assert_current_focused_application('')