Merge lp:~ahayzen/music-app/ap-helper-refactor-002 into lp:music-app/trusty

Proposed by Andrew Hayzen
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 603
Merged at revision: 603
Proposed branch: lp:~ahayzen/music-app/ap-helper-refactor-002
Merge into: lp:music-app/trusty
Diff against target: 841 lines (+233/-203)
4 files modified
MusicNowPlaying.qml (+3/-2)
MusicToolbar.qml (+4/-4)
tests/autopilot/music_app/__init__.py (+100/-55)
tests/autopilot/music_app/tests/test_music.py (+126/-142)
To merge this branch: bzr merge lp:~ahayzen/music-app/ap-helper-refactor-002
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Victor Thompson Approve
Review via email: mp+231815@code.launchpad.net

Commit message

* Make basic helpers for MusicNowPlaying and MusicToolbar
* Convert turn_shuffle and turn_repeat into set_shuffle and set_repeat

Description of the change

* Make basic helpers for MusicNowPlaying and MusicToolbar
* Convert turn_shuffle and turn_repeat into set_shuffle and set_repeat

Note ListItemWithActions helper and further methods will be added in future branches, I left them out of this to keep the diff low :)

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)
595. By Andrew Hayzen

* Fixes for missed get_count() cases

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

* Wait for now playing to be visible in populate_queue()
* Get now_playing_page again if it has moved

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

* Change toolbar.get_x_button to toolbar.click_x_button as they are always clicked

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

* Fix for case that was removed

599. By Andrew Hayzen

* Remove duplication

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

Inline comments:

1. test_music.py L477: Is it possible to move this to the toolbar helper now rather than leter?
2. test_music.py L503: Why aren't set_shufflet, etc in the toolbar helper?

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

1) I was trying to keep the diff small, so I was going to convert that and other things in another mp
2) It was in the MusicNowPlaying because that is the page where shuffle and repeat are set. But I suppose we could move to Toolbar as they are in the toolbar.

600. By Andrew Hayzen

* Move set_repeat set_shuffle into MusicToolbar
* Change fullPlayShape to playShape and others
* Change expandedPlayShape to smallPlayShape

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

* Fix for set_shuffle set_repeat still using now_playing_page rather than toolbar

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
Victor Thompson (vthompson) wrote :

I have one small inline comment. I think it'd be nice to fix it up.

review: Needs Fixing
602. By Andrew Hayzen

* Fix for test_mp3

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

* Merge of trunk

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

Looks good to me! Please top approve after balloons gives it the OK.

review: Approve
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, the function decorator was a nice touch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MusicNowPlaying.qml'
2--- MusicNowPlaying.qml 2014-08-20 17:35:52 +0000
3+++ MusicNowPlaying.qml 2014-08-27 17:32:22 +0000
4@@ -29,7 +29,7 @@
5
6 MusicPage {
7 id: nowPlaying
8- objectName: "nowplayingpage"
9+ objectName: "nowPlayingPage"
10 title: i18n.tr("Now Playing")
11 visible: false
12
13@@ -82,7 +82,7 @@
14
15 ListView {
16 id: queuelist
17- objectName: "queuelist"
18+ objectName: "nowPlayingQueueList"
19 anchors.fill: parent
20 anchors.bottomMargin: musicToolbar.mouseAreaOffset + musicToolbar.minimizedHeight
21 delegate: queueDelegate
22@@ -127,6 +127,7 @@
23 id: queueListItem
24 color: "transparent"
25 height: queuelist.normalHeight
26+ objectName: "nowPlayingListItem" + index
27 state: queuelist.currentIndex == index && !reordering ? "current" : ""
28
29 leftSideAction: Remove {
30
31=== modified file 'MusicToolbar.qml'
32--- MusicToolbar.qml 2014-08-21 19:32:12 +0000
33+++ MusicToolbar.qml 2014-08-27 17:32:22 +0000
34@@ -317,7 +317,7 @@
35 anchors.rightMargin: units.gu(1)
36 anchors.verticalCenter: parent.verticalCenter
37 height: units.gu(6)
38- objectName: "previousshape"
39+ objectName: "previousShape"
40 opacity: trackQueue.model.count === 0 ? .4 : 1
41 width: height
42
43@@ -400,7 +400,7 @@
44 antialiasing: true
45 color: styleMusic.toolbar.fullInnerPlayCircleColor
46 height: nowPlayingPlayButtonInner.height - units.gu(.1)
47- objectName: "nowPlayingPlayShape"
48+ objectName: "playShape"
49 radius: height / 2
50 width: height
51
52@@ -441,7 +441,7 @@
53 anchors.leftMargin: units.gu(1)
54 anchors.verticalCenter: parent.verticalCenter
55 height: units.gu(6)
56- objectName: "forwardshape"
57+ objectName: "forwardShape"
58 opacity: trackQueue.model.count === 0 ? .4 : 1
59 width: height
60
61@@ -902,7 +902,7 @@
62 antialiasing: true
63 color: "#444"
64 height: units.gu(7)
65- objectName: "playshape"
66+ objectName: "smallPlayShape"
67 radius: height / 2
68 width: height
69
70
71=== modified file 'tests/autopilot/music_app/__init__.py'
72--- tests/autopilot/music_app/__init__.py 2014-08-21 20:57:01 +0000
73+++ tests/autopilot/music_app/__init__.py 2014-08-27 17:32:22 +0000
74@@ -14,6 +14,14 @@
75 """Exception raised when there's an error in the Music App."""
76
77
78+def click_object(func):
79+ """Wrapper which clicks the returned object"""
80+ def func_wrapper(self, *args):
81+ return self.pointing_device.click_object(func(self, *args))
82+
83+ return func_wrapper
84+
85+
86 class MusicApp(object):
87 """Autopilot helper object for the Music application."""
88
89@@ -22,14 +30,13 @@
90 self.main_view = self.app.wait_select_single(MainView)
91 self.player = self.app.select_single(Player, objectName='player')
92
93- def populate_queue(self):
94- tracksPage = self.get_tracks_page() # switch to track tab
95-
96- # get and click to play first track
97- track = tracksPage.get_track(0)
98- self.app.pointing_device.click_object(track)
99-
100- # TODO: when using bottom edge wait for .isReady on tracksPage
101+ def get_now_playing_page(self):
102+ return self.app.wait_select_single(MusicNowPlaying,
103+ objectName="nowPlayingPage")
104+
105+ def get_toolbar(self):
106+ return self.app.select_single(MusicToolbar,
107+ objectName="musicToolbarObject")
108
109 def get_tracks_page(self):
110 """Open the Tracks tab.
111@@ -48,6 +55,18 @@
112 objectName="LoadingSpinner").running and
113 self.main_view.select_single("*", "allSongsModel").populated)
114
115+ def populate_queue(self):
116+ tracksPage = self.get_tracks_page() # switch to track tab
117+
118+ # get and click to play first track
119+ track = tracksPage.get_track(0)
120+ self.app.pointing_device.click_object(track)
121+
122+ # TODO: when using bottom edge wait for .isReady on tracksPage
123+
124+ # wait for now playing page to be visible
125+ self.get_now_playing_page().visible.wait_for(True)
126+
127
128 class Page(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
129 """Autopilot helper for Pages."""
130@@ -75,7 +94,79 @@
131
132
133 class Player(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
134- """Autopilot helper for Player """
135+ """Autopilot helper for Player"""
136+
137+
138+class MusicNowPlaying(MusicPage):
139+ """ Autopilot helper for now playing page """
140+ def __init__(self, *args):
141+ super(MusicPage, self).__init__(*args)
142+
143+ def get_count(self):
144+ return self.select_single("QQuickListView",
145+ objectName="nowPlayingQueueList").count
146+
147+ def get_track(self, i):
148+ return (self.wait_select_single("ListItemWithActions",
149+ objectName="nowPlayingListItem" + str(i)))
150+
151+
152+class MusicToolbar(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
153+ """Autopilot helper for the toolbar
154+
155+ expanded - refers to things when the toolbar is in its smaller state
156+ full - refers to things when the toolbar is in its larger state
157+ """
158+ def __init__(self, *args):
159+ super(MusicToolbar, self).__init__(*args)
160+
161+ root = self.get_root_instance()
162+ self.player = root.select_single(Player, objectName="player")
163+
164+ @click_object
165+ def click_small_play_button(self):
166+ return self.wait_select_single("*", objectName="smallPlayShape")
167+
168+ @click_object
169+ def click_forward_button(self):
170+ return self.wait_select_single("*", objectName="forwardShape")
171+
172+ @click_object
173+ def click_play_button(self):
174+ return self.wait_select_single("*", objectName="playShape")
175+
176+ @click_object
177+ def click_previous_button(self):
178+ return self.wait_select_single("*", objectName="previousShape")
179+
180+ @click_object
181+ def click_repeat_button(self):
182+ return self.wait_select_single("*", objectName="repeatShape")
183+
184+ @click_object
185+ def click_shuffle_button(self):
186+ return self.wait_select_single("*", objectName="shuffleShape")
187+
188+ def set_repeat(self, state):
189+ if self.player.repeat != state:
190+ self.click_repeat_button()
191+
192+ self.player.repeat.wait_for(state)
193+
194+ def set_shuffle(self, state):
195+ if self.player.shuffle != state:
196+ self.click_shuffle_button()
197+
198+ self.player.shuffle.wait_for(state)
199+
200+ def show(self):
201+ self.pointing_device.move_to_object(self)
202+
203+ x1, y1 = self.pointing_device.position()
204+
205+ y1 -= (self.height / 2) + 1 # get position at top of toolbar
206+
207+ self.pointing_device.drag(x1, y1, x1, y1 - self.fullHeight)
208
209
210 class MainView(ubuntuuitoolkit.MainView):
211@@ -91,10 +182,6 @@
212 objectName="LoadingSpinner")
213 spinner.running.wait_for(False)
214
215- def get_toolbar(self):
216- return self.select_single("MusicToolbar",
217- objectName="musicToolbarObject")
218-
219 def select_many_retry(self, object_type, **kwargs):
220 """Returns the item that is searched for with app.select_many
221 In case of no item was not found (not created yet) a second attempt is
222@@ -124,18 +211,6 @@
223
224 self.pointing_device.drag(x1, y1, x1 - (progressBar.width / 2) + 1, y1)
225
226- def show_toolbar(self):
227- # Get the toolbar object and create a mouse
228- toolbar = self.get_toolbar()
229-
230- # Move to the toolbar and get the position
231- self.pointing_device.move_to_object(toolbar)
232- x1, y1 = self.pointing_device.position()
233-
234- y1 -= (toolbar.height / 2) + 1 # get position at top of toolbar
235-
236- self.pointing_device.drag(x1, y1, x1, y1 - toolbar.fullHeight)
237-
238 def add_to_queue_from_albums_tab_album_page(self, artistName, trackTitle):
239 # switch to albums tab
240 self.switch_to_tab("albumstab")
241@@ -166,27 +241,6 @@
242 header = self.get_header()
243 header.click_action_button('newplaylistButton')
244
245- def get_player(self):
246- return self.select_single("*", objectName="player")
247-
248- def get_play_button(self):
249- return self.wait_select_single("*", objectName="playshape")
250-
251- def get_now_playing_play_button(self):
252- return self.wait_select_single("*", objectName="nowPlayingPlayShape")
253-
254- def get_repeat_button(self):
255- return self.wait_select_single("*", objectName="repeatShape")
256-
257- def get_shuffle_button(self):
258- return self.wait_select_single("*", objectName="shuffleShape")
259-
260- def get_forward_button(self):
261- return self.wait_select_single("*", objectName="forwardshape")
262-
263- def get_previous_button(self):
264- return self.wait_select_single("*", objectName="previousshape")
265-
266 def get_player_control_title(self):
267 return self.select_single("Label", objectName="playercontroltitle")
268
269@@ -264,11 +318,6 @@
270 if item.text == trackTitle:
271 return item
272
273- def get_queue_track_count(self):
274- queuelist = self.select_single(
275- "QQuickListView", objectName="queuelist")
276- return queuelist.count
277-
278 def get_queue_now_playing_artist(self, artistName):
279 playingartists = self.select_many(
280 "Label", objectName="nowplayingartist")
281@@ -321,10 +370,6 @@
282 return self.wait_select_single(
283 "QQuickListView", objectName="playlistslist")
284
285- def get_MusicNowPlaying_page(self):
286- return self.wait_select_single(
287- "MusicNowPlaying", objectName="nowplayingpage")
288-
289 def get_swipedelete_icon(self):
290 return self.wait_select_single(
291 "*", objectName="swipeDeleteAction",
292
293=== modified file 'tests/autopilot/music_app/tests/test_music.py'
294--- tests/autopilot/music_app/tests/test_music.py 2014-08-19 23:30:26 +0000
295+++ tests/autopilot/music_app/tests/test_music.py 2014-08-27 17:32:22 +0000
296@@ -41,42 +41,6 @@
297 def pointing_device(self):
298 return self.app.app.pointing_device
299
300- def turn_shuffle_off(self):
301- if self.player.shuffle:
302- shufflebutton = self.main_view.get_shuffle_button()
303- logger.debug("Turning off shuffle")
304- self.pointing_device.click_object(shufflebutton)
305- else:
306- logger.debug("Shuffle already off")
307- self.assertThat(self.player.shuffle, Eventually(Equals(False)))
308-
309- def turn_shuffle_on(self):
310- if not self.player.shuffle:
311- shufflebutton = self.main_view.get_shuffle_button()
312- logger.debug("Turning on shuffle")
313- self.pointing_device.click_object(shufflebutton)
314- else:
315- logger.debug("Shuffle already on")
316- self.assertThat(self.player.shuffle, Eventually(Equals(True)))
317-
318- def turn_repeat_off(self):
319- if self.player.repeat:
320- repeatbutton = self.main_view.get_repeat_button()
321- logger.debug("Turning off repeat")
322- self.pointing_device.click_object(repeatbutton)
323- else:
324- logger.debug("Repeat already off")
325- self.assertThat(self.player.repeat, Eventually(Equals(False)))
326-
327- def turn_repeat_on(self):
328- if not self.player.repeat:
329- repeatbutton = self.main_view.get_repeat_button()
330- logger.debug("Turning on repeat")
331- self.pointing_device.click_object(repeatbutton)
332- else:
333- logger.debug("Repeat already on")
334- self.assertThat(self.player.repeat, Eventually(Equals(True)))
335-
336 def test_reads_music_library(self):
337 """ tests if the music library is populated from our
338 fake mediascanner database"""
339@@ -91,21 +55,24 @@
340 def test_play_pause_library(self):
341 """ Test playing and pausing a track (Music Library must exist) """
342
343+ now_playing_page = self.app.get_now_playing_page()
344+ toolbar = self.app.get_toolbar()
345+
346 # get number of tracks in queue before queuing a track
347- initialtracksCount = self.main_view.get_queue_track_count()
348+ initial_tracks_count = now_playing_page.get_count()
349
350 self.main_view.add_to_queue_from_albums_tab_album_page(
351 self.artistName, self.trackTitle)
352
353 # verify track queue has added one to initial value
354- self.assertThat(self.main_view.get_queue_track_count(),
355- Eventually(Equals(initialtracksCount + 1)))
356+ self.assertThat(now_playing_page.get_count(),
357+ Eventually(Equals(initial_tracks_count + 1)))
358
359- endtracksCount = self.main_view.get_queue_track_count()
360+ end_tracks_count = now_playing_page.get_count()
361
362 # Assert that the song added to the list is not playing
363 self.assertThat(self.player.currentIndex,
364- Eventually(NotEquals(endtracksCount)))
365+ Eventually(NotEquals(end_tracks_count)))
366 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
367
368 # verify song's metadata matches the item added to the Now Playing view
369@@ -119,18 +86,21 @@
370 # click on close button to close the page
371 self.main_view.go_back()
372
373+ """ Track is playing"""
374 if self.main_view.wideAspect:
375- play_button = self.main_view.get_now_playing_play_button()
376+ click_play_button = toolbar.click_play_button
377 else:
378- play_button = self.main_view.get_play_button()
379- self.main_view.show_toolbar()
380-
381- """ Track is playing"""
382- self.pointing_device.click_object(play_button)
383+ if not toolbar.opened:
384+ toolbar.show()
385+
386+ click_play_button = toolbar.click_small_play_button
387+
388+ click_play_button()
389+
390 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
391
392 """ Track is not playing"""
393- self.pointing_device.click_object(play_button)
394+ click_play_button()
395 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
396
397 def test_play_pause_now_playing(self):
398@@ -138,17 +108,17 @@
399
400 self.app.populate_queue() # populate queue
401
402- playbutton = self.main_view.get_now_playing_play_button()
403+ toolbar = self.app.get_toolbar()
404
405 """ Track is playing"""
406 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
407- self.pointing_device.click_object(playbutton)
408+ toolbar.click_play_button()
409
410 """ Track is not playing"""
411 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
412
413 """ Track is playing"""
414- self.pointing_device.click_object(playbutton)
415+ toolbar.click_play_button()
416 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
417
418 def test_next_previous(self):
419@@ -156,7 +126,7 @@
420
421 self.app.populate_queue() # populate queue
422
423- playbutton = self.main_view.get_now_playing_play_button()
424+ toolbar = self.app.get_toolbar()
425
426 title = lambda: self.player.currentMetaTitle
427 artist = lambda: self.player.currentMetaArtist
428@@ -169,19 +139,18 @@
429 logger.debug("Original Song %s, %s" % (orgTitle, orgArtist))
430
431 """ Pause track """
432- self.pointing_device.click_object(playbutton)
433+ toolbar.click_play_button()
434 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
435
436- self.turn_shuffle_off()
437+ toolbar.set_shuffle(False)
438
439 """ Select next """
440 # goal is to go back and forth and ensure 2 different songs
441- forwardbutton = self.main_view.get_forward_button()
442- self.pointing_device.click_object(forwardbutton)
443+ toolbar.click_forward_button()
444 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
445
446 """ Pause track """
447- self.pointing_device.click_object(playbutton)
448+ toolbar.click_play_button()
449 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
450
451 # ensure different song
452@@ -192,15 +161,14 @@
453 logger.debug("Next Song %s, %s" % (nextTitle, nextArtist))
454
455 """ Seek to 0 """
456- self.main_view.seek_to_0()
457+ self.main_view.seek_to_0() # TODO: put in helper in future
458
459 """ Select previous """
460- previousbutton = self.main_view.get_previous_button()
461- self.pointing_device.click_object(previousbutton)
462+ toolbar.click_previous_button()
463 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
464
465 """ Pause track """
466- self.pointing_device.click_object(playbutton)
467+ toolbar.click_play_button()
468 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
469
470 # ensure we're back to original song
471@@ -212,27 +180,29 @@
472
473 self.app.populate_queue() # populate queue
474
475- playbutton = self.main_view.get_now_playing_play_button()
476+ now_playing_page = self.app.get_now_playing_page()
477+ toolbar = self.app.get_toolbar()
478
479 title = self.player.currentMetaTitle
480 artist = self.player.currentMetaArtist
481
482- self.turn_shuffle_off()
483+ toolbar.set_shuffle(False)
484
485- """ Track is playing """
486- count = 1
487 # ensure track appears before looping through queue more than once
488 # needs to contain test mp3 metadata and end in *.mp3
489- queue = self.main_view.get_queue_track_count()
490+ queue_size = now_playing_page.get_count()
491+ count = 0
492+
493 while title != "TestMP3Title" and artist != "TestMP3Artist":
494- self.assertThat(count, LessThan(queue))
495+ count = count + 1
496+
497+ self.assertThat(count, LessThan(queue_size))
498
499 """ Select next """
500- forwardbutton = self.main_view.get_forward_button()
501- self.pointing_device.click_object(forwardbutton)
502+ toolbar.click_forward_button()
503
504 """ Pause track """
505- self.pointing_device.click_object(playbutton)
506+ toolbar.click_play_button()
507 self.assertThat(self.player.isPlaying,
508 Eventually(Equals(False)))
509
510@@ -241,12 +211,10 @@
511 logger.debug("Current Song %s, %s" % (title, artist))
512 logger.debug("File found %s" % self.player.currentMetaFile)
513
514- count = count + 1
515-
516 # make sure mp3 plays
517 self.assertThat(self.player.source.endswith("mp3"),
518 Equals(True))
519- self.pointing_device.click_object(playbutton)
520+ toolbar.click_play_button()
521 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
522
523 def test_shuffle(self):
524@@ -255,20 +223,18 @@
525 self.app.populate_queue() # populate queue
526
527 """ Track is playing, shuffle is turned on"""
528- forwardbutton = self.main_view.get_forward_button()
529- playbutton = self.main_view.get_now_playing_play_button()
530- previousbutton = self.main_view.get_previous_button()
531+ toolbar = self.app.get_toolbar()
532
533 # play for a second, then pause
534 if not self.player.isPlaying:
535 logger.debug("Play not selected")
536- self.pointing_device.click_object(playbutton)
537+ toolbar.click_play_button()
538 else:
539 logger.debug("Already playing")
540
541 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
542 time.sleep(1)
543- self.pointing_device.click_object(playbutton)
544+ toolbar.click_play_button()
545 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
546
547 count = 0
548@@ -284,14 +250,15 @@
549 orgArtist = self.player.currentMetaArtist
550 logger.debug("Original Song %s, %s" % (orgTitle, orgArtist))
551
552- if (not self.main_view.toolbarShown):
553- self.main_view.show_toolbar()
554-
555- self.turn_shuffle_on()
556-
557- self.pointing_device.click_object(forwardbutton)
558+ if not toolbar.opened:
559+ toolbar.show()
560+
561+ toolbar.set_shuffle(True)
562+
563+ toolbar.click_forward_button()
564 self.assertThat(self.player.isPlaying,
565 Eventually(Equals(True)))
566+
567 title = self.player.currentMetaTitle
568 artist = self.player.currentMetaArtist
569 logger.debug("Current Song %s, %s" % (title, artist))
570@@ -299,13 +266,13 @@
571 # go back to previous and check against original
572 # play song, then pause before switching
573 time.sleep(1)
574- self.pointing_device.click_object(playbutton)
575+ toolbar.click_play_button()
576 self.assertThat(self.player.isPlaying,
577 Eventually(Equals(False)))
578
579- self.turn_shuffle_off()
580+ toolbar.set_shuffle(False)
581
582- self.pointing_device.click_object(previousbutton)
583+ toolbar.click_previous_button()
584
585 title = self.player.currentMetaTitle
586 artist = self.player.currentMetaArtist
587@@ -316,6 +283,7 @@
588 break
589 else:
590 logger.debug("Same track, no shuffle %s, %s" % (title, artist))
591+
592 count += 1
593
594 def test_show_albums_page(self):
595@@ -339,16 +307,17 @@
596 def test_add_song_to_queue_from_albums_page(self):
597 """tests navigating to the Albums tab and adding a song to queue"""
598
599+ now_playing_page = self.app.get_now_playing_page()
600+
601 # get number of tracks in queue before queuing a track
602- initialtracksCount = self.main_view.get_queue_track_count()
603+ initial_tracks_count = now_playing_page.get_count()
604
605 self.main_view.add_to_queue_from_albums_tab_album_page(
606 self.artistName, self.trackTitle)
607
608 # verify track queue has added one to initial value
609- endtracksCount = self.main_view.get_queue_track_count()
610- self.assertThat(endtracksCount,
611- Eventually(Equals(initialtracksCount + 1)))
612+ self.assertThat(now_playing_page.get_count(),
613+ Eventually(Equals(initial_tracks_count + 1)))
614
615 # Assert that the song added to the list is not playing
616 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
617@@ -369,18 +338,23 @@
618 """tests navigating to the Songs tab and adding the library to the
619 queue with the selected item being played. """
620
621+ now_playing_page = self.app.get_now_playing_page()
622+
623 # get number of tracks in queue before queuing a track
624- initialtracksCount = self.main_view.get_queue_track_count()
625+ initial_tracks_count = now_playing_page.get_count()
626
627 self.app.populate_queue() # populate queue
628
629+ # get now playing again as it has moved
630+ now_playing_page = self.app.get_now_playing_page()
631+
632 # verify track queue has added all songs to initial value
633- endtracksCount = self.main_view.get_queue_track_count()
634- self.assertThat(endtracksCount, Equals(initialtracksCount + 3))
635+ self.assertThat(now_playing_page.get_count(),
636+ Equals(initial_tracks_count + 3))
637
638 # Assert that the song added to the list is playing
639 self.assertThat(self.player.currentIndex,
640- Eventually(NotEquals(endtracksCount)))
641+ Eventually(NotEquals(now_playing_page.get_count())))
642 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
643
644 # verify song's metadata matches the item added to the Now Playing view
645@@ -395,8 +369,10 @@
646 """tests navigating to the Songs tab and adding a song from the library
647 to the queue via the expandable list view item. """
648
649+ now_playing_page = self.app.get_now_playing_page()
650+
651 # get number of tracks in queue before queuing a track
652- initialtracksCount = self.main_view.get_queue_track_count()
653+ initial_tracks_count = now_playing_page.get_count()
654
655 # switch to songs tab
656 self.main_view.switch_to_tab("tracksTab")
657@@ -420,13 +396,12 @@
658 self.pointing_device.click_object(queueaction)
659
660 # verify track queue has added all songs to initial value
661- endtracksCount = self.main_view.get_queue_track_count
662- self.assertThat(endtracksCount(),
663- Eventually(Equals(initialtracksCount + 1)))
664+ self.assertThat(now_playing_page.get_count(),
665+ Eventually(Equals(initial_tracks_count + 1)))
666
667 # Assert that the song added to the list is not playing
668 self.assertThat(self.player.currentIndex,
669- Eventually(NotEquals(endtracksCount())))
670+ Eventually(NotEquals(now_playing_page.get_count())))
671 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
672
673 # verify song's metadata matches the item added to the Now Playing view
674@@ -497,8 +472,10 @@
675 def test_artists_tab_album(self):
676 """tests navigating to the Artists tab and playing an album"""
677
678+ now_playing_page = self.app.get_now_playing_page()
679+
680 # get number of tracks in queue before queuing a track
681- initialtracksCount = self.main_view.get_queue_track_count()
682+ initial_tracks_count = now_playing_page.get_count()
683
684 # switch to artists tab
685 self.main_view.switch_to_tab("artiststab")
686@@ -527,13 +504,16 @@
687 self.trackTitle)
688 self.pointing_device.click_object(track)
689
690+ # get now playing again as it has moved
691+ now_playing_page = self.app.get_now_playing_page()
692+
693 # verify track queue has added all songs to initial value
694- endtracksCount = self.main_view.get_queue_track_count()
695- self.assertThat(endtracksCount, Equals(initialtracksCount + 2))
696+ self.assertThat(now_playing_page.get_count(),
697+ Equals(initial_tracks_count + 2))
698
699 # Assert that the song added to the list is playing
700 self.assertThat(self.player.currentIndex,
701- Eventually(NotEquals(endtracksCount)))
702+ Eventually(NotEquals(now_playing_page.get_count())))
703 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
704
705 # verify song's metadata matches the item added to the Now Playing view
706@@ -550,20 +530,21 @@
707
708 self.app.populate_queue() # populate queue
709
710+ now_playing_page = self.app.get_now_playing_page()
711+
712 # get initial queue count
713- initialqueueCount = self.main_view.get_queue_track_count()
714+ initial_queue_count = now_playing_page.get_count()
715
716 # get song to delete
717- artistToDelete = self.main_view.get_queue_now_playing_artist(
718- self.artistName)
719- musicnowplayingpage = self.main_view.get_MusicNowPlaying_page()
720+ track = now_playing_page.get_track(0)
721
722+ # TODO: make ListItemWithActions helper for swiping
723 # get coordinates to delete song
724- start_x = int(musicnowplayingpage.globalRect.x +
725- musicnowplayingpage.globalRect.width * 0.30)
726- stop_x = int(musicnowplayingpage.globalRect.x +
727- musicnowplayingpage.globalRect.width * 0.90)
728- line_y = int(artistToDelete.globalRect.y)
729+ start_x = int(now_playing_page.globalRect.x +
730+ now_playing_page.globalRect.width * 0.30)
731+ stop_x = int(now_playing_page.globalRect.x +
732+ now_playing_page.globalRect.width * 0.90)
733+ line_y = int(track.globalRect.y) + int(track.height / 2)
734
735 # swipe to remove song
736 self.pointing_device.move(start_x, line_y)
737@@ -574,24 +555,23 @@
738 self.pointing_device.click_object(swipedeleteicon)
739
740 # verify song has been deleted
741- finalqueueCount = self.main_view.get_queue_track_count()
742- self.assertThat(finalqueueCount,
743- Eventually(Equals(initialqueueCount - 1)))
744+ self.assertThat(now_playing_page.get_count(),
745+ Eventually(Equals(initial_queue_count - 1)))
746
747 def test_playback_stops_when_last_song_ends_and_repeat_off(self):
748 """Check that playback stops when the last song in the queue ends"""
749
750 self.app.populate_queue() # populate queue
751
752- self.turn_shuffle_off()
753- self.turn_repeat_off()
754+ now_playing_page = self.app.get_now_playing_page()
755+ toolbar = self.app.get_toolbar()
756
757- num_tracks = self.main_view.get_queue_track_count()
758+ toolbar.set_shuffle(False)
759+ toolbar.set_repeat(False)
760
761 # Skip through all songs in queue, stopping on last one.
762- forward_button = self.main_view.get_forward_button()
763- for count in range(0, num_tracks - 1):
764- self.pointing_device.click_object(forward_button)
765+ for count in range(0, now_playing_page.get_count() - 1):
766+ toolbar.click_forward_button()
767
768 # When the last song ends, playback should stop
769 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
770@@ -601,14 +581,15 @@
771
772 self.app.populate_queue() # populate queue
773
774- self.turn_shuffle_off()
775- self.turn_repeat_on()
776-
777- num_titles = self.main_view.get_queue_track_count()
778+ now_playing_page = self.app.get_now_playing_page()
779+ toolbar = self.app.get_toolbar()
780+
781+ toolbar.set_shuffle(False)
782+ toolbar.set_repeat(True)
783+
784 # Skip through all songs in queue, stopping on last one.
785- forward_button = self.main_view.get_forward_button()
786- for count in range(0, num_titles - 1):
787- self.pointing_device.click_object(forward_button)
788+ for count in range(0, now_playing_page.get_count() - 1):
789+ toolbar.click_forward_button()
790
791 # Make sure we loop back to first song after last song ends
792 actual_title = lambda: self.player.currentMetaTitle
793@@ -620,14 +601,15 @@
794
795 self.app.populate_queue() # populate queue
796
797- self.turn_shuffle_off()
798- self.turn_repeat_on()
799-
800- num_titles = self.main_view.get_queue_track_count()
801+ now_playing_page = self.app.get_now_playing_page()
802+ toolbar = self.app.get_toolbar()
803+
804+ toolbar.set_shuffle(False)
805+ toolbar.set_repeat(True)
806+
807 # Skip through all songs in queue, INCLUDING last one.
808- forward_button = self.main_view.get_forward_button()
809- for count in range(0, num_titles - 1):
810- self.pointing_device.click_object(forward_button)
811+ for count in range(0, now_playing_page.get_count() - 1):
812+ toolbar.click_forward_button()
813
814 actual_title = lambda: self.player.currentMetaTitle
815 self.assertThat(actual_title, Eventually(Equals(self.trackTitle)))
816@@ -638,17 +620,19 @@
817
818 self.app.populate_queue() # populate queue
819
820- self.turn_shuffle_off()
821- self.turn_repeat_on()
822-
823- prev_button = self.main_view.get_previous_button()
824+ toolbar = self.app.get_toolbar()
825+
826+ toolbar.set_shuffle(False)
827+ toolbar.set_repeat(True)
828+
829 initial_song = self.player.currentMetaTitle
830- self.pointing_device.click_object(prev_button)
831+ toolbar.click_previous_button()
832+
833 # If we're far enough into a song, pressing prev just takes us to the
834 # beginning of that track. In that case, hit prev again to actually
835 # skip over the track.
836 if self.player.currentMetaTitle == initial_song:
837- self.pointing_device.click_object(prev_button)
838+ toolbar.click_previous_button()
839
840 actual_title = lambda: self.player.currentMetaTitle
841 self.assertThat(actual_title, Eventually(Equals(self.lastTrackTitle)))

Subscribers

People subscribed via source and target branches

to status/vote changes: