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

Subscribers

People subscribed via source and target branches

to status/vote changes: