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
1=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
2--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-07 17:38:05 +0000
3+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-09 21:02:49 +0000
4@@ -25,12 +25,28 @@
5 self.assertThat(
6 self.get_qml_view().visible, Eventually(Equals(True)))
7
8+ def search_for_city(self, city):
9+ searchField = self.main_window.get_object("TextField", "SearchField")
10+ self.assertThat(lambda: searchField.visible, Eventually(Equals(True)))
11+ #poll clicking for focus for lack of better method, due to screen switching animation
12+ #is there a property we can use instead?
13+ timeout = 0
14+ while searchField.focus != True and timeout < 10:
15+ self.pointing_device.click_object(searchField)
16+ sleep(1)
17+ timeout += 1
18+ self.keyboard.type(city)
19+ self.assertThat(searchField.text, Eventually(Equals(city)))
20+ self.keyboard.press_and_release('Enter')
21+ return searchField
22+
23 def _open_add_location_page(self):
24 """Opens the AddLocationPage"""
25 # click on listitem to open AddLocationPage
26 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
27+ self.assertThat(lambda: locationList.visible, Eventually(Equals(True)))
28 addCityItem = locationList.get_children()[0]
29- self.assertThat(lambda: addCityItem, Eventually(NotEquals(None)))
30+ self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
31 self.pointing_device.move_to_object(addCityItem)
32 self.pointing_device.click()
33
34@@ -54,13 +70,7 @@
35 self._open_add_location_page()
36
37 # insert city name to search for
38- searchField = self.main_window.get_object("TextField", "SearchField")
39- self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
40- self.pointing_device.click_object(searchField)
41- self.assertThat(searchField.focus, Eventually(Equals(True)))
42- self.keyboard.type("London")
43- self.assertThat(searchField.text, Eventually(Equals("London")))
44- self.keyboard.press_and_release('Enter')
45+ self.search_for_city("London")
46
47 # wait for results and click on the first item
48 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
49@@ -72,6 +82,7 @@
50
51 # LocationManagerPage should be visible and "London" added
52 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
53+ self.assertThat(lambda: locationList, Eventually(NotEquals(None)))
54 addedItem = self.main_window.get_object('Standard', "existingLocation0")
55 self.assertThat(lambda: addedItem, Eventually(NotEquals(None)))
56 self.assertThat(addedItem.text, Eventually(Equals("London")))
57@@ -92,13 +103,7 @@
58 self._open_add_location_page()
59
60 # insert city name to search for
61- searchField = self.main_window.get_object("TextField", "SearchField")
62- self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
63- self.pointing_device.click_object(searchField)
64- self.assertThat(searchField.focus, Eventually(Equals(True)))
65- self.keyboard.type("London")
66- self.assertThat(searchField.text, Eventually(Equals("London")))
67- self.keyboard.press_and_release('Enter')
68+ searchField = self.search_for_city("London")
69
70 # wait for results and click on the first item
71 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
72@@ -133,13 +138,7 @@
73 self._open_add_location_page()
74
75 # insert city name to search for
76- searchField = self.main_window.get_object("TextField", "SearchField")
77- self.assertThat(lambda: searchField, Eventually(NotEquals(None)))
78- self.pointing_device.click_object(searchField)
79- self.assertThat(searchField.focus, Eventually(Equals(True)))
80- self.keyboard.type("UbuntuCity") # Unfortunately, no UbuntuCity in the world
81- self.assertThat(searchField.text, Eventually(Equals("UbuntuCity")))
82- self.keyboard.press_and_release('Enter')
83+ self.search_for_city("UbuntuCity")
84
85 # wait for result and look if label is shown
86 errorLabel = self.main_window.get_object('Label', 'noCityError')
87@@ -165,7 +164,7 @@
88 number_of_locations = self._get_number_of_locations()
89 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")
90 self.assertThat(lambda: firstLocation, Eventually(NotEquals(None)))
91-
92+
93 x, y, w, h = firstLocation.globalRect
94 tx = x + (w / 8)
95 ty = y + (h / 2)
96
97=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
98--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-04 11:09:32 +0000
99+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-09 21:02:49 +0000
100@@ -11,7 +11,7 @@
101
102 from __future__ import absolute_import
103
104-from testtools.matchers import Equals
105+from testtools.matchers import NotEquals, Equals
106 from autopilot.matchers import Eventually
107
108 from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin
109@@ -53,6 +53,7 @@
110 def test_refresh_tabs(self):
111 # get the dates from the test data
112 curr_dates = self.main_window.get_objects('Label','DayDateLabel')
113+ self.assertThat(lambda: curr_dates, Eventually(NotEquals(None)))
114 tab1_curr_date = curr_dates[0].text
115 tab2_curr_date = curr_dates[2].text
116
117@@ -63,5 +64,6 @@
118
119 # get the data from the refreshed tabs, have to be new
120 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')
121+ self.assertThat(lambda: refreshed_dates, Eventually(NotEquals(None)))
122 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
123 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)

Subscribers

People subscribed via source and target branches