on xenial help sign in
Use a fake application on the autopilot test_can_launch_application.
5aebfadLeo Arias
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+31
@@ -0,0 +1,31 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2014 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+from ubuntuuitoolkit import fixture_setup
21+
22+from unity8.shell import tests
23+
24+
25+class ApplicationLifeCycleTestCase(tests.UnityTestCase):
26+
27+ def create_test_application(self, test_qml=None):
28+ fake_application = fixture_setup.FakeApplication(test_qml)
29+ self.useFixture(fake_application)
30+ return (
31+ fake_application.qml_file_path, fake_application.desktop_file_path)
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+25−7
@@ -21,15 +21,21 @@
21
21
22from __future__ import absolute_import
22from __future__ import absolute_import
23
23
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
27
26
28from autopilot.matchers import Eventually
27from autopilot.matchers import Eventually
29from autopilot.platform import model
28from autopilot.platform import model
30from testtools.matchers import Equals, NotEquals
29from testtools.matchers import Equals, NotEquals
30+from ubuntuuitoolkit import (
31+ base,
32+ emulators as toolkit_emulators,
33+)
34+
35+from unity8.process_helpers import unlock_unity
36+from unity8.shell import disable_qml_mocking
37+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
31
38
32−import logging
33
39
34logger = logging.getLogger(__name__)
40logger = logging.getLogger(__name__)
35
41
@@ -72,18 +78,30 @@ class ApplicationLifecycleTests(UnityTestCase):
72 app_type='qt'
78 app_type='qt'
73 )
79 )
74
80
81+ def launch_fake_app(self):
82+ qml_file_path, desktop_file_path = self.create_test_application()
83+ desktop_file_name = os.path.basename(desktop_file_path)
84+ application_name, _ = os.path.splitext(desktop_file_name)
85+ self.launch_test_application(
86+ base.get_qmlscene_launch_command(),
87+ qml_file_path,
88+ '--desktop_file_hint={0}'.format(
89+ desktop_file_path),
90+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase,
91+ app_type='qt')
92+ return application_name
93+
75 @disable_qml_mocking
94 @disable_qml_mocking
76 def test_can_launch_application(self):
95 def test_can_launch_application(self):
77 """Must be able to launch an application."""
96 """Must be able to launch an application."""
78 unity_proxy = self.launch_unity()
97 unity_proxy = self.launch_unity()
79 unlock_unity(unity_proxy)
98 unlock_unity(unity_proxy)
80
99
81− app = self._launch_app("messaging-app")
100+ application_name = self.launch_fake_app()
82
101
83− self.assertThat(app, NotEquals(None))
84 self.assertThat(
102 self.assertThat(
85 self.main_window.get_current_focused_app_id(),
103 self.main_window.get_current_focused_app_id(),
86− Eventually(Equals("messaging-app"))
104+ Eventually(Equals(application_name))
87 )
105 )
88
106
89 @disable_qml_mocking
107 @disable_qml_mocking
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+3−10
@@ -24,13 +24,12 @@ import os
24from autopilot import platform
24from autopilot import platform
25from autopilot.matchers import Eventually
25from autopilot.matchers import Eventually
26from testtools.matchers import Equals
26from testtools.matchers import Equals
27−from ubuntuuitoolkit import fixture_setup
28
27
29from unity8 import process_helpers
28from unity8 import process_helpers
30−from unity8.shell import tests
29+from unity8.application_lifecycle import tests
31
30
32
31
33−class URLDispatcherTestCase(tests.UnityTestCase):
32+class URLDispatcherTestCase(tests.ApplicationLifeCycleTestCase):
34
33
35 scenarios = tests._get_device_emulation_scenarios()
34 scenarios = tests._get_device_emulation_scenarios()
36
35
@@ -57,14 +56,8 @@ MainView {
57 unity_proxy = self.launch_unity()
56 unity_proxy = self.launch_unity()
58 process_helpers.unlock_unity(unity_proxy)
57 process_helpers.unlock_unity(unity_proxy)
59
58
60− def create_test_application(self):
61− fake_application = fixture_setup.FakeApplication(self.test_qml)
62− self.useFixture(fake_application)
63− return (
64− fake_application.qml_file_path, fake_application.desktop_file_path)
65−
66 def test_swipe_out_application_started_by_url_dispatcher(self):
59 def test_swipe_out_application_started_by_url_dispatcher(self):
67− _, desktop_file_path = self.create_test_application()
60+ _, desktop_file_path = self.create_test_application(self.test_qml)
68 desktop_file_name = os.path.basename(desktop_file_path)
61 desktop_file_name = os.path.basename(desktop_file_path)
69 application_name, _ = os.path.splitext(desktop_file_name)
62 application_name, _ = os.path.splitext(desktop_file_name)
70
63