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
=== modified file 'app/ui/AddLocationPage.qml'
--- app/ui/AddLocationPage.qml 2015-08-06 00:10:53 +0000
+++ app/ui/AddLocationPage.qml 2015-08-14 00:11:23 +0000
@@ -118,29 +118,29 @@
118 }118 }
119119
120 // Builds a area label for the location, depending on the uniqueness of name, adminName1 and country120 // Builds a area label for the location, depending on the uniqueness of name, adminName1 and country
121 function buildAreaLabel(loc, a1Counts) {121 function buildAreaLabel(loc, a1Counts) {
122 var label = "";122 var label = "";
123 label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");123 label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
124 if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {124 if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
125 // even name and adminName1 are multiple, add adminName2125 // even name and adminName1 are multiple, add adminName2
126 label += ", "+loc.adminName2;126 label += ", "+loc.adminName2;
127 }127 }
128 label += ((label !== "") ? ", " : "") + loc.countryName128 label += ((label !== "") ? ", " : "") + loc.countryName
129 return label;129 return label;
130 }130 }
131131
132 function appendCities(list) {132 function appendCities(list) {
133 var a1Counts = {};133 var a1Counts = {};
134 // count occurrences of name+adminName1 and name+country134 // count occurrences of name+adminName1 and name+country
135 list.forEach(function(loc) {135 list.forEach(function(loc) {
136 a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;136 a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
137 });137 });
138 // add locations to listmodel138 // add locations to listmodel
139 list.forEach(function(loc) {139 list.forEach(function(loc) {
140 loc.areaLabel = buildAreaLabel(loc, a1Counts)140 loc.areaLabel = buildAreaLabel(loc, a1Counts)
141 citiesModel.append(loc);141 citiesModel.append(loc);
142 })142 })
143 }143 }
144144
145 function clearModelForLoading() {145 function clearModelForLoading() {
146 citiesModel.clear()146 citiesModel.clear()
@@ -180,6 +180,7 @@
180180
181 ListView {181 ListView {
182 id: locationList182 id: locationList
183 objectName: "locationList"
183184
184 clip: true185 clip: true
185 currentIndex: -1186 currentIndex: -1
@@ -287,6 +288,7 @@
287288
288 Label {289 Label {
289 id: noCity290 id: noCity
291 objectName: "noCity"
290 anchors {292 anchors {
291 centerIn: parent293 centerIn: parent
292 }294 }
293295
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-12 00:11:38 +0000
+++ debian/changelog 2015-08-14 00:11:23 +0000
@@ -17,6 +17,7 @@
17 * Create autopilot test which cancels adding a location (LP: #1452498)17 * Create autopilot test which cancels adding a location (LP: #1452498)
18 * Make the tests grab the top of the minimized tooltip to avoid resizing the18 * Make the tests grab the top of the minimized tooltip to avoid resizing the
19 app19 app
20 * Create autopilot test for no locations found from search (LP: #1452501)
2021
21 [ Andrew Hayzen ]22 [ Andrew Hayzen ]
22 * Add mocked locations for autopilot and add a test using the data23 * Add mocked locations for autopilot and add a test using the data
2324
=== modified file 'tests/autopilot/ubuntu_weather_app/__init__.py'
--- tests/autopilot/ubuntu_weather_app/__init__.py 2015-08-10 03:26:46 +0000
+++ tests/autopilot/ubuntu_weather_app/__init__.py 2015-08-14 00:11:23 +0000
@@ -104,11 +104,18 @@
104 def click_search_action(self):104 def click_search_action(self):
105 self.main_view.get_header().click_action_button("search")105 self.main_view.get_header().click_action_button("search")
106106
107 def get_results_count(self):
108 return self.wait_select_single(
109 "QQuickListView", objectName="locationList").count
110
107 def get_search_field(self):111 def get_search_field(self):
108 header = self.main_view.get_header()112 header = self.main_view.get_header()
109113
110 return header.select_single("TextField", objectName="searchField")114 return header.select_single("TextField", objectName="searchField")
111115
116 def is_empty_label_visible(self):
117 return self.select_single("Label", objectName="noCity").visible
118
112 def search(self, value):119 def search(self, value):
113 self.click_search_action()120 self.click_search_action()
114121
115122
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py 2015-08-10 03:26:46 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py 2015-08-14 00:11:23 +0000
@@ -12,6 +12,7 @@
12import logging12import logging
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
14from testtools.matchers import Equals14from testtools.matchers import Equals
15from testtools.matchers import NotEquals
1516
1617
17from ubuntu_weather_app.tests import UbuntuWeatherAppTestCaseWithData18from ubuntu_weather_app.tests import UbuntuWeatherAppTestCaseWithData
@@ -114,3 +115,26 @@
114 # Check that the location count did not change115 # Check that the location count did not change
115 self.assertThat(self.home_page.get_location_count,116 self.assertThat(self.home_page.get_location_count,
116 Eventually(Equals(self.start_count)))117 Eventually(Equals(self.start_count)))
118
119 def test_location_not_found(self):
120 """ tests empty search results for new location """
121
122 location_name = "UbuntuCity"
123
124 # Check that the empty search results label is not visible
125 self.assertThat(self.add_location_page.is_empty_label_visible(),
126 Equals(False))
127
128 # Check that the number of results is not zero
129 self.assertThat(self.add_location_page.get_results_count(),
130 NotEquals(0))
131
132 # Perform search
133 self.add_location_page.search(location_name)
134
135 # Check that the empty search results label is visible
136 self.assertThat(self.add_location_page.is_empty_label_visible(),
137 Eventually(Equals(True)))
138
139 # Check that the number of results is zero
140 self.assertThat(self.add_location_page.get_results_count(), Equals(0))

Subscribers

People subscribed via source and target branches

to all changes: