Merge lp:~nskaggs/ubuntu-weather-app/fix-ap-smoke-tests into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Martin Borho
Approved revision: 87
Merged at revision: 88
Proposed branch: lp:~nskaggs/ubuntu-weather-app/fix-ap-smoke-tests
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 123 lines (+25/-24)
2 files modified
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+22/-23)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+3/-1)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-weather-app/fix-ap-smoke-tests
Reviewer Review Type Date Requested Status
Martin Borho Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+179540@code.launchpad.net

Commit message

Fixes for autopilot smoke tests

Description of the change

Fixes for autopilot smoke tests

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: Approve (continuous-integration)
Revision history for this message
Martin Borho (martin-borho) wrote :

Looks good!

review: Approve
Revision history for this message
Martin Borho (martin-borho) wrote :

Nicholas,

I've added to a pending MP of mine additional assertions to detect when the network connection is missing at all and Dialog is shown to inform the user about that.

When merged, we can see in the smoke tests if the data provider is too slow or if the network connection is missing.

Cheers
Martin

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-07 17:38:05 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-09 21:02:49 +0000
@@ -25,12 +25,28 @@
25 self.assertThat(25 self.assertThat(
26 self.get_qml_view().visible, Eventually(Equals(True)))26 self.get_qml_view().visible, Eventually(Equals(True)))
2727
28 def search_for_city(self, city):
29 searchField = self.main_window.get_object("TextField", "SearchField")
30 self.assertThat(lambda: searchField.visible, Eventually(Equals(True)))
31 #poll clicking for focus for lack of better method, due to screen switching animation
32 #is there a property we can use instead?
33 timeout = 0
34 while searchField.focus != True and timeout < 10:
35 self.pointing_device.click_object(searchField)
36 sleep(1)
37 timeout += 1
38 self.keyboard.type(city)
39 self.assertThat(searchField.text, Eventually(Equals(city)))
40 self.keyboard.press_and_release('Enter')
41 return searchField
42
28 def _open_add_location_page(self):43 def _open_add_location_page(self):
29 """Opens the AddLocationPage"""44 """Opens the AddLocationPage"""
30 # click on listitem to open AddLocationPage45 # click on listitem to open AddLocationPage
31 locationList = self.main_window.get_object('QQuickListView', 'LocationList')46 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
47 self.assertThat(lambda: locationList.visible, Eventually(Equals(True)))
32 addCityItem = locationList.get_children()[0]48 addCityItem = locationList.get_children()[0]
33 self.assertThat(lambda: addCityItem, Eventually(NotEquals(None)))49 self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
34 self.pointing_device.move_to_object(addCityItem)50 self.pointing_device.move_to_object(addCityItem)
35 self.pointing_device.click()51 self.pointing_device.click()
3652
@@ -54,13 +70,7 @@
54 self._open_add_location_page()70 self._open_add_location_page()
5571
56 # insert city name to search for72 # insert city name to search for
57 searchField = self.main_window.get_object("TextField", "SearchField")73 self.search_for_city("London")
58 self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
59 self.pointing_device.click_object(searchField)
60 self.assertThat(searchField.focus, Eventually(Equals(True)))
61 self.keyboard.type("London")
62 self.assertThat(searchField.text, Eventually(Equals("London")))
63 self.keyboard.press_and_release('Enter')
6474
65 # wait for results and click on the first item75 # wait for results and click on the first item
66 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')76 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
@@ -72,6 +82,7 @@
7282
73 # LocationManagerPage should be visible and "London" added83 # LocationManagerPage should be visible and "London" added
74 locationList = self.main_window.get_object('QQuickListView', 'LocationList')84 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
85 self.assertThat(lambda: locationList, Eventually(NotEquals(None)))
75 addedItem = self.main_window.get_object('Standard', "existingLocation0")86 addedItem = self.main_window.get_object('Standard', "existingLocation0")
76 self.assertThat(lambda: addedItem, Eventually(NotEquals(None)))87 self.assertThat(lambda: addedItem, Eventually(NotEquals(None)))
77 self.assertThat(addedItem.text, Eventually(Equals("London")))88 self.assertThat(addedItem.text, Eventually(Equals("London")))
@@ -92,13 +103,7 @@
92 self._open_add_location_page()103 self._open_add_location_page()
93104
94 # insert city name to search for105 # insert city name to search for
95 searchField = self.main_window.get_object("TextField", "SearchField")106 searchField = self.search_for_city("London")
96 self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
97 self.pointing_device.click_object(searchField)
98 self.assertThat(searchField.focus, Eventually(Equals(True)))
99 self.keyboard.type("London")
100 self.assertThat(searchField.text, Eventually(Equals("London")))
101 self.keyboard.press_and_release('Enter')
102107
103 # wait for results and click on the first item108 # wait for results and click on the first item
104 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')109 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
@@ -133,13 +138,7 @@
133 self._open_add_location_page()138 self._open_add_location_page()
134139
135 # insert city name to search for140 # insert city name to search for
136 searchField = self.main_window.get_object("TextField", "SearchField")141 self.search_for_city("UbuntuCity")
137 self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
138 self.pointing_device.click_object(searchField)
139 self.assertThat(searchField.focus, Eventually(Equals(True)))
140 self.keyboard.type("UbuntuCity") # Unfortunately, no UbuntuCity in the world
141 self.assertThat(searchField.text, Eventually(Equals("UbuntuCity")))
142 self.keyboard.press_and_release('Enter')
143142
144 # wait for result and look if label is shown143 # wait for result and look if label is shown
145 errorLabel = self.main_window.get_object('Label', 'noCityError')144 errorLabel = self.main_window.get_object('Label', 'noCityError')
@@ -165,7 +164,7 @@
165 number_of_locations = self._get_number_of_locations()164 number_of_locations = self._get_number_of_locations()
166 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")165 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")
167 self.assertThat(lambda: firstLocation, Eventually(NotEquals(None)))166 self.assertThat(lambda: firstLocation, Eventually(NotEquals(None)))
168 167
169 x, y, w, h = firstLocation.globalRect168 x, y, w, h = firstLocation.globalRect
170 tx = x + (w / 8)169 tx = x + (w / 8)
171 ty = y + (h / 2)170 ty = y + (h / 2)
172171
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-04 11:09:32 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-09 21:02:49 +0000
@@ -11,7 +11,7 @@
1111
12from __future__ import absolute_import12from __future__ import absolute_import
1313
14from testtools.matchers import Equals14from testtools.matchers import NotEquals, Equals
15from autopilot.matchers import Eventually15from autopilot.matchers import Eventually
1616
17from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin17from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin
@@ -53,6 +53,7 @@
53 def test_refresh_tabs(self):53 def test_refresh_tabs(self):
54 # get the dates from the test data54 # get the dates from the test data
55 curr_dates = self.main_window.get_objects('Label','DayDateLabel')55 curr_dates = self.main_window.get_objects('Label','DayDateLabel')
56 self.assertThat(lambda: curr_dates, Eventually(NotEquals(None)))
56 tab1_curr_date = curr_dates[0].text57 tab1_curr_date = curr_dates[0].text
57 tab2_curr_date = curr_dates[2].text58 tab2_curr_date = curr_dates[2].text
5859
@@ -63,5 +64,6 @@
6364
64 # get the data from the refreshed tabs, have to be new65 # get the data from the refreshed tabs, have to be new
65 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')66 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')
67 self.assertThat(lambda: refreshed_dates, Eventually(NotEquals(None)))
66 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)68 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
67 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)69 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)

Subscribers

People subscribed via source and target branches