Merge lp:~carla-sella/ubuntu-clock-app/new-add_world_city_test into lp:ubuntu-clock-app

Proposed by Carla Sella
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 68
Merged at revision: 123
Proposed branch: lp:~carla-sella/ubuntu-clock-app/new-add_world_city_test
Merge into: lp:ubuntu-clock-app
Diff against target: 294 lines (+173/-0)
5 files modified
app/clock/ClockPage.qml (+1/-0)
app/worldclock/UserWorldCityDelegate.qml (+2/-0)
app/worldclock/WorldCityList.qml (+7/-0)
tests/autopilot/ubuntu_clock_app/emulators.py (+123/-0)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+40/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-clock-app/new-add_world_city_test
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+231131@code.launchpad.net

Commit message

Autopilot test for ubuntu-clock/reboot app

Description of the change

Need help on StateNotFoundError.

To post a comment you must log in.
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
Carla Sella (carla-sella) wrote :

Test is complete, only need to remove some commented lines in emulators.py commented for a problem with count property of QQuickRepeater - userWorldCityRepeater.

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
Carla Sella (carla-sella) wrote :

I had to put a sleep here:

202 + sleep(5)

as I could not find a way to fix a timing issue.
If I do not put a sleep here the count property of the QQuickListView will be zero and the test will fail as the for instruction just after the sleep will be skipped.

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
Nekhelesh Ramananthan (nik90) wrote :

Carla, I cannot help you yet with this issue since I am doing some last minute work that is required to replace the old clock app. So I will be busy until the end of the week with that. I will try to find a solution in the weekend for this MP.

Meanwhile I am marking this as a work-in-progress.

Revision history for this message
Carla Sella (carla-sella) wrote :

Ok thank you Nekhelesh.

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

Sry :/ But I think you have everything from your side. So this MP is blocked on me essentially. So I will take the blame for it :D

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
Carla Sella (carla-sella) wrote :

Test kept on fialing even if code looked ok to me, so Nekhelesh tested the QML and noticed that when you delete the last world city the count property remains set at one instead of zero. If you add 2 world cities (count=2), and then delete one, the count changes to 1. If you delete the last one, the count remains as 1. I have Reported bug #1368393 for this problem.
I will try to add a hack around the issue until the bug is fixed as this is a minor issue now as it does not affect the user.

Revision history for this message
Carla Sella (carla-sella) wrote :

I Discovered that deleting world city clock deletes the city from the clock app, but if you look with autopilot vis the world city is still there. Iadded a comment to bug #1368393 about this.

66. By Carla Sella

Completed add world city tests.

67. By Carla Sella

Commit for merging.

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

Fixed pep8 and pyflakes.

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) wrote :

oO passing :-)

Revision history for this message
Carla Sella (carla-sella) wrote :

Yeah! :P

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Is this ready to land now?

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

Looks good! As always thnx a lot for the AP test. More test coverage, mean happy QA team :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/clock/ClockPage.qml'
2--- app/clock/ClockPage.qml 2014-09-04 20:08:39 +0000
3+++ app/clock/ClockPage.qml 2014-09-12 19:44:41 +0000
4@@ -151,6 +151,7 @@
5
6 AddWorldCityButton {
7 id: addWorldCityButton
8+ objectName: "addWorldCityButton"
9
10 opacity: settingsIcon.opacity
11 anchors {
12
13=== modified file 'app/worldclock/UserWorldCityDelegate.qml'
14--- app/worldclock/UserWorldCityDelegate.qml 2014-09-04 21:03:56 +0000
15+++ app/worldclock/UserWorldCityDelegate.qml 2014-09-12 19:44:41 +0000
16@@ -53,6 +53,7 @@
17
18 Label {
19 text: model.city
20+ objectName: "userCityNameText"
21 width: parent.width
22 elide: Text.ElideRight
23 color: UbuntuColors.midAubergine
24@@ -60,6 +61,7 @@
25
26 Label {
27 text: model.country
28+ objectName: "userCountryNameText"
29 fontSize: "xx-small"
30 width: parent.width
31 elide: Text.ElideRight
32
33=== modified file 'app/worldclock/WorldCityList.qml'
34--- app/worldclock/WorldCityList.qml 2014-08-24 12:47:50 +0000
35+++ app/worldclock/WorldCityList.qml 2014-09-12 19:44:41 +0000
36@@ -34,6 +34,7 @@
37
38 Page {
39 id: worldCityList
40+ objectName: "worldCityList"
41
42 property bool isOnlineMode: false
43
44@@ -48,6 +49,7 @@
45 head: worldCityList.head
46 actions: [
47 Action {
48+ objectName: "searchButton"
49 iconName: "search"
50 text: i18n.tr("City")
51 onTriggered: {
52@@ -73,6 +75,7 @@
53
54 contents: TextField {
55 id: searchField
56+ objectName: "searchField"
57
58 inputMethodHints: Qt.ImhNoPredictiveText
59 placeholderText: i18n.tr("Search...")
60@@ -202,6 +205,7 @@
61
62 ListView {
63 id: cityList
64+ objectName: "cityList"
65
66 function addWorldCity(city, country, timezone) {
67 console.log("[LOG]: Adding city to U1db Database")
68@@ -255,6 +259,7 @@
69
70 delegate: ListItem.Base {
71 showDivider: false
72+ objectName: "worldCityItem" + index
73
74 Column {
75 id: worldCityDelegateColumn
76@@ -268,6 +273,7 @@
77
78 Label {
79 text: city
80+ objectName: "cityNameText"
81 width: parent.width
82 elide: Text.ElideRight
83 color: UbuntuColors.midAubergine
84@@ -275,6 +281,7 @@
85
86 Label {
87 text: country
88+ objectName: "countryNameText"
89 fontSize: "xx-small"
90 width: parent.width
91 elide: Text.ElideRight
92
93=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
94--- tests/autopilot/ubuntu_clock_app/emulators.py 2014-08-14 23:15:46 +0000
95+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-09-12 19:44:41 +0000
96@@ -20,6 +20,7 @@
97
98 from autopilot import logging as autopilot_logging
99 from autopilot.introspection import dbus
100+from testtools.matchers import GreaterThan
101
102 from ubuntuuitoolkit import pickers
103 import ubuntuuitoolkit
104@@ -59,6 +60,12 @@
105 """ Get the AlarmList object. """
106 return AlarmList.select(self)
107
108+ @autopilot_logging.log_action(logger.info)
109+ def get_worldCityList(self):
110+ """ Return the World City List page """
111+ return self.wait_select_single("WorldCityList",
112+ objectName="worldCityList")
113+
114
115 class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
116
117@@ -100,6 +107,74 @@
118 class ClockPage(PageWithBottomEdge):
119 """Autopilot helper for the Clock page."""
120
121+ @autopilot_logging.log_action(logger.info)
122+ def click_addCity_to_open_worldCityList(self):
123+ """Swipe to reveal WorldCityList"""
124+
125+ addWorldCityButton = self.wait_select_single(
126+ "AbstractButton", objectName="addWorldCityButton")
127+ self.pointing_device.click_object(addWorldCityButton)
128+
129+ def get_num_of_saved_cities(self):
130+ """Return the number of saved world cities"""
131+ return int(self._get_saved_world_city_list().count)
132+
133+ def _get_saved_world_city_list(self):
134+ """Return the saved world city listview object"""
135+ return self.wait_select_single(
136+ "QQuickRepeater", objectName='userWorldCityRepeater')
137+
138+ @autopilot_logging.log_action(logger.info)
139+ def delete_added_world_city(self, city_Name, country_Name):
140+ """ Delete added world city from user world city list """
141+ old_cities_count = self.get_num_of_saved_cities()
142+ index = 0
143+ for index in range(old_cities_count):
144+ if self.wait_select_single(
145+ objectName='userWorldCityItem{}'.format(index)).\
146+ wait_select_single("Label", objectName="userCityNameText").\
147+ text == city_Name:
148+ if self.wait_select_single(
149+ objectName='userWorldCityItem{}'.format(index)).\
150+ wait_select_single(
151+ "Label", objectName="userCountryNameText").\
152+ text == country_Name:
153+ self._delete_userWorldCityItem(index)
154+
155+ # FIXME -----------------------------------------------------------------
156+ # Commenting the following lines as deleting a world city when there is
157+ # only one in the user world city list does not decrease counter to 0 but
158+ # leaves it at 1 so the test fails
159+ # Reported bug #1368393
160+ # Discovered that deleting world city clock deletes the city from the clock
161+ # app, but if you look with autopilot vis the world city is still there
162+ # added a comment to bug #1368393
163+ #
164+ # try:
165+ # self._get_saved_world_city_list().count.wait_for(
166+ # old_cities_count - 1)
167+ # except AssertionError:
168+ # raise ClockEmulatorException('Error deleting city.')
169+ # -------------------------------------------------------------------------
170+
171+ def _delete_userWorldCityItem(self, index):
172+ cityItem = self.wait_select_single(
173+ objectName='userWorldCityItem{}'.format(index))
174+ self._swipe_to_delete(cityItem)
175+ self._confirm_removal(cityItem)
176+
177+ def _swipe_to_delete(self, cityItem):
178+ x, y, width, height = cityItem.globalRect
179+ start_x = x + (width * 0.2)
180+ stop_x = x + (width * 0.8)
181+ start_y = stop_y = y + (height // 2)
182+
183+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
184+
185+ def _confirm_removal(self, cityItem):
186+ deleteButton = cityItem.wait_select_single(name='delete')
187+ self.pointing_device.click_object(deleteButton)
188+
189
190 class Page11(Page):
191 """Autopilot helper for the Alarm page."""
192@@ -170,6 +245,54 @@
193 raise ClockEmulatorException('Error creating alarm.')
194
195
196+class WorldCityList(Page):
197+ """Autopilot helper for World City List page."""
198+
199+ @autopilot_logging.log_action(logger.info)
200+ def add_world_city_from_list(self, city_Name, country_Name):
201+ """Add world city from list
202+
203+ :param city_Name: world city name to add
204+ :param country_Name: country city name belongs to (same city name could
205+ be found in more countries)
206+ """
207+ self.wait_select_single("ActivityIndicator").running.wait_for(False)
208+ cityList = self.wait_select_single("QQuickListView",
209+ objectName="cityList")
210+
211+ cityList.count.wait_for(GreaterThan(0))
212+
213+ for index in range(int(cityList.count)):
214+ if cityList.wait_select_single(
215+ objectName="worldCityItem{}".format(index)).wait_select_single(
216+ "Label", objectName="cityNameText").text == city_Name:
217+ if cityList.wait_select_single(
218+ objectName="worldCityItem{}".format(index)).\
219+ wait_select_single("Label", objectName="countryNameText").\
220+ text == country_Name:
221+ cityList.click_element(
222+ "worldCityItem{}".format(index), direction=None)
223+ break
224+
225+ @autopilot_logging.log_action(logger.info)
226+ def search_world_city_(self, city_Name, country_Name):
227+ """Add world city by searching the world city name
228+
229+ :param city_Name: world city name to add
230+
231+ """
232+ header = self.main_view.get_header()
233+ header.click_action_button("searchButton")
234+ self._search_world_city(city_Name, country_Name)
235+
236+ def _search_world_city(self, city_Name, country_Name):
237+ header = self.main_view.get_header()
238+ searchTextfield = header.wait_select_single(
239+ "TextField", objectName='searchField')
240+ searchTextfield.visible.wait_for(True)
241+ searchTextfield.write(city_Name)
242+
243+
244 class EditAlarmPage(Page):
245 """Autopilot helper for the Add Alarm page."""
246
247
248=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
249--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-08-02 12:57:23 +0000
250+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-09-12 19:44:41 +0000
251@@ -42,3 +42,43 @@
252 self.main_view.visible, Eventually(Equals(True)))
253
254 self.page = self.main_view.open_clock()
255+
256+ def test_add_city_from_list_must_add_world_city(self):
257+ """Test if adding a world city chosing it from the list works"""
258+
259+ city_Name = "Amsterdam"
260+ country_Name = "Netherlands"
261+
262+ old_city_count = self.page.get_num_of_saved_cities()
263+
264+ self.page.click_addCity_to_open_worldCityList()
265+ worldCityList = self.main_view.get_worldCityList()
266+ worldCityList.add_world_city_from_list(city_Name, country_Name)
267+
268+ # Confirm that the city has been added
269+ self.assertThat(
270+ self.page.get_num_of_saved_cities,
271+ Eventually(Equals(old_city_count + 1)))
272+
273+ self.page.delete_added_world_city(city_Name, country_Name)
274+
275+ def test_add_city_by_searching_must_add_world_city(self):
276+ """Test if adding a world city serching in the list works"""
277+
278+ city_Name = "Venice"
279+ country_Name = "Provincia di Venezia, Veneto, Italy"
280+ brief_country_Name = " Veneto, Italy"
281+
282+ old_city_count = self.page.get_num_of_saved_cities()
283+
284+ self.page.click_addCity_to_open_worldCityList()
285+ worldCityList = self.main_view.get_worldCityList()
286+ worldCityList.search_world_city_(city_Name, country_Name)
287+ worldCityList.add_world_city_from_list(city_Name, country_Name)
288+
289+ # Confirm that the city has been added
290+ self.assertThat(
291+ self.page.get_num_of_saved_cities,
292+ Eventually(Equals(old_city_count + 1)))
293+
294+ self.page.delete_added_world_city(city_Name, brief_country_Name)

Subscribers

People subscribed via source and target branches