← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Victor Thompson has proposed merging lp:~vthompson/ubuntu-weather-app/fix-1452501-location-not-found into lp:ubuntu-weather-app/reboot.

Commit message:
* Create autopilot test for no locations found from search

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)
Related bugs:
  Bug #1452501 in Ubuntu Weather App: "[reboot] Autopilot Testcase Needed: No location found"
  https://bugs.launchpad.net/ubuntu-weather-app/+bug/1452501

For more details, see:
https://code.launchpad.net/~vthompson/ubuntu-weather-app/fix-1452501-location-not-found/+merge/267602

* Create autopilot test for no locations found from search

I also fixed the indentation of some of the code in AddLocationPage.qml
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~vthompson/ubuntu-weather-app/fix-1452501-location-not-found into lp:ubuntu-weather-app/reboot.
=== modified file 'app/ui/AddLocationPage.qml'
--- app/ui/AddLocationPage.qml	2015-08-06 00:10:53 +0000
+++ app/ui/AddLocationPage.qml	2015-08-11 01:01:05 +0000
@@ -118,29 +118,29 @@
     }
 
     // Builds a area label for the location, depending on the uniqueness of name, adminName1 and country
-     function buildAreaLabel(loc, a1Counts) {
-         var label = "";
-         label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
-         if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
-             // even name and adminName1 are multiple, add adminName2
-             label += ", "+loc.adminName2;
-         }
-         label += ((label !== "") ? ", " : "") + loc.countryName
-         return label;
-     }
+    function buildAreaLabel(loc, a1Counts) {
+        var label = "";
+        label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
+        if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
+            // even name and adminName1 are multiple, add adminName2
+            label += ", "+loc.adminName2;
+        }
+        label += ((label !== "") ? ", " : "") + loc.countryName
+        return label;
+    }
 
-     function appendCities(list) {
-         var a1Counts = {};
-         // count occurrences of name+adminName1 and name+country
-         list.forEach(function(loc) {
-             a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
-         });
-         // add locations to listmodel
-         list.forEach(function(loc) {
-             loc.areaLabel = buildAreaLabel(loc, a1Counts)
-             citiesModel.append(loc);
-         })
-     }
+    function appendCities(list) {
+        var a1Counts = {};
+        // count occurrences of name+adminName1 and name+country
+        list.forEach(function(loc) {
+            a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
+        });
+        // add locations to listmodel
+        list.forEach(function(loc) {
+            loc.areaLabel = buildAreaLabel(loc, a1Counts)
+            citiesModel.append(loc);
+        })
+    }
 
     function clearModelForLoading() {
         citiesModel.clear()
@@ -180,6 +180,7 @@
 
     ListView {
         id: locationList
+        objectName: "locationList"
 
         clip: true
         currentIndex: -1
@@ -287,6 +288,7 @@
 
     Label {
         id: noCity
+        objectName: "noCity"
         anchors {
             centerIn: parent
         }

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-09 16:51:36 +0000
+++ debian/changelog	2015-08-11 01:01:05 +0000
@@ -14,6 +14,7 @@
   * Create autopilot test which removes a single location (LP: #1452499)
   * Remove C++ flag from CMakeLists.txt
   * Show README files in QtCreator
+  * Create autopilot test for no locations found from search (LP: #1452501)
 
   [ Andrew Hayzen ]
   * Add mocked locations for autopilot and add a test using the data

=== modified file 'tests/autopilot/ubuntu_weather_app/__init__.py'
--- tests/autopilot/ubuntu_weather_app/__init__.py	2015-08-09 16:51:36 +0000
+++ tests/autopilot/ubuntu_weather_app/__init__.py	2015-08-11 01:01:05 +0000
@@ -102,11 +102,18 @@
     def click_search_action(self):
         self.main_view.get_header().click_action_button("search")
 
+    def get_results_count(self):
+        return self.wait_select_single(
+            "QQuickListView", objectName="locationList").count
+
     def get_search_field(self):
         header = self.main_view.get_header()
 
         return header.select_single("TextField", objectName="searchField")
 
+    def is_empty_label_visible(self):
+        return self.select_single("Label", objectName="noCity").visible
+
     def search(self, value):
         self.click_search_action()
 

=== 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-07-29 22:14:02 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_add_location_page.py	2015-08-11 01:01:05 +0000
@@ -12,6 +12,7 @@
 import logging
 from autopilot.matchers import Eventually
 from testtools.matchers import Equals
+from testtools.matchers import NotEquals
 
 
 from ubuntu_weather_app.tests import UbuntuWeatherAppTestCaseWithData
@@ -98,3 +99,26 @@
         # Check that the location was added
         self.assertThat(self.home_page.get_location_count,
                         Eventually(Equals(self.start_count + 1)))
+
+    def test_location_not_found(self):
+        """ tests empty search results for new location """
+
+        location_name = "UbuntuCity"
+
+        # Check that the empty search results label is not visible
+        self.assertThat(self.add_location_page.is_empty_label_visible(),
+                        Equals(False))
+
+        # Check that the number of results is not zero
+        self.assertThat(self.add_location_page.get_results_count(),
+                        NotEquals(0))
+
+        # Perform search
+        self.add_location_page.search(location_name)
+
+        # Check that the empty search results label is visible
+        self.assertThat(self.add_location_page.is_empty_label_visible(),
+                        Eventually(Equals(True)))
+
+        # Check that the number of results is zero
+        self.assertThat(self.add_location_page.get_results_count(), Equals(0))


Follow ups