Merge lp:~nskaggs/ubuntu-rssreader-app/add-ap-template into lp:ubuntu-rssreader-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Joey Chan
Approved revision: 434
Merged at revision: 435
Proposed branch: lp:~nskaggs/ubuntu-rssreader-app/add-ap-template
Merge into: lp:ubuntu-rssreader-app
Diff against target: 176 lines (+158/-0)
3 files modified
tests/autopilot/shorts_app/__init__.py (+41/-0)
tests/autopilot/shorts_app/tests/__init__.py (+100/-0)
tests/autopilot/shorts_app/tests/test_shorts.py (+17/-0)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-rssreader-app/add-ap-template
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Review via email: mp+288840@code.launchpad.net

Commit message

Re-add autopilot shell

Description of the change

Re-add autopilot shell

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'tests'
2=== added directory 'tests/autopilot'
3=== added directory 'tests/autopilot/shorts_app'
4=== added file 'tests/autopilot/shorts_app/__init__.py'
5--- tests/autopilot/shorts_app/__init__.py 1970-01-01 00:00:00 +0000
6+++ tests/autopilot/shorts_app/__init__.py 2016-03-11 21:33:09 +0000
7@@ -0,0 +1,41 @@
8+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
9+#
10+# Copyright (C) 2013-2016 Canonical Ltd.
11+#
12+# This program is free software; you can redistribute it and/or modify
13+# it under the terms of the GNU Lesser General Public License as published by
14+# the Free Software Foundation; version 3.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Lesser General Public License for more details.
20+#
21+# You should have received a copy of the GNU Lesser General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
24+"""Shorts app autopilot helpers."""
25+
26+import ubuntuuitoolkit
27+
28+
29+class ShortsApp(object):
30+
31+ """Autopilot helper object for the shorts application."""
32+
33+ def __init__(self, app_proxy):
34+ self.app = app_proxy
35+ self.main_view = self.app.select_single(MainView)
36+
37+ @property
38+ def pointing_device(self):
39+ return self.app.pointing_device
40+
41+
42+class MainView(ubuntuuitoolkit.MainView):
43+
44+ """Autopilot custom proxy object for the MainView."""
45+
46+ def __init__(self, *args):
47+ super(MainView, self).__init__(*args)
48+ self.visible.wait_for(True)
49
50=== added directory 'tests/autopilot/shorts_app/tests'
51=== added file 'tests/autopilot/shorts_app/tests/__init__.py'
52--- tests/autopilot/shorts_app/tests/__init__.py 1970-01-01 00:00:00 +0000
53+++ tests/autopilot/shorts_app/tests/__init__.py 2016-03-11 21:33:09 +0000
54@@ -0,0 +1,100 @@
55+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
56+# Copyright 2013-2016 Canonical
57+#
58+# This program is free software: you can redistribute it and/or modify it
59+# under the terms of the GNU General Public License version 3, as published
60+# by the Free Software Foundation.
61+
62+"""Shorts app autopilot tests."""
63+
64+import os.path
65+import fixtures
66+import logging
67+import tempfile
68+import gi
69+
70+from autopilot import logging as autopilot_logging
71+from autopilot.testcase import AutopilotTestCase
72+import ubuntuuitoolkit
73+
74+import shorts_app
75+gi.require_version('Click', '0.4')
76+from gi.repository import Click
77+
78+
79+logger = logging.getLogger(__name__)
80+
81+
82+class ShortsTestCase(AutopilotTestCase):
83+
84+ """A common testcase class that provides useful methods for the shorts
85+ app.
86+
87+ """
88+
89+ local_build_location = os.path.dirname(os.path.dirname(os.getcwd()))
90+ sdk_build_location = os.path.join(os.path.dirname(local_build_location),
91+ os.path.basename(local_build_location)
92+ + '-build')
93+
94+ local_build_location_qml = os.path.join(
95+ local_build_location, 'shorts', 'qml', 'shorts-app.qml')
96+ local_build_location_binary = os.path.join(local_build_location,
97+ 'shorts', 'shorts-app')
98+ sdk_build_location_qml = os.path.join(
99+ sdk_build_location, 'shorts', 'qml', 'shorts-app.qml')
100+ sdk_build_location_binary = os.path.join(sdk_build_location,
101+ 'shorts', 'shorts-app')
102+ installed_location_binary = os.path.join('usr', 'bin',
103+ 'shorts-app')
104+ installed_location_qml = os.path.join('usr', 'share',
105+ 'shorts-app', 'qml',
106+ 'shorts-app.qml')
107+
108+ def setUp(self):
109+ super(ShortsTestCase, self).setUp()
110+ launcher_method, _ = self.get_launcher_method_and_type()
111+ self.app = shorts_app.ShortsApp(launcher_method())
112+
113+ def get_launcher_method_and_type(self):
114+ if os.path.exists(self.local_build_location_binary):
115+ launcher = self.launch_test_local
116+ test_type = 'local'
117+ elif os.path.exists(self.sdk_build_location_binary):
118+ launcher = self.launch_test_sdk
119+ test_type = 'sdk'
120+ elif os.path.exists(self.installed_location_binary):
121+ launcher = self.launch_test_installed
122+ test_type = 'deb'
123+ else:
124+ launcher = self.launch_test_click
125+ test_type = 'click'
126+ return launcher, test_type
127+
128+ @autopilot_logging.log_action(logger.info)
129+ def launch_test_local(self):
130+ return self.launch_test_application(
131+ self.local_build_location_binary,
132+ app_type='qt',
133+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
134+
135+ @autopilot_logging.log_action(logger.info)
136+ def launch_test_sdk(self):
137+ return self.launch_test_application(
138+ self.sdk_build_location_binary,
139+ app_type='qt',
140+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
141+
142+ @autopilot_logging.log_action(logger.info)
143+ def launch_test_installed(self):
144+ return self.launch_test_application(
145+ self.installed_location_binary,
146+ app_type='qt',
147+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
148+
149+ @autopilot_logging.log_action(logger.info)
150+ def launch_test_click(self):
151+ return self.launch_click_package(
152+ "com.ubuntu.shorts",
153+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
154+
155
156=== added file 'tests/autopilot/shorts_app/tests/test_shorts.py'
157--- tests/autopilot/shorts_app/tests/test_shorts.py 1970-01-01 00:00:00 +0000
158+++ tests/autopilot/shorts_app/tests/test_shorts.py 2016-03-11 21:33:09 +0000
159@@ -0,0 +1,17 @@
160+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
161+# Copyright 2013-2016 Canonical
162+#
163+# This program is free software: you can redistribute it and/or modify it
164+# under the terms of the GNU General Public License version 3, as published
165+# by the Free Software Foundation.
166+
167+"""Shorts app autopilot tests."""
168+
169+from shorts_app.tests import ShortsTestCase
170+
171+
172+class TestMainWindow(ShortsTestCase):
173+ def test_example_test(self):
174+ """Just launch app, assert on main view"""
175+ main_view = self.app.main_view
176+ self.assertTrue(main_view)

Subscribers

People subscribed via source and target branches