on xenial help sign in
Use a fake application on the autopilot test_can_launch_application.
commit5aebfad6fd5383691f11e65dffcec1bf6d7e5ec9 authorLeo Arias <leo.arias@canonical.com> dateMon 7 Apr 2014, 14:46 (13 years ago) parente7f1040
3 files changed+59−17
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+31 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+25−7 tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+3−10
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 @@
2121
2222from __future__ import absolute_import
2323
24−from unity8.process_helpers import unlock_unity
25−from unity8.shell import disable_qml_mocking
26−from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
24+import logging
25+import os
2726
2827from autopilot.matchers import Eventually
2928from autopilot.platform import model
3029from 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
3138
32−import logging
3339
3440logger = logging.getLogger(__name__)
3541
@@ -72,18 +78,30 @@ class ApplicationLifecycleTests(UnityTestCase):
7278 app_type='qt'
7379 )
7480
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+
7594 @disable_qml_mocking
7695 def test_can_launch_application(self):
7796 """Must be able to launch an application."""
7897 unity_proxy = self.launch_unity()
7998 unlock_unity(unity_proxy)
8099
81− app = self._launch_app("messaging-app")
100+ application_name = self.launch_fake_app()
82101
83− self.assertThat(app, NotEquals(None))
84102 self.assertThat(
85103 self.main_window.get_current_focused_app_id(),
86− Eventually(Equals("messaging-app"))
104+ Eventually(Equals(application_name))
87105 )
88106
89107 @disable_qml_mocking
tests/autopilot/unity8/application_lifecycle/tests/test_url_dispatcher.py+3−10
@@ -24,13 +24,12 @@ import os
2424from autopilot import platform
2525from autopilot.matchers import Eventually
2626from testtools.matchers import Equals
27−from ubuntuuitoolkit import fixture_setup
2827
2928from unity8 import process_helpers
30−from unity8.shell import tests
29+from unity8.application_lifecycle import tests
3130
3231
33−class URLDispatcherTestCase(tests.UnityTestCase):
32+class URLDispatcherTestCase(tests.ApplicationLifeCycleTestCase):
3433
3534 scenarios = tests._get_device_emulation_scenarios()
3635
@@ -57,14 +56,8 @@ MainView {
5756 unity_proxy = self.launch_unity()
5857 process_helpers.unlock_unity(unity_proxy)
5958
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−
6659 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)
6861 desktop_file_name = os.path.basename(desktop_file_path)
6962 application_name, _ = os.path.splitext(desktop_file_name)
7063