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
1=== modified file 'tests/autopilot/music_app/__init__.py'
2--- tests/autopilot/music_app/__init__.py 2014-05-23 15:00:21 +0000
3+++ tests/autopilot/music_app/__init__.py 2014-08-18 20:02:22 +0000
4@@ -6,3 +6,256 @@
5 # by the Free Software Foundation.
6
7 """music-app tests and emulators - top level package."""
8+import ubuntuuitoolkit
9+from time import sleep
10+
11+
12+class MainView(ubuntuuitoolkit.MainView):
13+
14+ """An emulator class that makes it easy to interact with the
15+ music-app.
16+ """
17+ retry_delay = 0.2
18+
19+ def get_toolbar(self):
20+ return self.select_single("MusicToolbar",
21+ objectName="musicToolbarObject")
22+
23+ def select_many_retry(self, object_type, **kwargs):
24+ """Returns the item that is searched for with app.select_many
25+ In case of no item was not found (not created yet) a second attempt is
26+ taken 1 second later"""
27+ items = self.select_many(object_type, **kwargs)
28+ tries = 10
29+ while len(items) < 1 and tries > 0:
30+ sleep(self.retry_delay)
31+ items = self.select_many(object_type, **kwargs)
32+ tries = tries - 1
33+ return items
34+
35+ def tap_item(self, item):
36+ self.pointing_device.move_to_object(item)
37+ self.pointing_device.press()
38+ sleep(2)
39+ self.pointing_device.release()
40+
41+ def seek_to_0(self):
42+ # Get the progress bar object
43+ progressBar = self.wait_select_single(
44+ "*", objectName="progressBarShape")
45+
46+ # Move to the progress bar and get the position
47+ self.pointing_device.move_to_object(progressBar)
48+ x1, y1 = self.pointing_device.position()
49+
50+ self.pointing_device.drag(x1, y1, x1 - (progressBar.width / 2) + 1, y1)
51+
52+ def show_toolbar(self):
53+ # Get the toolbar object and create a mouse
54+ toolbar = self.get_toolbar()
55+
56+ # Move to the toolbar and get the position
57+ self.pointing_device.move_to_object(toolbar)
58+ x1, y1 = self.pointing_device.position()
59+
60+ y1 -= (toolbar.height / 2) + 1 # get position at top of toolbar
61+
62+ self.pointing_device.drag(x1, y1, x1, y1 - toolbar.fullHeight)
63+
64+ def add_to_queue_from_albums_tab_album_page(self, artistName, trackTitle):
65+ # switch to albums tab
66+ self.switch_to_tab("albumstab")
67+
68+ # select album
69+ albumartist = self.get_albums_albumartist(artistName)
70+ self.pointing_device.click_object(albumartist)
71+
72+ # get track item to swipe and queue
73+ trackitem = self.get_songs_page_listview_tracktitle(trackTitle)
74+ songspage = self.get_songs_page_listview()
75+
76+ # get coordinates to swipe
77+ start_x = int(songspage.globalRect.x +
78+ (songspage.globalRect.width * 0.9))
79+ stop_x = int(songspage.globalRect.x)
80+ line_y = int(trackitem.globalRect.y)
81+
82+ # swipe to add to queue
83+ self.pointing_device.move(start_x, line_y)
84+ self.pointing_device.drag(start_x, line_y, stop_x, line_y)
85+
86+ # click on add to queue
87+ queueaction = self.get_add_to_queue_action()
88+ self.pointing_device.click_object(queueaction)
89+
90+ def tap_new_playlist_action(self):
91+ header = self.get_header()
92+ header.click_action_button('newplaylistButton')
93+
94+ def get_player(self):
95+ return self.select_single("*", objectName="player")
96+
97+ def get_play_button(self):
98+ return self.wait_select_single("*", objectName="playshape")
99+
100+ def get_now_playing_play_button(self):
101+ return self.wait_select_single("*", objectName="nowPlayingPlayShape")
102+
103+ def get_repeat_button(self):
104+ return self.wait_select_single("*", objectName="repeatShape")
105+
106+ def get_shuffle_button(self):
107+ return self.wait_select_single("*", objectName="shuffleShape")
108+
109+ def get_forward_button(self):
110+ return self.wait_select_single("*", objectName="forwardshape")
111+
112+ def get_previous_button(self):
113+ return self.wait_select_single("*", objectName="previousshape")
114+
115+ def get_player_control_title(self):
116+ return self.select_single("Label", objectName="playercontroltitle")
117+
118+ def get_spinner(self):
119+ return self.select_single("ActivityIndicator",
120+ objectName="LoadingSpinner")
121+
122+ def get_first_genre_item(self):
123+ return self.wait_select_single("*", objectName="genreItemObject")
124+
125+ def get_albumstab(self):
126+ return self.select_single("Tab", objectName="albumstab")
127+
128+ def get_albums_albumartist_list(self):
129+ return self.select_many("Label", objectName="albums-albumartist")
130+
131+ def get_albums_albumartist(self, artistName):
132+ albumartistList = self.get_albums_albumartist_list()
133+ for item in albumartistList:
134+ if item.text == artistName:
135+ return item
136+
137+ def get_add_to_queue_action(self):
138+ return self.wait_select_single("*",
139+ objectName="addToQueueAction",
140+ primed=True)
141+
142+ def get_add_to_playlist_action(self):
143+ return self.wait_select_single("*",
144+ objectName="addToPlaylistAction",
145+ primed=True)
146+
147+ def get_add_to_queue_button(self):
148+ return self.wait_select_single("QQuickImage",
149+ objectName="albumpage-queue-all")
150+
151+ def get_album_page_artist(self):
152+ return self.wait_select_single("Label",
153+ objectName="albumpage-albumartist")
154+
155+ def get_songs_page_artist(self):
156+ return self.wait_select_single("Label",
157+ objectName="songspage-albumartist")
158+
159+ def get_artist_page_artist(self):
160+ return self.wait_select_single("Label",
161+ objectName="artistpage-albumartist")
162+
163+ def get_artist_page_artist_cover(self):
164+ return self.wait_select_single("*",
165+ objectName="artistpage-albumcover")
166+
167+ def get_artiststab(self):
168+ return self.select_single("Tab", objectName="artiststab")
169+
170+ def get_artists_artist_list(self):
171+ return self.select_many("Label", objectName="artists-artist")
172+
173+ def get_artists_artist(self, artistName):
174+ artistList = self.get_artists_artist_list()
175+ for item in artistList:
176+ if item.text == artistName:
177+ return item
178+
179+ def close_buttons(self):
180+ return self.select_many("Button", text="close")
181+
182+ def get_album_page_listview_tracktitle(self, trackTitle):
183+ tracktitles = self.select_many_retry(
184+ "Label", objectName="albumpage-tracktitle")
185+ for item in tracktitles:
186+ if item.text == trackTitle:
187+ return item
188+
189+ def get_songs_page_listview_tracktitle(self, trackTitle):
190+ tracktitles = self.select_many_retry(
191+ "Label", objectName="songspage-tracktitle")
192+ for item in tracktitles:
193+ if item.text == trackTitle:
194+ return item
195+
196+ def get_queue_track_count(self):
197+ queuelist = self.select_single(
198+ "QQuickListView", objectName="queuelist")
199+ return queuelist.count
200+
201+ def get_queue_now_playing_artist(self, artistName):
202+ playingartists = self.select_many(
203+ "Label", objectName="nowplayingartist")
204+ for item in playingartists:
205+ if item.text == artistName:
206+ return item
207+
208+ def get_queue_now_playing_title(self, trackTitle):
209+ playingtitles = self.select_many(
210+ "Label", objectName="nowplayingtitle")
211+ for item in playingtitles:
212+ if item.text == trackTitle:
213+ return item
214+
215+ def get_tracks_tab_listview(self):
216+ return self.select_single("QQuickListView",
217+ objectName="trackstab-listview")
218+
219+ def get_songs_page_listview(self):
220+ return self.select_single("QQuickListView",
221+ objectName="songspage-listview")
222+
223+ def get_songs_tab_tracktitle(self, trackTitle):
224+ tracktitles = self.select_many_retry(
225+ "Label", objectName="tracktitle")
226+ for item in tracktitles:
227+ if item.text == trackTitle:
228+ return item
229+
230+ def get_newPlaylistDialog_createButton(self):
231+ return self.wait_select_single(
232+ "Button", objectName="newPlaylistDialog_createButton")
233+
234+ def get_newPlaylistDialog_name_textfield(self):
235+ return self.wait_select_single(
236+ "TextField", objectName="playlistnameTextfield")
237+
238+ def get_addtoplaylistview(self):
239+ return self.wait_select_single(
240+ "QQuickListView", objectName="addtoplaylistview")
241+
242+ def get_playlistname(self, playlistname):
243+ playlistnames = self.select_many_retry(
244+ "Standard", objectName="playlist")
245+ for item in playlistnames:
246+ if item.name == playlistname:
247+ return item
248+
249+ def get_playlistslist(self):
250+ return self.wait_select_single(
251+ "QQuickListView", objectName="playlistslist")
252+
253+ def get_MusicNowPlaying_page(self):
254+ return self.wait_select_single(
255+ "MusicNowPlaying", objectName="nowplayingpage")
256+
257+ def get_swipedelete_icon(self):
258+ return self.wait_select_single(
259+ "*", objectName="swipeDeleteAction",
260+ primed=True)
261
262=== removed file 'tests/autopilot/music_app/emulators.py'
263--- tests/autopilot/music_app/emulators.py 2014-08-07 19:14:02 +0000
264+++ tests/autopilot/music_app/emulators.py 1970-01-01 00:00:00 +0000
265@@ -1,261 +0,0 @@
266-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
267-# Copyright 2013, 2014 Canonical
268-#
269-# This program is free software: you can redistribute it and/or modify it
270-# under the terms of the GNU General Public License version 3, as published
271-# by the Free Software Foundation.
272-
273-"""Music app autopilot emulators."""
274-from ubuntuuitoolkit import emulators as toolkit_emulators
275-from time import sleep
276-
277-
278-class MainView(toolkit_emulators.MainView):
279-
280- """An emulator class that makes it easy to interact with the
281- music-app.
282- """
283- retry_delay = 0.2
284-
285- def get_toolbar(self):
286- return self.select_single("MusicToolbar",
287- objectName="musicToolbarObject")
288-
289- def select_many_retry(self, object_type, **kwargs):
290- """Returns the item that is searched for with app.select_many
291- In case of no item was not found (not created yet) a second attempt is
292- taken 1 second later"""
293- items = self.select_many(object_type, **kwargs)
294- tries = 10
295- while len(items) < 1 and tries > 0:
296- sleep(self.retry_delay)
297- items = self.select_many(object_type, **kwargs)
298- tries = tries - 1
299- return items
300-
301- def tap_item(self, item):
302- self.pointing_device.move_to_object(item)
303- self.pointing_device.press()
304- sleep(2)
305- self.pointing_device.release()
306-
307- def seek_to_0(self):
308- # Get the progress bar object
309- progressBar = self.wait_select_single(
310- "*", objectName="progressBarShape")
311-
312- # Move to the progress bar and get the position
313- self.pointing_device.move_to_object(progressBar)
314- x1, y1 = self.pointing_device.position()
315-
316- self.pointing_device.drag(x1, y1, x1 - (progressBar.width / 2) + 1, y1)
317-
318- def show_toolbar(self):
319- # Get the toolbar object and create a mouse
320- toolbar = self.get_toolbar()
321-
322- # Move to the toolbar and get the position
323- self.pointing_device.move_to_object(toolbar)
324- x1, y1 = self.pointing_device.position()
325-
326- y1 -= (toolbar.height / 2) + 1 # get position at top of toolbar
327-
328- self.pointing_device.drag(x1, y1, x1, y1 - toolbar.fullHeight)
329-
330- def add_to_queue_from_albums_tab_album_page(self, artistName, trackTitle):
331- # switch to albums tab
332- self.switch_to_tab("albumstab")
333-
334- # select album
335- albumartist = self.get_albums_albumartist(artistName)
336- self.pointing_device.click_object(albumartist)
337-
338- # get track item to swipe and queue
339- trackitem = self.get_songs_page_listview_tracktitle(trackTitle)
340- songspage = self.get_songs_page_listview()
341-
342- # get coordinates to swipe
343- start_x = int(songspage.globalRect.x +
344- (songspage.globalRect.width * 0.9))
345- stop_x = int(songspage.globalRect.x)
346- line_y = int(trackitem.globalRect.y)
347-
348- # swipe to add to queue
349- self.pointing_device.move(start_x, line_y)
350- self.pointing_device.drag(start_x, line_y, stop_x, line_y)
351-
352- # click on add to queue
353- queueaction = self.get_add_to_queue_action()
354- self.pointing_device.click_object(queueaction)
355-
356- def tap_new_playlist_action(self):
357- header = self.get_header()
358- header.click_action_button('newplaylistButton')
359-
360- def get_player(self):
361- return self.select_single("*", objectName="player")
362-
363- def get_play_button(self):
364- return self.wait_select_single("*", objectName="playshape")
365-
366- def get_now_playing_play_button(self):
367- return self.wait_select_single("*", objectName="nowPlayingPlayShape")
368-
369- def get_repeat_button(self):
370- return self.wait_select_single("*", objectName="repeatShape")
371-
372- def get_shuffle_button(self):
373- return self.wait_select_single("*", objectName="shuffleShape")
374-
375- def get_forward_button(self):
376- return self.wait_select_single("*", objectName="forwardshape")
377-
378- def get_previous_button(self):
379- return self.wait_select_single("*", objectName="previousshape")
380-
381- def get_player_control_title(self):
382- return self.select_single("Label", objectName="playercontroltitle")
383-
384- def get_spinner(self):
385- return self.select_single("ActivityIndicator",
386- objectName="LoadingSpinner")
387-
388- def get_first_genre_item(self):
389- return self.wait_select_single("*", objectName="genreItemObject")
390-
391- def get_albumstab(self):
392- return self.select_single("Tab", objectName="albumstab")
393-
394- def get_albums_albumartist_list(self):
395- return self.select_many("Label", objectName="albums-albumartist")
396-
397- def get_albums_albumartist(self, artistName):
398- albumartistList = self.get_albums_albumartist_list()
399- for item in albumartistList:
400- if item.text == artistName:
401- return item
402-
403- def get_add_to_queue_action(self):
404- return self.wait_select_single("*",
405- objectName="addToQueueAction",
406- primed=True)
407-
408- def get_add_to_playlist_action(self):
409- return self.wait_select_single("*",
410- objectName="addToPlaylistAction",
411- primed=True)
412-
413- def get_add_to_queue_button(self):
414- return self.wait_select_single("QQuickImage",
415- objectName="albumpage-queue-all")
416-
417- def get_album_page_artist(self):
418- return self.wait_select_single("Label",
419- objectName="albumpage-albumartist")
420-
421- def get_songs_page_artist(self):
422- return self.wait_select_single("Label",
423- objectName="songspage-albumartist")
424-
425- def get_artist_page_artist(self):
426- return self.wait_select_single("Label",
427- objectName="artistpage-albumartist")
428-
429- def get_artist_page_artist_cover(self):
430- return self.wait_select_single("*",
431- objectName="artistpage-albumcover")
432-
433- def get_artiststab(self):
434- return self.select_single("Tab", objectName="artiststab")
435-
436- def get_artists_artist_list(self):
437- return self.select_many("Label", objectName="artists-artist")
438-
439- def get_artists_artist(self, artistName):
440- artistList = self.get_artists_artist_list()
441- for item in artistList:
442- if item.text == artistName:
443- return item
444-
445- def close_buttons(self):
446- return self.select_many("Button", text="close")
447-
448- def get_album_page_listview_tracktitle(self, trackTitle):
449- tracktitles = self.select_many_retry(
450- "Label", objectName="albumpage-tracktitle")
451- for item in tracktitles:
452- if item.text == trackTitle:
453- return item
454-
455- def get_songs_page_listview_tracktitle(self, trackTitle):
456- tracktitles = self.select_many_retry(
457- "Label", objectName="songspage-tracktitle")
458- for item in tracktitles:
459- if item.text == trackTitle:
460- return item
461-
462- def get_queue_track_count(self):
463- queuelist = self.select_single(
464- "QQuickListView", objectName="queuelist")
465- return queuelist.count
466-
467- def get_queue_now_playing_artist(self, artistName):
468- playingartists = self.select_many(
469- "Label", objectName="nowplayingartist")
470- for item in playingartists:
471- if item.text == artistName:
472- return item
473-
474- def get_queue_now_playing_title(self, trackTitle):
475- playingtitles = self.select_many(
476- "Label", objectName="nowplayingtitle")
477- for item in playingtitles:
478- if item.text == trackTitle:
479- return item
480-
481- def get_tracks_tab_listview(self):
482- return self.select_single("QQuickListView",
483- objectName="trackstab-listview")
484-
485- def get_songs_page_listview(self):
486- return self.select_single("QQuickListView",
487- objectName="songspage-listview")
488-
489- def get_songs_tab_tracktitle(self, trackTitle):
490- tracktitles = self.select_many_retry(
491- "Label", objectName="tracktitle")
492- for item in tracktitles:
493- if item.text == trackTitle:
494- return item
495-
496- def get_newPlaylistDialog_createButton(self):
497- return self.wait_select_single(
498- "Button", objectName="newPlaylistDialog_createButton")
499-
500- def get_newPlaylistDialog_name_textfield(self):
501- return self.wait_select_single(
502- "TextField", objectName="playlistnameTextfield")
503-
504- def get_addtoplaylistview(self):
505- return self.wait_select_single(
506- "QQuickListView", objectName="addtoplaylistview")
507-
508- def get_playlistname(self, playlistname):
509- playlistnames = self.select_many_retry(
510- "Standard", objectName="playlist")
511- for item in playlistnames:
512- if item.name == playlistname:
513- return item
514-
515- def get_playlistslist(self):
516- return self.wait_select_single(
517- "QQuickListView", objectName="playlistslist")
518-
519- def get_MusicNowPlaying_page(self):
520- return self.wait_select_single(
521- "MusicNowPlaying", objectName="nowplayingpage")
522-
523- def get_swipedelete_icon(self):
524- return self.wait_select_single(
525- "*", objectName="swipeDeleteAction",
526- primed=True)
527
528=== modified file 'tests/autopilot/music_app/tests/__init__.py'
529--- tests/autopilot/music_app/tests/__init__.py 2014-06-27 01:23:04 +0000
530+++ tests/autopilot/music_app/tests/__init__.py 2014-08-18 20:02:22 +0000
531@@ -15,16 +15,16 @@
532 import music_app
533
534 import fixtures
535-from music_app import emulators
536+from music_app import MainView
537
538 from autopilot import logging as autopilot_logging
539 from autopilot.input import Mouse, Touch, Pointer
540 from autopilot.platform import model
541 from autopilot.testcase import AutopilotTestCase
542
543+import ubuntuuitoolkit
544 from ubuntuuitoolkit import (
545 base,
546- emulators as toolkit_emulators,
547 fixture_setup as toolkit_fixtures
548 )
549
550@@ -75,7 +75,7 @@
551 self.local_location,
552 "debug",
553 app_type='qt',
554- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
555+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
556
557 @autopilot_logging.log_action(logger.info)
558 def launch_test_installed(self):
559@@ -84,13 +84,13 @@
560 self.installed_location,
561 "debug",
562 app_type='qt',
563- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
564+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
565
566 @autopilot_logging.log_action(logger.info)
567 def launch_test_click(self):
568 self.app = self.launch_click_package(
569 "com.ubuntu.music",
570- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
571+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
572
573 def _copy_xauthority_file(self, directory):
574 """ Copy .Xauthority file to directory, if it exists in /home
575@@ -251,4 +251,4 @@
576
577 @property
578 def main_view(self):
579- return self.app.select_single(emulators.MainView)
580+ return self.app.select_single(MainView)

Subscribers

People subscribed via source and target branches

to status/vote changes: