Merge lp:~nik90/ubuntu-clock-app/use-default-swipe-delete into lp:ubuntu-clock-app/saucy
- use-default-swipe-delete
- Merge into saucy
Status: | Merged |
---|---|
Approved by: | Nekhelesh Ramananthan |
Approved revision: | 262 |
Merged at revision: | 262 |
Proposed branch: | lp:~nik90/ubuntu-clock-app/use-default-swipe-delete |
Merge into: | lp:ubuntu-clock-app/saucy |
Diff against target: |
702 lines (+165/-309) 11 files modified
alarm/AlarmPage.qml (+1/-8) clock/ClockPage.qml (+4/-12) clock/WorldClock.qml (+1/-0) common/SwipeDelete.qml (+0/-67) stopwatch/LapList.qml (+4/-9) tests/autopilot/ubuntu_clock_app/emulators.py (+75/-75) tests/autopilot/ubuntu_clock_app/tests/test_alarm.py (+2/-0) tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+35/-58) tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py (+2/-7) tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+40/-65) timer/PresetList.qml (+1/-8) |
To merge this branch: | bzr merge lp:~nik90/ubuntu-clock-app/use-default-swipe-delete |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Ubuntu Clock Developers | Pending | ||
Review via email: mp+191905@code.launchpad.net |
Commit message
Adds confirm to delete option to clock, alarm, timer and stopwatch. It also removes the custom swipe delete class since it is now provided by the SDK. Autopilot tests have been fixed, cleaned and ported to Autopilot 1.4. They also make more use of upstream UITK emulator functions.
Description of the change
This MP implements the following,
UI Change
- Adds confirm to delete option to clock, alarm, timer and stopwatch.
- It removes the custom swipe delete class since it is now provided by the SDK.
Autopilot Tests
- Ports clock app autopilot tests to 1.4 which results in less assert statements and other improvements.
- Emulator function and test cases clean up
- It also improves the testing logic of the delete_
2 Autopilot tests test_delete_
Another point worth noting is that the alarm test cases have not been ported to 1.4. However the alarm tests are skipped until the Alarm features matures and is more stable. This should happen in the upcoming weeks at which point the alarm test cases will also be updated.
Nekhelesh Ramananthan (nik90) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:253
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
This looks good, but I'm getting failures on my desktop using it ;-( I see the lab has some failures also. I'll dig in to see what's up in a minute if you believe this to be working.
The changes to get rid of "get_button_x" are good, as is the swipe to delete :-)
Nekhelesh Ramananthan (nik90) wrote : | # |
I am getting failures in the tests ubuntu_
Nicholas Skaggs (nskaggs) wrote : | # |
Let's await the fix for the upstream confirm delete issue. nik90 can you add a comment with a link to the bug once it's been filed?
Nekhelesh Ramananthan (nik90) wrote : | # |
MP is frozen until https:/
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:259
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:259
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 260. By Nekhelesh Ramananthan
-
Added an additional assert statement to ensure that world city list is available before returning it
- 261. By Nekhelesh Ramananthan
-
reverted previous commit
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:260
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:261
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 262. By Nekhelesh Ramananthan
-
Fixed add local city test failure
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:262
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:262
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:262
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:262
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:262
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
Leo says the emulator has landed and thus this should work very shortly :-) Perhaps tomorrow :-)
Nekhelesh Ramananthan (nik90) wrote : | # |
Yup it landed 20 hours ago. Waiting on the update to land in the jenkins machine :-).
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:262
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) : | # |
Preview Diff
1 | === modified file 'alarm/AlarmPage.qml' |
2 | --- alarm/AlarmPage.qml 2013-10-26 13:55:35 +0000 |
3 | +++ alarm/AlarmPage.qml 2013-11-07 16:34:52 +0000 |
4 | @@ -217,14 +217,7 @@ |
5 | |
6 | selected: listSavedAlarm.currentIndex == index |
7 | removable: true |
8 | - |
9 | - // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs |
10 | - // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089 |
11 | - // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand. |
12 | - backgroundIndicator: SwipeDelete { |
13 | - id: swipeDelete |
14 | - state: swipingState |
15 | - } |
16 | + confirmRemoval: true |
17 | |
18 | onItemRemoved: { |
19 | var alarm = alarmModel.get(index) |
20 | |
21 | === modified file 'clock/ClockPage.qml' |
22 | --- clock/ClockPage.qml 2013-11-01 16:10:28 +0000 |
23 | +++ clock/ClockPage.qml 2013-11-07 16:34:52 +0000 |
24 | @@ -214,6 +214,7 @@ |
25 | currentIndex: -1 |
26 | |
27 | delegate: ListItem.Standard { |
28 | + objectName: "savedworldcity" + index |
29 | Label { |
30 | text: cityName |
31 | objectName: "city_name" |
32 | @@ -231,18 +232,9 @@ |
33 | |
34 | selected: listWorldClocks.currentIndex == index |
35 | removable: true |
36 | - |
37 | - // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs |
38 | - // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089 |
39 | - // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand. |
40 | - backgroundIndicator: SwipeDelete { |
41 | - id: swipeDelete |
42 | - state: swipingState |
43 | - } |
44 | - |
45 | - onItemRemoved: { |
46 | - worldModel.removePreset(index); |
47 | - } |
48 | + confirmRemoval: true |
49 | + |
50 | + onItemRemoved: worldModel.removePreset(index); |
51 | } |
52 | } |
53 | } |
54 | |
55 | === modified file 'clock/WorldClock.qml' |
56 | --- clock/WorldClock.qml 2013-10-25 04:33:48 +0000 |
57 | +++ clock/WorldClock.qml 2013-11-07 16:34:52 +0000 |
58 | @@ -126,6 +126,7 @@ |
59 | section.labelPositioning: ViewSection.InlineLabels |
60 | |
61 | delegate: ListItem.Base { |
62 | + objectName: "worldcity" + index |
63 | visible: !errorMessage.visible |
64 | height: adminName || adminName2 ? units.gu(8) : units.gu(6) |
65 | Column { |
66 | |
67 | === removed file 'common/SwipeDelete.qml' |
68 | --- common/SwipeDelete.qml 2013-07-20 07:54:03 +0000 |
69 | +++ common/SwipeDelete.qml 1970-01-01 00:00:00 +0000 |
70 | @@ -1,67 +0,0 @@ |
71 | -/* |
72 | - * Copyright (C) 2013 Canonical Ltd |
73 | - * |
74 | - * This program is free software: you can redistribute it and/or modify |
75 | - * it under the terms of the GNU General Public License version 3 as |
76 | - * published by the Free Software Foundation. |
77 | - * |
78 | - * This program is distributed in the hope that it will be useful, |
79 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
80 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
81 | - * GNU General Public License for more details. |
82 | - * |
83 | - * You should have received a copy of the GNU General Public License |
84 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
85 | - * |
86 | - * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com> |
87 | - */ |
88 | - |
89 | -import QtQuick 2.0 |
90 | -import Ubuntu.Components 0.1 |
91 | - |
92 | -// Qml element to customize list item swipe behavior. |
93 | -Rectangle { |
94 | - id: swipeBackgroundItem |
95 | - |
96 | - anchors.fill: parent |
97 | - color: Theme.palette.normal.base; |
98 | - |
99 | - Image { |
100 | - id: swipeDeleteIcon |
101 | - |
102 | - property int slidingMargin: units.gu(12) |
103 | - |
104 | - anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: parent.right } |
105 | - verticalAlignment: Image.AlignVCenter |
106 | - fillMode: Image.Pad |
107 | - } |
108 | - |
109 | - Label { |
110 | - id: swipeBackgroundText |
111 | - |
112 | - property int slidingMargin: units.gu(3) |
113 | - |
114 | - anchors.fill: parent |
115 | - verticalAlignment: Text.AlignVCenter |
116 | - color: Theme.palette.normal.baseText |
117 | - fontSize: "large" |
118 | - } |
119 | - |
120 | - states: [ |
121 | - State { |
122 | - name: "SwipingRight" |
123 | - PropertyChanges { target: swipeBackgroundText; anchors.rightMargin: swipeBackgroundText.slidingMargin |
124 | - anchors.leftMargin: 0; horizontalAlignment: Text.AlignRight; text: i18n.tr("Delete") } |
125 | - PropertyChanges { target: swipeDeleteIcon; anchors.rightMargin: swipeDeleteIcon.slidingMargin |
126 | - anchors.leftMargin: 0; horizontalAlignment: Image.AlignRight; source: Qt.resolvedUrl("../images/trash_icon.png")} |
127 | - }, |
128 | - |
129 | - State { |
130 | - name: "SwipingLeft" |
131 | - PropertyChanges { target: swipeBackgroundText; anchors.rightMargin: 0; anchors.leftMargin: swipeBackgroundText.slidingMargin |
132 | - horizontalAlignment: Text.AlignLeft; text: i18n.tr("Delete") } |
133 | - PropertyChanges { target: swipeDeleteIcon; anchors.rightMargin: 0; source: Qt.resolvedUrl("../images/trash_icon.png") |
134 | - anchors.leftMargin: swipeDeleteIcon.slidingMargin; horizontalAlignment: Image.AlignLeft } |
135 | - } |
136 | - ] |
137 | -} |
138 | |
139 | === modified file 'stopwatch/LapList.qml' |
140 | --- stopwatch/LapList.qml 2013-10-26 13:55:35 +0000 |
141 | +++ stopwatch/LapList.qml 2013-11-07 16:34:52 +0000 |
142 | @@ -91,15 +91,10 @@ |
143 | } |
144 | |
145 | removable: true |
146 | - |
147 | - // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs |
148 | - // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089 |
149 | - // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand. |
150 | - backgroundIndicator: SwipeDelete { |
151 | - id: swipeDelete |
152 | - state: swipingState |
153 | - } |
154 | - |
155 | + // FIXME: Confirm removal for stopwatch is not required. However if set to false, then the SDK does not display |
156 | + // the delete text and icon leading to the user not being aware which action is performed on swiping left/right. |
157 | + // Reported bug at https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089 |
158 | + confirmRemoval: true |
159 | onItemRemoved: lapModel.remove(index) |
160 | |
161 | Label { |
162 | |
163 | === modified file 'tests/autopilot/ubuntu_clock_app/emulators.py' |
164 | --- tests/autopilot/ubuntu_clock_app/emulators.py 2013-10-26 13:02:16 +0000 |
165 | +++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-11-07 16:34:52 +0000 |
166 | @@ -13,16 +13,20 @@ |
167 | # |
168 | # You should have received a copy of the GNU Lesser General Public License |
169 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
170 | +# |
171 | +# Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com> |
172 | +# Nicholas Skaggs <nicholas.skaggs@canonical.com> |
173 | |
174 | from ubuntuuitoolkit import emulators as toolkit_emulators |
175 | from autopilot.matchers import Eventually |
176 | from testtools.matchers import Not, Is, Equals |
177 | from time import sleep |
178 | |
179 | - |
180 | class MainView(toolkit_emulators.MainView): |
181 | |
182 | + # Common Emulator Functions |
183 | def _drag_page(self, page, test_case, direction): |
184 | + """Function to drag the page up/down""" |
185 | page_func = lambda: self.select_single(page) |
186 | test_case.assertThat(page_func, Eventually(Not(Is(None)))) |
187 | page = self.select_single(page) |
188 | @@ -49,59 +53,58 @@ |
189 | self._drag_page(page, test_case, "down") |
190 | |
191 | def longpress_object(self, obj): |
192 | + """Function to longpress an object""" |
193 | self.pointing_device.move_to_object(obj) |
194 | self.pointing_device.press() |
195 | sleep(2) |
196 | self.pointing_device.release() |
197 | |
198 | - #stopwatch page |
199 | - def get_stopwatch_label(self): |
200 | - """Returns the select for the stopwatch label""" |
201 | - return self.select_single("Label", objectName="labelStopwatch") |
202 | - |
203 | - def get_stopwatch_button(self): |
204 | - """Returns the select for the stopwatch button""" |
205 | - return self.select_single("AnalogStopwatch", |
206 | - objectName="buttonStopwatch") |
207 | - |
208 | - def get_lap_button(self): |
209 | - """Returns the select for the lap button""" |
210 | - return self.select_single("Button", objectName="lapButton") |
211 | - |
212 | - def get_reset_button(self): |
213 | - """Returns the select for the reset button""" |
214 | - return self.select_single("ImageButton", objectName="resetButton") |
215 | - |
216 | - def get_laps(self): |
217 | - """Returns the select for the lap count""" |
218 | - return self.select_single("ListModel", objectName="laps") |
219 | - |
220 | - #timer page |
221 | - def get_toolbar_timer(self): |
222 | - """Returns the toolbar of timer tab""" |
223 | - return self.select_single("ToolbarItems") |
224 | - |
225 | - def get_toolbar_timer_button(self, button_idx): |
226 | - """Returns a button of toolbar of timer tab""" |
227 | - toolbar = self.select_single("ToolbarItems") |
228 | - button = toolbar.get_children() |
229 | - return button[button_idx] |
230 | - |
231 | - def get_toolbar_timer_add_preset_button(self): |
232 | - """Returns the button for add preset of toolbar of timer tab""" |
233 | - return self.select_single('ActionItem', objectName="addPresetButton") |
234 | - |
235 | - def get_toolbar_timer_save_preset_button(self): |
236 | - """Returns the button for add preset of toolbar of timer tab""" |
237 | - return self.select_single("ActionItem", objectName="savePresetButton") |
238 | - |
239 | + # CLOCK Page Emulator Functions |
240 | + def get_clock_page(self): |
241 | + """Return the page containing the main clock.""" |
242 | + return self.select_single("ClockPage") |
243 | + |
244 | + def get_time_label(self): |
245 | + """Return the label with the timer countdown""" |
246 | + return self.wait_select_single("Label", objectName="currentTimeLabel") |
247 | + |
248 | + # WORLD CLOCK Page Emulator Functions |
249 | + def get_world_cities_page(self): |
250 | + """Return the page containing the world cities.""" |
251 | + return self.wait_select_single("WorldClock") |
252 | + |
253 | + def get_world_cities_list(self): |
254 | + """Return the component containing the list of available world cities.""" |
255 | + return self.wait_select_single(objectName="worldList") |
256 | + |
257 | + def get_city_name(self, city): |
258 | + """Return the name of the city passed as argument""" |
259 | + return city.select_single('Label', objectName='city_name').text |
260 | + |
261 | + def get_saved_cities_list(self): |
262 | + """Return the component containing list of user saved world city locations.""" |
263 | + return self.wait_select_single(objectName="listWorldClocks") |
264 | + |
265 | + def grab_first_listed_city(self): |
266 | + """Return the first city from the available world cities list (both local and online)""" |
267 | + return self.wait_select_single("Base", objectName="worldcity0") |
268 | + |
269 | + def select_city(self, city): |
270 | + """Click the selected city passed as argument""" |
271 | + self.pointing_device.click_object(city) |
272 | + |
273 | + def grab_first_saved_city(self): |
274 | + """Return the first city from the user saved world cities list""" |
275 | + return self.wait_select_single("Standard", objectName="savedworldcity0") |
276 | + |
277 | + # TIMER Page Emulator Functions |
278 | def get_timer_name_preset(self): |
279 | """Returns the TextField where insert the name of the preset""" |
280 | - return self.select_single("LabelDots", objectName="namePreset") |
281 | + return self.wait_select_single("LabelDots", objectName="namePreset") |
282 | |
283 | def get_timer_minute_hand(self): |
284 | """Returns the hour hand of clock in timer tab""" |
285 | - return self.select_single("AnalogTouchHand", objectName="minuteHand") |
286 | + return self.wait_select_single("AnalogTouchHand", objectName="minuteHand") |
287 | |
288 | def get_preset_label_text(self): |
289 | """Returns the label with the preset text""" |
290 | @@ -115,22 +118,40 @@ |
291 | |
292 | def get_label_timer(self): |
293 | """Return the label with the timer countdown""" |
294 | - return self.select_single("Label", objectName="labelTimer") |
295 | + return self.wait_select_single("Label", objectName="labelTimer") |
296 | |
297 | def get_first_preset_list_item(self): |
298 | """Returns the first preset list item in the timer page.""" |
299 | - return self.select_single("Standard", objectName="preset0") |
300 | - |
301 | - def get_time_label(self): |
302 | - """Return the label with the timer countdown""" |
303 | - return self.select_single("Label", objectName="currentTimeLabel") |
304 | + return self.wait_select_single("Standard", objectName="preset0") |
305 | |
306 | def get_num_of_presets(self): |
307 | """Returns the number of presets in the timer page.""" |
308 | timer_page = self.select_single("TimerPage") |
309 | - return int(timer_page.select_single("QQuickListView").count) |
310 | - |
311 | - #alarm page |
312 | + return int(timer_page.wait_select_single("QQuickListView").count) |
313 | + |
314 | + # STOPWATCH Page Emulator Functions |
315 | + def get_stopwatch_label(self): |
316 | + """Returns the select for the stopwatch label""" |
317 | + return self.wait_select_single("Label", objectName="labelStopwatch") |
318 | + |
319 | + def get_stopwatch_button(self): |
320 | + """Returns the select for the stopwatch button""" |
321 | + return self.wait_select_single("AnalogStopwatch", |
322 | + objectName="buttonStopwatch") |
323 | + |
324 | + def get_lap_button(self): |
325 | + """Returns the select for the lap button""" |
326 | + return self.wait_select_single("Button", objectName="lapButton") |
327 | + |
328 | + def get_reset_button(self): |
329 | + """Returns the select for the reset button""" |
330 | + return self.wait_select_single("ImageButton", objectName="resetButton") |
331 | + |
332 | + def get_laps(self): |
333 | + """Returns the select for the lap count""" |
334 | + return self.wait_select_single("ListModel", objectName="laps") |
335 | + |
336 | + # ALARM Page Emulator Functions |
337 | def get_addalarm_page(self): |
338 | """Returns the add alarm page object""" |
339 | return self.select_single("Page", objectName="addAlarmPage") |
340 | @@ -285,25 +306,4 @@ |
341 | test_case.assertThat(lambda: self.select_single( |
342 | "OptionSelector", objectName="RepeatSelector").selectedIndex+1, |
343 | Eventually(Equals(occurence))) |
344 | - |
345 | - #world clock page |
346 | - def get_add_city_button(self): |
347 | - """Return the button for adding a new clock location.""" |
348 | - return self.select_single( |
349 | - "ActionItem", objectName="addCityAction") |
350 | - |
351 | - def get_world_cities_page(self): |
352 | - """Return the page containing the world cities.""" |
353 | - return self.select_single("WorldClock") |
354 | - |
355 | - def get_clock_page(self): |
356 | - """Return the page containing the main clock.""" |
357 | - return self.select_single("ClockPage") |
358 | - |
359 | - def get_world_cities_list(self): |
360 | - """Return the component containing the list of world cities.""" |
361 | - return self.select_single(objectName="worldList") |
362 | - |
363 | - def get_selected_cities_list(self): |
364 | - """Return the component containing list of selected clock locations.""" |
365 | - return self.select_single(objectName="listWorldClocks") |
366 | + |
367 | |
368 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_alarm.py' |
369 | --- tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2013-10-22 15:20:06 +0000 |
370 | +++ tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2013-11-07 16:34:52 +0000 |
371 | @@ -13,6 +13,8 @@ |
372 | # |
373 | # You should have received a copy of the GNU General Public License |
374 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
375 | +# |
376 | +# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com> |
377 | |
378 | """Tests for the Clock App - Alarm""" |
379 | |
380 | |
381 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py' |
382 | --- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-10-25 04:33:48 +0000 |
383 | +++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-11-07 16:34:52 +0000 |
384 | @@ -15,6 +15,7 @@ |
385 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
386 | # |
387 | # Authored by: Renato Araujo Oliveira Filho <renato@canonical.com> |
388 | +# Nekhelesh Ramananthan <krnekhelesh@gmail.com> |
389 | |
390 | """ |
391 | Tests for the Clock App, main window. |
392 | @@ -54,64 +55,40 @@ |
393 | # and compare the values |
394 | self.assertThat(label.text, Eventually(NotEquals(''))) |
395 | |
396 | - def test_add_remove_world_location(self): |
397 | - """It must be possible to add and remove world locations.""" |
398 | + def test_add_local_world_city(self): |
399 | + """Test to check if adding a local listed world city works""" |
400 | |
401 | - self.assert_no_cities_selected() |
402 | + # Open clock toolbar |
403 | self.main_view.open_toolbar() |
404 | - self.switch_to_world_cities_page() |
405 | - city = self.grab_first_city() |
406 | - city_name = self.city_name_from(city) |
407 | - |
408 | - self.select_city(city) |
409 | - |
410 | - selected_city_name = self.city_name_from(self.selected_city()) |
411 | - self.assertThat(selected_city_name, Eventually(Equals(city_name))) |
412 | - |
413 | - delete_button = self.enable_delete_button() |
414 | - self.pointing_device.click_object(delete_button) |
415 | - self.assert_no_cities_selected() |
416 | - |
417 | - def city_name_from(self, city): |
418 | - return city.select_single('Label', objectName='city_name').text |
419 | - |
420 | - def enable_delete_button(self): |
421 | - selected_city = self.selected_city() |
422 | - x, y, w, h = selected_city.globalRect |
423 | - |
424 | - tx = x + (w / 8) |
425 | - ty = y + (h / 2) |
426 | - |
427 | - self.pointing_device.drag(tx, ty, w - w / 8, ty) |
428 | - delete_button = selected_city.select_many("QQuickItem")[2] |
429 | - self.assertThat(lambda: delete_button, Eventually(NotEquals(None))) |
430 | - |
431 | - return delete_button |
432 | - |
433 | - def switch_to_world_cities_page(self): |
434 | - add_city_button = self.main_view.get_add_city_button() |
435 | - self.pointing_device.click_object(add_city_button) |
436 | - self.assertThat(self.main_view.get_world_cities_page, Eventually(NotEquals(None))) |
437 | - |
438 | - def grab_first_city(self): |
439 | - self.assertThat(self.main_view.get_world_cities_list, Eventually(NotEquals(None))) |
440 | - cities_list = self.main_view.get_world_cities_list() |
441 | - self.assertThat(lambda: not cities_list.select_many("Base"), Eventually(Equals(False))) |
442 | - |
443 | - return cities_list.select_many("Base")[0] |
444 | - |
445 | - def select_city(self, city): |
446 | - self.pointing_device.click_object(city) |
447 | - self.assertThat(self.main_view.get_clock_page, Eventually(NotEquals(None))) |
448 | - |
449 | - def selected_city(self): |
450 | - self.assertThat(self.main_view.get_selected_cities_list, Eventually(NotEquals(None))) |
451 | - selected_cities = self.main_view.get_selected_cities_list() |
452 | - self.assertThat(lambda: not selected_cities.select_many("Standard"), Eventually(Equals(False))) |
453 | - |
454 | - return selected_cities.select_many("Standard")[0] |
455 | - |
456 | - def assert_no_cities_selected(self): |
457 | + |
458 | + # Click add city toolbar button |
459 | + self.main_view.get_toolbar().click_button('addCityAction') |
460 | + |
461 | + # Click on first city in the list shown and ensure that it was saved |
462 | + city = self.main_view.grab_first_listed_city() |
463 | + city_name = self.main_view.get_city_name(city) |
464 | + self.main_view.select_city(city) |
465 | + saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city()) |
466 | + self.assertThat(saved_city_name, Eventually(Equals(city_name))) |
467 | + |
468 | + def test_delete_local_world_city(self): |
469 | + """Test to check if deleting a saved local world city works""" |
470 | + |
471 | + # Add a local world city |
472 | + self.test_add_local_world_city() |
473 | + |
474 | + # Close toolbar and drag page up to see the saved world city list |
475 | + self.main_view.close_toolbar() |
476 | self.main_view.drag_page_up("ClockPage", self) |
477 | - cities = self.main_view.get_selected_cities_list() |
478 | - self.assertThat(cities.count, Eventually(Equals(0))) |
479 | + |
480 | + # Get the saved world city and swipe to delete |
481 | + old_saved_city_count = self.main_view.get_saved_cities_list().count |
482 | + saved_city = self.main_view.grab_first_saved_city() |
483 | + saved_city.swipe_to_delete() |
484 | + saved_city.confirm_removal() |
485 | + |
486 | + # Assert deletion of saved city |
487 | + cities = self.main_view.get_saved_cities_list() |
488 | + self.assertThat( |
489 | + cities.count, |
490 | + Eventually(Equals(old_saved_city_count - 1))) |
491 | |
492 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py' |
493 | --- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-14 02:07:36 +0000 |
494 | +++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-11-07 16:34:52 +0000 |
495 | @@ -35,8 +35,7 @@ |
496 | self.assertThat( |
497 | self.main_view.visible, Eventually(Equals(True))) |
498 | |
499 | - #move to stopwatch tab |
500 | - #ignoring the emulator tab functions until fixed |
501 | + # Move to stopwatch tab |
502 | self.main_view.switch_to_tab("StopwatchTab") |
503 | |
504 | def tearDown(self): |
505 | @@ -45,15 +44,11 @@ |
506 | def test_start_stop_reset_stopwatch(self): |
507 | """Test to check the proper functioning of the start/stop/reset of stopwatch""" |
508 | |
509 | - self.assertThat(self.main_view.get_stopwatch_button, Eventually(Not(Is(None)))) |
510 | start_stop_button = self.main_view.get_stopwatch_button() |
511 | - self.assertThat(self.main_view.get_stopwatch_label, Eventually(Not(Is(None)))) |
512 | stopwatch_label = self.main_view.get_stopwatch_label() |
513 | - self.assertThat(self.main_view.get_reset_button, Eventually(Not(Is(None)))) |
514 | reset_button = self.main_view.get_reset_button() |
515 | |
516 | - # Press the start button to start the stopwatch |
517 | - self.assertThat(self.main_view.get_stopwatch_label, Eventually(Not(Is(None)))) |
518 | + # Press the start button to start the stopwatch and check if the stopwatch starts ticking |
519 | stopwatch_label_before = self.main_view.get_stopwatch_label().text |
520 | self.pointing_device.click_object(start_stop_button) |
521 | self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0"))) |
522 | |
523 | === modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py' |
524 | --- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-10-16 18:54:28 +0000 |
525 | +++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-11-07 16:34:52 +0000 |
526 | @@ -15,6 +15,7 @@ |
527 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
528 | # |
529 | # Authored by: Riccardo Padovani <rpadovani@ubuntu-it.org> |
530 | +# Nekhelesh Ramananthan <krnekhelesh@gmail.com> |
531 | |
532 | """Tests for the Clock App - Timer""" |
533 | |
534 | @@ -36,7 +37,7 @@ |
535 | self.assertThat( |
536 | self.main_view.visible, Eventually(Equals(True))) |
537 | |
538 | - #move to timer tab |
539 | + # Move to Timer tab |
540 | self.main_view.switch_to_tab("TimerTab") |
541 | |
542 | def select_name_preset_label(self): |
543 | @@ -55,13 +56,10 @@ |
544 | self.main_view.open_toolbar() |
545 | |
546 | # Click the add preset button |
547 | - self.assertThat(self.main_view.get_toolbar_timer_add_preset_button, Eventually(Not(Is(None)))) |
548 | - add_preset_button = self.main_view.get_toolbar_timer_add_preset_button() |
549 | - self.pointing_device.click_object(add_preset_button) |
550 | + self.main_view.get_toolbar().click_button('addPresetButton') |
551 | |
552 | - # Write in the label |
553 | + # Set Timer label as "test" |
554 | self.main_view.drag_page_up("TimerPage", self) |
555 | - self.assertThat(self.main_view.get_timer_name_preset, Eventually(Not(Is(None)))) |
556 | label = self.select_name_preset_label() |
557 | self.assertThat(label.focus, Eventually(Equals(True))) |
558 | self.keyboard.type("test") |
559 | @@ -69,10 +67,8 @@ |
560 | |
561 | self.main_view.drag_page_down("TimerPage", self) |
562 | |
563 | - # Set minute |
564 | - self.assertThat(self.main_view.get_timer_minute_hand, Eventually(Not(Is(None)))) |
565 | + # Set timer minute |
566 | minute = self.main_view.get_timer_minute_hand() |
567 | - |
568 | timeout = 0 |
569 | while label.focus == True and timeout < 10: |
570 | TimerLabel = self.main_view.get_label_timer() |
571 | @@ -83,49 +79,15 @@ |
572 | x, y, w, h = minute.globalRect |
573 | tx = x + (w / 2) |
574 | ty = y + (h / 2.5) |
575 | - self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2)) |
576 | - |
577 | - self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None)))) |
578 | - num_of_presets_old = self.main_view.get_num_of_presets() |
579 | - |
580 | - # Press "Save" toolbar button |
581 | - self.assertThat(self.main_view.get_toolbar_timer_save_preset_button, Eventually(Not(Is(None)))) |
582 | - |
583 | - #make sure preset is saved, and shows up properly |
584 | - timeout = 0 |
585 | - while self.main_view.get_num_of_presets() != num_of_presets_old + 1 and timeout < 10: |
586 | - save_preset_button = self.main_view.get_toolbar_timer_save_preset_button() |
587 | - self.pointing_device.click_object(save_preset_button) |
588 | - sleep(1) |
589 | - timeout += 1 |
590 | - |
591 | - def test_delete_preset(self): |
592 | - """Test if the swipe of a preset deletes it""" |
593 | - |
594 | - # Create a new preset |
595 | - self.test_add_preset() |
596 | - |
597 | - self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None)))) |
598 | - num_of_presets_old = self.main_view.get_num_of_presets() |
599 | - self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None)))) |
600 | - |
601 | - self.main_view.drag_page_up("TimerPage", self) |
602 | - |
603 | - # Delete the preset |
604 | - timeout = 0 |
605 | - while self.main_view.get_num_of_presets() != num_of_presets_old - 1 and timeout < 10: |
606 | - first_preset = self.main_view.get_first_preset_list_item() |
607 | - x, y, w, h = first_preset.globalRect |
608 | - tx = x + (w / 8) |
609 | - ty = y + (h / 2) |
610 | - self.pointing_device.drag(tx, ty, w - w / 8, ty) |
611 | - sleep(1) |
612 | - timeout += 1 |
613 | - |
614 | - # Check has been deleted |
615 | + self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2)) |
616 | + |
617 | + # Press "Save" toolbar button and ensure that preset is saved and check that |
618 | + # the timer preset has been added. |
619 | + num_of_presets_old = self.main_view.get_num_of_presets() |
620 | + self.main_view.get_toolbar().click_button('savePresetButton') |
621 | self.assertThat( |
622 | self.main_view.get_num_of_presets, |
623 | - Eventually(Equals(num_of_presets_old - 1))) |
624 | + Eventually(Equals(num_of_presets_old + 1))) |
625 | |
626 | def test_run_preset(self): |
627 | """Tests if a preset can runs""" |
628 | @@ -133,26 +95,39 @@ |
629 | # Create a new preset |
630 | self.test_add_preset() |
631 | |
632 | + self.main_view.drag_page_up("TimerPage", self) |
633 | + |
634 | # Click to select the preset |
635 | - self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None)))) |
636 | - first_preset = self.main_view.get_first_preset_list_item() |
637 | - |
638 | - self.main_view.drag_page_up("TimerPage", self) |
639 | + # FIXME: Instead of always running the first preset, run the preset which was created |
640 | + first_preset = self.main_view.get_first_preset_list_item() |
641 | self.pointing_device.click_object(first_preset) |
642 | |
643 | self.main_view.drag_page_down("TimerPage", self) |
644 | |
645 | # Click to start the preset |
646 | - self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None)))) |
647 | - timeout = 0 |
648 | - while self.main_view.get_label_timer() is None and timeout < 10: |
649 | - label = self.main_view.get_label_timer() |
650 | - self.pointing_device.click_object(label) |
651 | - sleep(1) |
652 | - timeout += 1 |
653 | + label = self.main_view.get_label_timer() |
654 | + self.pointing_device.click_object(label) |
655 | |
656 | # Check if timer is started |
657 | - self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None)))) |
658 | - label_timer = self.main_view.get_label_timer() |
659 | - self.pointing_device.click_object(label_timer) |
660 | - self.assertThat(label_timer.text, Eventually(NotEquals("21:00"))) |
661 | + self.assertThat(label.text, Eventually(NotEquals("03:00"))) |
662 | + |
663 | + def test_delete_preset(self): |
664 | + """Test if the swipe of a preset deletes it""" |
665 | + |
666 | + # Create a new preset |
667 | + self.test_add_preset() |
668 | + |
669 | + num_of_presets_old = self.main_view.get_num_of_presets() |
670 | + self.main_view.drag_page_up("TimerPage", self) |
671 | + |
672 | + # Delete the preset |
673 | + # FIXME: Delete the preset that was added instead of always deleting the first preset |
674 | + first_preset = self.main_view.get_first_preset_list_item() |
675 | + first_preset.swipe_to_delete() |
676 | + first_preset.confirm_removal() |
677 | + |
678 | + # Check that the timer preset has been deleted |
679 | + self.assertThat( |
680 | + self.main_view.get_num_of_presets, |
681 | + Eventually(Equals(num_of_presets_old - 1))) |
682 | + |
683 | |
684 | === modified file 'timer/PresetList.qml' |
685 | --- timer/PresetList.qml 2013-10-26 13:48:27 +0000 |
686 | +++ timer/PresetList.qml 2013-11-07 16:34:52 +0000 |
687 | @@ -87,14 +87,7 @@ |
688 | |
689 | selected: listTimerPreset.currentIndex == index |
690 | removable: true |
691 | - |
692 | - // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs |
693 | - // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089 |
694 | - // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand. |
695 | - backgroundIndicator: SwipeDelete { |
696 | - id: swipeDelete |
697 | - state: swipingState |
698 | - } |
699 | + confirmRemoval: true |
700 | |
701 | onItemRemoved: { |
702 | presetModel.removePreset(index); |
Requesting nskaggs review of autopilot tests. Tests fail due to the upstream confirm_removal() function. Logs shown in http:// paste.ubuntu. com/6318817/. Consistent failure in other places as well.