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
=== modified file 'dropping-letters.qml'
--- dropping-letters.qml 2013-05-07 18:05:17 +0000
+++ dropping-letters.qml 2013-07-14 11:02:26 +0000
@@ -57,6 +57,7 @@
5757
58 Flipable {58 Flipable {
59 id: flipable59 id: flipable
60 objectName: "flipable"
60 property bool flipped: false61 property bool flipped: false
61 property variant db: null62 property variant db: null
62 anchors.fill: parent63 anchors.fill: parent
@@ -159,6 +160,7 @@
159 }160 }
160 Label {161 Label {
161 id: playbutton162 id: playbutton
163 objectName: "playButton"
162 text: i18n.tr("Play")164 text: i18n.tr("Play")
163 anchors.top: logo.bottom165 anchors.top: logo.bottom
164 anchors.topMargin: units.gu(2)166 anchors.topMargin: units.gu(2)
@@ -356,6 +358,7 @@
356 id: suggestedWordContainer358 id: suggestedWordContainer
357 Label {359 Label {
358 id: accum360 id: accum
361 objectName: "accumulate"
359 anchors.centerIn: parent362 anchors.centerIn: parent
360 text: ""363 text: ""
361 color: "white"364 color: "white"
@@ -482,6 +485,7 @@
482485
483 Timer {486 Timer {
484 id: droptimer487 id: droptimer
488 objectName: "dropTimer"
485 repeat: true489 repeat: true
486 running: flipable.flipped490 running: flipable.flipped
487 interval: 2000491 interval: 2000
@@ -519,7 +523,7 @@
519 anchors.left: main.left523 anchors.left: main.left
520 anchors.right: main.right524 anchors.right: main.right
521 scale: -1525 scale: -1
522 color: "#efefea"526 color: "#efefef"
523 Row {527 Row {
524 anchors.horizontalCenter: game.horizontalCenter528 anchors.horizontalCenter: game.horizontalCenter
525 anchors.top: game.top529 anchors.top: game.top
526530
=== added directory 'tests'
=== added directory 'tests/autopilot'
=== added directory 'tests/autopilot/dropping_letters_app'
=== added file 'tests/autopilot/dropping_letters_app/__init__.py'
--- tests/autopilot/dropping_letters_app/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/__init__.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,6 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
07
=== added directory 'tests/autopilot/dropping_letters_app/emulators'
=== added file 'tests/autopilot/dropping_letters_app/emulators/__init__.py'
--- tests/autopilot/dropping_letters_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/emulators/__init__.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,6 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
07
=== added file 'tests/autopilot/dropping_letters_app/emulators/main_window.py'
--- tests/autopilot/dropping_letters_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/emulators/main_window.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,25 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17
18"""Calendar app autopilot emulators."""
19
20
21class MainWindow(object):
22 """An emulator class that makes it easy to interact with the Dropping Letters app."""
23
24 def __init__(self, app):
25 self.app = app
026
=== added file 'tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py'
--- tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/emulators/ubuntusdk.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,154 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
18
19from testtools.matchers import Equals, NotEquals, Not, Is
20from autopilot.matchers import Eventually
21
22class ubuntusdk(object):
23 """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
24
25 def __init__(self, autopilot, app):
26 self.app = app
27 self.autopilot = autopilot
28
29 def get_qml_view(self):
30 """Get the main QML view"""
31 return self.app.select_single("QQuickView")
32
33 def get_object(self, typeName, name):
34 """Get a specific object"""
35 return self.app.select_single(typeName, objectName=name)
36
37 def get_objects(self, typeName, name):
38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)
40
41 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""
43 tabs = self.get_tabs()
44 currentTab = tabs.selectedTabIndex
45
46 #perform operations until tab == currentTab
47 while tab != currentTab:
48 if tab > currentTab:
49 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex
53
54 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not
57 if self.get_toolbar().opened:
58 self.hide_toolbar()
59 else:
60 self.open_toolbar()
61
62 def get_toolbar(self):
63 """Returns the toolbar in the main events view."""
64 return self.app.select_single("Toolbar")
65
66 def get_toolbar_button(self, buttonLabel):
67 """Returns the toolbar button at position index"""
68 toolbar = self.get_toolbar()
69 if not toolbar.opened:
70 self.open_toolbar()
71 row = toolbar.select_single("ToolbarActions")
72 loaderList = row.select_many("QQuickLoader")
73 for loader in loaderList:
74 buttonList = loader.select_many("Button")
75 for button in buttonList:
76 if button.text == buttonLabel:
77 return button
78
79 def click_toolbar_button(self, buttonLabel):
80 """Clicks the toolbar button with buttonLabel"""
81 #The toolbar button is assumed to be the following format
82 #ToolbarActions {
83 # Action {
84 # objectName: "name"
85 # text: value
86 button = self.get_toolbar_button(buttonLabel)
87 self.autopilot.pointing_device.click_object(button)
88
89 def open_toolbar(self):
90 """Open the toolbar"""
91 qmlView = self.get_qml_view()
92
93 lineX = int(qmlView.x + qmlView.width * 0.50)
94 startY = int(qmlView.y + qmlView.height - 1)
95 stopY = int(qmlView.y + qmlView.height * 0.95)
96
97 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
98
99 def hide_toolbar(self):
100 """Hide the toolbar"""
101 qmlView = self.get_qml_view()
102
103 lineX = int(qmlView.x + qmlView.width * 0.50)
104 startY = int(qmlView.y + qmlView.height * 0.95)
105 stopY = int(qmlView.y + qmlView.height - 1)
106
107 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
108
109 def set_popup_value(self, popover, button, value):
110 """Changes the given popover selector to the request value
111 At the moment this only works for values that are currently visible. To
112 access the remaining items, a help method to drag and recheck is needed."""
113 #The popover is assumed to be the following format
114 # Popover {
115 # Column {
116 # ListView {
117 # delegate: Standard {
118 # objectName: "name"
119 # text: value
120
121 self.autopilot.pointing_device.click_object(button)
122 #we'll get all matching objects, incase the popover is reused between buttons
123 itemList = lambda: self.get_objects("Standard", popover)
124
125 for item in itemList():
126 if item.get_properties()['text'] == value:
127 self.autopilot.pointing_device.click_object(item)
128
129 def get_tabs(self):
130 """Return all tabs"""
131 return self.get_object("Tabs", "rootTabs")
132
133 def _previous_tab(self):
134 """Switch to the previous tab"""
135 qmlView = self.get_qml_view()
136
137 startX = int(qmlView.x + qmlView.width * 0.35)
138 stopX = int(qmlView.x + qmlView.width * 0.50)
139 lineY = int(qmlView.y + qmlView.height * 0.05)
140
141 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
142 self.autopilot.pointing_device.click()
143 self.autopilot.pointing_device.click()
144
145 def _next_tab(self):
146 """Switch to the next tab"""
147 qmlView = self.get_qml_view()
148
149 startX = int(qmlView.x + qmlView.width * 0.50)
150 stopX = int(qmlView.x + qmlView.width * 0.35)
151 lineY = int(qmlView.y + qmlView.height * 0.05)
152
153 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
154 self.autopilot.pointing_device.click()
0155
=== added directory 'tests/autopilot/dropping_letters_app/tests'
=== added file 'tests/autopilot/dropping_letters_app/tests/__init__.py'
--- tests/autopilot/dropping_letters_app/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/tests/__init__.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,62 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""Dropping Letters app autopilot tests."""
9
10import os.path
11
12from autopilot.input import Mouse, Touch, Pointer
13from autopilot.matchers import Eventually
14from autopilot.platform import model
15from autopilot.testcase import AutopilotTestCase
16from testtools.matchers import Equals
17
18from dropping_letters_app.emulators.main_window import MainWindow
19from dropping_letters_app.emulators.ubuntusdk import ubuntusdk
20
21
22class DroppingLettersTestCase(AutopilotTestCase):
23
24 """A common test case class that provides several useful methods for
25 calendar-app tests.
26
27 """
28 if model() == 'Desktop':
29 scenarios = [('with mouse', dict(input_device_class=Mouse))]
30 else:
31 scenarios = [('with touch', dict(input_device_class=Touch))]
32
33 local_location = "../../dropping-letters.qml"
34
35 def setUp(self):
36 self.pointing_device = Pointer(self.input_device_class.create())
37 super(DroppingLettersTestCase, self).setUp()
38 if os.path.exists(self.local_location):
39 self.launch_test_local()
40 else:
41 self.launch_test_installed()
42
43 def launch_test_local(self):
44 self.app = self.launch_test_application(
45 "qmlscene",
46 self.local_location,
47 app_type='qt')
48
49 def launch_test_installed(self):
50 self.app = self.launch_test_application(
51 "qmlscene",
52 "/usr/share/dropping-letters/dropping-letters.qml",
53 "--desktop_file_hint=/usr/share/applications/dropping-letters.desktop",
54 app_type='qt')
55
56 @property
57 def main_window(self):
58 return MainWindow(self.app)
59
60 @property
61 def ubuntusdk(self):
62 return ubuntusdk(self, self.app)
063
=== added file 'tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py'
--- tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/dropping_letters_app/tests/test_dropping_letters.py 2013-07-14 11:02:26 +0000
@@ -0,0 +1,25 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""Dropping Letters app autopilot tests."""
9
10from __future__ import absolute_import
11
12from autopilot.matchers import Eventually
13from testtools.matchers import Equals
14
15from dropping_letters_app.tests import DroppingLettersTestCase
16
17
18class TestMainWindow(DroppingLettersTestCase):
19
20 def setUp(self):
21 super(TestMainWindow, self).setUp()
22 self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
23
24 def tearDown(self):
25 super(TestMainWindow, self).tearDown()

Subscribers

People subscribed via source and target branches