Merge lp:~om26er/ubuntu-rssreader-app/add_autopilot_structure into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Omer Akram
Status: Merged
Approved by: Joey Chan
Approved revision: 11
Merged at revision: 11
Proposed branch: lp:~om26er/ubuntu-rssreader-app/add_autopilot_structure
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 182 lines (+140/-0)
7 files modified
debian/control (+8/-0)
debian/ubuntu-rssreader-app-autopilot.install (+1/-0)
tests/autopilot/ubuntu_rssreader_app/__init__.py (+8/-0)
tests/autopilot/ubuntu_rssreader_app/emulators/__init__.py (+6/-0)
tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py (+24/-0)
tests/autopilot/ubuntu_rssreader_app/tests/__init__.py (+55/-0)
tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py (+38/-0)
To merge this branch: bzr merge lp:~om26er/ubuntu-rssreader-app/add_autopilot_structure
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Shorts Developers Pending
Review via email: mp+166788@code.launchpad.net

Commit message

Adds initial structure for autopilot testing

Description of the change

Adds initial structure for autopilot testing

To post a comment you must log in.
Revision history for this message
Joey Chan (qqworini) wrote :

can u explain what is "autopilot" ? sounds like an auto mode in plane

Revision history for this message
Svenn-Arne Dragly (dragly) wrote :

I think Autopilot is a testing framework that will allow us to write unit tests (and similar) for the RSS reader.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

> can u explain what is "autopilot" ? sounds like an auto mode in plane

Its an auto mode indeed ;) but for testing the UI, see https://wiki.ubuntu.com/Touch/Testing/Autopilot

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-04-11 21:21:44 +0000
3+++ debian/control 2013-05-31 13:12:34 +0000
4@@ -16,3 +16,11 @@
5 qtdeclarative5-qtquick2-plugin
6 Description: RSS Reader application
7 Core RSS Reader application
8+
9+Package: ubuntu-rssreader-app-autopilot
10+Architecture: all
11+Depends: libautopilot-qt,
12+ libqt5test5,
13+ ubuntu-rssreader-app (= ${source:Version})
14+Description: Autopilot tests for RSS reader Application
15+ This package contains the autopilot tests for the RSS reader
16
17=== added file 'debian/ubuntu-rssreader-app-autopilot.install'
18--- debian/ubuntu-rssreader-app-autopilot.install 1970-01-01 00:00:00 +0000
19+++ debian/ubuntu-rssreader-app-autopilot.install 2013-05-31 13:12:34 +0000
20@@ -0,0 +1,1 @@
21+tests/autopilot/ubuntu_rssreader_app/* usr/lib/python2.7/dist-packages/ubuntu_rssreader_app/
22
23=== added directory 'tests'
24=== added directory 'tests/autopilot'
25=== added directory 'tests/autopilot/ubuntu_rssreader_app'
26=== added file 'tests/autopilot/ubuntu_rssreader_app/__init__.py'
27--- tests/autopilot/ubuntu_rssreader_app/__init__.py 1970-01-01 00:00:00 +0000
28+++ tests/autopilot/ubuntu_rssreader_app/__init__.py 2013-05-31 13:12:34 +0000
29@@ -0,0 +1,8 @@
30+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
31+# Copyright 2013 Canonical
32+#
33+# This program is free software: you can redistribute it and/or modify it
34+# under the terms of the GNU General Public License version 3, as published
35+# by the Free Software Foundation.
36+
37+"""RSS reader app tests and emulators - top level package."""
38
39=== added directory 'tests/autopilot/ubuntu_rssreader_app/emulators'
40=== added file 'tests/autopilot/ubuntu_rssreader_app/emulators/__init__.py'
41--- tests/autopilot/ubuntu_rssreader_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
42+++ tests/autopilot/ubuntu_rssreader_app/emulators/__init__.py 2013-05-31 13:12:34 +0000
43@@ -0,0 +1,6 @@
44+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
45+# Copyright 2013 Canonical
46+#
47+# This program is free software: you can redistribute it and/or modify it
48+# under the terms of the GNU General Public License version 3, as published
49+# by the Free Software Foundation.
50
51=== added file 'tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py'
52--- tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
53+++ tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 2013-05-31 13:12:34 +0000
54@@ -0,0 +1,24 @@
55+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
56+# Copyright 2013 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+"""RSS Reader app autopilot emulators."""
63+
64+
65+class MainWindow(object):
66+ """An emulator class that makes it easy to interact with the
67+ rssreader-app.
68+
69+ """
70+ def __init__(self, app):
71+ self.app = app
72+
73+ def get_qml_view(self):
74+ """Get the main QML view"""
75+ return self.app.select_single("QQuickView")
76+
77+ def get_toolbar(self):
78+ return self.app.select_single("Toolbar")
79
80=== added directory 'tests/autopilot/ubuntu_rssreader_app/tests'
81=== added file 'tests/autopilot/ubuntu_rssreader_app/tests/__init__.py'
82--- tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 1970-01-01 00:00:00 +0000
83+++ tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-05-31 13:12:34 +0000
84@@ -0,0 +1,55 @@
85+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
86+# Copyright 2013 Canonical
87+#
88+# This program is free software: you can redistribute it and/or modify it
89+# under the terms of the GNU General Public License version 3, as published
90+# by the Free Software Foundation.
91+
92+"""RSSReader app autopilot tests."""
93+
94+import os.path
95+
96+from autopilot.input import Mouse, Touch, Pointer
97+from autopilot.platform import model
98+from autopilot.testcase import AutopilotTestCase
99+
100+from ubuntu_rssreader_app.emulators.main_window import MainWindow
101+
102+
103+class RssreaderTestCase(AutopilotTestCase):
104+
105+ """A common test case class that provides several useful methods for
106+ rrsreader-app tests.
107+
108+ """
109+ if model() == 'Desktop':
110+ scenarios = [('with mouse', dict(input_device_class=Mouse))]
111+ else:
112+ scenarios = [('with touch', dict(input_device_class=Touch))]
113+
114+ local_location = "../../ubuntu-rssreader-app.qml"
115+
116+ def setUp(self):
117+ self.pointing_device = Pointer(self.input_device_class.create())
118+ super(RssreaderTestCase, self).setUp()
119+ if os.path.exists(self.local_location):
120+ self.launch_test_local()
121+ else:
122+ self.launch_test_installed()
123+
124+ def launch_test_local(self):
125+ self.app = self.launch_test_application(
126+ "qmlscene",
127+ self.local_location,
128+ app_type='qt')
129+
130+ def launch_test_installed(self):
131+ self.app = self.launch_test_application(
132+ "qmlscene",
133+ "/usr/share/ubuntu-rssreader-app/ubuntu-rssreader-app.qml",
134+ "--desktop_file_hint=/usr/share/applications/ubuntu-rssreader-app.desktop",
135+ app_type='qt')
136+
137+ @property
138+ def main_window(self):
139+ return MainWindow(self.app)
140
141=== added file 'tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py'
142--- tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 1970-01-01 00:00:00 +0000
143+++ tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-05-31 13:12:34 +0000
144@@ -0,0 +1,38 @@
145+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
146+# Copyright 2013 Canonical
147+#
148+# This program is free software: you can redistribute it and/or modify it
149+# under the terms of the GNU General Public License version 3, as published
150+# by the Free Software Foundation.
151+
152+"""RSS Reader app autopilot tests."""
153+
154+from __future__ import absolute_import
155+
156+from autopilot.matchers import Eventually
157+from testtools.matchers import Equals
158+
159+from ubuntu_rssreader_app.tests import RssreaderTestCase
160+
161+
162+class TestMainWindow(RssreaderTestCase):
163+
164+ def setUp(self):
165+ super(TestMainWindow, self).setUp()
166+ self.assertThat(
167+ self.main_window.get_qml_view().visible, Eventually(Equals(True)))
168+
169+ def tearDown(self):
170+ super(TestMainWindow, self).tearDown()
171+
172+ def test_toolbar_shows(self):
173+ """Make sure that dragging from the bottom reveals the hidden
174+ toolbar."""
175+ toolbar = self.main_window.get_toolbar()
176+
177+ x, y, w, h = toolbar.globalRect
178+ tx = x + (w / 2)
179+ ty = y + (h - 2)
180+
181+ self.pointing_device.drag(tx, ty, tx, ty - h)
182+ self.assertThat(toolbar.state, Eventually(Equals("spread")))

Subscribers

People subscribed via source and target branches