Merge lp:~martin-borho/ubuntu-weather-app/autopilot-ubuntusdk-update into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho on 2013-07-12
Status: Merged
Approved by: Martin Borho on 2013-07-16
Approved revision: 64
Merged at revision: 67
Proposed branch: lp:~martin-borho/ubuntu-weather-app/autopilot-ubuntusdk-update
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 275 lines (+74/-94)
5 files modified
tests/autopilot/ubuntu_weather_app/emulators/main_window.py (+0/-25)
tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py (+60/-52)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+1/-2)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+6/-6)
ubuntu-weather-app.qml (+7/-9)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/autopilot-ubuntusdk-update
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) 2013-07-12 Approve on 2013-07-16
Günter Schwann (community) Approve on 2013-07-16
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2013-07-12
Review via email: mp+174371@code.launchpad.net

Commit message

Updated ubuntusdk emulator for autopilot, fixed Bug #1195241 as by-product.

Description of the change

* Updated ubuntusdk emulator for autopilot
* Removed LoadingTabs to get updated ubuntusdk fully supported, Fixed as a by-product Bug #1195241.
* Removed old main_window.py emulator
* test_search_city made more reliable

To post a comment you must log in.
Günter Schwann (schwann) wrote :

Instead of looping through all buttons, here
102 + for button in buttonList:
you could use:
button = toolbar.select_single("ActionItem", objectName=buttonObject)

Otherwise looks good to me.

review: Approve
Nicholas Skaggs (nskaggs) wrote :

Martin, am I crazy or does this seem to have the weird back button misclicking issue? Otherwise this looks great.

review: Approve
Martin Borho (martin-borho) wrote :

Yes, it has..

Anyways, will merge...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'tests/autopilot/ubuntu_weather_app/emulators/main_window.py'
2--- tests/autopilot/ubuntu_weather_app/emulators/main_window.py 2013-06-20 16:10:06 +0000
3+++ tests/autopilot/ubuntu_weather_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
4@@ -1,25 +0,0 @@
5-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6-# Copyright 2013 Canonical
7-#
8-# This program is free software: you can redistribute it and/or modify it
9-# under the terms of the GNU General Public License version 3, as published
10-# by the Free Software Foundation.
11-
12-
13-class MainWindow(object):
14- """An emulator class that makes it easy to interact with the weather app"""
15-
16- def __init__(self, autopilot, app):
17- self.app = app
18- self.autopilot= autopilot
19-
20- def get_qml_view(self):
21- return self.app.select_single("QQuickView")
22-
23- def get_object(self, typeName, name):
24- """Get a specific object"""
25- return self.app.select_single(typeName, objectName=name)
26-
27- def get_objects(self, typeName, name):
28- """Get more than one object"""
29- return self.app.select_many(typeName, objectName=name)
30
31=== modified file 'tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py'
32--- tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-07-03 19:57:03 +0000
33+++ tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-07-12 09:37:30 +0000
34@@ -38,6 +38,10 @@
35 """Get more than one object"""
36 return self.app.select_many(typeName, objectName=name)
37
38+ def get_tabs(self):
39+ """Return all tabs"""
40+ return self.app.select_single("Tabs")
41+
42 def switch_to_tab(self, tab):
43 """Switch to the specified tab number"""
44 tabs = self.get_tabs()
45@@ -46,11 +50,37 @@
46 #perform operations until tab == currentTab
47 while tab != currentTab:
48 if tab > currentTab:
49+ self._next_tab()
50+ if tab < currentTab:
51 self._previous_tab()
52- if tab < currentTab:
53- self._next_tab()
54 currentTab = tabs.selectedTabIndex
55
56+ def _previous_tab(self):
57+ """Switch to the previous tab"""
58+ qmlView = self.get_qml_view()
59+
60+ startX = int(qmlView.x + qmlView.width * 0.10)
61+ stopX = int(qmlView.x + qmlView.width * 0.45)
62+ lineY = int(qmlView.y + qmlView.height * 0.05)
63+
64+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
65+ self.autopilot.pointing_device.move(startX, lineY)
66+ self.autopilot.pointing_device.click()
67+ self.autopilot.pointing_device.click()
68+
69+ def _next_tab(self):
70+ """Switch to the next tab"""
71+ qmlView = self.get_qml_view()
72+
73+ startX = int(qmlView.x + qmlView.width * 0.45)
74+ stopX = int(qmlView.x + qmlView.width * 0.10)
75+ lineY = int(qmlView.y + qmlView.height * 0.05)
76+
77+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
78+ self.autopilot.pointing_device.move(startX, lineY)
79+ self.autopilot.pointing_device.click()
80+ self.autopilot.pointing_device.click()
81+
82 def toggle_toolbar(self):
83 """Toggle the toolbar between revealed and hidden"""
84 #check and see if the toolbar is open or not
85@@ -63,23 +93,29 @@
86 """Returns the toolbar in the main events view."""
87 return self.app.select_single("Toolbar")
88
89- def get_toolbar_button(self, buttonName):
90- """Returns the toolbar button at position index"""
91+ def get_toolbar_button(self, buttonObject):
92+ """Returns the toolbar button with objectName buttonObject"""
93 toolbar = self.get_toolbar()
94 if not toolbar.opened:
95 self.open_toolbar()
96- button = self.get_object('ActionItem', buttonName)
97- return button
98+ buttonList = toolbar.select_many("ActionItem")
99+ #old version is ToolbarButton
100+ if not buttonList:
101+ buttonList = toolbar.select_many("ToolbarButton")
102+ for button in buttonList:
103+ if button.objectName == buttonObject:
104+ return button
105
106- def click_toolbar_button(self, buttonName):
107- """Clicks the toolbar button with buttonLabel"""
108+ def click_toolbar_button(self, buttonObject):
109+ """Clicks the toolbar button with objectName buttonObject"""
110 #The toolbar button is assumed to be the following format
111- #ToolbarItems {
112- # ToolbarButton {
113+ #Toolbar {
114+ # ...
115+ # ActionItem {
116 # objectName: "name"
117- # text: value
118- button = self.get_toolbar_button(buttonName)
119+ button = self.get_toolbar_button(buttonObject)
120 self.autopilot.pointing_device.click_object(button)
121+ return button
122
123 def open_toolbar(self):
124 """Open the toolbar"""
125@@ -106,44 +142,16 @@
126 At the moment this only works for values that are currently visible. To
127 access the remaining items, a help method to drag and recheck is needed."""
128 #The popover is assumed to be the following format
129- # Popover {
130- # Column {
131- # ListView {
132- # delegate: Standard {
133- # objectName: "name"
134- # text: value
135-
136- self.autopilot.pointing_device.click_object(button)
137- #we'll get all matching objects, incase the popover is reused between buttons
138- itemList = lambda: self.get_objects("Standard", popover)
139-
140- for item in itemList():
141- if item.get_properties()['text'] == value:
142+ #Component {
143+ # id: actionSelectionPopover
144+ #
145+ #ActionSelectionPopover {
146+ # actions: ActionList {
147+ # Action {
148+
149+ popList = self.get_object("ActionSelectionPopover", popover)
150+ itemList = popList.select_many("Label")
151+ for item in itemList:
152+ if item.text == value:
153 self.autopilot.pointing_device.click_object(item)
154-
155- def get_tabs(self):
156- """Return all tabs"""
157- return self.get_object("Tabs", "rootTabs")
158-
159- def _previous_tab(self):
160- """Switch to the previous tab"""
161- qmlView = self.get_qml_view()
162-
163- startX = int(qmlView.x + qmlView.width * 0.35)
164- stopX = int(qmlView.x + qmlView.width * 0.50)
165- lineY = int(qmlView.y + qmlView.height * 0.05)
166-
167- self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
168- self.autopilot.pointing_device.click()
169- self.autopilot.pointing_device.click()
170-
171- def _next_tab(self):
172- """Switch to the next tab"""
173- qmlView = self.get_qml_view()
174-
175- startX = int(qmlView.x + qmlView.width * 0.50)
176- stopX = int(qmlView.x + qmlView.width * 0.35)
177- lineY = int(qmlView.y + qmlView.height * 0.05)
178-
179- self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
180- self.autopilot.pointing_device.click()
181\ No newline at end of file
182+ return item
183
184=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
185--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-06-20 16:10:56 +0000
186+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-07-12 09:37:30 +0000
187@@ -16,7 +16,6 @@
188 from autopilot.platform import model
189 from autopilot.testcase import AutopilotTestCase
190
191-from ubuntu_weather_app.emulators.main_window import MainWindow
192 from ubuntu_weather_app.emulators.ubuntusdk import ubuntusdk
193
194 class WeatherTestCase(AutopilotTestCase):
195@@ -76,7 +75,7 @@
196 @property
197 def main_window(self):
198 return ubuntusdk(self, self.app)#MainWindow(self, self.app)
199-
200+
201
202 class DatabaseMixin(object):
203
204
205=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
206--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-07-03 19:41:03 +0000
207+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-07-12 09:37:30 +0000
208@@ -88,11 +88,11 @@
209 for x in range(6):
210 self.keyboard.press_and_release('BackSpace')
211 self.assertThat(searchField.text, Eventually(Equals("")))
212- self.keyboard.type("Hanbu")
213- for x in range(3):
214- self.keyboard.press_and_release('BackSpace')
215- self.keyboard.type("mburg")
216+ self.keyboard.type("Hamburg")
217 self.keyboard.press_and_release('Enter')
218+ # move the cursor to gain some time
219+ self.pointing_device.move_to_object(resultsList)
220+ self.pointing_device.move_to_object(searchField)
221 firstResult = resultsList.get_children()[0].get_children()[0]
222 self.assertThat(firstResult.text, Eventually(Equals("Hamburg, DE")))
223
224@@ -122,8 +122,8 @@
225 def test_remove_location(self):
226 """Removes location"""
227 # check loading screen diappears
228- loadingPage = self.main_window.get_object("Tabs", "LoadingTabs")
229- self.assertThat(loadingPage.visible, Eventually(Equals(False)))
230+ loadingPage = self.main_window.get_object("Page", "MainPage")
231+ self.assertThat(loadingPage.visible, Eventually(Equals(True)))
232
233 # go to the location manegr
234 self._open_location_manager()
235
236=== modified file 'ubuntu-weather-app.qml'
237--- ubuntu-weather-app.qml 2013-06-26 10:43:49 +0000
238+++ ubuntu-weather-app.qml 2013-07-12 09:37:30 +0000
239@@ -63,7 +63,6 @@
240 tabsString += "}"; // END Tabs componen
241 if(bigLoading !== null) {
242 bigLoading.destroy();
243- tabs.visible = false;
244 }
245 loading.running = false;
246 tabsObject = Qt.createQmlObject(tabsString, tabPage, "tabs")
247@@ -131,6 +130,7 @@
248
249 Page {
250 id: tabPage
251+ objectName: "MainPage"
252 visible: false
253 ActivityIndicator{
254 id:loading
255@@ -144,14 +144,12 @@
256 rightMargin: units.gu(1)
257 }
258 }
259- Tabs {
260- id: tabs
261- objectName: "LoadingTabs"
262- anchors.fill: parent
263- Tab {
264- title: "Loading..."
265- Components.LoadingComponent{id:bigLoading; anchors.fill: parent; z: 2;}
266- }
267+ ActivityIndicator{
268+ id:bigLoading
269+ objectName: "LoadingSpinner"
270+ running: true
271+ z: 1
272+ anchors.centerIn: parent
273 }
274 }
275 }

Subscribers

People subscribed via source and target branches