Merge lp:~martin-borho/ubuntu-weather-app/adddel-1230297 into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: Martin Borho
Approved revision: 142
Merged at revision: 135
Proposed branch: lp:~martin-borho/ubuntu-weather-app/adddel-1230297
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Prerequisite: lp:~martin-borho/ubuntu-weather-app/LocationLookup
Diff against target: 583 lines (+166/-102)
6 files modified
components/AddLocationSheet.qml (+9/-3)
components/LocationManagerSheet.qml (+8/-0)
tests/autopilot/ubuntu_weather_app/emulators.py (+4/-12)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+16/-0)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+123/-81)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+6/-6)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/adddel-1230297
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Raúl Yeguas Approve
Review via email: mp+189135@code.launchpad.net

Commit message

fixes Bug #1230297: Removing a location add adding a new one fails

Description of the change

fixes Bug #1230297: Removing a location add adding a new one fails

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: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
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
Raúl Yeguas (neokore) wrote :

Well done, Martin!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
140. By Martin Borho

removed get_object(s) methods from autopilot tests

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
141. By Martin Borho

trying again

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
142. By Martin Borho

trigger jenkins

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/AddLocationSheet.qml'
2--- components/AddLocationSheet.qml 2013-09-28 10:27:32 +0000
3+++ components/AddLocationSheet.qml 2013-10-07 07:26:44 +0000
4@@ -34,11 +34,10 @@
5 doneButton: false
6
7 Component.onCompleted: {
8- locationsRemoved.clear()
9 Cities.preList.forEach(function(loc) {
10 citiesModel.append(loc)
11 })
12- Theme.palette.selected.backgroundText = "#656565" //color: Theme.palette.normal.baseText
13+ Theme.palette.normal.backgroundText = "#656565" //color: Theme.palette.normal.baseText
14 }
15
16 WorkerScript {
17@@ -176,9 +175,12 @@
18 Label {
19 id: noCityError
20 objectName: "noCityError"
21+ width: parent.width-units.gu(6)
22 visible: false
23 anchors.centerIn: parent
24- fontSize: "small"
25+ fontSize: "medium"
26+ wrapMode: Text.WordWrap
27+ horizontalAlignment: Text.AlignHCenter
28 }
29 Component {
30 id: sectionHeading
31@@ -209,6 +211,8 @@
32 id: searchResultName
33 objectName: "searchResult" + index
34 text: name
35+ width: parent.width-units.gu(3)
36+ elide: Text.ElideRight
37 anchors {
38 top: parent.top
39 topMargin: units.gu(0.5)
40@@ -219,6 +223,8 @@
41 }
42 Label {
43 text: areaLabel
44+ width: parent.width-units.gu(3)
45+ elide: Text.ElideRight
46 anchors {
47 top: searchResultName.bottom
48 bottom: parent.bottom
49
50=== modified file 'components/LocationManagerSheet.qml'
51--- components/LocationManagerSheet.qml 2013-10-01 20:57:27 +0000
52+++ components/LocationManagerSheet.qml 2013-10-07 07:26:44 +0000
53@@ -155,6 +155,8 @@
54 id: currentLocationLabel
55 objectName: "CurrentLocationLabel"
56 text: ""
57+ width: parent.width-lookupItemAddButton.width-units.gu(5.5)
58+ elide: Text.ElideRight
59 anchors {
60 top: parent.top
61 topMargin: units.gu(0.5)
62@@ -166,6 +168,8 @@
63 Label {
64 id: currentLocationAreaLabel
65 text: ""
66+ width: parent.width-lookupItemAddButton.width-units.gu(5.5)
67+ elide: Text.ElideRight
68 anchors {
69 top: currentLocationLabel.bottom
70 bottom: parent.bottom
71@@ -226,6 +230,8 @@
72 id: searchResultName
73 objectName: "existingLocation" + index
74 text: name
75+ width: parent.width-units.gu(3)
76+ elide: Text.ElideRight
77 anchors {
78 top: parent.top
79 topMargin: units.gu(0.5)
80@@ -236,6 +242,8 @@
81 }
82 Label {
83 text: adminName1.replace(/ Region$/,'')+", "+((Countries.codes[country]) ? i18n.tr(Countries.codes[country]): country)
84+ width: parent.width-units.gu(3)
85+ elide: Text.ElideRight
86 anchors {
87 top: searchResultName.bottom
88 bottom: parent.bottom
89
90=== modified file 'tests/autopilot/ubuntu_weather_app/emulators.py'
91--- tests/autopilot/ubuntu_weather_app/emulators.py 2013-08-04 11:09:32 +0000
92+++ tests/autopilot/ubuntu_weather_app/emulators.py 2013-10-07 07:26:44 +0000
93@@ -14,14 +14,6 @@
94
95 class MainView(toolkit_emulators.MainView):
96
97- def get_object(self, typeName, name):
98- """Get a specific object"""
99- return self.select_single(typeName, objectName=name)
100-
101- def get_objects(self, typeName, name):
102- """Get more than one object"""
103- return self.select_many(typeName, objectName=name)
104-
105 def get_tabs(self):
106 """Return the LocationTabs emulator of the MainView."""
107 tabs = self.select_single(Tabs)
108@@ -31,10 +23,10 @@
109 class Tabs(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
110 """LocationTabs Autopilot emulator."""
111
112- def get_current_tab(self):
113- """Return the currently selected tab."""
114+ def get_current_tab(self):
115+ """Return the currently selected tab."""
116 return self.select_many('LocationTab')[self.selectedTabIndex]
117
118- def get_number_of_tabs(self):
119- """Return the number of tabs."""
120+ def get_number_of_tabs(self):
121+ """Return the number of tabs."""
122 return len(self.select_many('LocationTab'))
123
124=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
125--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-10-01 20:57:27 +0000
126+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-10-07 07:26:44 +0000
127@@ -17,6 +17,8 @@
128 from autopilot.input import Mouse, Touch, Pointer
129 from autopilot.platform import model
130 from autopilot.testcase import AutopilotTestCase
131+from testtools.matchers import Equals, NotEquals, Is, Not
132+from autopilot.matchers import Eventually
133
134 from ubuntuuitoolkit import emulators as toolkit_emulators
135 from ubuntu_weather_app.emulators import MainView
136@@ -100,6 +102,20 @@
137 """Clicks the cancel button"""
138 self.pointing_device.click_object(self.main_window.select_many('Button')[0])
139
140+class LocationManagerMixin(object):
141+ """Mixin for LocationManager related methods"""
142+ def _open_add_location_page(self):
143+ """Opens the AddLocationPage"""
144+ # click on listitem to open AddLocationPage
145+ self.assertThat(lambda: self.main_window.select_single('Standard', objectName='AddCityListItem'), Eventually(Not(Is(None))))
146+ addCityItem = self.main_window.select_single('Standard', objectName='AddCityListItem')
147+ self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
148+ self.pointing_device.move_to_object(addCityItem)
149+ self.pointing_device.click()
150+
151+ addLocPage = self.main_window.select_single("DefaultSheet", objectName="AddLocationSheet")
152+ self.assertThat(addLocPage.visible, Eventually(Equals(True)))
153+
154 class DatabaseMixin(object):
155
156 """
157
158=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
159--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-10-01 22:45:27 +0000
160+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-10-07 07:26:44 +0000
161@@ -12,13 +12,13 @@
162 from testtools.matchers import Equals, NotEquals, Is, Not
163 from autopilot.matchers import Eventually
164
165-from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin
166+from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin, LocationManagerMixin
167 from ubuntu_weather_app.tests.weatherdata import locations_data
168
169 from time import sleep
170
171+class TestLocationManager(WeatherTestCase, DatabaseMixin, SheetMixin, LocationManagerMixin):
172
173-class TestLocationManager(WeatherTestCase, DatabaseMixin, SheetMixin):
174 def setUp(self):
175 self.clean_db()
176 super(TestLocationManager, self).setUp()
177@@ -26,8 +26,9 @@
178 self.get_qml_view().visible, Eventually(Equals(True)))
179
180 def search_for_city(self, city):
181- self.assertThat(lambda: self.main_window.get_object('TextField', 'SearchField'), Eventually(Not(Is(None))))
182- searchField = self.main_window.get_object("TextField", "SearchField")
183+ self.assertThat(lambda: self.main_window.select_single('TextField', objectName='SearchField'),
184+ Eventually(Not(Is(None))))
185+ searchField = self.main_window.select_single("TextField", objectName="SearchField")
186 #poll clicking for focus for lack of better method, due to screen switching animation
187 #is there a property we can use instead?
188 timeout = 0
189@@ -40,19 +41,6 @@
190 self.keyboard.press_and_release('Enter')
191 return searchField
192
193- def _open_add_location_page(self):
194- """Opens the AddLocationPage"""
195- # click on listitem to open AddLocationPage
196- self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
197- locationList = self.main_window.get_object('QQuickListView', 'LocationList')
198- addCityItem = locationList.get_children()[0]
199- self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
200- self.pointing_device.move_to_object(addCityItem)
201- self.pointing_device.click()
202-
203- addLocPage = self.main_window.get_object("DefaultSheet", "AddLocationSheet")
204- self.assertThat(addLocPage.visible, Eventually(Equals(True)))
205-
206 def select_single_retry(self, object_type, **kwargs):
207 """Returns the item that is searched for with app.select_single
208 In case of the item was not found (not created yet) a second attempt is
209@@ -73,62 +61,68 @@
210 self.search_for_city("London")
211
212 # wait for results and click on the first item
213- # http_failed = lambda: self.main_window.get_object('SplashComponent', 'HTTPFailedSplash').visible
214+ # http_failed = lambda: self.main_window.select_single('SplashComponent', objectName='HTTPFailedSplash').visible
215 # self.assertThat(http_failed, Eventually(NotEquals(True)))
216- load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
217+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='SearchingSpinner')
218 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
219- resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
220+ resultsList = self.main_window.select_single('QQuickListView', objectName='SearchResultList')
221 self.assertThat(resultsList.visible, Eventually(Equals(True)))
222- self.assertThat(lambda: self.main_window.get_object('Label', 'searchResult0'), Eventually(Not(Is(None))))
223- firstResult = self.main_window.get_object('Label', 'searchResult0')
224+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='searchResult0'),
225+ Eventually(Not(Is(None))))
226+ firstResult = self.main_window.select_single('Label', objectName='searchResult0')
227 self.pointing_device.move_to_object(firstResult)
228 self.pointing_device.click()
229
230 # LocationManagerPage should be visible and "London" added
231- self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
232- locationList = self.main_window.get_object('QQuickListView', 'LocationList')
233- self.assertThat(lambda: self.main_window.get_object('Label', 'existingLocation0'), Eventually(Not(Is(None))))
234- addedItem = self.main_window.get_object('Label', "existingLocation0")
235+ self.assertThat(lambda: self.main_window.select_single('QQuickListView', objectName='LocationList'),
236+ Eventually(Not(Is(None))))
237+ locationList = self.main_window.select_single('QQuickListView', objectName='LocationList')
238+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='existingLocation0'),
239+ Eventually(Not(Is(None))))
240+ addedItem = self.main_window.select_single('Label', objectName="existingLocation0")
241 self.assertThat(addedItem.text, Eventually(Equals("London")))
242 self._click_sheet_confirm()
243
244 # back to locations, wait till data is loaded
245- load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
246+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
247 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
248
249 # only location is there
250- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
251+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
252 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
253- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
254+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
255 self.assertEqual(1, len(tabObjects))
256
257 def test_add_predefined_location(self):
258 """Adds a location"""
259 self._open_add_location_page()
260
261- resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
262+ resultsList = self.main_window.select_single('QQuickListView', objectName='SearchResultList')
263 self.assertThat(resultsList.visible, Eventually(Equals(True)))
264- self.assertThat(lambda: self.main_window.get_object('Label', 'searchResult4'), Eventually(Not(Is(None))))
265- testResult = self.main_window.get_object('Label', 'searchResult4')
266+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='searchResult4'),
267+ Eventually(Not(Is(None))))
268+ testResult = self.main_window.select_single('Label', objectName='searchResult4')
269 self.pointing_device.move_to_object(testResult)
270 self.pointing_device.click()
271
272- # LocationManagerPage should be visible and "London" added
273- self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
274- locationList = self.main_window.get_object('QQuickListView', 'LocationList')
275- self.assertThat(lambda: self.main_window.get_object('Label', 'existingLocation0'), Eventually(Not(Is(None))))
276- addedItem = self.main_window.get_object('Label', "existingLocation0")
277+ # LocationManagerPage should be visible and location added
278+ self.assertThat(lambda: self.main_window.select_single('QQuickListView', objectName='LocationList'),
279+ Eventually(Not(Is(None))))
280+ locationList = self.main_window.select_single('QQuickListView', objectName='LocationList')
281+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='existingLocation0'),
282+ Eventually(Not(Is(None))))
283+ addedItem = self.main_window.select_single('Label', objectName="existingLocation0")
284 self.assertThat(addedItem.text, Eventually(Equals("Cairo")))
285 self._click_sheet_confirm()
286
287 # back to locations, wait till data is loaded
288- load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
289+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
290 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
291
292 # only location is there
293- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
294+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
295 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
296- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
297+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
298 self.assertEqual(1, len(tabObjects))
299
300 def test_search_city(self):
301@@ -139,19 +133,21 @@
302 searchField = self.search_for_city("London")
303
304 # wait for results and click on the first item
305- #http_failed = lambda: self.main_window.get_object('SplashComponent', 'HTTPFailedSplash').visible
306+ #http_failed = lambda: self.main_window.select_single('SplashComponent', objectName='HTTPFailedSplash').visible
307 #self.assertThat(http_failed, Eventually(NotEquals(True)))
308- load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
309+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='SearchingSpinner')
310 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
311- resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
312+ resultsList = self.main_window.select_single('QQuickListView', objectName='SearchResultList')
313 self.assertThat(resultsList.visible, Eventually(Equals(True)))
314- self.assertThat(lambda: self.main_window.get_object('Label', 'searchResult0'), Eventually(Not(Is(None))))
315+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='searchResult0'),
316+ Eventually(Not(Is(None))))
317 firstResult = self.select_single_retry("Label", objectName="searchResult0")
318 self.assertThat(firstResult.text, Eventually(Equals("London")))
319
320 # regain focus, clear search field and do another search
321- self.assertThat(lambda: self.main_window.get_object('TextField', 'SearchField'), Eventually(Not(Is(None))))
322- searchField = self.main_window.get_object("TextField", "SearchField")
323+ self.assertThat(lambda: self.main_window.select_single('TextField', objectName='SearchField'),
324+ Eventually(Not(Is(None))))
325+ searchField = self.main_window.select_single("TextField", objectName="SearchField")
326 self.pointing_device.click_object(searchField)
327 self.assertThat(lambda: self.main_window.select_single('AbstractButton'), Eventually(Not(Is(None))))
328 clear_button = searchField.select_single("AbstractButton")
329@@ -161,10 +157,11 @@
330 self.pointing_device.click_object(searchField)
331 self.keyboard.type("Hamburg")
332 self.keyboard.press_and_release('Enter')
333- load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
334+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='SearchingSpinner')
335 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
336 self.assertThat(resultsList.visible, Eventually(Equals(True)))
337- self.assertThat(lambda: self.main_window.get_object('Label', 'searchResult0'), Eventually(Not(Is(None))))
338+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='searchResult0'),
339+ Eventually(Not(Is(None))))
340 firstResult = self.select_single_retry("Label", objectName="searchResult0")
341 self.assertThat(firstResult.text, Eventually(Equals("Hamburg")))
342
343@@ -172,8 +169,9 @@
344 """Cancel the cities search"""
345 self._open_add_location_page()
346 self._click_sheet_cancel()
347- self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
348- locationList = self.main_window.get_object('QQuickListView', 'LocationList')
349+ self.assertThat(lambda: self.main_window.select_single('QQuickListView', objectName='LocationList'),
350+ Eventually(Not(Is(None))))
351+ locationList = self.main_window.select_single('QQuickListView', objectName='LocationList')
352 self.assertThat(locationList.visible, Eventually(Equals(True)))
353
354 def test_no_location_found(self):
355@@ -184,56 +182,61 @@
356 self.search_for_city("UbuntuCity")
357
358 # wait for result and look if label is shown
359- # http_failed = lambda: self.main_window.get_object('SplashComponent', 'HTTPFailedSearch').visible
360+ # http_failed = lambda: self.main_window.select_single('SplashComponent', objectName='HTTPFailedSearch').visible
361 # self.assertThat(http_failed, Eventually(NotEquals(True)))
362- load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
363+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='SearchingSpinner')
364 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
365- errorLabel = self.main_window.get_object('Label', 'noCityError')
366+ errorLabel = self.main_window.select_single('Label', objectName='noCityError')
367 self.assertThat(errorLabel.visible, Eventually(Equals(True)))
368
369 def test_location_lookup(self):
370 """Tests the location lookup"""
371 # start lookup
372- self.assertThat(lambda: self.main_window.get_object('Standard', 'LocationLookupItem'), Eventually(Not(Is(None))))
373- lookupItem = self.main_window.get_object('Standard', 'LocationLookupItem')
374+ self.assertThat(lambda: self.main_window.select_single('Standard', objectName='LocationLookupItem'),
375+ Eventually(Not(Is(None))))
376+ lookupItem = self.main_window.select_single('Standard', objectName='LocationLookupItem')
377 self.pointing_device.click_object(lookupItem)
378
379 # wait for result
380- load_indicator = self.main_window.get_object('ActivityIndicator', 'LookupIndicator')
381+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LookupIndicator')
382 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
383
384 # check a location was found
385- self.assertThat(lambda: self.main_window.get_object('Label', 'CurrentLocationLabel'), Eventually(Not(Is(None))))
386- location = self.main_window.get_object('Label', 'CurrentLocationLabel')
387+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='CurrentLocationLabel'),
388+ Eventually(Not(Is(None))))
389+ location = self.main_window.select_single('Label', objectName='CurrentLocationLabel')
390 self.assertThat(location.text, Eventually(Not(Equals(""))))
391 location_name = location.text
392
393 # add location
394- self.assertThat(lambda: self.main_window.get_object('Button', 'LookupItemAddButton'), Eventually(Not(Is(None))))
395- add_button = self.main_window.get_object('Button', 'LookupItemAddButton')
396+ self.assertThat(lambda: self.main_window.select_single('Button', objectName='LookupItemAddButton'),
397+ Eventually(Not(Is(None))))
398+ add_button = self.main_window.select_single('Button', objectName='LookupItemAddButton')
399 self.pointing_device.click_object(add_button)
400
401- # LocationManagerPage should be visible and "London" added
402- self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
403- locationList = self.main_window.get_object('QQuickListView', 'LocationList')
404- self.assertThat(lambda: self.main_window.get_object('Label', 'existingLocation0'), Eventually(Not(Is(None))))
405- addedItem = self.main_window.get_object('Label', "existingLocation0")
406+ # LocationManagerPage should be visible and location added
407+ self.assertThat(lambda: self.main_window.select_single('QQuickListView', objectName='LocationList'),
408+ Eventually(Not(Is(None))))
409+ locationList = self.main_window.select_single('QQuickListView', objectName='LocationList')
410+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='existingLocation0'),
411+ Eventually(Not(Is(None))))
412+ addedItem = self.main_window.select_single('Label', objectName="existingLocation0")
413 self.assertThat(addedItem.text, Eventually(Equals(location_name)))
414 self._click_sheet_confirm()
415
416 # back to locations, wait till data is loaded
417- load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
418+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
419 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
420
421 # only location is there
422- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
423+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
424 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
425- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
426+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
427 self.assertEqual(1, len(tabObjects))
428
429
430-
431-class TestLocationManagerWithLocation(WeatherTestCase, DatabaseMixin, SheetMixin):
432+
433+class TestLocationManagerWithLocation(WeatherTestCase, DatabaseMixin, SheetMixin, LocationManagerMixin):
434 def setUp(self):
435 self.clean_db()
436 self.launch_and_quit_app()
437@@ -250,18 +253,20 @@
438 def _swipe_location_to_remove(self):
439 """Swipe right to delete the first location"""
440 number_of_locations = self._get_number_of_locations()
441- self.assertThat(lambda: self.app.select_single('Standard', objectName='existingLocationItem0'), Eventually(Not(Is(None))))
442+ self.assertThat(lambda: self.app.select_single('Standard', objectName='existingLocationItem0'),
443+ Eventually(Not(Is(None))))
444 first_location = self.app.select_single("Standard", objectName="existingLocationItem0")
445
446 x, y, w, h = first_location.globalRect
447 tx = x + (w / 8)
448 ty = y + (h / 2)
449 self.pointing_device.drag(tx, ty, tx + w/4*3 , ty)
450-
451+
452 self.assertThat(lambda: first_location.select_many('Label')[2].visible, Eventually(Not(Is(None))))
453 trashcanLabel = first_location.select_many('Label')[2]
454 timeout = 0
455- while timeout < 10 and first_location.select_many('Label') and self.app.select_single("Standard", objectName="existingLocationItem0"):
456+ while timeout < 10 and first_location.select_many('Label') \
457+ and self.app.select_single("Standard", objectName="existingLocationItem0"):
458 self.pointing_device.click_object(trashcanLabel)
459 sleep(1)
460 timeout += 1
461@@ -274,11 +279,11 @@
462 def test_remove_location(self):
463 """Removes location"""
464 # wait till data is loaded
465- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
466+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
467 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
468
469 # count locations at start
470- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
471+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
472 tabsSumStart = len(tabObjects)
473
474 # go to the location manager and remove location
475@@ -287,19 +292,19 @@
476 self._click_sheet_confirm()
477
478 # back to locations, only one is left
479- load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
480+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
481 self.assertThat(load_indicator.running, Eventually(Equals(False)))
482- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
483+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
484 self.assertThat(lambda: tabsSumStart-1, Eventually(Equals(len(tabObjects))))
485
486 def test_cancel_remove_location(self):
487 """Cancels removing of location"""
488 # wait data is loaded
489- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
490+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
491 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
492
493 # count locations at start
494- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
495+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
496 tabsSumStart = len(tabObjects)
497
498 # go to the location manager, remove location, but click cancel
499@@ -308,8 +313,45 @@
500 self._click_sheet_cancel()
501
502 # back to locations, no loction is removed
503- loadingPage = self.main_window.get_object("Tabs", "rootTabs")
504+ loadingPage = self.main_window.select_single("Tabs", objectName="rootTabs")
505 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
506- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
507+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
508 self.assertEqual(tabsSumStart, len(tabObjects))
509
510+ def test_del_add_bug(self):
511+ """Tests if remvoing and add ad loction in one action works
512+ https://bugs.launchpad.net/ubuntu-weather-app/+bug/1230297"""
513+ # remove a location
514+ self._open_location_manager()
515+ number_of_locations = self._get_number_of_locations()
516+ self._swipe_location_to_remove()
517+ self._open_add_location_page()
518+
519+ # add a location
520+ resultsList = self.main_window.select_single('QQuickListView', objectName='SearchResultList')
521+ self.assertThat(resultsList.visible, Eventually(Equals(True)))
522+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='searchResult4'),
523+ Eventually(Not(Is(None))))
524+ testResult = self.main_window.select_single('Label', objectName='searchResult4')
525+ self.pointing_device.move_to_object(testResult)
526+ self.pointing_device.click()
527+
528+ # LocationManagerPage should be visible and location added
529+ self.assertThat(lambda: self.main_window.select_single('QQuickListView', objectName='LocationList'),
530+ Eventually(Not(Is(None))))
531+ locationList = self.main_window.select_single('QQuickListView', objectName='LocationList')
532+ self.assertThat(lambda: self.main_window.select_single('Label', objectName='existingLocation1'),
533+ Eventually(Not(Is(None))))
534+ addedItem = self.main_window.select_single('Label', objectName="existingLocation1")
535+ self.assertThat(addedItem.text, Eventually(Equals("Cairo")))
536+ self.assertThat(lambda: self._get_number_of_locations(), Eventually(Equals(number_of_locations)))
537+ self._click_sheet_confirm()
538+
539+ # back to locations, wait till data is loaded
540+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
541+ self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
542+
543+ # count the tabs
544+ tabObjects = self.main_window.select_many('LocationTab', objectName='LocationTab')
545+ self.assertThat(lambda: number_of_locations, Eventually(Equals(len(tabObjects))))
546+ self.assertThat(tabObjects[1].title, Eventually(Equals("Cairo")))
547
548=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
549--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-14 20:28:56 +0000
550+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-10-07 07:26:44 +0000
551@@ -42,7 +42,7 @@
552
553 # first tab should be visible after start
554 tabs = self.main_window.get_tabs()
555- tabObjects = self.main_window.get_objects('LocationTab','LocationTab')
556+ tabObjects = self.main_window.select_many('LocationTab',objectName='LocationTab')
557 self.assertThat(tabs.selectedTabIndex, Eventually(Equals(0)))
558 self.assertThat(tabObjects[0].visible, Eventually(Equals(True)))
559 self.assertThat(tabObjects[1].visible, Eventually(Equals(False)))
560@@ -56,18 +56,18 @@
561
562 def test_refresh_tabs(self):
563 # get the dates from the test data
564- self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
565- curr_dates = self.main_window.get_objects('Label','DayDateLabel')
566+ self.assertThat(lambda: self.main_window.select_many('Label', objectName='DayDateLabel'), Eventually(Not(Is(None))))
567+ curr_dates = self.main_window.select_many('Label', objectName='DayDateLabel')
568 tab1_curr_date = curr_dates[0].text
569 tab2_curr_date = curr_dates[2].text
570
571 # refresh and wait till loading has finished
572 self.main_window.open_toolbar().click_button("RefreshButton")
573- load_indicator = self.main_window.get_object('ActivityIndicator', 'LoadingSpinner')
574+ load_indicator = self.main_window.select_single('ActivityIndicator', objectName='LoadingSpinner')
575 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
576
577 # get the data from the refreshed tabs, have to be new
578- self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
579- refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')
580+ self.assertThat(lambda: self.main_window.select_many('Label',objectName='DayDateLabel'), Eventually(Not(Is(None))))
581+ refreshed_dates = self.main_window.select_many('Label',objectName='DayDateLabel')
582 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
583 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)

Subscribers

People subscribed via source and target branches