Merge lp:~ahayzen/music-app/ap-new-emulators-1341681 into lp:music-app/trusty

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 583
Merged at revision: 583
Proposed branch: lp:~ahayzen/music-app/ap-new-emulators-1341681
Merge into: lp:music-app/trusty
Diff against target: 580 lines (+259/-267)
3 files modified
tests/autopilot/music_app/__init__.py (+253/-0)
tests/autopilot/music_app/emulators.py (+0/-261)
tests/autopilot/music_app/tests/__init__.py (+6/-6)
To merge this branch: bzr merge lp:~ahayzen/music-app/ap-new-emulators-1341681
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+231256@code.launchpad.net

Commit message

* Switch to custom proxy object emulator, instead of calling via old emulators module

Description of the change

* Switch to custom proxy object emulator, instead of calling via old emulators module

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
Nicholas Skaggs (nskaggs) wrote :

LGTM

review: Approve
Revision history for this message
Victor Thompson (vthompson) wrote :

Looks good to me. I was going to suggest we move the class docstring to be immediately after the class declaration, as that seems to be the way it's usually done, but it was like that before.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/music_app/__init__.py'
--- tests/autopilot/music_app/__init__.py 2014-05-23 15:00:21 +0000
+++ tests/autopilot/music_app/__init__.py 2014-08-18 20:02:22 +0000
@@ -6,3 +6,256 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8"""music-app tests and emulators - top level package."""8"""music-app tests and emulators - top level package."""
9import ubuntuuitoolkit
10from time import sleep
11
12
13class MainView(ubuntuuitoolkit.MainView):
14
15 """An emulator class that makes it easy to interact with the
16 music-app.
17 """
18 retry_delay = 0.2
19
20 def get_toolbar(self):
21 return self.select_single("MusicToolbar",
22 objectName="musicToolbarObject")
23
24 def select_many_retry(self, object_type, **kwargs):
25 """Returns the item that is searched for with app.select_many
26 In case of no item was not found (not created yet) a second attempt is
27 taken 1 second later"""
28 items = self.select_many(object_type, **kwargs)
29 tries = 10
30 while len(items) < 1 and tries > 0:
31 sleep(self.retry_delay)
32 items = self.select_many(object_type, **kwargs)
33 tries = tries - 1
34 return items
35
36 def tap_item(self, item):
37 self.pointing_device.move_to_object(item)
38 self.pointing_device.press()
39 sleep(2)
40 self.pointing_device.release()
41
42 def seek_to_0(self):
43 # Get the progress bar object
44 progressBar = self.wait_select_single(
45 "*", objectName="progressBarShape")
46
47 # Move to the progress bar and get the position
48 self.pointing_device.move_to_object(progressBar)
49 x1, y1 = self.pointing_device.position()
50
51 self.pointing_device.drag(x1, y1, x1 - (progressBar.width / 2) + 1, y1)
52
53 def show_toolbar(self):
54 # Get the toolbar object and create a mouse
55 toolbar = self.get_toolbar()
56
57 # Move to the toolbar and get the position
58 self.pointing_device.move_to_object(toolbar)
59 x1, y1 = self.pointing_device.position()
60
61 y1 -= (toolbar.height / 2) + 1 # get position at top of toolbar
62
63 self.pointing_device.drag(x1, y1, x1, y1 - toolbar.fullHeight)
64
65 def add_to_queue_from_albums_tab_album_page(self, artistName, trackTitle):
66 # switch to albums tab
67 self.switch_to_tab("albumstab")
68
69 # select album
70 albumartist = self.get_albums_albumartist(artistName)
71 self.pointing_device.click_object(albumartist)
72
73 # get track item to swipe and queue
74 trackitem = self.get_songs_page_listview_tracktitle(trackTitle)
75 songspage = self.get_songs_page_listview()
76
77 # get coordinates to swipe
78 start_x = int(songspage.globalRect.x +
79 (songspage.globalRect.width * 0.9))
80 stop_x = int(songspage.globalRect.x)
81 line_y = int(trackitem.globalRect.y)
82
83 # swipe to add to queue
84 self.pointing_device.move(start_x, line_y)
85 self.pointing_device.drag(start_x, line_y, stop_x, line_y)
86
87 # click on add to queue
88 queueaction = self.get_add_to_queue_action()
89 self.pointing_device.click_object(queueaction)
90
91 def tap_new_playlist_action(self):
92 header = self.get_header()
93 header.click_action_button('newplaylistButton')
94
95 def get_player(self):
96 return self.select_single("*", objectName="player")
97
98 def get_play_button(self):
99 return self.wait_select_single("*", objectName="playshape")
100
101 def get_now_playing_play_button(self):
102 return self.wait_select_single("*", objectName="nowPlayingPlayShape")
103
104 def get_repeat_button(self):
105 return self.wait_select_single("*", objectName="repeatShape")
106
107 def get_shuffle_button(self):
108 return self.wait_select_single("*", objectName="shuffleShape")
109
110 def get_forward_button(self):
111 return self.wait_select_single("*", objectName="forwardshape")
112
113 def get_previous_button(self):
114 return self.wait_select_single("*", objectName="previousshape")
115
116 def get_player_control_title(self):
117 return self.select_single("Label", objectName="playercontroltitle")
118
119 def get_spinner(self):
120 return self.select_single("ActivityIndicator",
121 objectName="LoadingSpinner")
122
123 def get_first_genre_item(self):
124 return self.wait_select_single("*", objectName="genreItemObject")
125
126 def get_albumstab(self):
127 return self.select_single("Tab", objectName="albumstab")
128
129 def get_albums_albumartist_list(self):
130 return self.select_many("Label", objectName="albums-albumartist")
131
132 def get_albums_albumartist(self, artistName):
133 albumartistList = self.get_albums_albumartist_list()
134 for item in albumartistList:
135 if item.text == artistName:
136 return item
137
138 def get_add_to_queue_action(self):
139 return self.wait_select_single("*",
140 objectName="addToQueueAction",
141 primed=True)
142
143 def get_add_to_playlist_action(self):
144 return self.wait_select_single("*",
145 objectName="addToPlaylistAction",
146 primed=True)
147
148 def get_add_to_queue_button(self):
149 return self.wait_select_single("QQuickImage",
150 objectName="albumpage-queue-all")
151
152 def get_album_page_artist(self):
153 return self.wait_select_single("Label",
154 objectName="albumpage-albumartist")
155
156 def get_songs_page_artist(self):
157 return self.wait_select_single("Label",
158 objectName="songspage-albumartist")
159
160 def get_artist_page_artist(self):
161 return self.wait_select_single("Label",
162 objectName="artistpage-albumartist")
163
164 def get_artist_page_artist_cover(self):
165 return self.wait_select_single("*",
166 objectName="artistpage-albumcover")
167
168 def get_artiststab(self):
169 return self.select_single("Tab", objectName="artiststab")
170
171 def get_artists_artist_list(self):
172 return self.select_many("Label", objectName="artists-artist")
173
174 def get_artists_artist(self, artistName):
175 artistList = self.get_artists_artist_list()
176 for item in artistList:
177 if item.text == artistName:
178 return item
179
180 def close_buttons(self):
181 return self.select_many("Button", text="close")
182
183 def get_album_page_listview_tracktitle(self, trackTitle):
184 tracktitles = self.select_many_retry(
185 "Label", objectName="albumpage-tracktitle")
186 for item in tracktitles:
187 if item.text == trackTitle:
188 return item
189
190 def get_songs_page_listview_tracktitle(self, trackTitle):
191 tracktitles = self.select_many_retry(
192 "Label", objectName="songspage-tracktitle")
193 for item in tracktitles:
194 if item.text == trackTitle:
195 return item
196
197 def get_queue_track_count(self):
198 queuelist = self.select_single(
199 "QQuickListView", objectName="queuelist")
200 return queuelist.count
201
202 def get_queue_now_playing_artist(self, artistName):
203 playingartists = self.select_many(
204 "Label", objectName="nowplayingartist")
205 for item in playingartists:
206 if item.text == artistName:
207 return item
208
209 def get_queue_now_playing_title(self, trackTitle):
210 playingtitles = self.select_many(
211 "Label", objectName="nowplayingtitle")
212 for item in playingtitles:
213 if item.text == trackTitle:
214 return item
215
216 def get_tracks_tab_listview(self):
217 return self.select_single("QQuickListView",
218 objectName="trackstab-listview")
219
220 def get_songs_page_listview(self):
221 return self.select_single("QQuickListView",
222 objectName="songspage-listview")
223
224 def get_songs_tab_tracktitle(self, trackTitle):
225 tracktitles = self.select_many_retry(
226 "Label", objectName="tracktitle")
227 for item in tracktitles:
228 if item.text == trackTitle:
229 return item
230
231 def get_newPlaylistDialog_createButton(self):
232 return self.wait_select_single(
233 "Button", objectName="newPlaylistDialog_createButton")
234
235 def get_newPlaylistDialog_name_textfield(self):
236 return self.wait_select_single(
237 "TextField", objectName="playlistnameTextfield")
238
239 def get_addtoplaylistview(self):
240 return self.wait_select_single(
241 "QQuickListView", objectName="addtoplaylistview")
242
243 def get_playlistname(self, playlistname):
244 playlistnames = self.select_many_retry(
245 "Standard", objectName="playlist")
246 for item in playlistnames:
247 if item.name == playlistname:
248 return item
249
250 def get_playlistslist(self):
251 return self.wait_select_single(
252 "QQuickListView", objectName="playlistslist")
253
254 def get_MusicNowPlaying_page(self):
255 return self.wait_select_single(
256 "MusicNowPlaying", objectName="nowplayingpage")
257
258 def get_swipedelete_icon(self):
259 return self.wait_select_single(
260 "*", objectName="swipeDeleteAction",
261 primed=True)
9262
=== removed file 'tests/autopilot/music_app/emulators.py'
--- tests/autopilot/music_app/emulators.py 2014-08-07 19:14:02 +0000
+++ tests/autopilot/music_app/emulators.py 1970-01-01 00:00:00 +0000
@@ -1,261 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013, 2014 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"""Music app autopilot emulators."""
9from ubuntuuitoolkit import emulators as toolkit_emulators
10from time import sleep
11
12
13class MainView(toolkit_emulators.MainView):
14
15 """An emulator class that makes it easy to interact with the
16 music-app.
17 """
18 retry_delay = 0.2
19
20 def get_toolbar(self):
21 return self.select_single("MusicToolbar",
22 objectName="musicToolbarObject")
23
24 def select_many_retry(self, object_type, **kwargs):
25 """Returns the item that is searched for with app.select_many
26 In case of no item was not found (not created yet) a second attempt is
27 taken 1 second later"""
28 items = self.select_many(object_type, **kwargs)
29 tries = 10
30 while len(items) < 1 and tries > 0:
31 sleep(self.retry_delay)
32 items = self.select_many(object_type, **kwargs)
33 tries = tries - 1
34 return items
35
36 def tap_item(self, item):
37 self.pointing_device.move_to_object(item)
38 self.pointing_device.press()
39 sleep(2)
40 self.pointing_device.release()
41
42 def seek_to_0(self):
43 # Get the progress bar object
44 progressBar = self.wait_select_single(
45 "*", objectName="progressBarShape")
46
47 # Move to the progress bar and get the position
48 self.pointing_device.move_to_object(progressBar)
49 x1, y1 = self.pointing_device.position()
50
51 self.pointing_device.drag(x1, y1, x1 - (progressBar.width / 2) + 1, y1)
52
53 def show_toolbar(self):
54 # Get the toolbar object and create a mouse
55 toolbar = self.get_toolbar()
56
57 # Move to the toolbar and get the position
58 self.pointing_device.move_to_object(toolbar)
59 x1, y1 = self.pointing_device.position()
60
61 y1 -= (toolbar.height / 2) + 1 # get position at top of toolbar
62
63 self.pointing_device.drag(x1, y1, x1, y1 - toolbar.fullHeight)
64
65 def add_to_queue_from_albums_tab_album_page(self, artistName, trackTitle):
66 # switch to albums tab
67 self.switch_to_tab("albumstab")
68
69 # select album
70 albumartist = self.get_albums_albumartist(artistName)
71 self.pointing_device.click_object(albumartist)
72
73 # get track item to swipe and queue
74 trackitem = self.get_songs_page_listview_tracktitle(trackTitle)
75 songspage = self.get_songs_page_listview()
76
77 # get coordinates to swipe
78 start_x = int(songspage.globalRect.x +
79 (songspage.globalRect.width * 0.9))
80 stop_x = int(songspage.globalRect.x)
81 line_y = int(trackitem.globalRect.y)
82
83 # swipe to add to queue
84 self.pointing_device.move(start_x, line_y)
85 self.pointing_device.drag(start_x, line_y, stop_x, line_y)
86
87 # click on add to queue
88 queueaction = self.get_add_to_queue_action()
89 self.pointing_device.click_object(queueaction)
90
91 def tap_new_playlist_action(self):
92 header = self.get_header()
93 header.click_action_button('newplaylistButton')
94
95 def get_player(self):
96 return self.select_single("*", objectName="player")
97
98 def get_play_button(self):
99 return self.wait_select_single("*", objectName="playshape")
100
101 def get_now_playing_play_button(self):
102 return self.wait_select_single("*", objectName="nowPlayingPlayShape")
103
104 def get_repeat_button(self):
105 return self.wait_select_single("*", objectName="repeatShape")
106
107 def get_shuffle_button(self):
108 return self.wait_select_single("*", objectName="shuffleShape")
109
110 def get_forward_button(self):
111 return self.wait_select_single("*", objectName="forwardshape")
112
113 def get_previous_button(self):
114 return self.wait_select_single("*", objectName="previousshape")
115
116 def get_player_control_title(self):
117 return self.select_single("Label", objectName="playercontroltitle")
118
119 def get_spinner(self):
120 return self.select_single("ActivityIndicator",
121 objectName="LoadingSpinner")
122
123 def get_first_genre_item(self):
124 return self.wait_select_single("*", objectName="genreItemObject")
125
126 def get_albumstab(self):
127 return self.select_single("Tab", objectName="albumstab")
128
129 def get_albums_albumartist_list(self):
130 return self.select_many("Label", objectName="albums-albumartist")
131
132 def get_albums_albumartist(self, artistName):
133 albumartistList = self.get_albums_albumartist_list()
134 for item in albumartistList:
135 if item.text == artistName:
136 return item
137
138 def get_add_to_queue_action(self):
139 return self.wait_select_single("*",
140 objectName="addToQueueAction",
141 primed=True)
142
143 def get_add_to_playlist_action(self):
144 return self.wait_select_single("*",
145 objectName="addToPlaylistAction",
146 primed=True)
147
148 def get_add_to_queue_button(self):
149 return self.wait_select_single("QQuickImage",
150 objectName="albumpage-queue-all")
151
152 def get_album_page_artist(self):
153 return self.wait_select_single("Label",
154 objectName="albumpage-albumartist")
155
156 def get_songs_page_artist(self):
157 return self.wait_select_single("Label",
158 objectName="songspage-albumartist")
159
160 def get_artist_page_artist(self):
161 return self.wait_select_single("Label",
162 objectName="artistpage-albumartist")
163
164 def get_artist_page_artist_cover(self):
165 return self.wait_select_single("*",
166 objectName="artistpage-albumcover")
167
168 def get_artiststab(self):
169 return self.select_single("Tab", objectName="artiststab")
170
171 def get_artists_artist_list(self):
172 return self.select_many("Label", objectName="artists-artist")
173
174 def get_artists_artist(self, artistName):
175 artistList = self.get_artists_artist_list()
176 for item in artistList:
177 if item.text == artistName:
178 return item
179
180 def close_buttons(self):
181 return self.select_many("Button", text="close")
182
183 def get_album_page_listview_tracktitle(self, trackTitle):
184 tracktitles = self.select_many_retry(
185 "Label", objectName="albumpage-tracktitle")
186 for item in tracktitles:
187 if item.text == trackTitle:
188 return item
189
190 def get_songs_page_listview_tracktitle(self, trackTitle):
191 tracktitles = self.select_many_retry(
192 "Label", objectName="songspage-tracktitle")
193 for item in tracktitles:
194 if item.text == trackTitle:
195 return item
196
197 def get_queue_track_count(self):
198 queuelist = self.select_single(
199 "QQuickListView", objectName="queuelist")
200 return queuelist.count
201
202 def get_queue_now_playing_artist(self, artistName):
203 playingartists = self.select_many(
204 "Label", objectName="nowplayingartist")
205 for item in playingartists:
206 if item.text == artistName:
207 return item
208
209 def get_queue_now_playing_title(self, trackTitle):
210 playingtitles = self.select_many(
211 "Label", objectName="nowplayingtitle")
212 for item in playingtitles:
213 if item.text == trackTitle:
214 return item
215
216 def get_tracks_tab_listview(self):
217 return self.select_single("QQuickListView",
218 objectName="trackstab-listview")
219
220 def get_songs_page_listview(self):
221 return self.select_single("QQuickListView",
222 objectName="songspage-listview")
223
224 def get_songs_tab_tracktitle(self, trackTitle):
225 tracktitles = self.select_many_retry(
226 "Label", objectName="tracktitle")
227 for item in tracktitles:
228 if item.text == trackTitle:
229 return item
230
231 def get_newPlaylistDialog_createButton(self):
232 return self.wait_select_single(
233 "Button", objectName="newPlaylistDialog_createButton")
234
235 def get_newPlaylistDialog_name_textfield(self):
236 return self.wait_select_single(
237 "TextField", objectName="playlistnameTextfield")
238
239 def get_addtoplaylistview(self):
240 return self.wait_select_single(
241 "QQuickListView", objectName="addtoplaylistview")
242
243 def get_playlistname(self, playlistname):
244 playlistnames = self.select_many_retry(
245 "Standard", objectName="playlist")
246 for item in playlistnames:
247 if item.name == playlistname:
248 return item
249
250 def get_playlistslist(self):
251 return self.wait_select_single(
252 "QQuickListView", objectName="playlistslist")
253
254 def get_MusicNowPlaying_page(self):
255 return self.wait_select_single(
256 "MusicNowPlaying", objectName="nowplayingpage")
257
258 def get_swipedelete_icon(self):
259 return self.wait_select_single(
260 "*", objectName="swipeDeleteAction",
261 primed=True)
2620
=== modified file 'tests/autopilot/music_app/tests/__init__.py'
--- tests/autopilot/music_app/tests/__init__.py 2014-06-27 01:23:04 +0000
+++ tests/autopilot/music_app/tests/__init__.py 2014-08-18 20:02:22 +0000
@@ -15,16 +15,16 @@
15import music_app15import music_app
1616
17import fixtures17import fixtures
18from music_app import emulators18from music_app import MainView
1919
20from autopilot import logging as autopilot_logging20from autopilot import logging as autopilot_logging
21from autopilot.input import Mouse, Touch, Pointer21from autopilot.input import Mouse, Touch, Pointer
22from autopilot.platform import model22from autopilot.platform import model
23from autopilot.testcase import AutopilotTestCase23from autopilot.testcase import AutopilotTestCase
2424
25import ubuntuuitoolkit
25from ubuntuuitoolkit import (26from ubuntuuitoolkit import (
26 base,27 base,
27 emulators as toolkit_emulators,
28 fixture_setup as toolkit_fixtures28 fixture_setup as toolkit_fixtures
29)29)
3030
@@ -75,7 +75,7 @@
75 self.local_location,75 self.local_location,
76 "debug",76 "debug",
77 app_type='qt',77 app_type='qt',
78 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)78 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
7979
80 @autopilot_logging.log_action(logger.info)80 @autopilot_logging.log_action(logger.info)
81 def launch_test_installed(self):81 def launch_test_installed(self):
@@ -84,13 +84,13 @@
84 self.installed_location,84 self.installed_location,
85 "debug",85 "debug",
86 app_type='qt',86 app_type='qt',
87 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)87 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
8888
89 @autopilot_logging.log_action(logger.info)89 @autopilot_logging.log_action(logger.info)
90 def launch_test_click(self):90 def launch_test_click(self):
91 self.app = self.launch_click_package(91 self.app = self.launch_click_package(
92 "com.ubuntu.music",92 "com.ubuntu.music",
93 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)93 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
9494
95 def _copy_xauthority_file(self, directory):95 def _copy_xauthority_file(self, directory):
96 """ Copy .Xauthority file to directory, if it exists in /home96 """ Copy .Xauthority file to directory, if it exists in /home
@@ -251,4 +251,4 @@
251251
252 @property252 @property
253 def main_view(self):253 def main_view(self):
254 return self.app.select_single(emulators.MainView)254 return self.app.select_single(MainView)

Subscribers

People subscribed via source and target branches

to status/vote changes: