Merge lp:~adriangoodyer/dropping-letters/testcase_infrastructure into lp:dropping-letters

Proposed by adriangoodyer
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 38
Merged at revision: 33
Proposed branch: lp:~adriangoodyer/dropping-letters/testcase_infrastructure
Merge into: lp:dropping-letters
Diff against target: 357 lines (+283/-1)
7 files modified
dropping-letters.qml (+5/-1)
tests/autopilot/dropping_letters_app/__init__.py (+6/-0)
tests/autopilot/dropping_letters_app/emulators/__init__.py (+6/-0)
tests/autopilot/dropping_letters_app/emulators/main_window.py (+25/-0)
tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py (+154/-0)
tests/autopilot/dropping_letters_app/tests/__init__.py (+62/-0)
tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py (+25/-0)
To merge this branch: bzr merge lp:~adriangoodyer/dropping-letters/testcase_infrastructure
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+174607@code.launchpad.net

Commit message

- Infrasructure for the dropping-letters app test cases

- UbuntuSdk imported

Description of the change

- Infrasructure for the dropping-letters app test cases

- UbuntuSdk imported

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Looks good! Thanks Adrian!

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

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~adriangoodyer/dropping-letters/testcase_infrastructure/+merge/174607/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-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=== modified file 'dropping-letters.qml'
2--- dropping-letters.qml 2013-05-07 18:05:17 +0000
3+++ dropping-letters.qml 2013-07-14 11:02:26 +0000
4@@ -57,6 +57,7 @@
5
6 Flipable {
7 id: flipable
8+ objectName: "flipable"
9 property bool flipped: false
10 property variant db: null
11 anchors.fill: parent
12@@ -159,6 +160,7 @@
13 }
14 Label {
15 id: playbutton
16+ objectName: "playButton"
17 text: i18n.tr("Play")
18 anchors.top: logo.bottom
19 anchors.topMargin: units.gu(2)
20@@ -356,6 +358,7 @@
21 id: suggestedWordContainer
22 Label {
23 id: accum
24+ objectName: "accumulate"
25 anchors.centerIn: parent
26 text: ""
27 color: "white"
28@@ -482,6 +485,7 @@
29
30 Timer {
31 id: droptimer
32+ objectName: "dropTimer"
33 repeat: true
34 running: flipable.flipped
35 interval: 2000
36@@ -519,7 +523,7 @@
37 anchors.left: main.left
38 anchors.right: main.right
39 scale: -1
40- color: "#efefea"
41+ color: "#efefef"
42 Row {
43 anchors.horizontalCenter: game.horizontalCenter
44 anchors.top: game.top
45
46=== added directory 'tests'
47=== added directory 'tests/autopilot'
48=== added directory 'tests/autopilot/dropping_letters_app'
49=== added file 'tests/autopilot/dropping_letters_app/__init__.py'
50--- tests/autopilot/dropping_letters_app/__init__.py 1970-01-01 00:00:00 +0000
51+++ tests/autopilot/dropping_letters_app/__init__.py 2013-07-14 11:02:26 +0000
52@@ -0,0 +1,6 @@
53+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
54+# Copyright 2013 Canonical
55+#
56+# This program is free software: you can redistribute it and/or modify it
57+# under the terms of the GNU General Public License version 3, as published
58+# by the Free Software Foundation.
59
60=== added directory 'tests/autopilot/dropping_letters_app/emulators'
61=== added file 'tests/autopilot/dropping_letters_app/emulators/__init__.py'
62--- tests/autopilot/dropping_letters_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
63+++ tests/autopilot/dropping_letters_app/emulators/__init__.py 2013-07-14 11:02:26 +0000
64@@ -0,0 +1,6 @@
65+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
66+# Copyright 2013 Canonical
67+#
68+# This program is free software: you can redistribute it and/or modify it
69+# under the terms of the GNU General Public License version 3, as published
70+# by the Free Software Foundation.
71
72=== added file 'tests/autopilot/dropping_letters_app/emulators/main_window.py'
73--- tests/autopilot/dropping_letters_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
74+++ tests/autopilot/dropping_letters_app/emulators/main_window.py 2013-07-14 11:02:26 +0000
75@@ -0,0 +1,25 @@
76+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
77+#
78+# Copyright (C) 2013 Canonical Ltd
79+#
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU General Public License version 3 as
82+# published by the Free Software Foundation.
83+#
84+# This program is distributed in the hope that it will be useful,
85+# but WITHOUT ANY WARRANTY; without even the implied warranty of
86+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87+# GNU General Public License for more details.
88+#
89+# You should have received a copy of the GNU General Public License
90+# along with this program. If not, see <http://www.gnu.org/licenses/>.
91+#
92+
93+"""Calendar app autopilot emulators."""
94+
95+
96+class MainWindow(object):
97+ """An emulator class that makes it easy to interact with the Dropping Letters app."""
98+
99+ def __init__(self, app):
100+ self.app = app
101
102=== added file 'tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py'
103--- tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
104+++ tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 2013-07-14 11:02:26 +0000
105@@ -0,0 +1,154 @@
106+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
107+#
108+# Copyright (C) 2013 Canonical Ltd
109+#
110+# This program is free software: you can redistribute it and/or modify
111+# it under the terms of the GNU General Public License version 3 as
112+# published by the Free Software Foundation.
113+#
114+# This program is distributed in the hope that it will be useful,
115+# but WITHOUT ANY WARRANTY; without even the implied warranty of
116+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+# GNU General Public License for more details.
118+#
119+# You should have received a copy of the GNU General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+#
122+# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
123+
124+from testtools.matchers import Equals, NotEquals, Not, Is
125+from autopilot.matchers import Eventually
126+
127+class ubuntusdk(object):
128+ """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
129+
130+ def __init__(self, autopilot, app):
131+ self.app = app
132+ self.autopilot = autopilot
133+
134+ def get_qml_view(self):
135+ """Get the main QML view"""
136+ return self.app.select_single("QQuickView")
137+
138+ def get_object(self, typeName, name):
139+ """Get a specific object"""
140+ return self.app.select_single(typeName, objectName=name)
141+
142+ def get_objects(self, typeName, name):
143+ """Get more than one object"""
144+ return self.app.select_many(typeName, objectName=name)
145+
146+ def switch_to_tab(self, tab):
147+ """Switch to the specified tab number"""
148+ tabs = self.get_tabs()
149+ currentTab = tabs.selectedTabIndex
150+
151+ #perform operations until tab == currentTab
152+ while tab != currentTab:
153+ if tab > currentTab:
154+ self._previous_tab()
155+ if tab < currentTab:
156+ self._next_tab()
157+ currentTab = tabs.selectedTabIndex
158+
159+ def toggle_toolbar(self):
160+ """Toggle the toolbar between revealed and hidden"""
161+ #check and see if the toolbar is open or not
162+ if self.get_toolbar().opened:
163+ self.hide_toolbar()
164+ else:
165+ self.open_toolbar()
166+
167+ def get_toolbar(self):
168+ """Returns the toolbar in the main events view."""
169+ return self.app.select_single("Toolbar")
170+
171+ def get_toolbar_button(self, buttonLabel):
172+ """Returns the toolbar button at position index"""
173+ toolbar = self.get_toolbar()
174+ if not toolbar.opened:
175+ self.open_toolbar()
176+ row = toolbar.select_single("ToolbarActions")
177+ loaderList = row.select_many("QQuickLoader")
178+ for loader in loaderList:
179+ buttonList = loader.select_many("Button")
180+ for button in buttonList:
181+ if button.text == buttonLabel:
182+ return button
183+
184+ def click_toolbar_button(self, buttonLabel):
185+ """Clicks the toolbar button with buttonLabel"""
186+ #The toolbar button is assumed to be the following format
187+ #ToolbarActions {
188+ # Action {
189+ # objectName: "name"
190+ # text: value
191+ button = self.get_toolbar_button(buttonLabel)
192+ self.autopilot.pointing_device.click_object(button)
193+
194+ def open_toolbar(self):
195+ """Open the toolbar"""
196+ qmlView = self.get_qml_view()
197+
198+ lineX = int(qmlView.x + qmlView.width * 0.50)
199+ startY = int(qmlView.y + qmlView.height - 1)
200+ stopY = int(qmlView.y + qmlView.height * 0.95)
201+
202+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
203+
204+ def hide_toolbar(self):
205+ """Hide the toolbar"""
206+ qmlView = self.get_qml_view()
207+
208+ lineX = int(qmlView.x + qmlView.width * 0.50)
209+ startY = int(qmlView.y + qmlView.height * 0.95)
210+ stopY = int(qmlView.y + qmlView.height - 1)
211+
212+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
213+
214+ def set_popup_value(self, popover, button, value):
215+ """Changes the given popover selector to the request value
216+ At the moment this only works for values that are currently visible. To
217+ access the remaining items, a help method to drag and recheck is needed."""
218+ #The popover is assumed to be the following format
219+ # Popover {
220+ # Column {
221+ # ListView {
222+ # delegate: Standard {
223+ # objectName: "name"
224+ # text: value
225+
226+ self.autopilot.pointing_device.click_object(button)
227+ #we'll get all matching objects, incase the popover is reused between buttons
228+ itemList = lambda: self.get_objects("Standard", popover)
229+
230+ for item in itemList():
231+ if item.get_properties()['text'] == value:
232+ self.autopilot.pointing_device.click_object(item)
233+
234+ def get_tabs(self):
235+ """Return all tabs"""
236+ return self.get_object("Tabs", "rootTabs")
237+
238+ def _previous_tab(self):
239+ """Switch to the previous tab"""
240+ qmlView = self.get_qml_view()
241+
242+ startX = int(qmlView.x + qmlView.width * 0.35)
243+ stopX = int(qmlView.x + qmlView.width * 0.50)
244+ lineY = int(qmlView.y + qmlView.height * 0.05)
245+
246+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
247+ self.autopilot.pointing_device.click()
248+ self.autopilot.pointing_device.click()
249+
250+ def _next_tab(self):
251+ """Switch to the next tab"""
252+ qmlView = self.get_qml_view()
253+
254+ startX = int(qmlView.x + qmlView.width * 0.50)
255+ stopX = int(qmlView.x + qmlView.width * 0.35)
256+ lineY = int(qmlView.y + qmlView.height * 0.05)
257+
258+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
259+ self.autopilot.pointing_device.click()
260
261=== added directory 'tests/autopilot/dropping_letters_app/tests'
262=== added file 'tests/autopilot/dropping_letters_app/tests/__init__.py'
263--- tests/autopilot/dropping_letters_app/tests/__init__.py 1970-01-01 00:00:00 +0000
264+++ tests/autopilot/dropping_letters_app/tests/__init__.py 2013-07-14 11:02:26 +0000
265@@ -0,0 +1,62 @@
266+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
267+# Copyright 2013 Canonical
268+#
269+# This program is free software: you can redistribute it and/or modify it
270+# under the terms of the GNU General Public License version 3, as published
271+# by the Free Software Foundation.
272+
273+"""Dropping Letters app autopilot tests."""
274+
275+import os.path
276+
277+from autopilot.input import Mouse, Touch, Pointer
278+from autopilot.matchers import Eventually
279+from autopilot.platform import model
280+from autopilot.testcase import AutopilotTestCase
281+from testtools.matchers import Equals
282+
283+from dropping_letters_app.emulators.main_window import MainWindow
284+from dropping_letters_app.emulators.ubuntusdk import ubuntusdk
285+
286+
287+class DroppingLettersTestCase(AutopilotTestCase):
288+
289+ """A common test case class that provides several useful methods for
290+ calendar-app tests.
291+
292+ """
293+ if model() == 'Desktop':
294+ scenarios = [('with mouse', dict(input_device_class=Mouse))]
295+ else:
296+ scenarios = [('with touch', dict(input_device_class=Touch))]
297+
298+ local_location = "../../dropping-letters.qml"
299+
300+ def setUp(self):
301+ self.pointing_device = Pointer(self.input_device_class.create())
302+ super(DroppingLettersTestCase, self).setUp()
303+ if os.path.exists(self.local_location):
304+ self.launch_test_local()
305+ else:
306+ self.launch_test_installed()
307+
308+ def launch_test_local(self):
309+ self.app = self.launch_test_application(
310+ "qmlscene",
311+ self.local_location,
312+ app_type='qt')
313+
314+ def launch_test_installed(self):
315+ self.app = self.launch_test_application(
316+ "qmlscene",
317+ "/usr/share/dropping-letters/dropping-letters.qml",
318+ "--desktop_file_hint=/usr/share/applications/dropping-letters.desktop",
319+ app_type='qt')
320+
321+ @property
322+ def main_window(self):
323+ return MainWindow(self.app)
324+
325+ @property
326+ def ubuntusdk(self):
327+ return ubuntusdk(self, self.app)
328
329=== added file 'tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py'
330--- tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 1970-01-01 00:00:00 +0000
331+++ tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 2013-07-14 11:02:26 +0000
332@@ -0,0 +1,25 @@
333+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
334+# Copyright 2013 Canonical
335+#
336+# This program is free software: you can redistribute it and/or modify it
337+# under the terms of the GNU General Public License version 3, as published
338+# by the Free Software Foundation.
339+
340+"""Dropping Letters app autopilot tests."""
341+
342+from __future__ import absolute_import
343+
344+from autopilot.matchers import Eventually
345+from testtools.matchers import Equals
346+
347+from dropping_letters_app.tests import DroppingLettersTestCase
348+
349+
350+class TestMainWindow(DroppingLettersTestCase):
351+
352+ def setUp(self):
353+ super(TestMainWindow, self).setUp()
354+ self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
355+
356+ def tearDown(self):
357+ super(TestMainWindow, self).tearDown()

Subscribers

People subscribed via source and target branches