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

Proposed by Andrew Hayzen
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 616
Merged at revision: 634
Proposed branch: lp:~ahayzen/music-app/ap-helper-refactor-004
Merge into: lp:music-app/trusty
Prerequisite: lp:~ahayzen/music-app/ap-helper-refactor-003
Diff against target: 701 lines (+210/-189)
3 files modified
MusicToolbar.qml (+3/-0)
tests/autopilot/music_app/__init__.py (+25/-7)
tests/autopilot/music_app/tests/test_music.py (+182/-182)
To merge this branch: bzr merge lp:~ahayzen/music-app/ap-helper-refactor-004
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+233291@code.launchpad.net

Commit message

* Remove main_view and pointing_device properties
* Use virtual model of metadata rather than hardcoding track_index, track_title etc
* Improve toolbar handling
* Make click_play_button helper automatically choose the correct button
* Improve some tests especially ones with 'while'
* Improve code comments

Description of the change

* Remove main_view and pointing_device properties
* Use virtual model of metadata rather than hardcoding track_index, track_title etc
* Improve toolbar handling
* Make click_play_button helper automatically choose the correct button
* Improve some tests especially ones with 'while'
* Improve code comments

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)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

#blocked bug 1365247 (mediascanner2 db schema change)

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

#unblocked

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

See inline comments.

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

PASSED: Continuous integration, rev:614
http://91.189.93.70:8080/job/music-app-ci/1109/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/music-app-utopic-amd64-ci/333

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/music-app-ci/1109/rebuild

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (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 :

I think having this "virtual model" for metadata currently hurts the readability of the tests that use it, but I know having it will prove useful in the future. Also, the restructuring of some of the various loops looks good. Approved, but waiting for a secondary review by balloons.

review: Approve
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MusicToolbar.qml'
--- MusicToolbar.qml 2014-08-22 23:41:29 +0000
+++ MusicToolbar.qml 2014-09-10 13:42:37 +0000
@@ -51,6 +51,9 @@
51 property alias animating: musicToolbarPanel.animating51 property alias animating: musicToolbarPanel.animating
52 property alias opened: musicToolbarPanel.opened52 property alias opened: musicToolbarPanel.opened
5353
54 // Alias for autopilot
55 property alias currentMode: musicToolbarPanel.currentMode
56
54 Connections {57 Connections {
55 id: pageStackConn58 id: pageStackConn
56 target: mainPageStack59 target: mainPageStack
5760
=== modified file 'tests/autopilot/music_app/__init__.py'
--- tests/autopilot/music_app/__init__.py 2014-09-04 20:02:14 +0000
+++ tests/autopilot/music_app/__init__.py 2014-09-10 13:42:37 +0000
@@ -15,8 +15,19 @@
1515
16def click_object(func):16def click_object(func):
17 """Wrapper which clicks the returned object"""17 """Wrapper which clicks the returned object"""
18 def func_wrapper(self, *args):18 def func_wrapper(self, *args, **kwargs):
19 return self.pointing_device.click_object(func(self, *args))19 return self.pointing_device.click_object(func(self, *args, **kwargs))
20
21 return func_wrapper
22
23
24def ensure_toolbar_visible(func):
25 """Wrapper which ensures the toolbar is shown before clicking"""
26 def func_wrapper(self, *args, **kwargs):
27 if not self.opened:
28 self.show()
29
30 return func(self, *args, **kwargs)
2031
21 return func_wrapper32 return func_wrapper
2233
@@ -268,30 +279,35 @@
268 root = self.get_root_instance()279 root = self.get_root_instance()
269 self.player = root.select_single(Player, objectName="player")280 self.player = root.select_single(Player, objectName="player")
270281
271 @click_object282 @ensure_toolbar_visible
272 def click_small_play_button(self):
273 return self.wait_select_single("*", objectName="smallPlayShape")
274
275 @click_object283 @click_object
276 def click_forward_button(self):284 def click_forward_button(self):
277 return self.wait_select_single("*", objectName="forwardShape")285 return self.wait_select_single("*", objectName="forwardShape")
278286
287 @ensure_toolbar_visible
279 @click_object288 @click_object
280 def click_play_button(self):289 def click_play_button(self):
281 return self.wait_select_single("*", objectName="playShape")290 if self.currentMode == "full":
291 return self.wait_select_single("*", objectName="playShape")
292 else:
293 return self.wait_select_single("*", objectName="smallPlayShape")
282294
295 @ensure_toolbar_visible
283 @click_object296 @click_object
284 def click_previous_button(self):297 def click_previous_button(self):
285 return self.wait_select_single("*", objectName="previousShape")298 return self.wait_select_single("*", objectName="previousShape")
286299
300 @ensure_toolbar_visible
287 @click_object301 @click_object
288 def click_repeat_button(self):302 def click_repeat_button(self):
289 return self.wait_select_single("*", objectName="repeatShape")303 return self.wait_select_single("*", objectName="repeatShape")
290304
305 @ensure_toolbar_visible
291 @click_object306 @click_object
292 def click_shuffle_button(self):307 def click_shuffle_button(self):
293 return self.wait_select_single("*", objectName="shuffleShape")308 return self.wait_select_single("*", objectName="shuffleShape")
294309
310 @ensure_toolbar_visible
295 def seek_to(self, percentage):311 def seek_to(self, percentage):
296 progress_bar = self.wait_select_single(312 progress_bar = self.wait_select_single(
297 "*", objectName="progressBarShape")313 "*", objectName="progressBarShape")
@@ -303,12 +319,14 @@
303319
304 self.pointing_device.drag(x1, y1, x2, y1)320 self.pointing_device.drag(x1, y1, x2, y1)
305321
322 @ensure_toolbar_visible
306 def set_repeat(self, state):323 def set_repeat(self, state):
307 if self.player.repeat != state:324 if self.player.repeat != state:
308 self.click_repeat_button()325 self.click_repeat_button()
309326
310 self.player.repeat.wait_for(state)327 self.player.repeat.wait_for(state)
311328
329 @ensure_toolbar_visible
312 def set_shuffle(self, state):330 def set_shuffle(self, state):
313 if self.player.shuffle != state:331 if self.player.shuffle != state:
314 self.click_shuffle_button()332 self.click_shuffle_button()
315333
=== modified file 'tests/autopilot/music_app/tests/test_music.py'
--- tests/autopilot/music_app/tests/test_music.py 2014-09-04 20:02:14 +0000
+++ tests/autopilot/music_app/tests/test_music.py 2014-09-10 13:42:37 +0000
@@ -9,7 +9,6 @@
99
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12import time
13import logging12import logging
14from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
15from testtools.matchers import Equals, LessThan, NotEquals14from testtools.matchers import Equals, LessThan, NotEquals
@@ -25,36 +24,44 @@
25 def setUp(self):24 def setUp(self):
26 super(TestMainWindow, self).setUp()25 super(TestMainWindow, self).setUp()
2726
28 self.album_artist_index = 0 # position on AlbumsPage27 # metadata for test tracks sorted by title
29 self.album_index = 0 # position on MusicAlbums28 # tests should sort themselves if they require by artist/album
30 self.artist_index = 0 # position on MusicArtists29 self.tracks = [
31 self.track_index = 0 # position on MusicTracks30 {
32 self.track_title = u"Gran Vals"31 "album": "",
33 self.artist_name = u"Francisco Tárrega"32 "artist": u"Francisco Tárrega",
34 self.last_track_title = u"TestMP3Title"33 "source": "1.ogg",
3534 "title": u"Gran Vals"
36 @property35 },
37 def main_view(self):36 {
38 return self.app.main_view37 "album": "",
38 "artist": "Josh Woodward",
39 "source": "2.ogg",
40 "title": "Swansong"
41 },
42 {
43 "album": "TestMP3Album",
44 "artist": "TestMP3Artist",
45 "source": "3.mp3",
46 "title": "TestMP3Title",
47 }
48 ]
3949
40 @property50 @property
41 def player(self):51 def player(self):
42 return self.app.player52 return self.app.player
4353
44 @property
45 def pointing_device(self):
46 return self.app.app.pointing_device
47
48 def test_reads_music_library(self):54 def test_reads_music_library(self):
49 """ tests if the music library is populated from our55 """ tests if the music library is populated from our
50 fake mediascanner database"""56 fake mediascanner database"""
5157
52 self.app.populate_queue() # populate queue58 self.app.populate_queue() # populate queue
5359
54 title = lambda: self.player.currentMetaTitle60 # Check current meta data is correct
55 artist = lambda: self.player.currentMetaArtist61 self.assertThat(self.player.currentMetaTitle,
56 self.assertThat(title, Eventually(Equals(self.track_title)))62 Eventually(Equals(self.tracks[0]["title"])))
57 self.assertThat(artist, Eventually(Equals(self.artist_name)))63 self.assertThat(self.player.currentMetaArtist,
64 Eventually(Equals(self.tracks[0]["artist"])))
5865
59 def test_play_pause_library(self):66 def test_play_pause_library(self):
60 """ Test playing and pausing a track (Music Library must exist) """67 """ Test playing and pausing a track (Music Library must exist) """
@@ -65,21 +72,17 @@
65 # get number of tracks in queue before queuing a track72 # get number of tracks in queue before queuing a track
66 initial_tracks_count = now_playing_page.get_count()73 initial_tracks_count = now_playing_page.get_count()
6774
68 # switch to albums tab75 # switch to albums tab and select the album
69 albums_page = self.app.get_albums_page()76 self.app.get_albums_page().click_album(0)
70 albums_page.click_album(self.album_index) # select album
7177
72 # get track item to swipe and queue78 # get track item to swipe and queue
73 songs_page = self.app.get_songs_page()79 track = self.app.get_songs_page().get_track(0)
74
75 track = songs_page.get_track(0)
76 track.swipe_reveal_actions()80 track.swipe_reveal_actions()
7781
78 track.click_add_to_queue_action() # add track to the queue82 track.click_add_to_queue_action() # add track to the queue
7983
80 # verify track queue has added one to initial value84 # wait for track to be queued
81 self.assertThat(now_playing_page.get_count(),85 now_playing_page.get_count().wait_for(initial_tracks_count + 1)
82 Eventually(Equals(initial_tracks_count + 1)))
8386
84 end_tracks_count = now_playing_page.get_count()87 end_tracks_count = now_playing_page.get_count()
8588
@@ -92,28 +95,19 @@
92 current_track = now_playing_page.get_track(self.player.currentIndex)95 current_track = now_playing_page.get_track(self.player.currentIndex)
9396
94 self.assertThat(current_track.get_label_text("artistLabel"),97 self.assertThat(current_track.get_label_text("artistLabel"),
95 Equals(self.artist_name))98 Equals(self.tracks[0]["artist"]))
96 self.assertThat(current_track.get_label_text("titleLabel"),99 self.assertThat(current_track.get_label_text("titleLabel"),
97 Equals(self.track_title))100 Equals(self.tracks[0]["title"]))
98101
99 # click on close button to close the page102 # click on close button to close the page
100 self.main_view.go_back()103 self.app.main_view.go_back()
101104
102 """ Track is playing"""105 # click the play button to start playing
103 if self.main_view.wideAspect:106 toolbar.click_play_button()
104 click_play_button = toolbar.click_play_button
105 else:
106 if not toolbar.opened:
107 toolbar.show()
108
109 click_play_button = toolbar.click_small_play_button
110
111 click_play_button()
112
113 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))107 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
114108
115 """ Track is not playing"""109 # click the play button to stop playing
116 click_play_button()110 toolbar.click_play_button()
117 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))111 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
118112
119 def test_play_pause_now_playing(self):113 def test_play_pause_now_playing(self):
@@ -123,15 +117,15 @@
123117
124 toolbar = self.app.get_toolbar()118 toolbar = self.app.get_toolbar()
125119
126 """ Track is playing"""120 # check that the player is playing and then select pause
127 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))121 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
128 toolbar.click_play_button()122 toolbar.click_play_button()
129123
130 """ Track is not playing"""124 # check that the player is paused and then select play
131 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))125 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
132
133 """ Track is playing"""
134 toolbar.click_play_button()126 toolbar.click_play_button()
127
128 # check that the player is playing
135 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))129 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
136130
137 def test_next_previous(self):131 def test_next_previous(self):
@@ -141,179 +135,177 @@
141135
142 toolbar = self.app.get_toolbar()136 toolbar = self.app.get_toolbar()
143137
144 title = lambda: self.player.currentMetaTitle138 # save original song data for later
145 artist = lambda: self.player.currentMetaArtist139 org_title = self.player.currentMetaTitle
146140 org_artist = self.player.currentMetaArtist
147 orgTitle = self.player.currentMetaTitle
148 orgArtist = self.player.currentMetaArtist
149141
150 # check original track142 # check original track
151 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))143 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
152 logger.debug("Original Song %s, %s" % (orgTitle, orgArtist))144 logger.debug("Original Song %s, %s" % (org_title, org_artist))
153145
154 """ Pause track """146 # select pause and check the player has stopped
155 toolbar.click_play_button()147 toolbar.click_play_button()
156 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))148 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
157149
158 toolbar.set_shuffle(False)150 toolbar.set_shuffle(False) # ensure shuffe is off
159151
160 """ Select next """
161 # goal is to go back and forth and ensure 2 different songs152 # goal is to go back and forth and ensure 2 different songs
162 toolbar.click_forward_button()153 toolbar.click_forward_button()
163 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))154 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
164155
165 """ Pause track """156 # select pause and check the player has stopped
166 toolbar.click_play_button()157 toolbar.click_play_button()
167 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))158 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
168159
169 # ensure different song160 # ensure different song
170 self.assertThat(title, Eventually(NotEquals(orgTitle)))161 self.assertThat(self.player.currentMetaTitle,
171 self.assertThat(artist, Eventually(NotEquals(orgArtist)))162 Eventually(NotEquals(org_title)))
172 nextTitle = self.player.currentMetaTitle163 self.assertThat(self.player.currentMetaArtist,
173 nextArtist = self.player.currentMetaArtist164 Eventually(NotEquals(org_artist)))
174 logger.debug("Next Song %s, %s" % (nextTitle, nextArtist))165
166 logger.debug("Next Song %s, %s" % (self.player.currentMetaTitle,
167 self.player.currentMetaArtist))
175168
176 toolbar.seek_to(0) # seek to 0 (start)169 toolbar.seek_to(0) # seek to 0 (start)
177170
178 """ Select previous """171 # select previous and ensure the track is playing
179 toolbar.click_previous_button()172 toolbar.click_previous_button()
180 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))173 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
181174
182 """ Pause track """175 # select pause and check the player has stopped
183 toolbar.click_play_button()176 toolbar.click_play_button()
184 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))177 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
185178
186 # ensure we're back to original song179 # ensure we're back to original song
187 self.assertThat(title, Eventually(Equals(orgTitle)))180 self.assertThat(self.player.currentMetaTitle,
188 self.assertThat(artist, Eventually(Equals(orgArtist)))181 Eventually(Equals(org_title)))
182 self.assertThat(self.player.currentMetaArtist,
183 Eventually(Equals(org_artist)))
189184
190 def test_mp3(self):185 def test_mp3(self):
191 """ Test that mp3 "plays" or at least doesn't crash on load """186 """ Test that mp3 "plays" or at least doesn't crash on load """
192187
193 self.app.populate_queue() # populate queue
194
195 now_playing_page = self.app.get_now_playing_page()
196 toolbar = self.app.get_toolbar()188 toolbar = self.app.get_toolbar()
197189
198 title = self.player.currentMetaTitle190 # Get list of tracks which are mp3 and then take the index of the first
199 artist = self.player.currentMetaArtist191 i = [i for i, track in enumerate(self.tracks)
200192 if track["source"].endswith("mp3")][0]
201 toolbar.set_shuffle(False)193
202194 # switch to tracks page
203 # ensure track appears before looping through queue more than once195 tracks_page = self.app.get_tracks_page()
204 # needs to contain test mp3 metadata and end in *.mp3196
205 queue_size = now_playing_page.get_count()197 # get track row and swipe to reveal actions
206 count = 0198 track = tracks_page.get_track(i)
207199 track.swipe_reveal_actions()
208 while title != "TestMP3Title" and artist != "TestMP3Artist":200
209 count = count + 1201 track.click_add_to_queue_action() # add track to queue
210202
211 self.assertThat(count, LessThan(queue_size))203 # wait for the player index to change
212204 self.player.currentIndex.wait_for(0)
213 """ Select next """205
214 toolbar.click_forward_button()206 # Ensure the current track is mp3
215
216 """ Pause track """
217 toolbar.click_play_button()
218 self.assertThat(self.player.isPlaying,
219 Eventually(Equals(False)))
220
221 title = self.player.currentMetaTitle
222 artist = self.player.currentMetaArtist
223 logger.debug("Current Song %s, %s" % (title, artist))
224 logger.debug("File found %s" % self.player.currentMetaFile)
225
226 # make sure mp3 plays
227 self.assertThat(self.player.source.endswith("mp3"),207 self.assertThat(self.player.source.endswith("mp3"),
228 Equals(True))208 Equals(True))
209
210 # Start playing the track
229 toolbar.click_play_button()211 toolbar.click_play_button()
212
213 # Check that the track is playing
230 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))214 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
231215
216 # Stop playing the track
217 toolbar.click_play_button()
218
219 # Check current meta data is correct
220 self.assertThat(self.player.currentMetaTitle,
221 Eventually(Equals(self.tracks[i]["title"])))
222 self.assertThat(self.player.currentMetaArtist,
223 Eventually(Equals(self.tracks[i]["artist"])))
224
232 def test_shuffle(self):225 def test_shuffle(self):
233 """ Test shuffle (Music Library must exist) """226 """ Test shuffle (Music Library must exist) """
234227
235 self.app.populate_queue() # populate queue228 self.app.populate_queue() # populate queue
236229
237 """ Track is playing, shuffle is turned on"""230 # at this point the track is playing and shuffle is enabled
231
238 toolbar = self.app.get_toolbar()232 toolbar = self.app.get_toolbar()
239233
240 # play for a second, then pause234 # pause the track if it is playing
241 if not self.player.isPlaying:235 if self.player.isPlaying:
242 logger.debug("Play not selected")
243 toolbar.click_play_button()236 toolbar.click_play_button()
244 else:237
245 logger.debug("Already playing")238 self.player.isPlaying.wait_for(False)
246239
247 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))240 toolbar.set_shuffle(True) # enable shuffle
248 time.sleep(1)241
249 toolbar.click_play_button()242 # save original song metadata
250 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))243 org_title = self.player.currentMetaTitle
244 org_artist = self.player.currentMetaArtist
245
246 logger.debug("Original Song %s, %s" % (org_title, org_artist))
251247
252 count = 0248 count = 0
253 while True:249
250 # loop while the track is the same if different then a shuffle occurred
251 while (org_title == self.player.currentMetaTitle and
252 org_artist == self.player.currentMetaArtist):
253 logger.debug("count %s" % (count))
254
255 # check count is valid
254 self.assertThat(count, LessThan(100))256 self.assertThat(count, LessThan(100))
255257
256 # goal is to hit next under shuffle mode258 # select next track
257 # then verify original track is not the previous track
258 # this means a true shuffle happened
259 # if it doesn't try again, up to count times
260
261 orgTitle = self.player.currentMetaTitle
262 orgArtist = self.player.currentMetaArtist
263 logger.debug("Original Song %s, %s" % (orgTitle, orgArtist))
264
265 if not toolbar.opened:
266 toolbar.show()
267
268 toolbar.set_shuffle(True)
269
270 toolbar.click_forward_button()259 toolbar.click_forward_button()
271 self.assertThat(self.player.isPlaying,260
272 Eventually(Equals(True)))261 # pause the track if it is playing
273262 if self.player.isPlaying:
274 title = self.player.currentMetaTitle263 toolbar.click_play_button()
275 artist = self.player.currentMetaArtist264
276 logger.debug("Current Song %s, %s" % (title, artist))265 # check it is paused
277266 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
278 # go back to previous and check against original267
279 # play song, then pause before switching268 # save current file so we can check it goes back
280 time.sleep(1)269 source = self.player.currentMetaFile
281 toolbar.click_play_button()270
282 self.assertThat(self.player.isPlaying,271 # select previous track while will break if this previous track
283 Eventually(Equals(False)))272 # is different and therefore a shuffle has occurred
284
285 toolbar.set_shuffle(False)
286
287 toolbar.click_previous_button()273 toolbar.click_previous_button()
288274
289 title = self.player.currentMetaTitle275 # pause the track if it is playing
290 artist = self.player.currentMetaArtist276 if self.player.isPlaying:
291277 toolbar.click_play_button()
292 if title != orgTitle and artist != orgArtist:278
293 # we shuffled properly279 # check it is paused
294 logger.debug("Yay, shuffled %s, %s" % (title, artist))280 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
295 break281
296 else:282 # check the file has actually changed
297 logger.debug("Same track, no shuffle %s, %s" % (title, artist))283 self.assertThat(self.player.currentMetaFile,
298284 Eventually(NotEquals(source)))
299 count += 1285
286 count += 1 # increment count
300287
301 def test_show_albums_page(self):288 def test_show_albums_page(self):
302 """tests navigating to the Albums tab and displaying the album page"""289 """tests navigating to the Albums tab and displaying the album page"""
303290
304 # switch to albums tab291 # switch to albums tab
305 albums_page = self.app.get_albums_page()292 albums_page = self.app.get_albums_page()
306 albums_page.click_album(self.album_index) # select album293 albums_page.click_album(0) # select album
307294
308 # get songs page album artist295 # get songs page album artist
309 songs_page = self.app.get_songs_page()296 songs_page = self.app.get_songs_page()
310 artist_label = songs_page.get_header_artist_label()297 artist_label = songs_page.get_header_artist_label()
311298
299 # build list of tracks sorted by album
300 tracks = self.tracks[:]
301 tracks.sort(key=lambda track: track["album"])
302
303 # check that the first is the same as
312 self.assertThat(artist_label.text,304 self.assertThat(artist_label.text,
313 Eventually(Equals(self.artist_name)))305 Eventually(Equals(tracks[0]["artist"])))
314306
315 # click on close button to close songs page307 # click on close button to close songs page
316 self.main_view.go_back()308 self.app.main_view.go_back()
317309
318 # check that the albums page is now visible310 # check that the albums page is now visible
319 self.assertThat(albums_page.visible, Eventually(Equals(True)))311 self.assertThat(albums_page.visible, Eventually(Equals(True)))
@@ -328,7 +320,11 @@
328320
329 # switch to albums tab321 # switch to albums tab
330 albums_page = self.app.get_albums_page()322 albums_page = self.app.get_albums_page()
331 albums_page.click_album(self.album_index) # select album323 albums_page.click_album(0) # select album
324
325 # build list of tracks sorted by album
326 tracks = self.tracks[:]
327 tracks.sort(key=lambda track: track["album"])
332328
333 # get track item to swipe and queue329 # get track item to swipe and queue
334 songs_page = self.app.get_songs_page()330 songs_page = self.app.get_songs_page()
@@ -349,12 +345,12 @@
349 current_track = now_playing_page.get_track(self.player.currentIndex)345 current_track = now_playing_page.get_track(self.player.currentIndex)
350346
351 self.assertThat(current_track.get_label_text("artistLabel"),347 self.assertThat(current_track.get_label_text("artistLabel"),
352 Equals(self.artist_name))348 Equals(tracks[0]["artist"]))
353 self.assertThat(current_track.get_label_text("titleLabel"),349 self.assertThat(current_track.get_label_text("titleLabel"),
354 Equals(self.track_title))350 Equals(tracks[0]["title"]))
355351
356 # click on close button to close songs page352 # click on close button to close songs page
357 self.main_view.go_back()353 self.app.main_view.go_back()
358354
359 # check that the albums page is now visible355 # check that the albums page is now visible
360 self.assertThat(albums_page.visible, Eventually(Equals(True)))356 self.assertThat(albums_page.visible, Eventually(Equals(True)))
@@ -386,9 +382,9 @@
386 current_track = now_playing_page.get_track(self.player.currentIndex)382 current_track = now_playing_page.get_track(self.player.currentIndex)
387383
388 self.assertThat(current_track.get_label_text("artistLabel"),384 self.assertThat(current_track.get_label_text("artistLabel"),
389 Equals(self.artist_name))385 Equals(self.tracks[0]["artist"]))
390 self.assertThat(current_track.get_label_text("titleLabel"),386 self.assertThat(current_track.get_label_text("titleLabel"),
391 Equals(self.track_title))387 Equals(self.tracks[0]["title"]))
392388
393 def test_add_song_to_queue_from_songs_tab(self):389 def test_add_song_to_queue_from_songs_tab(self):
394 """tests navigating to the Songs tab and adding a song from the library390 """tests navigating to the Songs tab and adding a song from the library
@@ -403,7 +399,7 @@
403 tracks_page = self.app.get_tracks_page()399 tracks_page = self.app.get_tracks_page()
404400
405 # get track row and swipe to reveal actions401 # get track row and swipe to reveal actions
406 track = tracks_page.get_track(self.track_index)402 track = tracks_page.get_track(0)
407 track.swipe_reveal_actions()403 track.swipe_reveal_actions()
408404
409 track.click_add_to_queue_action() # add track to queue405 track.click_add_to_queue_action() # add track to queue
@@ -421,9 +417,9 @@
421 current_track = now_playing_page.get_track(self.player.currentIndex)417 current_track = now_playing_page.get_track(self.player.currentIndex)
422418
423 self.assertThat(current_track.get_label_text("artistLabel"),419 self.assertThat(current_track.get_label_text("artistLabel"),
424 Equals(self.artist_name))420 Equals(self.tracks[0]["artist"]))
425 self.assertThat(current_track.get_label_text("titleLabel"),421 self.assertThat(current_track.get_label_text("titleLabel"),
426 Equals(self.track_title))422 Equals(self.tracks[0]["title"]))
427423
428 def test_create_playlist_from_songs_tab(self):424 def test_create_playlist_from_songs_tab(self):
429 """tests navigating to the Songs tab and creating a playlist by425 """tests navigating to the Songs tab and creating a playlist by
@@ -433,7 +429,7 @@
433 tracks_page = self.app.get_tracks_page()429 tracks_page = self.app.get_tracks_page()
434430
435 # get track row and swipe to reveal actions431 # get track row and swipe to reveal actions
436 track = tracks_page.get_track(self.track_index)432 track = tracks_page.get_track(0)
437 track.swipe_reveal_actions()433 track.swipe_reveal_actions()
438434
439 track.click_add_to_playlist_action() # add track to queue435 track.click_add_to_playlist_action() # add track to queue
@@ -484,26 +480,30 @@
484480
485 # switch to artists tab481 # switch to artists tab
486 artists_page = self.app.get_artists_page()482 artists_page = self.app.get_artists_page()
487 artists_page.click_artist(self.artist_index)483 artists_page.click_artist(0)
484
485 # build list of tracks sorted by artist
486 tracks = self.tracks[:]
487 tracks.sort(key=lambda track: track["artist"])
488488
489 # get albums (by an artist) page489 # get albums (by an artist) page
490 albums_page = self.app.get_albums_artist_page()490 albums_page = self.app.get_albums_artist_page()
491491
492 # check album artist label is correct492 # check album artist label is correct
493 self.assertThat(albums_page.get_artist(), Equals(self.artist_name))493 self.assertThat(albums_page.get_artist(), Equals(tracks[0]["artist"]))
494494
495 # click on album to show tracks495 # click on album to show tracks
496 albums_page.click_artist(self.album_artist_index)496 albums_page.click_artist(0)
497497
498 # get song page album artist498 # get song page album artist
499 songs_page = self.app.get_songs_page()499 songs_page = self.app.get_songs_page()
500500
501 # check the artist label501 # check the artist label
502 artist_label = songs_page.get_header_artist_label()502 artist_label = songs_page.get_header_artist_label()
503 self.assertThat(artist_label.text, Equals(self.artist_name))503 self.assertThat(artist_label.text, Equals(tracks[0]["artist"]))
504504
505 # click on track to play505 # click on track to play
506 songs_page.click_track(self.track_index)506 songs_page.click_track(0)
507507
508 # get now playing again as it has moved508 # get now playing again as it has moved
509 now_playing_page = self.app.get_now_playing_page()509 now_playing_page = self.app.get_now_playing_page()
@@ -521,9 +521,9 @@
521 current_track = now_playing_page.get_track(self.player.currentIndex)521 current_track = now_playing_page.get_track(self.player.currentIndex)
522522
523 self.assertThat(current_track.get_label_text("artistLabel"),523 self.assertThat(current_track.get_label_text("artistLabel"),
524 Equals(self.artist_name))524 Equals(tracks[0]["artist"]))
525 self.assertThat(current_track.get_label_text("titleLabel"),525 self.assertThat(current_track.get_label_text("titleLabel"),
526 Equals(self.track_title))526 Equals(tracks[0]["title"]))
527527
528 def test_swipe_to_delete_song(self):528 def test_swipe_to_delete_song(self):
529 """tests navigating to the Now Playing queue, swiping to delete a529 """tests navigating to the Now Playing queue, swiping to delete a
@@ -537,7 +537,7 @@
537 initial_queue_count = now_playing_page.get_count()537 initial_queue_count = now_playing_page.get_count()
538538
539 # get track row and swipe to reveal swipe to delete539 # get track row and swipe to reveal swipe to delete
540 track = now_playing_page.get_track(self.track_index)540 track = now_playing_page.get_track(0)
541 track.swipe_to_delete()541 track.swipe_to_delete()
542542
543 track.confirm_removal() # confirm delete543 track.confirm_removal() # confirm delete
@@ -580,8 +580,8 @@
580 toolbar.click_forward_button()580 toolbar.click_forward_button()
581581
582 # Make sure we loop back to first song after last song ends582 # Make sure we loop back to first song after last song ends
583 actual_title = lambda: self.player.currentMetaTitle583 self.assertThat(self.player.currentMetaTitle,
584 self.assertThat(actual_title, Eventually(Equals(self.track_title)))584 Eventually(Equals(self.tracks[0]["title"])))
585 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))585 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
586586
587 def test_pressing_next_from_last_song_plays_first_when_repeat_on(self):587 def test_pressing_next_from_last_song_plays_first_when_repeat_on(self):
@@ -599,8 +599,9 @@
599 for count in range(0, now_playing_page.get_count() - 1):599 for count in range(0, now_playing_page.get_count() - 1):
600 toolbar.click_forward_button()600 toolbar.click_forward_button()
601601
602 actual_title = lambda: self.player.currentMetaTitle602 # Make sure we loop back to first song after last song ends
603 self.assertThat(actual_title, Eventually(Equals(self.track_title)))603 self.assertThat(self.player.currentMetaTitle,
604 Eventually(Equals(self.tracks[0]["title"])))
604 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))605 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
605606
606 def test_pressing_prev_from_first_song_plays_last_when_repeat_on(self):607 def test_pressing_prev_from_first_song_plays_last_when_repeat_on(self):
@@ -622,7 +623,6 @@
622 if self.player.currentMetaTitle == initial_song:623 if self.player.currentMetaTitle == initial_song:
623 toolbar.click_previous_button()624 toolbar.click_previous_button()
624625
625 actual_title = lambda: self.player.currentMetaTitle626 self.assertThat(self.player.currentMetaTitle,
626 self.assertThat(actual_title,627 Eventually(Equals(self.tracks[-1]["title"])))
627 Eventually(Equals(self.last_track_title)))
628 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))628 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))

Subscribers

People subscribed via source and target branches

to status/vote changes: