Merge lp:~vthompson/ubuntu-weather-app/fix-1452501-location-not-found into lp:ubuntu-weather-app

Proposed by Victor Thompson on 2015-08-11
Status: Merged
Approved by: Andrew Hayzen on 2015-08-17
Approved revision: 91
Merged at revision: 95
Proposed branch: lp:~vthompson/ubuntu-weather-app/fix-1452501-location-not-found
Merge into: lp:ubuntu-weather-app
Diff against target: 145 lines (+56/-22)
4 files modified
app/ui/AddLocationPage.qml (+24/-22)
debian/changelog (+1/-0)
tests/autopilot/ubuntu_weather_app/__init__.py (+7/-0)
tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py (+24/-0)
To merge this branch: bzr merge lp:~vthompson/ubuntu-weather-app/fix-1452501-location-not-found
Reviewer Review Type Date Requested Status
Andrew Hayzen 2015-08-11 Approve on 2015-08-17
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-08-14
Review via email: mp+267602@code.launchpad.net

Commit message

* Create autopilot test for no locations found from search

Description of the change

* Create autopilot test for no locations found from search

I also fixed the indentation of some of the code in AddLocationPage.qml

To post a comment you must log in.
91. By Victor Thompson on 2015-08-14

Merge and resolve conflicts

Andrew Hayzen (ahayzen) wrote :

LGTM :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ui/AddLocationPage.qml'
2--- app/ui/AddLocationPage.qml 2015-08-06 00:10:53 +0000
3+++ app/ui/AddLocationPage.qml 2015-08-14 00:11:23 +0000
4@@ -118,29 +118,29 @@
5 }
6
7 // Builds a area label for the location, depending on the uniqueness of name, adminName1 and country
8- function buildAreaLabel(loc, a1Counts) {
9- var label = "";
10- label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
11- if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
12- // even name and adminName1 are multiple, add adminName2
13- label += ", "+loc.adminName2;
14- }
15- label += ((label !== "") ? ", " : "") + loc.countryName
16- return label;
17- }
18+ function buildAreaLabel(loc, a1Counts) {
19+ var label = "";
20+ label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
21+ if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
22+ // even name and adminName1 are multiple, add adminName2
23+ label += ", "+loc.adminName2;
24+ }
25+ label += ((label !== "") ? ", " : "") + loc.countryName
26+ return label;
27+ }
28
29- function appendCities(list) {
30- var a1Counts = {};
31- // count occurrences of name+adminName1 and name+country
32- list.forEach(function(loc) {
33- a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
34- });
35- // add locations to listmodel
36- list.forEach(function(loc) {
37- loc.areaLabel = buildAreaLabel(loc, a1Counts)
38- citiesModel.append(loc);
39- })
40- }
41+ function appendCities(list) {
42+ var a1Counts = {};
43+ // count occurrences of name+adminName1 and name+country
44+ list.forEach(function(loc) {
45+ a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
46+ });
47+ // add locations to listmodel
48+ list.forEach(function(loc) {
49+ loc.areaLabel = buildAreaLabel(loc, a1Counts)
50+ citiesModel.append(loc);
51+ })
52+ }
53
54 function clearModelForLoading() {
55 citiesModel.clear()
56@@ -180,6 +180,7 @@
57
58 ListView {
59 id: locationList
60+ objectName: "locationList"
61
62 clip: true
63 currentIndex: -1
64@@ -287,6 +288,7 @@
65
66 Label {
67 id: noCity
68+ objectName: "noCity"
69 anchors {
70 centerIn: parent
71 }
72
73=== modified file 'debian/changelog'
74--- debian/changelog 2015-08-12 00:11:38 +0000
75+++ debian/changelog 2015-08-14 00:11:23 +0000
76@@ -17,6 +17,7 @@
77 * Create autopilot test which cancels adding a location (LP: #1452498)
78 * Make the tests grab the top of the minimized tooltip to avoid resizing the
79 app
80+ * Create autopilot test for no locations found from search (LP: #1452501)
81
82 [ Andrew Hayzen ]
83 * Add mocked locations for autopilot and add a test using the data
84
85=== modified file 'tests/autopilot/ubuntu_weather_app/__init__.py'
86--- tests/autopilot/ubuntu_weather_app/__init__.py 2015-08-10 03:26:46 +0000
87+++ tests/autopilot/ubuntu_weather_app/__init__.py 2015-08-14 00:11:23 +0000
88@@ -104,11 +104,18 @@
89 def click_search_action(self):
90 self.main_view.get_header().click_action_button("search")
91
92+ def get_results_count(self):
93+ return self.wait_select_single(
94+ "QQuickListView", objectName="locationList").count
95+
96 def get_search_field(self):
97 header = self.main_view.get_header()
98
99 return header.select_single("TextField", objectName="searchField")
100
101+ def is_empty_label_visible(self):
102+ return self.select_single("Label", objectName="noCity").visible
103+
104 def search(self, value):
105 self.click_search_action()
106
107
108=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py'
109--- tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py 2015-08-10 03:26:46 +0000
110+++ tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py 2015-08-14 00:11:23 +0000
111@@ -12,6 +12,7 @@
112 import logging
113 from autopilot.matchers import Eventually
114 from testtools.matchers import Equals
115+from testtools.matchers import NotEquals
116
117
118 from ubuntu_weather_app.tests import UbuntuWeatherAppTestCaseWithData
119@@ -114,3 +115,26 @@
120 # Check that the location count did not change
121 self.assertThat(self.home_page.get_location_count,
122 Eventually(Equals(self.start_count)))
123+
124+ def test_location_not_found(self):
125+ """ tests empty search results for new location """
126+
127+ location_name = "UbuntuCity"
128+
129+ # Check that the empty search results label is not visible
130+ self.assertThat(self.add_location_page.is_empty_label_visible(),
131+ Equals(False))
132+
133+ # Check that the number of results is not zero
134+ self.assertThat(self.add_location_page.get_results_count(),
135+ NotEquals(0))
136+
137+ # Perform search
138+ self.add_location_page.search(location_name)
139+
140+ # Check that the empty search results label is visible
141+ self.assertThat(self.add_location_page.is_empty_label_visible(),
142+ Eventually(Equals(True)))
143+
144+ # Check that the number of results is zero
145+ self.assertThat(self.add_location_page.get_results_count(), Equals(0))

Subscribers

People subscribed via source and target branches

to all changes: