Merge lp:~elopio/ubuntu-ui-toolkit/datepicker-autopilot_helper-pick_time into lp:ubuntu-ui-toolkit/staging

Proposed by Leo Arias
Status: Merged
Approved by: Cris Dywan
Approved revision: 1048
Merged at revision: 1067
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/datepicker-autopilot_helper-pick_time
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~elopio/ubuntu-ui-toolkit/datepicker-autopilot_helper
Diff against target: 208 lines (+123/-18)
2 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/pickers.py (+62/-13)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_date_picker.py (+61/-5)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/datepicker-autopilot_helper-pick_time
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+218915@code.launchpad.net

Commit message

Added autopilot helpers to pick a time from a date picker.

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
Cris Dywan (kalikiana) wrote :

Looks sensible to me.

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

PASSED: Continuous integration, rev:1047
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/199/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/122
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/109
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/31
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/31/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/632
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/296
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/296/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7018
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/101
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/152
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/152/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/199/rebuild

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

FAILED: Autolanding.
Unapproved changes made after approval.
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-autolanding/101/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/381
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/325
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-autolanding/45
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-autolanding/45
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-autolanding/45/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-autolanding/45
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/851
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/745
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/745/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7454
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/289
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/422
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/422/artifact/work/output/*zip*/output.zip

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

PASSED: Continuous integration, rev:1048
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/263/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/384
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/328
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/95
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/95
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/95/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/95
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/855
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/752
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/752/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7462
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/291
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/427
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/427/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/263/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/pickers.py'
2--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/pickers.py 2014-05-20 14:43:46 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/pickers.py 2014-05-20 14:43:46 +0000
4@@ -72,27 +72,26 @@
5 'Picker', objectName='PickerRow_YearPicker')
6 list_view = picker.select_single(
7 _qquicklistview.QQuickListView, objectName='Picker_Linear')
8- self._pick_date_value(self.year, year, list_view)
9+ self._pick_value(self.year, year, list_view)
10
11 @autopilot_logging.log_action(logger.info)
12 def _pick_month(self, month):
13- picker = self.select_single(
14- 'Picker', objectName='PickerRow_MonthPicker')
15- path_view = picker.select_single(
16- QQuickPathView, objectName='Picker_WrapAround')
17- self._pick_date_value(self.month, month, path_view)
18+ self._pick_value_from_path_view('Month', self.month, month)
19
20 @autopilot_logging.log_action(logger.info)
21 def _pick_day(self, day):
22+ # Python's date object starts at one. The model in the date picker
23+ # at 0.
24+ self._pick_value_from_path_view('Day', self.day - 1, day - 1)
25+
26+ def _pick_value_from_path_view(self, type_, current_value, new_value):
27 picker = self.select_single(
28- 'Picker', objectName='PickerRow_DayPicker')
29+ 'Picker', objectName='PickerRow_{}Picker'.format(type_))
30 path_view = picker.select_single(
31 QQuickPathView, objectName='Picker_WrapAround')
32- # Python's date object starts at one. The model in the date picker
33- # at 0.
34- self._pick_date_value(self.get_date().day - 1, day - 1, path_view)
35+ self._pick_value(current_value, new_value, path_view)
36
37- def _pick_date_value(self, current_value, new_value, scrollable):
38+ def _pick_value(self, current_value, new_value, scrollable):
39 if new_value > current_value:
40 direction = 'below'
41 elif new_value < current_value:
42@@ -112,8 +111,58 @@
43 """
44 # Python's date object starts at one. The model in the date picker
45 # at 0.
46- return datetime.date(
47- self.year, self.month + 1, self.day)
48+ return datetime.date(self.year, self.month + 1, self.day)
49+
50+ @autopilot_logging.log_action(logger.info)
51+ def pick_time(self, time):
52+ """Pick a time from the date picker.
53+
54+ :parameter time: The time to pick.
55+ :type time: An object with hour, minute and second attributes, like
56+ python's datetime.time.
57+ :raises ubuntuuitoolkit.ToolkitException if the mode of the picker
58+ doesn't let select a time.
59+
60+ """
61+ if not self._is_time_picker():
62+ raise _common.ToolkitException(
63+ "Can't pick time. The picker mode is: {!r}.".format(self.mode))
64+ if 'Hours' in self.mode:
65+ self._pick_hour(time.hour)
66+ self.hours.wait_for(time.hour)
67+ if 'Minutes' in self.mode:
68+ self._pick_minute(time.minute)
69+ self.minutes.wait_for(time.minute)
70+ if 'Seconds' in self.mode:
71+ self._pick_second(time.second)
72+ self.seconds.wait_for(time.second)
73+
74+ def _is_time_picker(self):
75+ mode = self.mode
76+ if 'Hours' in mode or 'Minutes' in mode or 'Seconds' in mode:
77+ return True
78+ else:
79+ return False
80+
81+ @autopilot_logging.log_action(logger.info)
82+ def _pick_hour(self, hour):
83+ self._pick_value_from_path_view('Hours', self.hours, hour)
84+
85+ @autopilot_logging.log_action(logger.info)
86+ def _pick_minute(self, minute):
87+ self._pick_value_from_path_view('Minutes', self.minutes, minute)
88+
89+ @autopilot_logging.log_action(logger.info)
90+ def _pick_second(self, second):
91+ self._pick_value_from_path_view('Seconds', self.seconds, second)
92+
93+ def get_time(self):
94+ """Return the currently selected time.
95+
96+ :return: a python datetime.time object with the selected time.
97+
98+ """
99+ return datetime.time(self.hours, self.minutes, self.seconds)
100
101
102 class QQuickPathView(_flickable.Scrollable):
103
104=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_date_picker.py'
105--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_date_picker.py 2014-05-20 14:43:46 +0000
106+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_date_picker.py 2014-05-20 14:43:46 +0000
107@@ -50,6 +50,15 @@
108 id: timePicker
109 objectName: 'timePicker'
110 mode: 'Hours|Minutes|Seconds'
111+ date: {
112+ var d = new Date()
113+ // Make sure that the picker will have higher and lower values
114+ // to select.
115+ d.setHours(12)
116+ d.setMinutes('30')
117+ d.setSeconds('30')
118+ return d
119+ }
120 }
121 }
122 }
123@@ -59,6 +68,8 @@
124 super(DatePickerBaseTestCase, self).setUp()
125 self.date_picker = self.main_view.select_single(
126 pickers.DatePicker, objectName='datePicker')
127+ self.time_picker = self.main_view.select_single(
128+ pickers.DatePicker, objectName='timePicker')
129
130
131 class DatePickerTestCase(DatePickerBaseTestCase):
132@@ -68,14 +79,22 @@
133 self.date_picker, pickers.DatePicker)
134
135 def test_pick_date_on_time_picker_must_raise_exception(self):
136- time_picker = self.main_view.select_single(
137- pickers.DatePicker, objectName='timePicker')
138 error = self.assertRaises(
139- ubuntuuitoolkit.ToolkitException, time_picker.pick_date, 'dummy')
140+ ubuntuuitoolkit.ToolkitException, self.time_picker.pick_date,
141+ 'dummy')
142 self.assertEqual(
143 str(error),
144 "Can't pick date. The picker mode is: {!r}.".format(
145- time_picker.mode))
146+ self.time_picker.mode))
147+
148+ def test_pick_time_on_date_picker_must_raise_exception(self):
149+ error = self.assertRaises(
150+ ubuntuuitoolkit.ToolkitException, self.date_picker.pick_time,
151+ 'dummy')
152+ self.assertEqual(
153+ str(error),
154+ "Can't pick time. The picker mode is: {!r}.".format(
155+ self.date_picker.mode))
156
157 def test_swipe_to_show_one_more_below_must_select_next_index(self):
158 """Test that we don't end up swiping more than needed.
159@@ -137,11 +156,48 @@
160 ('lower day', {
161 'date_to_pick': datetime.date(
162 SELECTED_YEAR, SELECTED_MONTH, SELECTED_DAY - 10)}),
163- ('change all value', {
164+ ('change all values', {
165 'date_to_pick': datetime.date(
166 SELECTED_YEAR - 10, SELECTED_MONTH + 4, SELECTED_DAY - 10)}),
167 ]
168
169 def test_pick_date(self):
170+ """Test that picking a date updates the picker."""
171 self.date_picker.pick_date(self.date_to_pick)
172 self.assertEqual(self.date_picker.get_date(), self.date_to_pick)
173+
174+
175+class PickTimeFromDatePickerTestCase(DatePickerBaseTestCase):
176+
177+ SELECTED_HOUR = 12
178+ SELECTED_MINUTE = 30
179+ SELECTED_SECOND = 30
180+
181+ scenarios = [
182+ ('higher hour', {
183+ 'time_to_pick': datetime.time(
184+ SELECTED_HOUR + 6, SELECTED_MINUTE, SELECTED_SECOND)}),
185+ ('lower hour', {
186+ 'time_to_pick': datetime.time(
187+ SELECTED_HOUR - 6, SELECTED_MINUTE, SELECTED_SECOND)}),
188+ ('higher minute', {
189+ 'time_to_pick': datetime.time(
190+ SELECTED_HOUR, SELECTED_MINUTE + 10, SELECTED_SECOND)}),
191+ ('lower minute', {
192+ 'time_to_pick': datetime.time(
193+ SELECTED_HOUR, SELECTED_MINUTE - 10, SELECTED_SECOND)}),
194+ ('higher second', {
195+ 'time_to_pick': datetime.time(
196+ SELECTED_HOUR, SELECTED_MINUTE, SELECTED_SECOND + 10)}),
197+ ('lower second', {
198+ 'time_to_pick': datetime.time(
199+ SELECTED_HOUR, SELECTED_MINUTE, SELECTED_SECOND - 10)}),
200+ ('change all values', {
201+ 'time_to_pick': datetime.time(
202+ SELECTED_HOUR + 6, SELECTED_MINUTE - 10,
203+ SELECTED_SECOND + 10)}),
204+ ]
205+
206+ def test_pick_time(self):
207+ self.time_picker.pick_time(self.time_to_pick)
208+ self.assertEqual(self.time_picker.get_time(), self.time_to_pick)

Subscribers

People subscribed via source and target branches