Merge lp:~ahayzen/music-app/ap-helper-refactor-004 into lp:music-app/trusty
- ap-helper-refactor-004
- Merge into trusty
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 |
Related bugs: |
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:610
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Andrew Hayzen (ahayzen) wrote : | # |
#blocked bug 1365247 (mediascanner2 db schema change)
Andrew Hayzen (ahayzen) wrote : | # |
#unblocked
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:611
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:612
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:613
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Victor Thompson (vthompson) wrote : | # |
See inline comments.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:614
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:614
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:616
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:616
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
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.
Nicholas Skaggs (nskaggs) : | # |
Preview Diff
1 | === modified file 'MusicToolbar.qml' |
2 | --- MusicToolbar.qml 2014-08-22 23:41:29 +0000 |
3 | +++ MusicToolbar.qml 2014-09-10 13:42:37 +0000 |
4 | @@ -51,6 +51,9 @@ |
5 | property alias animating: musicToolbarPanel.animating |
6 | property alias opened: musicToolbarPanel.opened |
7 | |
8 | + // Alias for autopilot |
9 | + property alias currentMode: musicToolbarPanel.currentMode |
10 | + |
11 | Connections { |
12 | id: pageStackConn |
13 | target: mainPageStack |
14 | |
15 | === modified file 'tests/autopilot/music_app/__init__.py' |
16 | --- tests/autopilot/music_app/__init__.py 2014-09-04 20:02:14 +0000 |
17 | +++ tests/autopilot/music_app/__init__.py 2014-09-10 13:42:37 +0000 |
18 | @@ -15,8 +15,19 @@ |
19 | |
20 | def click_object(func): |
21 | """Wrapper which clicks the returned object""" |
22 | - def func_wrapper(self, *args): |
23 | - return self.pointing_device.click_object(func(self, *args)) |
24 | + def func_wrapper(self, *args, **kwargs): |
25 | + return self.pointing_device.click_object(func(self, *args, **kwargs)) |
26 | + |
27 | + return func_wrapper |
28 | + |
29 | + |
30 | +def ensure_toolbar_visible(func): |
31 | + """Wrapper which ensures the toolbar is shown before clicking""" |
32 | + def func_wrapper(self, *args, **kwargs): |
33 | + if not self.opened: |
34 | + self.show() |
35 | + |
36 | + return func(self, *args, **kwargs) |
37 | |
38 | return func_wrapper |
39 | |
40 | @@ -268,30 +279,35 @@ |
41 | root = self.get_root_instance() |
42 | self.player = root.select_single(Player, objectName="player") |
43 | |
44 | - @click_object |
45 | - def click_small_play_button(self): |
46 | - return self.wait_select_single("*", objectName="smallPlayShape") |
47 | - |
48 | + @ensure_toolbar_visible |
49 | @click_object |
50 | def click_forward_button(self): |
51 | return self.wait_select_single("*", objectName="forwardShape") |
52 | |
53 | + @ensure_toolbar_visible |
54 | @click_object |
55 | def click_play_button(self): |
56 | - return self.wait_select_single("*", objectName="playShape") |
57 | + if self.currentMode == "full": |
58 | + return self.wait_select_single("*", objectName="playShape") |
59 | + else: |
60 | + return self.wait_select_single("*", objectName="smallPlayShape") |
61 | |
62 | + @ensure_toolbar_visible |
63 | @click_object |
64 | def click_previous_button(self): |
65 | return self.wait_select_single("*", objectName="previousShape") |
66 | |
67 | + @ensure_toolbar_visible |
68 | @click_object |
69 | def click_repeat_button(self): |
70 | return self.wait_select_single("*", objectName="repeatShape") |
71 | |
72 | + @ensure_toolbar_visible |
73 | @click_object |
74 | def click_shuffle_button(self): |
75 | return self.wait_select_single("*", objectName="shuffleShape") |
76 | |
77 | + @ensure_toolbar_visible |
78 | def seek_to(self, percentage): |
79 | progress_bar = self.wait_select_single( |
80 | "*", objectName="progressBarShape") |
81 | @@ -303,12 +319,14 @@ |
82 | |
83 | self.pointing_device.drag(x1, y1, x2, y1) |
84 | |
85 | + @ensure_toolbar_visible |
86 | def set_repeat(self, state): |
87 | if self.player.repeat != state: |
88 | self.click_repeat_button() |
89 | |
90 | self.player.repeat.wait_for(state) |
91 | |
92 | + @ensure_toolbar_visible |
93 | def set_shuffle(self, state): |
94 | if self.player.shuffle != state: |
95 | self.click_shuffle_button() |
96 | |
97 | === modified file 'tests/autopilot/music_app/tests/test_music.py' |
98 | --- tests/autopilot/music_app/tests/test_music.py 2014-09-04 20:02:14 +0000 |
99 | +++ tests/autopilot/music_app/tests/test_music.py 2014-09-10 13:42:37 +0000 |
100 | @@ -9,7 +9,6 @@ |
101 | |
102 | from __future__ import absolute_import |
103 | |
104 | -import time |
105 | import logging |
106 | from autopilot.matchers import Eventually |
107 | from testtools.matchers import Equals, LessThan, NotEquals |
108 | @@ -25,36 +24,44 @@ |
109 | def setUp(self): |
110 | super(TestMainWindow, self).setUp() |
111 | |
112 | - self.album_artist_index = 0 # position on AlbumsPage |
113 | - self.album_index = 0 # position on MusicAlbums |
114 | - self.artist_index = 0 # position on MusicArtists |
115 | - self.track_index = 0 # position on MusicTracks |
116 | - self.track_title = u"Gran Vals" |
117 | - self.artist_name = u"Francisco Tárrega" |
118 | - self.last_track_title = u"TestMP3Title" |
119 | - |
120 | - @property |
121 | - def main_view(self): |
122 | - return self.app.main_view |
123 | + # metadata for test tracks sorted by title |
124 | + # tests should sort themselves if they require by artist/album |
125 | + self.tracks = [ |
126 | + { |
127 | + "album": "", |
128 | + "artist": u"Francisco Tárrega", |
129 | + "source": "1.ogg", |
130 | + "title": u"Gran Vals" |
131 | + }, |
132 | + { |
133 | + "album": "", |
134 | + "artist": "Josh Woodward", |
135 | + "source": "2.ogg", |
136 | + "title": "Swansong" |
137 | + }, |
138 | + { |
139 | + "album": "TestMP3Album", |
140 | + "artist": "TestMP3Artist", |
141 | + "source": "3.mp3", |
142 | + "title": "TestMP3Title", |
143 | + } |
144 | + ] |
145 | |
146 | @property |
147 | def player(self): |
148 | return self.app.player |
149 | |
150 | - @property |
151 | - def pointing_device(self): |
152 | - return self.app.app.pointing_device |
153 | - |
154 | def test_reads_music_library(self): |
155 | """ tests if the music library is populated from our |
156 | fake mediascanner database""" |
157 | |
158 | self.app.populate_queue() # populate queue |
159 | |
160 | - title = lambda: self.player.currentMetaTitle |
161 | - artist = lambda: self.player.currentMetaArtist |
162 | - self.assertThat(title, Eventually(Equals(self.track_title))) |
163 | - self.assertThat(artist, Eventually(Equals(self.artist_name))) |
164 | + # Check current meta data is correct |
165 | + self.assertThat(self.player.currentMetaTitle, |
166 | + Eventually(Equals(self.tracks[0]["title"]))) |
167 | + self.assertThat(self.player.currentMetaArtist, |
168 | + Eventually(Equals(self.tracks[0]["artist"]))) |
169 | |
170 | def test_play_pause_library(self): |
171 | """ Test playing and pausing a track (Music Library must exist) """ |
172 | @@ -65,21 +72,17 @@ |
173 | # get number of tracks in queue before queuing a track |
174 | initial_tracks_count = now_playing_page.get_count() |
175 | |
176 | - # switch to albums tab |
177 | - albums_page = self.app.get_albums_page() |
178 | - albums_page.click_album(self.album_index) # select album |
179 | + # switch to albums tab and select the album |
180 | + self.app.get_albums_page().click_album(0) |
181 | |
182 | # get track item to swipe and queue |
183 | - songs_page = self.app.get_songs_page() |
184 | - |
185 | - track = songs_page.get_track(0) |
186 | + track = self.app.get_songs_page().get_track(0) |
187 | track.swipe_reveal_actions() |
188 | |
189 | track.click_add_to_queue_action() # add track to the queue |
190 | |
191 | - # verify track queue has added one to initial value |
192 | - self.assertThat(now_playing_page.get_count(), |
193 | - Eventually(Equals(initial_tracks_count + 1))) |
194 | + # wait for track to be queued |
195 | + now_playing_page.get_count().wait_for(initial_tracks_count + 1) |
196 | |
197 | end_tracks_count = now_playing_page.get_count() |
198 | |
199 | @@ -92,28 +95,19 @@ |
200 | current_track = now_playing_page.get_track(self.player.currentIndex) |
201 | |
202 | self.assertThat(current_track.get_label_text("artistLabel"), |
203 | - Equals(self.artist_name)) |
204 | + Equals(self.tracks[0]["artist"])) |
205 | self.assertThat(current_track.get_label_text("titleLabel"), |
206 | - Equals(self.track_title)) |
207 | + Equals(self.tracks[0]["title"])) |
208 | |
209 | # click on close button to close the page |
210 | - self.main_view.go_back() |
211 | - |
212 | - """ Track is playing""" |
213 | - if self.main_view.wideAspect: |
214 | - click_play_button = toolbar.click_play_button |
215 | - else: |
216 | - if not toolbar.opened: |
217 | - toolbar.show() |
218 | - |
219 | - click_play_button = toolbar.click_small_play_button |
220 | - |
221 | - click_play_button() |
222 | - |
223 | + self.app.main_view.go_back() |
224 | + |
225 | + # click the play button to start playing |
226 | + toolbar.click_play_button() |
227 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
228 | |
229 | - """ Track is not playing""" |
230 | - click_play_button() |
231 | + # click the play button to stop playing |
232 | + toolbar.click_play_button() |
233 | self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
234 | |
235 | def test_play_pause_now_playing(self): |
236 | @@ -123,15 +117,15 @@ |
237 | |
238 | toolbar = self.app.get_toolbar() |
239 | |
240 | - """ Track is playing""" |
241 | + # check that the player is playing and then select pause |
242 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
243 | toolbar.click_play_button() |
244 | |
245 | - """ Track is not playing""" |
246 | + # check that the player is paused and then select play |
247 | self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
248 | - |
249 | - """ Track is playing""" |
250 | toolbar.click_play_button() |
251 | + |
252 | + # check that the player is playing |
253 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
254 | |
255 | def test_next_previous(self): |
256 | @@ -141,179 +135,177 @@ |
257 | |
258 | toolbar = self.app.get_toolbar() |
259 | |
260 | - title = lambda: self.player.currentMetaTitle |
261 | - artist = lambda: self.player.currentMetaArtist |
262 | - |
263 | - orgTitle = self.player.currentMetaTitle |
264 | - orgArtist = self.player.currentMetaArtist |
265 | + # save original song data for later |
266 | + org_title = self.player.currentMetaTitle |
267 | + org_artist = self.player.currentMetaArtist |
268 | |
269 | # check original track |
270 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
271 | - logger.debug("Original Song %s, %s" % (orgTitle, orgArtist)) |
272 | + logger.debug("Original Song %s, %s" % (org_title, org_artist)) |
273 | |
274 | - """ Pause track """ |
275 | + # select pause and check the player has stopped |
276 | toolbar.click_play_button() |
277 | self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
278 | |
279 | - toolbar.set_shuffle(False) |
280 | + toolbar.set_shuffle(False) # ensure shuffe is off |
281 | |
282 | - """ Select next """ |
283 | # goal is to go back and forth and ensure 2 different songs |
284 | toolbar.click_forward_button() |
285 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
286 | |
287 | - """ Pause track """ |
288 | + # select pause and check the player has stopped |
289 | toolbar.click_play_button() |
290 | self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
291 | |
292 | # ensure different song |
293 | - self.assertThat(title, Eventually(NotEquals(orgTitle))) |
294 | - self.assertThat(artist, Eventually(NotEquals(orgArtist))) |
295 | - nextTitle = self.player.currentMetaTitle |
296 | - nextArtist = self.player.currentMetaArtist |
297 | - logger.debug("Next Song %s, %s" % (nextTitle, nextArtist)) |
298 | + self.assertThat(self.player.currentMetaTitle, |
299 | + Eventually(NotEquals(org_title))) |
300 | + self.assertThat(self.player.currentMetaArtist, |
301 | + Eventually(NotEquals(org_artist))) |
302 | + |
303 | + logger.debug("Next Song %s, %s" % (self.player.currentMetaTitle, |
304 | + self.player.currentMetaArtist)) |
305 | |
306 | toolbar.seek_to(0) # seek to 0 (start) |
307 | |
308 | - """ Select previous """ |
309 | + # select previous and ensure the track is playing |
310 | toolbar.click_previous_button() |
311 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
312 | |
313 | - """ Pause track """ |
314 | + # select pause and check the player has stopped |
315 | toolbar.click_play_button() |
316 | self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
317 | |
318 | # ensure we're back to original song |
319 | - self.assertThat(title, Eventually(Equals(orgTitle))) |
320 | - self.assertThat(artist, Eventually(Equals(orgArtist))) |
321 | + self.assertThat(self.player.currentMetaTitle, |
322 | + Eventually(Equals(org_title))) |
323 | + self.assertThat(self.player.currentMetaArtist, |
324 | + Eventually(Equals(org_artist))) |
325 | |
326 | def test_mp3(self): |
327 | """ Test that mp3 "plays" or at least doesn't crash on load """ |
328 | |
329 | - self.app.populate_queue() # populate queue |
330 | - |
331 | - now_playing_page = self.app.get_now_playing_page() |
332 | toolbar = self.app.get_toolbar() |
333 | |
334 | - title = self.player.currentMetaTitle |
335 | - artist = self.player.currentMetaArtist |
336 | - |
337 | - toolbar.set_shuffle(False) |
338 | - |
339 | - # ensure track appears before looping through queue more than once |
340 | - # needs to contain test mp3 metadata and end in *.mp3 |
341 | - queue_size = now_playing_page.get_count() |
342 | - count = 0 |
343 | - |
344 | - while title != "TestMP3Title" and artist != "TestMP3Artist": |
345 | - count = count + 1 |
346 | - |
347 | - self.assertThat(count, LessThan(queue_size)) |
348 | - |
349 | - """ Select next """ |
350 | - toolbar.click_forward_button() |
351 | - |
352 | - """ Pause track """ |
353 | - toolbar.click_play_button() |
354 | - self.assertThat(self.player.isPlaying, |
355 | - Eventually(Equals(False))) |
356 | - |
357 | - title = self.player.currentMetaTitle |
358 | - artist = self.player.currentMetaArtist |
359 | - logger.debug("Current Song %s, %s" % (title, artist)) |
360 | - logger.debug("File found %s" % self.player.currentMetaFile) |
361 | - |
362 | - # make sure mp3 plays |
363 | + # Get list of tracks which are mp3 and then take the index of the first |
364 | + i = [i for i, track in enumerate(self.tracks) |
365 | + if track["source"].endswith("mp3")][0] |
366 | + |
367 | + # switch to tracks page |
368 | + tracks_page = self.app.get_tracks_page() |
369 | + |
370 | + # get track row and swipe to reveal actions |
371 | + track = tracks_page.get_track(i) |
372 | + track.swipe_reveal_actions() |
373 | + |
374 | + track.click_add_to_queue_action() # add track to queue |
375 | + |
376 | + # wait for the player index to change |
377 | + self.player.currentIndex.wait_for(0) |
378 | + |
379 | + # Ensure the current track is mp3 |
380 | self.assertThat(self.player.source.endswith("mp3"), |
381 | Equals(True)) |
382 | + |
383 | + # Start playing the track |
384 | toolbar.click_play_button() |
385 | + |
386 | + # Check that the track is playing |
387 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
388 | |
389 | + # Stop playing the track |
390 | + toolbar.click_play_button() |
391 | + |
392 | + # Check current meta data is correct |
393 | + self.assertThat(self.player.currentMetaTitle, |
394 | + Eventually(Equals(self.tracks[i]["title"]))) |
395 | + self.assertThat(self.player.currentMetaArtist, |
396 | + Eventually(Equals(self.tracks[i]["artist"]))) |
397 | + |
398 | def test_shuffle(self): |
399 | """ Test shuffle (Music Library must exist) """ |
400 | |
401 | self.app.populate_queue() # populate queue |
402 | |
403 | - """ Track is playing, shuffle is turned on""" |
404 | + # at this point the track is playing and shuffle is enabled |
405 | + |
406 | toolbar = self.app.get_toolbar() |
407 | |
408 | - # play for a second, then pause |
409 | - if not self.player.isPlaying: |
410 | - logger.debug("Play not selected") |
411 | + # pause the track if it is playing |
412 | + if self.player.isPlaying: |
413 | toolbar.click_play_button() |
414 | - else: |
415 | - logger.debug("Already playing") |
416 | - |
417 | - self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
418 | - time.sleep(1) |
419 | - toolbar.click_play_button() |
420 | - self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
421 | + |
422 | + self.player.isPlaying.wait_for(False) |
423 | + |
424 | + toolbar.set_shuffle(True) # enable shuffle |
425 | + |
426 | + # save original song metadata |
427 | + org_title = self.player.currentMetaTitle |
428 | + org_artist = self.player.currentMetaArtist |
429 | + |
430 | + logger.debug("Original Song %s, %s" % (org_title, org_artist)) |
431 | |
432 | count = 0 |
433 | - while True: |
434 | + |
435 | + # loop while the track is the same if different then a shuffle occurred |
436 | + while (org_title == self.player.currentMetaTitle and |
437 | + org_artist == self.player.currentMetaArtist): |
438 | + logger.debug("count %s" % (count)) |
439 | + |
440 | + # check count is valid |
441 | self.assertThat(count, LessThan(100)) |
442 | |
443 | - # goal is to hit next under shuffle mode |
444 | - # then verify original track is not the previous track |
445 | - # this means a true shuffle happened |
446 | - # if it doesn't try again, up to count times |
447 | - |
448 | - orgTitle = self.player.currentMetaTitle |
449 | - orgArtist = self.player.currentMetaArtist |
450 | - logger.debug("Original Song %s, %s" % (orgTitle, orgArtist)) |
451 | - |
452 | - if not toolbar.opened: |
453 | - toolbar.show() |
454 | - |
455 | - toolbar.set_shuffle(True) |
456 | - |
457 | + # select next track |
458 | toolbar.click_forward_button() |
459 | - self.assertThat(self.player.isPlaying, |
460 | - Eventually(Equals(True))) |
461 | - |
462 | - title = self.player.currentMetaTitle |
463 | - artist = self.player.currentMetaArtist |
464 | - logger.debug("Current Song %s, %s" % (title, artist)) |
465 | - |
466 | - # go back to previous and check against original |
467 | - # play song, then pause before switching |
468 | - time.sleep(1) |
469 | - toolbar.click_play_button() |
470 | - self.assertThat(self.player.isPlaying, |
471 | - Eventually(Equals(False))) |
472 | - |
473 | - toolbar.set_shuffle(False) |
474 | - |
475 | + |
476 | + # pause the track if it is playing |
477 | + if self.player.isPlaying: |
478 | + toolbar.click_play_button() |
479 | + |
480 | + # check it is paused |
481 | + self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
482 | + |
483 | + # save current file so we can check it goes back |
484 | + source = self.player.currentMetaFile |
485 | + |
486 | + # select previous track while will break if this previous track |
487 | + # is different and therefore a shuffle has occurred |
488 | toolbar.click_previous_button() |
489 | |
490 | - title = self.player.currentMetaTitle |
491 | - artist = self.player.currentMetaArtist |
492 | - |
493 | - if title != orgTitle and artist != orgArtist: |
494 | - # we shuffled properly |
495 | - logger.debug("Yay, shuffled %s, %s" % (title, artist)) |
496 | - break |
497 | - else: |
498 | - logger.debug("Same track, no shuffle %s, %s" % (title, artist)) |
499 | - |
500 | - count += 1 |
501 | + # pause the track if it is playing |
502 | + if self.player.isPlaying: |
503 | + toolbar.click_play_button() |
504 | + |
505 | + # check it is paused |
506 | + self.assertThat(self.player.isPlaying, Eventually(Equals(False))) |
507 | + |
508 | + # check the file has actually changed |
509 | + self.assertThat(self.player.currentMetaFile, |
510 | + Eventually(NotEquals(source))) |
511 | + |
512 | + count += 1 # increment count |
513 | |
514 | def test_show_albums_page(self): |
515 | """tests navigating to the Albums tab and displaying the album page""" |
516 | |
517 | # switch to albums tab |
518 | albums_page = self.app.get_albums_page() |
519 | - albums_page.click_album(self.album_index) # select album |
520 | + albums_page.click_album(0) # select album |
521 | |
522 | # get songs page album artist |
523 | songs_page = self.app.get_songs_page() |
524 | artist_label = songs_page.get_header_artist_label() |
525 | |
526 | + # build list of tracks sorted by album |
527 | + tracks = self.tracks[:] |
528 | + tracks.sort(key=lambda track: track["album"]) |
529 | + |
530 | + # check that the first is the same as |
531 | self.assertThat(artist_label.text, |
532 | - Eventually(Equals(self.artist_name))) |
533 | + Eventually(Equals(tracks[0]["artist"]))) |
534 | |
535 | # click on close button to close songs page |
536 | - self.main_view.go_back() |
537 | + self.app.main_view.go_back() |
538 | |
539 | # check that the albums page is now visible |
540 | self.assertThat(albums_page.visible, Eventually(Equals(True))) |
541 | @@ -328,7 +320,11 @@ |
542 | |
543 | # switch to albums tab |
544 | albums_page = self.app.get_albums_page() |
545 | - albums_page.click_album(self.album_index) # select album |
546 | + albums_page.click_album(0) # select album |
547 | + |
548 | + # build list of tracks sorted by album |
549 | + tracks = self.tracks[:] |
550 | + tracks.sort(key=lambda track: track["album"]) |
551 | |
552 | # get track item to swipe and queue |
553 | songs_page = self.app.get_songs_page() |
554 | @@ -349,12 +345,12 @@ |
555 | current_track = now_playing_page.get_track(self.player.currentIndex) |
556 | |
557 | self.assertThat(current_track.get_label_text("artistLabel"), |
558 | - Equals(self.artist_name)) |
559 | + Equals(tracks[0]["artist"])) |
560 | self.assertThat(current_track.get_label_text("titleLabel"), |
561 | - Equals(self.track_title)) |
562 | + Equals(tracks[0]["title"])) |
563 | |
564 | # click on close button to close songs page |
565 | - self.main_view.go_back() |
566 | + self.app.main_view.go_back() |
567 | |
568 | # check that the albums page is now visible |
569 | self.assertThat(albums_page.visible, Eventually(Equals(True))) |
570 | @@ -386,9 +382,9 @@ |
571 | current_track = now_playing_page.get_track(self.player.currentIndex) |
572 | |
573 | self.assertThat(current_track.get_label_text("artistLabel"), |
574 | - Equals(self.artist_name)) |
575 | + Equals(self.tracks[0]["artist"])) |
576 | self.assertThat(current_track.get_label_text("titleLabel"), |
577 | - Equals(self.track_title)) |
578 | + Equals(self.tracks[0]["title"])) |
579 | |
580 | def test_add_song_to_queue_from_songs_tab(self): |
581 | """tests navigating to the Songs tab and adding a song from the library |
582 | @@ -403,7 +399,7 @@ |
583 | tracks_page = self.app.get_tracks_page() |
584 | |
585 | # get track row and swipe to reveal actions |
586 | - track = tracks_page.get_track(self.track_index) |
587 | + track = tracks_page.get_track(0) |
588 | track.swipe_reveal_actions() |
589 | |
590 | track.click_add_to_queue_action() # add track to queue |
591 | @@ -421,9 +417,9 @@ |
592 | current_track = now_playing_page.get_track(self.player.currentIndex) |
593 | |
594 | self.assertThat(current_track.get_label_text("artistLabel"), |
595 | - Equals(self.artist_name)) |
596 | + Equals(self.tracks[0]["artist"])) |
597 | self.assertThat(current_track.get_label_text("titleLabel"), |
598 | - Equals(self.track_title)) |
599 | + Equals(self.tracks[0]["title"])) |
600 | |
601 | def test_create_playlist_from_songs_tab(self): |
602 | """tests navigating to the Songs tab and creating a playlist by |
603 | @@ -433,7 +429,7 @@ |
604 | tracks_page = self.app.get_tracks_page() |
605 | |
606 | # get track row and swipe to reveal actions |
607 | - track = tracks_page.get_track(self.track_index) |
608 | + track = tracks_page.get_track(0) |
609 | track.swipe_reveal_actions() |
610 | |
611 | track.click_add_to_playlist_action() # add track to queue |
612 | @@ -484,26 +480,30 @@ |
613 | |
614 | # switch to artists tab |
615 | artists_page = self.app.get_artists_page() |
616 | - artists_page.click_artist(self.artist_index) |
617 | + artists_page.click_artist(0) |
618 | + |
619 | + # build list of tracks sorted by artist |
620 | + tracks = self.tracks[:] |
621 | + tracks.sort(key=lambda track: track["artist"]) |
622 | |
623 | # get albums (by an artist) page |
624 | albums_page = self.app.get_albums_artist_page() |
625 | |
626 | # check album artist label is correct |
627 | - self.assertThat(albums_page.get_artist(), Equals(self.artist_name)) |
628 | + self.assertThat(albums_page.get_artist(), Equals(tracks[0]["artist"])) |
629 | |
630 | # click on album to show tracks |
631 | - albums_page.click_artist(self.album_artist_index) |
632 | + albums_page.click_artist(0) |
633 | |
634 | # get song page album artist |
635 | songs_page = self.app.get_songs_page() |
636 | |
637 | # check the artist label |
638 | artist_label = songs_page.get_header_artist_label() |
639 | - self.assertThat(artist_label.text, Equals(self.artist_name)) |
640 | + self.assertThat(artist_label.text, Equals(tracks[0]["artist"])) |
641 | |
642 | # click on track to play |
643 | - songs_page.click_track(self.track_index) |
644 | + songs_page.click_track(0) |
645 | |
646 | # get now playing again as it has moved |
647 | now_playing_page = self.app.get_now_playing_page() |
648 | @@ -521,9 +521,9 @@ |
649 | current_track = now_playing_page.get_track(self.player.currentIndex) |
650 | |
651 | self.assertThat(current_track.get_label_text("artistLabel"), |
652 | - Equals(self.artist_name)) |
653 | + Equals(tracks[0]["artist"])) |
654 | self.assertThat(current_track.get_label_text("titleLabel"), |
655 | - Equals(self.track_title)) |
656 | + Equals(tracks[0]["title"])) |
657 | |
658 | def test_swipe_to_delete_song(self): |
659 | """tests navigating to the Now Playing queue, swiping to delete a |
660 | @@ -537,7 +537,7 @@ |
661 | initial_queue_count = now_playing_page.get_count() |
662 | |
663 | # get track row and swipe to reveal swipe to delete |
664 | - track = now_playing_page.get_track(self.track_index) |
665 | + track = now_playing_page.get_track(0) |
666 | track.swipe_to_delete() |
667 | |
668 | track.confirm_removal() # confirm delete |
669 | @@ -580,8 +580,8 @@ |
670 | toolbar.click_forward_button() |
671 | |
672 | # Make sure we loop back to first song after last song ends |
673 | - actual_title = lambda: self.player.currentMetaTitle |
674 | - self.assertThat(actual_title, Eventually(Equals(self.track_title))) |
675 | + self.assertThat(self.player.currentMetaTitle, |
676 | + Eventually(Equals(self.tracks[0]["title"]))) |
677 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
678 | |
679 | def test_pressing_next_from_last_song_plays_first_when_repeat_on(self): |
680 | @@ -599,8 +599,9 @@ |
681 | for count in range(0, now_playing_page.get_count() - 1): |
682 | toolbar.click_forward_button() |
683 | |
684 | - actual_title = lambda: self.player.currentMetaTitle |
685 | - self.assertThat(actual_title, Eventually(Equals(self.track_title))) |
686 | + # Make sure we loop back to first song after last song ends |
687 | + self.assertThat(self.player.currentMetaTitle, |
688 | + Eventually(Equals(self.tracks[0]["title"]))) |
689 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
690 | |
691 | def test_pressing_prev_from_first_song_plays_last_when_repeat_on(self): |
692 | @@ -622,7 +623,6 @@ |
693 | if self.player.currentMetaTitle == initial_song: |
694 | toolbar.click_previous_button() |
695 | |
696 | - actual_title = lambda: self.player.currentMetaTitle |
697 | - self.assertThat(actual_title, |
698 | - Eventually(Equals(self.last_track_title))) |
699 | + self.assertThat(self.player.currentMetaTitle, |
700 | + Eventually(Equals(self.tracks[-1]["title"]))) |
701 | self.assertThat(self.player.isPlaying, Eventually(Equals(True))) |
FAILED: Continuous integration, rev:609 91.189. 93.70:8080/ job/music- app-ci/ 1090/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 1844/console 91.189. 93.70:8080/ job/music- app-utopic- amd64-ci/ 314/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/music- app-ci/ 1090/rebuild
http://