Merge lp:~nik90/ubuntu-clock-app/use-default-swipe-delete into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
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
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_local_world_city() testcase.

2 Autopilot tests test_delete_local_world_city() and test_delete_preset() are failing due to bug https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1245651. Wait until this is fixed before merging.

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.

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

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.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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 :-)

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

I am getting failures in the tests ubuntu_clock_app.tests.test_clock.TestClock.test_add_remove_world_location(with mouse) and ubuntu_clock_app.tests.test_timer.TestTimer.test_delete_preset(with mouse) as the lab suggests. This is due to the confirm_delete() upstream function we discussed on IRC. Other tests should pass.

Revision history for this message
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?

review: Needs Fixing
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

MP is frozen until https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1245651 is fixed. Until then porting is autopilot 1.4 is being implemented.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
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

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
262. By Nekhelesh Ramananthan

Fixed add local city test failure

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Leo says the emulator has landed and thus this should work very shortly :-) Perhaps tomorrow :-)

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Yup it landed 20 hours ago. Waiting on the update to land in the jenkins machine :-).

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'alarm/AlarmPage.qml'
--- alarm/AlarmPage.qml 2013-10-26 13:55:35 +0000
+++ alarm/AlarmPage.qml 2013-11-07 16:34:52 +0000
@@ -217,14 +217,7 @@
217217
218 selected: listSavedAlarm.currentIndex == index218 selected: listSavedAlarm.currentIndex == index
219 removable: true219 removable: true
220220 confirmRemoval: true
221 // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs
222 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089
223 // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand.
224 backgroundIndicator: SwipeDelete {
225 id: swipeDelete
226 state: swipingState
227 }
228221
229 onItemRemoved: {222 onItemRemoved: {
230 var alarm = alarmModel.get(index)223 var alarm = alarmModel.get(index)
231224
=== modified file 'clock/ClockPage.qml'
--- clock/ClockPage.qml 2013-11-01 16:10:28 +0000
+++ clock/ClockPage.qml 2013-11-07 16:34:52 +0000
@@ -214,6 +214,7 @@
214 currentIndex: -1214 currentIndex: -1
215215
216 delegate: ListItem.Standard {216 delegate: ListItem.Standard {
217 objectName: "savedworldcity" + index
217 Label {218 Label {
218 text: cityName219 text: cityName
219 objectName: "city_name"220 objectName: "city_name"
@@ -231,18 +232,9 @@
231232
232 selected: listWorldClocks.currentIndex == index233 selected: listWorldClocks.currentIndex == index
233 removable: true234 removable: true
234235 confirmRemoval: true
235 // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs236
236 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089237 onItemRemoved: worldModel.removePreset(index);
237 // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand.
238 backgroundIndicator: SwipeDelete {
239 id: swipeDelete
240 state: swipingState
241 }
242
243 onItemRemoved: {
244 worldModel.removePreset(index);
245 }
246 }238 }
247 }239 }
248 }240 }
249241
=== modified file 'clock/WorldClock.qml'
--- clock/WorldClock.qml 2013-10-25 04:33:48 +0000
+++ clock/WorldClock.qml 2013-11-07 16:34:52 +0000
@@ -126,6 +126,7 @@
126 section.labelPositioning: ViewSection.InlineLabels126 section.labelPositioning: ViewSection.InlineLabels
127127
128 delegate: ListItem.Base {128 delegate: ListItem.Base {
129 objectName: "worldcity" + index
129 visible: !errorMessage.visible130 visible: !errorMessage.visible
130 height: adminName || adminName2 ? units.gu(8) : units.gu(6)131 height: adminName || adminName2 ? units.gu(8) : units.gu(6)
131 Column {132 Column {
132133
=== removed file 'common/SwipeDelete.qml'
--- common/SwipeDelete.qml 2013-07-20 07:54:03 +0000
+++ common/SwipeDelete.qml 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21
22// Qml element to customize list item swipe behavior.
23Rectangle {
24 id: swipeBackgroundItem
25
26 anchors.fill: parent
27 color: Theme.palette.normal.base;
28
29 Image {
30 id: swipeDeleteIcon
31
32 property int slidingMargin: units.gu(12)
33
34 anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: parent.right }
35 verticalAlignment: Image.AlignVCenter
36 fillMode: Image.Pad
37 }
38
39 Label {
40 id: swipeBackgroundText
41
42 property int slidingMargin: units.gu(3)
43
44 anchors.fill: parent
45 verticalAlignment: Text.AlignVCenter
46 color: Theme.palette.normal.baseText
47 fontSize: "large"
48 }
49
50 states: [
51 State {
52 name: "SwipingRight"
53 PropertyChanges { target: swipeBackgroundText; anchors.rightMargin: swipeBackgroundText.slidingMargin
54 anchors.leftMargin: 0; horizontalAlignment: Text.AlignRight; text: i18n.tr("Delete") }
55 PropertyChanges { target: swipeDeleteIcon; anchors.rightMargin: swipeDeleteIcon.slidingMargin
56 anchors.leftMargin: 0; horizontalAlignment: Image.AlignRight; source: Qt.resolvedUrl("../images/trash_icon.png")}
57 },
58
59 State {
60 name: "SwipingLeft"
61 PropertyChanges { target: swipeBackgroundText; anchors.rightMargin: 0; anchors.leftMargin: swipeBackgroundText.slidingMargin
62 horizontalAlignment: Text.AlignLeft; text: i18n.tr("Delete") }
63 PropertyChanges { target: swipeDeleteIcon; anchors.rightMargin: 0; source: Qt.resolvedUrl("../images/trash_icon.png")
64 anchors.leftMargin: swipeDeleteIcon.slidingMargin; horizontalAlignment: Image.AlignLeft }
65 }
66 ]
67}
680
=== modified file 'stopwatch/LapList.qml'
--- stopwatch/LapList.qml 2013-10-26 13:55:35 +0000
+++ stopwatch/LapList.qml 2013-11-07 16:34:52 +0000
@@ -91,15 +91,10 @@
91 }91 }
92 92
93 removable: true93 removable: true
94 94 // FIXME: Confirm removal for stopwatch is not required. However if set to false, then the SDK does not display
95 // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs95 // the delete text and icon leading to the user not being aware which action is performed on swiping left/right.
96 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/124208996 // Reported bug at https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089
97 // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand.97 confirmRemoval: true
98 backgroundIndicator: SwipeDelete {
99 id: swipeDelete
100 state: swipingState
101 }
102
103 onItemRemoved: lapModel.remove(index)98 onItemRemoved: lapModel.remove(index)
104 99
105 Label {100 Label {
106101
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-10-26 13:02:16 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2013-11-07 16:34:52 +0000
@@ -13,16 +13,20 @@
13#13#
14# You should have received a copy of the GNU Lesser General Public License14# 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/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
18# Nicholas Skaggs <nicholas.skaggs@canonical.com>
1619
17from ubuntuuitoolkit import emulators as toolkit_emulators20from ubuntuuitoolkit import emulators as toolkit_emulators
18from autopilot.matchers import Eventually21from autopilot.matchers import Eventually
19from testtools.matchers import Not, Is, Equals22from testtools.matchers import Not, Is, Equals
20from time import sleep23from time import sleep
2124
22
23class MainView(toolkit_emulators.MainView):25class MainView(toolkit_emulators.MainView):
2426
27 # Common Emulator Functions
25 def _drag_page(self, page, test_case, direction):28 def _drag_page(self, page, test_case, direction):
29 """Function to drag the page up/down"""
26 page_func = lambda: self.select_single(page)30 page_func = lambda: self.select_single(page)
27 test_case.assertThat(page_func, Eventually(Not(Is(None))))31 test_case.assertThat(page_func, Eventually(Not(Is(None))))
28 page = self.select_single(page)32 page = self.select_single(page)
@@ -49,59 +53,58 @@
49 self._drag_page(page, test_case, "down")53 self._drag_page(page, test_case, "down")
5054
51 def longpress_object(self, obj):55 def longpress_object(self, obj):
56 """Function to longpress an object"""
52 self.pointing_device.move_to_object(obj)57 self.pointing_device.move_to_object(obj)
53 self.pointing_device.press()58 self.pointing_device.press()
54 sleep(2)59 sleep(2)
55 self.pointing_device.release()60 self.pointing_device.release()
5661
57 #stopwatch page62 # CLOCK Page Emulator Functions
58 def get_stopwatch_label(self):63 def get_clock_page(self):
59 """Returns the select for the stopwatch label"""64 """Return the page containing the main clock."""
60 return self.select_single("Label", objectName="labelStopwatch")65 return self.select_single("ClockPage")
6166
62 def get_stopwatch_button(self):67 def get_time_label(self):
63 """Returns the select for the stopwatch button"""68 """Return the label with the timer countdown"""
64 return self.select_single("AnalogStopwatch",69 return self.wait_select_single("Label", objectName="currentTimeLabel")
65 objectName="buttonStopwatch")70
6671 # WORLD CLOCK Page Emulator Functions
67 def get_lap_button(self):72 def get_world_cities_page(self):
68 """Returns the select for the lap button"""73 """Return the page containing the world cities."""
69 return self.select_single("Button", objectName="lapButton")74 return self.wait_select_single("WorldClock")
7075
71 def get_reset_button(self):76 def get_world_cities_list(self):
72 """Returns the select for the reset button"""77 """Return the component containing the list of available world cities."""
73 return self.select_single("ImageButton", objectName="resetButton")78 return self.wait_select_single(objectName="worldList")
7479
75 def get_laps(self):80 def get_city_name(self, city):
76 """Returns the select for the lap count"""81 """Return the name of the city passed as argument"""
77 return self.select_single("ListModel", objectName="laps")82 return city.select_single('Label', objectName='city_name').text
7883
79 #timer page84 def get_saved_cities_list(self):
80 def get_toolbar_timer(self):85 """Return the component containing list of user saved world city locations."""
81 """Returns the toolbar of timer tab"""86 return self.wait_select_single(objectName="listWorldClocks")
82 return self.select_single("ToolbarItems")87
8388 def grab_first_listed_city(self):
84 def get_toolbar_timer_button(self, button_idx):89 """Return the first city from the available world cities list (both local and online)"""
85 """Returns a button of toolbar of timer tab"""90 return self.wait_select_single("Base", objectName="worldcity0")
86 toolbar = self.select_single("ToolbarItems")91
87 button = toolbar.get_children()92 def select_city(self, city):
88 return button[button_idx]93 """Click the selected city passed as argument"""
8994 self.pointing_device.click_object(city)
90 def get_toolbar_timer_add_preset_button(self):95
91 """Returns the button for add preset of toolbar of timer tab"""96 def grab_first_saved_city(self):
92 return self.select_single('ActionItem', objectName="addPresetButton")97 """Return the first city from the user saved world cities list"""
9398 return self.wait_select_single("Standard", objectName="savedworldcity0")
94 def get_toolbar_timer_save_preset_button(self):99
95 """Returns the button for add preset of toolbar of timer tab"""100 # TIMER Page Emulator Functions
96 return self.select_single("ActionItem", objectName="savePresetButton")
97
98 def get_timer_name_preset(self):101 def get_timer_name_preset(self):
99 """Returns the TextField where insert the name of the preset"""102 """Returns the TextField where insert the name of the preset"""
100 return self.select_single("LabelDots", objectName="namePreset")103 return self.wait_select_single("LabelDots", objectName="namePreset")
101104
102 def get_timer_minute_hand(self):105 def get_timer_minute_hand(self):
103 """Returns the hour hand of clock in timer tab"""106 """Returns the hour hand of clock in timer tab"""
104 return self.select_single("AnalogTouchHand", objectName="minuteHand")107 return self.wait_select_single("AnalogTouchHand", objectName="minuteHand")
105108
106 def get_preset_label_text(self):109 def get_preset_label_text(self):
107 """Returns the label with the preset text"""110 """Returns the label with the preset text"""
@@ -115,22 +118,40 @@
115118
116 def get_label_timer(self):119 def get_label_timer(self):
117 """Return the label with the timer countdown"""120 """Return the label with the timer countdown"""
118 return self.select_single("Label", objectName="labelTimer")121 return self.wait_select_single("Label", objectName="labelTimer")
119122
120 def get_first_preset_list_item(self):123 def get_first_preset_list_item(self):
121 """Returns the first preset list item in the timer page."""124 """Returns the first preset list item in the timer page."""
122 return self.select_single("Standard", objectName="preset0")125 return self.wait_select_single("Standard", objectName="preset0")
123
124 def get_time_label(self):
125 """Return the label with the timer countdown"""
126 return self.select_single("Label", objectName="currentTimeLabel")
127126
128 def get_num_of_presets(self):127 def get_num_of_presets(self):
129 """Returns the number of presets in the timer page."""128 """Returns the number of presets in the timer page."""
130 timer_page = self.select_single("TimerPage")129 timer_page = self.select_single("TimerPage")
131 return int(timer_page.select_single("QQuickListView").count)130 return int(timer_page.wait_select_single("QQuickListView").count)
132131
133 #alarm page132 # STOPWATCH Page Emulator Functions
133 def get_stopwatch_label(self):
134 """Returns the select for the stopwatch label"""
135 return self.wait_select_single("Label", objectName="labelStopwatch")
136
137 def get_stopwatch_button(self):
138 """Returns the select for the stopwatch button"""
139 return self.wait_select_single("AnalogStopwatch",
140 objectName="buttonStopwatch")
141
142 def get_lap_button(self):
143 """Returns the select for the lap button"""
144 return self.wait_select_single("Button", objectName="lapButton")
145
146 def get_reset_button(self):
147 """Returns the select for the reset button"""
148 return self.wait_select_single("ImageButton", objectName="resetButton")
149
150 def get_laps(self):
151 """Returns the select for the lap count"""
152 return self.wait_select_single("ListModel", objectName="laps")
153
154 # ALARM Page Emulator Functions
134 def get_addalarm_page(self):155 def get_addalarm_page(self):
135 """Returns the add alarm page object"""156 """Returns the add alarm page object"""
136 return self.select_single("Page", objectName="addAlarmPage")157 return self.select_single("Page", objectName="addAlarmPage")
@@ -285,25 +306,4 @@
285 test_case.assertThat(lambda: self.select_single(306 test_case.assertThat(lambda: self.select_single(
286 "OptionSelector", objectName="RepeatSelector").selectedIndex+1,307 "OptionSelector", objectName="RepeatSelector").selectedIndex+1,
287 Eventually(Equals(occurence)))308 Eventually(Equals(occurence)))
288309
289 #world clock page
290 def get_add_city_button(self):
291 """Return the button for adding a new clock location."""
292 return self.select_single(
293 "ActionItem", objectName="addCityAction")
294
295 def get_world_cities_page(self):
296 """Return the page containing the world cities."""
297 return self.select_single("WorldClock")
298
299 def get_clock_page(self):
300 """Return the page containing the main clock."""
301 return self.select_single("ClockPage")
302
303 def get_world_cities_list(self):
304 """Return the component containing the list of world cities."""
305 return self.select_single(objectName="worldList")
306
307 def get_selected_cities_list(self):
308 """Return the component containing list of selected clock locations."""
309 return self.select_single(objectName="listWorldClocks")
310310
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_alarm.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2013-10-22 15:20:06 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2013-11-07 16:34:52 +0000
@@ -13,6 +13,8 @@
13#13#
14# You should have received a copy of the GNU General Public License14# 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/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
1618
17"""Tests for the Clock App - Alarm"""19"""Tests for the Clock App - Alarm"""
1820
1921
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-10-25 04:33:48 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-11-07 16:34:52 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#16#
17# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>17# Authored by: Renato Araujo Oliveira Filho <renato@canonical.com>
18# Nekhelesh Ramananthan <krnekhelesh@gmail.com>
1819
19"""20"""
20Tests for the Clock App, main window.21Tests for the Clock App, main window.
@@ -54,64 +55,40 @@
54 # and compare the values55 # and compare the values
55 self.assertThat(label.text, Eventually(NotEquals('')))56 self.assertThat(label.text, Eventually(NotEquals('')))
5657
57 def test_add_remove_world_location(self):58 def test_add_local_world_city(self):
58 """It must be possible to add and remove world locations."""59 """Test to check if adding a local listed world city works"""
5960
60 self.assert_no_cities_selected()61 # Open clock toolbar
61 self.main_view.open_toolbar()62 self.main_view.open_toolbar()
62 self.switch_to_world_cities_page()63
63 city = self.grab_first_city()64 # Click add city toolbar button
64 city_name = self.city_name_from(city)65 self.main_view.get_toolbar().click_button('addCityAction')
6566
66 self.select_city(city)67 # Click on first city in the list shown and ensure that it was saved
6768 city = self.main_view.grab_first_listed_city()
68 selected_city_name = self.city_name_from(self.selected_city())69 city_name = self.main_view.get_city_name(city)
69 self.assertThat(selected_city_name, Eventually(Equals(city_name)))70 self.main_view.select_city(city)
7071 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())
71 delete_button = self.enable_delete_button()72 self.assertThat(saved_city_name, Eventually(Equals(city_name)))
72 self.pointing_device.click_object(delete_button)73
73 self.assert_no_cities_selected()74 def test_delete_local_world_city(self):
7475 """Test to check if deleting a saved local world city works"""
75 def city_name_from(self, city):76
76 return city.select_single('Label', objectName='city_name').text77 # Add a local world city
7778 self.test_add_local_world_city()
78 def enable_delete_button(self):79
79 selected_city = self.selected_city()80 # Close toolbar and drag page up to see the saved world city list
80 x, y, w, h = selected_city.globalRect81 self.main_view.close_toolbar()
81
82 tx = x + (w / 8)
83 ty = y + (h / 2)
84
85 self.pointing_device.drag(tx, ty, w - w / 8, ty)
86 delete_button = selected_city.select_many("QQuickItem")[2]
87 self.assertThat(lambda: delete_button, Eventually(NotEquals(None)))
88
89 return delete_button
90
91 def switch_to_world_cities_page(self):
92 add_city_button = self.main_view.get_add_city_button()
93 self.pointing_device.click_object(add_city_button)
94 self.assertThat(self.main_view.get_world_cities_page, Eventually(NotEquals(None)))
95
96 def grab_first_city(self):
97 self.assertThat(self.main_view.get_world_cities_list, Eventually(NotEquals(None)))
98 cities_list = self.main_view.get_world_cities_list()
99 self.assertThat(lambda: not cities_list.select_many("Base"), Eventually(Equals(False)))
100
101 return cities_list.select_many("Base")[0]
102
103 def select_city(self, city):
104 self.pointing_device.click_object(city)
105 self.assertThat(self.main_view.get_clock_page, Eventually(NotEquals(None)))
106
107 def selected_city(self):
108 self.assertThat(self.main_view.get_selected_cities_list, Eventually(NotEquals(None)))
109 selected_cities = self.main_view.get_selected_cities_list()
110 self.assertThat(lambda: not selected_cities.select_many("Standard"), Eventually(Equals(False)))
111
112 return selected_cities.select_many("Standard")[0]
113
114 def assert_no_cities_selected(self):
115 self.main_view.drag_page_up("ClockPage", self)82 self.main_view.drag_page_up("ClockPage", self)
116 cities = self.main_view.get_selected_cities_list()83
117 self.assertThat(cities.count, Eventually(Equals(0)))84 # Get the saved world city and swipe to delete
85 old_saved_city_count = self.main_view.get_saved_cities_list().count
86 saved_city = self.main_view.grab_first_saved_city()
87 saved_city.swipe_to_delete()
88 saved_city.confirm_removal()
89
90 # Assert deletion of saved city
91 cities = self.main_view.get_saved_cities_list()
92 self.assertThat(
93 cities.count,
94 Eventually(Equals(old_saved_city_count - 1)))
11895
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-08-14 02:07:36 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-11-07 16:34:52 +0000
@@ -35,8 +35,7 @@
35 self.assertThat(35 self.assertThat(
36 self.main_view.visible, Eventually(Equals(True)))36 self.main_view.visible, Eventually(Equals(True)))
3737
38 #move to stopwatch tab38 # Move to stopwatch tab
39 #ignoring the emulator tab functions until fixed
40 self.main_view.switch_to_tab("StopwatchTab")39 self.main_view.switch_to_tab("StopwatchTab")
4140
42 def tearDown(self):41 def tearDown(self):
@@ -45,15 +44,11 @@
45 def test_start_stop_reset_stopwatch(self):44 def test_start_stop_reset_stopwatch(self):
46 """Test to check the proper functioning of the start/stop/reset of stopwatch"""45 """Test to check the proper functioning of the start/stop/reset of stopwatch"""
4746
48 self.assertThat(self.main_view.get_stopwatch_button, Eventually(Not(Is(None))))
49 start_stop_button = self.main_view.get_stopwatch_button()47 start_stop_button = self.main_view.get_stopwatch_button()
50 self.assertThat(self.main_view.get_stopwatch_label, Eventually(Not(Is(None))))
51 stopwatch_label = self.main_view.get_stopwatch_label()48 stopwatch_label = self.main_view.get_stopwatch_label()
52 self.assertThat(self.main_view.get_reset_button, Eventually(Not(Is(None))))
53 reset_button = self.main_view.get_reset_button()49 reset_button = self.main_view.get_reset_button()
5450
55 # Press the start button to start the stopwatch51 # Press the start button to start the stopwatch and check if the stopwatch starts ticking
56 self.assertThat(self.main_view.get_stopwatch_label, Eventually(Not(Is(None))))
57 stopwatch_label_before = self.main_view.get_stopwatch_label().text52 stopwatch_label_before = self.main_view.get_stopwatch_label().text
58 self.pointing_device.click_object(start_stop_button)53 self.pointing_device.click_object(start_stop_button)
59 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))54 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))
6055
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-10-16 18:54:28 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-11-07 16:34:52 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#16#
17# Authored by: Riccardo Padovani <rpadovani@ubuntu-it.org>17# Authored by: Riccardo Padovani <rpadovani@ubuntu-it.org>
18# Nekhelesh Ramananthan <krnekhelesh@gmail.com>
1819
19"""Tests for the Clock App - Timer"""20"""Tests for the Clock App - Timer"""
2021
@@ -36,7 +37,7 @@
36 self.assertThat(37 self.assertThat(
37 self.main_view.visible, Eventually(Equals(True)))38 self.main_view.visible, Eventually(Equals(True)))
3839
39 #move to timer tab40 # Move to Timer tab
40 self.main_view.switch_to_tab("TimerTab")41 self.main_view.switch_to_tab("TimerTab")
4142
42 def select_name_preset_label(self):43 def select_name_preset_label(self):
@@ -55,13 +56,10 @@
55 self.main_view.open_toolbar()56 self.main_view.open_toolbar()
5657
57 # Click the add preset button58 # Click the add preset button
58 self.assertThat(self.main_view.get_toolbar_timer_add_preset_button, Eventually(Not(Is(None))))59 self.main_view.get_toolbar().click_button('addPresetButton')
59 add_preset_button = self.main_view.get_toolbar_timer_add_preset_button()
60 self.pointing_device.click_object(add_preset_button)
6160
62 # Write in the label61 # Set Timer label as "test"
63 self.main_view.drag_page_up("TimerPage", self)62 self.main_view.drag_page_up("TimerPage", self)
64 self.assertThat(self.main_view.get_timer_name_preset, Eventually(Not(Is(None))))
65 label = self.select_name_preset_label()63 label = self.select_name_preset_label()
66 self.assertThat(label.focus, Eventually(Equals(True)))64 self.assertThat(label.focus, Eventually(Equals(True)))
67 self.keyboard.type("test")65 self.keyboard.type("test")
@@ -69,10 +67,8 @@
6967
70 self.main_view.drag_page_down("TimerPage", self)68 self.main_view.drag_page_down("TimerPage", self)
7169
72 # Set minute70 # Set timer minute
73 self.assertThat(self.main_view.get_timer_minute_hand, Eventually(Not(Is(None))))
74 minute = self.main_view.get_timer_minute_hand()71 minute = self.main_view.get_timer_minute_hand()
75
76 timeout = 072 timeout = 0
77 while label.focus == True and timeout < 10:73 while label.focus == True and timeout < 10:
78 TimerLabel = self.main_view.get_label_timer()74 TimerLabel = self.main_view.get_label_timer()
@@ -83,49 +79,15 @@
83 x, y, w, h = minute.globalRect79 x, y, w, h = minute.globalRect
84 tx = x + (w / 2)80 tx = x + (w / 2)
85 ty = y + (h / 2.5)81 ty = y + (h / 2.5)
86 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))82 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
8783
88 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))84 # Press "Save" toolbar button and ensure that preset is saved and check that
89 num_of_presets_old = self.main_view.get_num_of_presets()85 # the timer preset has been added.
9086 num_of_presets_old = self.main_view.get_num_of_presets()
91 # Press "Save" toolbar button87 self.main_view.get_toolbar().click_button('savePresetButton')
92 self.assertThat(self.main_view.get_toolbar_timer_save_preset_button, Eventually(Not(Is(None))))
93
94 #make sure preset is saved, and shows up properly
95 timeout = 0
96 while self.main_view.get_num_of_presets() != num_of_presets_old + 1 and timeout < 10:
97 save_preset_button = self.main_view.get_toolbar_timer_save_preset_button()
98 self.pointing_device.click_object(save_preset_button)
99 sleep(1)
100 timeout += 1
101
102 def test_delete_preset(self):
103 """Test if the swipe of a preset deletes it"""
104
105 # Create a new preset
106 self.test_add_preset()
107
108 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))
109 num_of_presets_old = self.main_view.get_num_of_presets()
110 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))
111
112 self.main_view.drag_page_up("TimerPage", self)
113
114 # Delete the preset
115 timeout = 0
116 while self.main_view.get_num_of_presets() != num_of_presets_old - 1 and timeout < 10:
117 first_preset = self.main_view.get_first_preset_list_item()
118 x, y, w, h = first_preset.globalRect
119 tx = x + (w / 8)
120 ty = y + (h / 2)
121 self.pointing_device.drag(tx, ty, w - w / 8, ty)
122 sleep(1)
123 timeout += 1
124
125 # Check has been deleted
126 self.assertThat(88 self.assertThat(
127 self.main_view.get_num_of_presets,89 self.main_view.get_num_of_presets,
128 Eventually(Equals(num_of_presets_old - 1)))90 Eventually(Equals(num_of_presets_old + 1)))
12991
130 def test_run_preset(self):92 def test_run_preset(self):
131 """Tests if a preset can runs"""93 """Tests if a preset can runs"""
@@ -133,26 +95,39 @@
133 # Create a new preset95 # Create a new preset
134 self.test_add_preset()96 self.test_add_preset()
13597
98 self.main_view.drag_page_up("TimerPage", self)
99
136 # Click to select the preset100 # Click to select the preset
137 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))101 # FIXME: Instead of always running the first preset, run the preset which was created
138 first_preset = self.main_view.get_first_preset_list_item()102 first_preset = self.main_view.get_first_preset_list_item()
139
140 self.main_view.drag_page_up("TimerPage", self)
141 self.pointing_device.click_object(first_preset)103 self.pointing_device.click_object(first_preset)
142104
143 self.main_view.drag_page_down("TimerPage", self)105 self.main_view.drag_page_down("TimerPage", self)
144106
145 # Click to start the preset107 # Click to start the preset
146 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))108 label = self.main_view.get_label_timer()
147 timeout = 0109 self.pointing_device.click_object(label)
148 while self.main_view.get_label_timer() is None and timeout < 10:
149 label = self.main_view.get_label_timer()
150 self.pointing_device.click_object(label)
151 sleep(1)
152 timeout += 1
153110
154 # Check if timer is started111 # Check if timer is started
155 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))112 self.assertThat(label.text, Eventually(NotEquals("03:00")))
156 label_timer = self.main_view.get_label_timer()113
157 self.pointing_device.click_object(label_timer)114 def test_delete_preset(self):
158 self.assertThat(label_timer.text, Eventually(NotEquals("21:00")))115 """Test if the swipe of a preset deletes it"""
116
117 # Create a new preset
118 self.test_add_preset()
119
120 num_of_presets_old = self.main_view.get_num_of_presets()
121 self.main_view.drag_page_up("TimerPage", self)
122
123 # Delete the preset
124 # FIXME: Delete the preset that was added instead of always deleting the first preset
125 first_preset = self.main_view.get_first_preset_list_item()
126 first_preset.swipe_to_delete()
127 first_preset.confirm_removal()
128
129 # Check that the timer preset has been deleted
130 self.assertThat(
131 self.main_view.get_num_of_presets,
132 Eventually(Equals(num_of_presets_old - 1)))
133
159134
=== modified file 'timer/PresetList.qml'
--- timer/PresetList.qml 2013-10-26 13:48:27 +0000
+++ timer/PresetList.qml 2013-11-07 16:34:52 +0000
@@ -87,14 +87,7 @@
87 87
88 selected: listTimerPreset.currentIndex == index88 selected: listTimerPreset.currentIndex == index
89 removable: true89 removable: true
90 90 confirmRemoval: true
91 // TODO: Replace SwipeDelete custom component with SDK default component. Ensure that bugs
92 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1241506, https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242089
93 // and https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1236464 are fixed beforehand.
94 backgroundIndicator: SwipeDelete {
95 id: swipeDelete
96 state: swipingState
97 }
98 91
99 onItemRemoved: {92 onItemRemoved: {
100 presetModel.removePreset(index);93 presetModel.removePreset(index);

Subscribers

People subscribed via source and target branches