← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ahayzen/ubuntu-weather-app/fix-1492321-autopilot-tests into lp:ubuntu-weather-app/reboot

 

Andrew Hayzen has proposed merging lp:~ahayzen/ubuntu-weather-app/fix-1492321-autopilot-tests into lp:ubuntu-weather-app/reboot.

Commit message:
* Fix for wind test failing and some selects not waiting for visible=True

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)
Related bugs:
  Bug #1492321 in Ubuntu Weather App: "[reboot] ubuntu_weather_app.tests.test_settings_page.TestSettingsPage.test_switch_wind_speed_units is failing"
  https://bugs.launchpad.net/ubuntu-weather-app/+bug/1492321

For more details, see:
https://code.launchpad.net/~ahayzen/ubuntu-weather-app/fix-1492321-autopilot-tests/+merge/270224

* Fix for wind test failing and some selects not waiting for visible=True
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~ahayzen/ubuntu-weather-app/fix-1492321-autopilot-tests into lp:ubuntu-weather-app/reboot.
=== modified file 'app/components/DayDelegateExtraInfo.qml'
--- app/components/DayDelegateExtraInfo.qml	2015-08-26 20:35:22 +0000
+++ app/components/DayDelegateExtraInfo.qml	2015-09-04 20:52:59 +0000
@@ -25,8 +25,14 @@
     anchors {
         centerIn: parent
     }
+    objectName: "dayDelegateExtraInfo"
     spacing: units.gu(2)
 
+    // Hack for autopilot otherwise Albums appears as MusicPage
+    // due to bug 1341671 it is required that there is a property so that
+    // qml doesn't optimise using the parent type
+    property bool bug1341671workaround: true
+
     // FIXME: extended-infomation_* aren't actually on device
 
     // Overview text
@@ -51,6 +57,7 @@
         id: windForecast
         forecast: i18n.tr("Winds")
         imageSource: "../graphics/extended-information_wind.svg"
+        objectName: "windForecast"
         value: modelData.wind
     }
 

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-27 13:47:07 +0000
+++ debian/changelog	2015-09-04 20:52:59 +0000
@@ -41,6 +41,7 @@
   * Split day delegate extra info into a separate component that is loaded on demand
   * Use ListView per Location Pane so that scrolling vertically only affect the currently focused pane
   * Add autopilot tests which check that data is migrated correctly (LP: #1485262)
+  * Fix for wind test failing and some selects not waiting for visible=True (LP: #1492321)
 
   [ Carla Sella ]
   * Create autopilot test which shows the day delegate (LP: #1452491)

=== modified file 'tests/autopilot/ubuntu_weather_app/__init__.py'
--- tests/autopilot/ubuntu_weather_app/__init__.py	2015-08-26 20:35:22 +0000
+++ tests/autopilot/ubuntu_weather_app/__init__.py	2015-09-04 20:52:59 +0000
@@ -20,7 +20,9 @@
 def click_object(func):
     """Wrapper which clicks the returned object"""
     def func_wrapper(self, *args, **kwargs):
-        return self.pointing_device.click_object(func(self, *args, **kwargs))
+        item = func(self, *args, **kwargs)
+        self.pointing_device.click_object(item)
+        return item
 
     return func_wrapper
 
@@ -48,7 +50,7 @@
             LocationsPage, objectName="locationsPage")
 
     def get_settings_page(self):
-        return self.main_view.wait_select_single(SettingsPage)
+        return self.main_view.wait_select_single(SettingsPage, visible=True)
 
 
 class Page(UbuntuUIToolkitCustomProxyObjectBase):
@@ -129,6 +131,27 @@
         self.searching.wait_for(False)
 
 
+class DayDelegate(UbuntuUIToolkitCustomProxyObjectBase):
+    @click_object
+    def click_self(self):
+        return self
+
+    def get_extra_info(self):
+        """Expand the delegate and get the extra info"""
+        self.click_self()
+
+        return self.wait_select_single(DayDelegateExtraInfo,
+                                       objectName="dayDelegateExtraInfo",
+                                       visible=True)
+
+
+class DayDelegateExtraInfo(UbuntuUIToolkitCustomProxyObjectBase):
+    @property
+    def wind(self):
+        return self.select_single("ForecastDetailsDelegate",
+                                  objectName="windForecast").value
+
+
 class HomePage(PageWithBottomEdge):
     """Autopilot helper for HomePage."""
     def __init__(self, *args, **kwargs):
@@ -148,7 +171,7 @@
         listview = self.wait_select_single(
             "LocationPane", objectName="locationListView" + str(location))
         return listview.wait_select_single(
-            "DayDelegate", objectName="dayDelegate" + str(day))
+            DayDelegate, objectName="dayDelegate" + str(day))
 
     @click_object
     def click_daydelegate(self, day_delegate):
@@ -212,21 +235,26 @@
         return self.select_single("StandardListItem", title=listitem_title)
 
     def get_units_page(self):
-        return self.main_view.wait_select_single(UnitsPage)
+        return self.main_view.wait_select_single(UnitsPage, visible=True)
 
 
 class UnitsPage(Page):
     """Autopilot helper for UnitsPage."""
     @click_object
+    def click_not_selected_listitem(self, unit_name):
+        return self.get_expanded_listitem(unit_name, "False")
+
+    @click_object
+    def click_units_listitem(self, listitem):
+        return self.select_single("ExpandableListItem", objectName=listitem)
+
     def expand_units_listitem(self, listitem):
-        return self.select_single("ExpandableListItem", objectName=listitem)
+        item = self.click_units_listitem(listitem)
+        item.expanded.wait_for(True)
+        return item
 
     def get_expanded_listitem(self, listitem, showIcon):
         listitemSetting = self.select_single(
             "ExpandableListItem", objectName=listitem)
         return listitemSetting.select_single(
             "StandardListItem", showIcon=showIcon)
-
-    @click_object
-    def click_not_selected_listitem(self, unit_name):
-        return self.get_expanded_listitem(unit_name, "False")

=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings_page.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_settings_page.py	2015-08-24 16:56:55 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_settings_page.py	2015-09-04 20:52:59 +0000
@@ -27,7 +27,6 @@
         super(TestSettingsPage, self).setUp()
 
         self.home_page = self.app.get_home_page()
-        self.home_page.click_settings_button()
 
     def test_switch_temperature_units(self):
         """ tests switching temperature units in Units page """
@@ -56,13 +55,17 @@
         previous_unit = self._change_listitem_unit(unit_name)
 
         day_delegate = self.home_page.get_daydelegate(0, 0)
-        wind_unit = day_delegate.wind.split(" ", 1)
+        extra_day_delegate = day_delegate.get_extra_info()
+        wind_unit = extra_day_delegate.wind.split(" ", 1)
 
         self.assertThat(wind_unit[0].endswith(previous_unit), Equals(False))
 
     def _change_listitem_unit(self, unit_name):
         """ Common actions to change listitem unit for temperature and wind
             speed tests """
+
+        self.home_page.click_settings_button()
+
         settings_page = self.app.get_settings_page()
         settings_page.click_settings_page_listitem("Units")
 
@@ -87,5 +90,5 @@
             if low_unit == high_unit:
                 return high_unit
         elif unit_name == "windSetting":
-            wind_unit = day_delegate.wind.split(" ", 1)[0][-3:]
-            return wind_unit
+            extra_day_delegate = day_delegate.get_extra_info()
+            return extra_day_delegate.wind.split(" ", 1)[0][-3:]


Follow ups