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

Proposed by Martin Borho
Status: Merged
Approved by: Martin Borho
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) Approve
Günter Schwann (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
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.
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
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
Revision history for this message
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
Revision history for this message
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
=== removed file 'tests/autopilot/ubuntu_weather_app/emulators/main_window.py'
--- tests/autopilot/ubuntu_weather_app/emulators/main_window.py 2013-06-20 16:10:06 +0000
+++ tests/autopilot/ubuntu_weather_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8
9class MainWindow(object):
10 """An emulator class that makes it easy to interact with the weather app"""
11
12 def __init__(self, autopilot, app):
13 self.app = app
14 self.autopilot= autopilot
15
16 def get_qml_view(self):
17 return self.app.select_single("QQuickView")
18
19 def get_object(self, typeName, name):
20 """Get a specific object"""
21 return self.app.select_single(typeName, objectName=name)
22
23 def get_objects(self, typeName, name):
24 """Get more than one object"""
25 return self.app.select_many(typeName, objectName=name)
260
=== modified file 'tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py'
--- tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-07-03 19:57:03 +0000
+++ tests/autopilot/ubuntu_weather_app/emulators/ubuntusdk.py 2013-07-12 09:37:30 +0000
@@ -38,6 +38,10 @@
38 """Get more than one object"""38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)39 return self.app.select_many(typeName, objectName=name)
4040
41 def get_tabs(self):
42 """Return all tabs"""
43 return self.app.select_single("Tabs")
44
41 def switch_to_tab(self, tab):45 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""46 """Switch to the specified tab number"""
43 tabs = self.get_tabs()47 tabs = self.get_tabs()
@@ -46,11 +50,37 @@
46 #perform operations until tab == currentTab50 #perform operations until tab == currentTab
47 while tab != currentTab:51 while tab != currentTab:
48 if tab > currentTab:52 if tab > currentTab:
53 self._next_tab()
54 if tab < currentTab:
49 self._previous_tab()55 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex56 currentTab = tabs.selectedTabIndex
5357
58 def _previous_tab(self):
59 """Switch to the previous tab"""
60 qmlView = self.get_qml_view()
61
62 startX = int(qmlView.x + qmlView.width * 0.10)
63 stopX = int(qmlView.x + qmlView.width * 0.45)
64 lineY = int(qmlView.y + qmlView.height * 0.05)
65
66 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
67 self.autopilot.pointing_device.move(startX, lineY)
68 self.autopilot.pointing_device.click()
69 self.autopilot.pointing_device.click()
70
71 def _next_tab(self):
72 """Switch to the next tab"""
73 qmlView = self.get_qml_view()
74
75 startX = int(qmlView.x + qmlView.width * 0.45)
76 stopX = int(qmlView.x + qmlView.width * 0.10)
77 lineY = int(qmlView.y + qmlView.height * 0.05)
78
79 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
80 self.autopilot.pointing_device.move(startX, lineY)
81 self.autopilot.pointing_device.click()
82 self.autopilot.pointing_device.click()
83
54 def toggle_toolbar(self):84 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""85 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not86 #check and see if the toolbar is open or not
@@ -63,23 +93,29 @@
63 """Returns the toolbar in the main events view."""93 """Returns the toolbar in the main events view."""
64 return self.app.select_single("Toolbar")94 return self.app.select_single("Toolbar")
6595
66 def get_toolbar_button(self, buttonName):96 def get_toolbar_button(self, buttonObject):
67 """Returns the toolbar button at position index"""97 """Returns the toolbar button with objectName buttonObject"""
68 toolbar = self.get_toolbar()98 toolbar = self.get_toolbar()
69 if not toolbar.opened:99 if not toolbar.opened:
70 self.open_toolbar()100 self.open_toolbar()
71 button = self.get_object('ActionItem', buttonName)101 buttonList = toolbar.select_many("ActionItem")
72 return button102 #old version is ToolbarButton
103 if not buttonList:
104 buttonList = toolbar.select_many("ToolbarButton")
105 for button in buttonList:
106 if button.objectName == buttonObject:
107 return button
73108
74 def click_toolbar_button(self, buttonName):109 def click_toolbar_button(self, buttonObject):
75 """Clicks the toolbar button with buttonLabel"""110 """Clicks the toolbar button with objectName buttonObject"""
76 #The toolbar button is assumed to be the following format111 #The toolbar button is assumed to be the following format
77 #ToolbarItems {112 #Toolbar {
78 # ToolbarButton {113 # ...
114 # ActionItem {
79 # objectName: "name"115 # objectName: "name"
80 # text: value116 button = self.get_toolbar_button(buttonObject)
81 button = self.get_toolbar_button(buttonName)
82 self.autopilot.pointing_device.click_object(button)117 self.autopilot.pointing_device.click_object(button)
118 return button
83119
84 def open_toolbar(self):120 def open_toolbar(self):
85 """Open the toolbar"""121 """Open the toolbar"""
@@ -106,44 +142,16 @@
106 At the moment this only works for values that are currently visible. To142 At the moment this only works for values that are currently visible. To
107 access the remaining items, a help method to drag and recheck is needed."""143 access the remaining items, a help method to drag and recheck is needed."""
108 #The popover is assumed to be the following format144 #The popover is assumed to be the following format
109 # Popover {145 #Component {
110 # Column {146 # id: actionSelectionPopover
111 # ListView {147 #
112 # delegate: Standard {148 #ActionSelectionPopover {
113 # objectName: "name"149 # actions: ActionList {
114 # text: value150 # Action {
115151
116 self.autopilot.pointing_device.click_object(button)152 popList = self.get_object("ActionSelectionPopover", popover)
117 #we'll get all matching objects, incase the popover is reused between buttons153 itemList = popList.select_many("Label")
118 itemList = lambda: self.get_objects("Standard", popover)154 for item in itemList:
119155 if item.text == value:
120 for item in itemList():
121 if item.get_properties()['text'] == value:
122 self.autopilot.pointing_device.click_object(item)156 self.autopilot.pointing_device.click_object(item)
123
124 def get_tabs(self):
125 """Return all tabs"""
126 return self.get_object("Tabs", "rootTabs")
127
128 def _previous_tab(self):
129 """Switch to the previous tab"""
130 qmlView = self.get_qml_view()
131
132 startX = int(qmlView.x + qmlView.width * 0.35)
133 stopX = int(qmlView.x + qmlView.width * 0.50)
134 lineY = int(qmlView.y + qmlView.height * 0.05)
135
136 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
137 self.autopilot.pointing_device.click()
138 self.autopilot.pointing_device.click()
139
140 def _next_tab(self):
141 """Switch to the next tab"""
142 qmlView = self.get_qml_view()
143
144 startX = int(qmlView.x + qmlView.width * 0.50)
145 stopX = int(qmlView.x + qmlView.width * 0.35)
146 lineY = int(qmlView.y + qmlView.height * 0.05)
147
148 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
149 self.autopilot.pointing_device.click()
150\ No newline at end of file157\ No newline at end of file
158 return item
151159
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-06-20 16:10:56 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2013-07-12 09:37:30 +0000
@@ -16,7 +16,6 @@
16from autopilot.platform import model16from autopilot.platform import model
17from autopilot.testcase import AutopilotTestCase17from autopilot.testcase import AutopilotTestCase
1818
19from ubuntu_weather_app.emulators.main_window import MainWindow
20from ubuntu_weather_app.emulators.ubuntusdk import ubuntusdk19from ubuntu_weather_app.emulators.ubuntusdk import ubuntusdk
2120
22class WeatherTestCase(AutopilotTestCase):21class WeatherTestCase(AutopilotTestCase):
@@ -76,7 +75,7 @@
76 @property75 @property
77 def main_window(self):76 def main_window(self):
78 return ubuntusdk(self, self.app)#MainWindow(self, self.app)77 return ubuntusdk(self, self.app)#MainWindow(self, self.app)
79 78
8079
81class DatabaseMixin(object):80class DatabaseMixin(object):
8281
8382
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-07-03 19:41:03 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-07-12 09:37:30 +0000
@@ -88,11 +88,11 @@
88 for x in range(6):88 for x in range(6):
89 self.keyboard.press_and_release('BackSpace')89 self.keyboard.press_and_release('BackSpace')
90 self.assertThat(searchField.text, Eventually(Equals("")))90 self.assertThat(searchField.text, Eventually(Equals("")))
91 self.keyboard.type("Hanbu")91 self.keyboard.type("Hamburg")
92 for x in range(3):
93 self.keyboard.press_and_release('BackSpace')
94 self.keyboard.type("mburg")
95 self.keyboard.press_and_release('Enter')92 self.keyboard.press_and_release('Enter')
93 # move the cursor to gain some time
94 self.pointing_device.move_to_object(resultsList)
95 self.pointing_device.move_to_object(searchField)
96 firstResult = resultsList.get_children()[0].get_children()[0]96 firstResult = resultsList.get_children()[0].get_children()[0]
97 self.assertThat(firstResult.text, Eventually(Equals("Hamburg, DE")))97 self.assertThat(firstResult.text, Eventually(Equals("Hamburg, DE")))
9898
@@ -122,8 +122,8 @@
122 def test_remove_location(self):122 def test_remove_location(self):
123 """Removes location"""123 """Removes location"""
124 # check loading screen diappears124 # check loading screen diappears
125 loadingPage = self.main_window.get_object("Tabs", "LoadingTabs")125 loadingPage = self.main_window.get_object("Page", "MainPage")
126 self.assertThat(loadingPage.visible, Eventually(Equals(False)))126 self.assertThat(loadingPage.visible, Eventually(Equals(True)))
127127
128 # go to the location manegr128 # go to the location manegr
129 self._open_location_manager()129 self._open_location_manager()
130130
=== modified file 'ubuntu-weather-app.qml'
--- ubuntu-weather-app.qml 2013-06-26 10:43:49 +0000
+++ ubuntu-weather-app.qml 2013-07-12 09:37:30 +0000
@@ -63,7 +63,6 @@
63 tabsString += "}"; // END Tabs componen63 tabsString += "}"; // END Tabs componen
64 if(bigLoading !== null) {64 if(bigLoading !== null) {
65 bigLoading.destroy();65 bigLoading.destroy();
66 tabs.visible = false;
67 }66 }
68 loading.running = false;67 loading.running = false;
69 tabsObject = Qt.createQmlObject(tabsString, tabPage, "tabs")68 tabsObject = Qt.createQmlObject(tabsString, tabPage, "tabs")
@@ -131,6 +130,7 @@
131130
132 Page {131 Page {
133 id: tabPage132 id: tabPage
133 objectName: "MainPage"
134 visible: false134 visible: false
135 ActivityIndicator{135 ActivityIndicator{
136 id:loading136 id:loading
@@ -144,14 +144,12 @@
144 rightMargin: units.gu(1)144 rightMargin: units.gu(1)
145 }145 }
146 }146 }
147 Tabs {147 ActivityIndicator{
148 id: tabs148 id:bigLoading
149 objectName: "LoadingTabs"149 objectName: "LoadingSpinner"
150 anchors.fill: parent150 running: true
151 Tab {151 z: 1
152 title: "Loading..."152 anchors.centerIn: parent
153 Components.LoadingComponent{id:bigLoading; anchors.fill: parent; z: 2;}
154 }
155 }153 }
156 }154 }
157 }155 }

Subscribers

People subscribed via source and target branches