Merge lp:~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker into lp:ubuntu-ui-toolkit

Proposed by I Ahmad
Status: Work in progress
Proposed branch: lp:~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 217 lines (+157/-2)
3 files modified
examples/ubuntu-ui-toolkit-gallery/Pickers.qml (+5/-0)
tests/autopilot/ubuntuuitoolkit/tests/__init__.py (+3/-2)
tests/autopilot/ubuntuuitoolkit/tests/gallery/test_picker.py (+149/-0)
To merge this branch: bzr merge lp:~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Chris Gagnon (community) Needs Fixing
Ubuntu SDK team Pending
Review via email: mp+192021@code.launchpad.net

Commit message

fixing review comments

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

if you use setUp you don't have to have duplicate code to open the page multiple times, see mp lp:~chris.gagnon/ubuntu-ui-toolkit/ap_testcases_for_picker_with_setup/+merge/192037

Doc strings are needed for describing what the test is testing for.
example:
"""circular picker must have a circular property equal to True and must ..."""

Don't hardcode the margin on line LP#52, maybe use instead:
use def flick(self, flickable, direction, delta=40, margin=10):

Otherwise it looks like good initial tests that can be expanded on later with the ap emulators. (I haven't tested this on the phone yet)

review: Needs Fixing
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

don't import all of time if you just need sleep.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:793
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker/+merge/192021/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1037/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/471
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3126
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/894
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/894
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/894/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/349
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4619
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4619/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3128
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3128/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2607
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2658
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/244
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/245

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1037/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:794
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker/+merge/192021/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1038/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/472
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3132/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/895
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/895
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/895/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/350
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4620
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4620/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3134
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3134/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2613
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2664/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/256
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/257

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1038/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:795
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~iahmad/ubuntu-ui-toolkit/ap_testcases_for_picker/+merge/192021/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1039/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/473
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3133
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/896
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/896
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/896/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/351
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4621
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4621/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3135
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3135/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2614
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2665
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/258
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/259

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1039/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:795
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1040/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/476
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3136
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/897
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/897
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/897/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/354
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4624
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4624/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3138
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3138/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2617
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2668
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/265
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/264

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1040/rebuild

review: Approve (continuous-integration)
Revision history for this message
I Ahmad (iahmad) wrote :

I ll wait for Jenkins bot to clear it first.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:795
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1055/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/6
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/6/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/3
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/3
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/3/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/5
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/6
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/6/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/6
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/6/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2643/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2694/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/325
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/324

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1055/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Iftikhar, the test runner is now fixed so that it does not mistakenly pass tests that do not complete. As you can see from the above, the autopilot test is getting stuck in some infinite loop and the tests now time out.

Unmerged revisions

795. By I Ahmad

fixing the review comments about time import and doc string

794. By I Ahmad

merge from chris gagnon branch to move the common code to setUp

793. By I Ahmad

missed the import for time module

792. By I Ahmad

catchup with trunk

791. By I Ahmad

flick margin adjustment

790. By I Ahmad

fixing pyflake warnings

789. By I Ahmad

work around for missing wait_select_single() method of AP

788. By I Ahmad

Added AP tests for Picker control and assigned object names to Picker example

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/ubuntu-ui-toolkit-gallery/Pickers.qml'
2--- examples/ubuntu-ui-toolkit-gallery/Pickers.qml 2013-09-12 07:54:12 +0000
3+++ examples/ubuntu-ui-toolkit-gallery/Pickers.qml 2013-10-22 06:08:21 +0000
4@@ -26,6 +26,7 @@
5 TemplateRow {
6 title: i18n.tr("Linear")
7 Picker {
8+ objectName: "picker_linear"
9 circular: false
10 model: ["Line1", "Line2", "Line3", "Line4", "Line5", "Line6", "Line7", "Line8", "Line9", "Line10"]
11
12@@ -43,6 +44,7 @@
13 TemplateRow {
14 title: i18n.tr("Circular")
15 Picker {
16+ objectName: "picker_circular"
17 delegate: PickerDelegate {
18 Label {
19 text: modelData
20@@ -66,6 +68,7 @@
21 TemplateRow {
22 title: i18n.tr("Infinite")
23 Picker {
24+ objectName: "picker_infinite"
25 id: picker
26 model: ListModel {}
27 circular: false
28@@ -101,6 +104,7 @@
29 TemplateRow {
30 title: i18n.tr("Clock")
31 Dialer {
32+ objectName: "dialer_clock"
33 size: units.gu(20)
34 handSpace: units.gu(4)
35 minimumValue: 0
36@@ -138,6 +142,7 @@
37 TemplateRow {
38 title: i18n.tr("Overlay")
39 Dialer {
40+ objectName: "dialer_overlay"
41 size: units.gu(20)
42 handSpace: units.gu(4)
43
44
45=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py'
46--- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2013-10-21 07:44:03 +0000
47+++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2013-10-22 06:08:21 +0000
48@@ -203,12 +203,13 @@
49 def flick(self, flickable, direction, delta=40):
50 """This funcito flicks the page from middle to the given direction."""
51 x, y, w, h = flickable.globalRect
52+ margin = 10
53 if direction == FlickDirection.UP:
54- self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
55+ self.pointing_device.drag(x + margin, y + h / 2, x + margin,
56 y + h / 2 - delta)
57 flickable.flicking.wait_for(False)
58 elif direction == FlickDirection.DOWN:
59- self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
60+ self.pointing_device.drag(x + margin, y + h / 2, x + margin,
61 y + h / 2 + delta)
62 flickable.flicking.wait_for(False)
63 else:
64
65=== added file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_picker.py'
66--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_picker.py 1970-01-01 00:00:00 +0000
67+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_picker.py 2013-10-22 06:08:21 +0000
68@@ -0,0 +1,149 @@
69+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
70+#
71+# Copyright (C) 2012, 2013 Canonical Ltd.
72+#
73+# This program is free software; you can redistribute it and/or modify
74+# it under the terms of the GNU Lesser General Public License as published by
75+# the Free Software Foundation; version 3.
76+#
77+# This program is distributed in the hope that it will be useful,
78+# but WITHOUT ANY WARRANTY; without even the implied warranty of
79+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80+# GNU Lesser General Public License for more details.
81+#
82+# You should have received a copy of the GNU Lesser General Public License
83+# along with this program. If not, see <http://www.gnu.org/licenses/>.
84+
85+"""Tests for the Ubuntu UI Toolkit Gallery - OptionSelector component"""
86+
87+from time import sleep
88+from autopilot.matchers import Eventually
89+from testtools.matchers import Equals
90+from ubuntuuitoolkit.tests.gallery import GalleryTestCase
91+from ubuntuuitoolkit.tests import FlickDirection
92+
93+
94+class Direction:
95+ """Enum for Circular Picker direction."""
96+
97+ BACKWARD, FORWARD = range(0, 2)
98+
99+
100+class PickerTests(GalleryTestCase):
101+ """Generic tests for the Gallery"""
102+
103+ def setUp(self):
104+ super(PickerTests, self).setUp()
105+ item = "Pickers"
106+ self.loadItem(item)
107+ self.checkPageHeader(item)
108+
109+ def test_picker_dialer(self):
110+ dialer_clock = self.getObject('dialer_clock')
111+ #Flick upward to reveal the hidden ui element.
112+ flickable = self.main_view.select_single('QQuickFlickable')
113+ self.assertIsNotNone(flickable)
114+ self.reveal_item_by_flick(dialer_clock, flickable, FlickDirection.UP)
115+ self.assertThat(flickable.flicking, Eventually(Equals(False)))
116+ #TODO: Need to add more testing logic.
117+
118+ def test_picker_dialerhand(self):
119+ dialer_overlay = self.getObject('dialer_overlay')
120+ #Flick upward to reveal the hidden ui element.
121+ flickable = self.main_view.select_single('QQuickFlickable')
122+ self.assertIsNotNone(flickable)
123+ self.reveal_item_by_flick(dialer_overlay, flickable, FlickDirection.UP)
124+ self.assertThat(flickable.flicking, Eventually(Equals(False)))
125+ #TODO: Need to add more testing logic.
126+
127+ def test_picker_linear_picker(self):
128+ """Testing the linear picker"""
129+
130+ linear = self.getObject('picker_linear')
131+ self.assertThat(linear.circular, Equals(False))
132+ listview = linear.select_single('QQuickListView')
133+ self.assertIsNotNone(listview)
134+ count = listview.count
135+ for i in range(0, count):
136+ line = linear.select_single('Label', text='Line' + str(i + 1))
137+ self.assertIsNotNone(line)
138+ self.pointing_device.click_object(line)
139+ linear = self.getObject('picker_linear')
140+ self.assertThat(linear.selectedIndex, Eventually(Equals(i)))
141+
142+ try:
143+ #try finding the next item.
144+ line = linear.select_single('Label', text='Line' + str(count + 1))
145+ self.assertIsNone(line)
146+ except:
147+ pass
148+
149+ def test_picker_circular_picker(self):
150+ """Testing the circular picker"""
151+
152+ circular = self.getObject('picker_circular')
153+ self.assertThat(circular.circular, Equals(True))
154+ selectedIndex = circular.selectedIndex
155+ #it seems picker needs some time to move to seletected index
156+ #this requires uses of wait_select_single method in autopilot
157+ #At time of writing this test, method is in trunk but not yet released.
158+ #So I am looping it here to mimick the wait and will update
159+ #once autopilot wait_select_single method becomes available.
160+ for i in range(0, 10):
161+ try:
162+ line = circular.select_single('Label',
163+ text='Line '
164+ + str(selectedIndex))
165+ self.assertIsNotNone(line)
166+ except:
167+ sleep(1)
168+
169+ self.pointing_device.click_object(line)
170+
171+ pathview = circular.select_single('QQuickPathView')
172+ self.assertIsNotNone(pathview)
173+ count = pathview.count
174+ direction_to_move = (Direction.BACKWARD
175+ if selectedIndex <= count / 2
176+ else Direction.FORWARD)
177+
178+ #Test logic should be independent of test data but it doesn't
179+ #look possible here, so have to rely on test data values in list
180+ if direction_to_move == Direction.BACKWARD:
181+ for i in range(selectedIndex, -2, -1):
182+ line = circular.select_single('Label',
183+ text='Line ' + str(i % count))
184+ self.assertIsNotNone(line)
185+ self.pointing_device.click_object(line)
186+ self.assertThat(circular.selectedIndex,
187+ Eventually(Equals(i % count)))
188+ else:
189+ for i in range(selectedIndex, count + 2):
190+ line = circular.select_single('Label',
191+ text='Line ' + str(i % count))
192+ self.assertIsNotNone(line)
193+ self.pointing_device.click_object(line)
194+ self.assertThat(circular.selectedIndex,
195+ Eventually(Equals(i % count)))
196+
197+ def test_picker_infinite_picker(self):
198+ """Testing the infinite picker"""
199+
200+ infinite = self.getObject('picker_infinite')
201+ self.assertThat(infinite.circular, Equals(False))
202+
203+ #Flick upward to reveal the hidden ui element.
204+ flickable = self.main_view.select_single('QQuickFlickable')
205+ self.assertIsNotNone(flickable)
206+ self.reveal_item_by_flick(infinite, flickable, FlickDirection.UP)
207+ self.assertThat(flickable.flicking, Eventually(Equals(False)))
208+
209+ listview = infinite.select_single('QQuickListView')
210+ self.assertIsNotNone(listview)
211+ count = listview.count
212+ for i in range(0, count + 10):
213+ line = infinite.select_single('Label', text='Line ' + str(i))
214+ self.assertIsNotNone(line)
215+ self.pointing_device.click_object(line)
216+ infinite = self.getObject('picker_infinite')
217+ self.assertThat(infinite.selectedIndex, Eventually(Equals(i)))

Subscribers

People subscribed via source and target branches

to status/vote changes: