Merge lp:~ahayzen/music-app/remix-async-now-playing into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 702
Merged at revision: 701
Proposed branch: lp:~ahayzen/music-app/remix-async-now-playing
Merge into: lp:music-app/remix
Diff against target: 256 lines (+43/-40)
4 files modified
MusicNowPlaying.qml (+3/-5)
music-app.qml (+24/-18)
tests/autopilot/music_app/__init__.py (+6/-0)
tests/autopilot/music_app/tests/test_music.py (+10/-17)
To merge this branch: bzr merge lp:~ahayzen/music-app/remix-async-now-playing
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+239518@code.launchpad.net

Commit message

* Async loading of MusicNowPlaying

Description of the change

* Async loading of MusicNowPlaying

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

LGTM!

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

* Fixes for autopilot

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

* Fixes for pyflakes and pep8

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 :

AP test updates LGTM!

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-10-22 22:39:03 +0000
3+++ MusicNowPlaying.qml 2014-10-24 12:56:33 +0000
4@@ -302,16 +302,14 @@
5
6 Connections {
7 target: player
8- onDurationChanged: {
9- musicToolbarFullDurationLabel.text = durationToString(player.duration)
10- progressSliderMusic.maximumValue = player.duration
11- }
12 onPositionChanged: {
13 // seeked is a workaround for bug 1310706 as the first position after a seek is sometimes invalid (0)
14 if (progressSliderMusic.seeking === false && !progressSliderMusic.seeked) {
15- progressSliderMusic.value = player.position
16 musicToolbarFullPositionLabel.text = durationToString(player.position)
17 musicToolbarFullDurationLabel.text = durationToString(player.duration)
18+
19+ progressSliderMusic.value = player.position
20+ progressSliderMusic.maximumValue = player.duration
21 }
22
23 progressSliderMusic.seeked = false;
24
25=== modified file 'music-app.qml'
26--- music-app.qml 2014-10-22 17:46:50 +0000
27+++ music-app.qml 2014-10-24 12:56:33 +0000
28@@ -87,9 +87,9 @@
29 break;
30 case Qt.Key_J: // Ctrl+J Jump to playing song
31 tabs.pushNowPlaying()
32- nowPlaying.isListView = true;
33+ mainPageStack.currentPage.isListView = true
34 break;
35- case Qt.Key_N: // Ctrl+N Show now playing
36+ case Qt.Key_N: // Ctrl+N Show Now playing
37 tabs.pushNowPlaying()
38 break;
39 case Qt.Key_P: // Ctrl+P Toggle playing state
40@@ -629,10 +629,10 @@
41 clear = clear === undefined ? false : clear // force clear and will ignore player.toggle()
42
43 if (!clear) {
44- // If same track and on now playing page then toggle
45- if (musicToolbar.currentPage === nowPlaying &&
46- trackQueue.model.get(player.currentIndex) !== undefined &&
47- Qt.resolvedUrl(trackQueue.model.get(player.currentIndex).filename) === file) {
48+ // If same track and on Now playing page then toggle
49+ if ((mainPageStack.currentPage.title === i18n.tr("Now playing") || mainPageStack.currentPage.title === i18n.tr("Queue"))
50+ && trackQueue.model.get(player.currentIndex) !== undefined
51+ && Qt.resolvedUrl(trackQueue.model.get(player.currentIndex).filename) === file) {
52 player.toggle()
53 return;
54 }
55@@ -645,7 +645,7 @@
56 if (play) {
57 player.playSong(file, index);
58
59- // Show the Now Playing page and make sure the track is visible
60+ // Show the Now playing page and make sure the track is visible
61 tabs.pushNowPlaying();
62 }
63 else {
64@@ -661,10 +661,8 @@
65 player.playSong(trackQueue.model.get(index).filename, index);
66 }
67
68- // Show the Now Playing page and make sure the track is visible
69- if (!nowPlaying.isListView) {
70- tabs.pushNowPlaying();
71- }
72+ // Show the Now playing page and make sure the track is visible
73+ tabs.pushNowPlaying();
74 }
75
76 function playRandomSong(shuffle)
77@@ -762,6 +760,7 @@
78 // list of tracks on startup. This is just during development
79 LibraryListModel {
80 id: trackQueue
81+ objectName: "trackQueue"
82
83 function append(listElement)
84 {
85@@ -842,7 +841,7 @@
86
87 MusicToolbar {
88 id: musicToolbar
89- visible: nowPlaying.isListView || !nowPlaying.visible
90+ visible: mainPageStack.currentPage.title !== i18n.tr("Now playing")
91 objectName: "musicToolbarObject"
92 z: 200 // put on top of everything else
93 }
94@@ -993,11 +992,22 @@
95 function pushNowPlaying()
96 {
97 // only push if on a different page
98- if (mainPageStack.currentPage !== nowPlaying) {
99+ if (mainPageStack.currentPage.title !== i18n.tr("Now playing")
100+ && mainPageStack.currentPage.title !== i18n.tr("Queue")) {
101+
102+ var comp = Qt.createComponent("MusicNowPlaying.qml")
103+ var nowPlaying = comp.createObject(mainPageStack, {});
104+
105+ if (nowPlaying === null) { // Error Handling
106+ console.log("Error creating object");
107+ }
108+
109 mainPageStack.push(nowPlaying);
110 }
111
112- nowPlaying.isListView = false; // ensure full view
113+ if (mainPageStack.currentPage.title === i18n.tr("Queue")) {
114+ mainPageStack.currentPage.isListView = false; // ensure full view
115+ }
116 }
117
118 Component.onCompleted: musicToolbar.currentTab = selectedTab
119@@ -1024,10 +1034,6 @@
120 id: albumsPage
121 }
122
123- MusicNowPlaying {
124- id: nowPlaying
125- }
126-
127 MusicaddtoPlaylist {
128 id: addtoPlaylist
129 }
130
131=== modified file 'tests/autopilot/music_app/__init__.py'
132--- tests/autopilot/music_app/__init__.py 2014-10-21 21:06:07 +0000
133+++ tests/autopilot/music_app/__init__.py 2014-10-24 12:56:33 +0000
134@@ -85,6 +85,10 @@
135 return self.main_view.wait_select_single(
136 MusicPlaylists, objectName='playlistsPage')
137
138+ def get_queue_count(self):
139+ return self.main_view.select_single("LibraryListModel",
140+ objectName="trackQueue").count
141+
142 def get_songs_page(self):
143 return self.app.wait_select_single(SongsPage, objectName="songsPage")
144
145@@ -237,6 +241,8 @@
146 root = self.get_root_instance()
147 self.player = root.select_single(Player, objectName="player")
148
149+ self.visible.wait_for(True)
150+
151 @ensure_now_playing_full
152 @click_object
153 def click_forward_button(self):
154
155=== modified file 'tests/autopilot/music_app/tests/test_music.py'
156--- tests/autopilot/music_app/tests/test_music.py 2014-10-07 15:24:08 +0000
157+++ tests/autopilot/music_app/tests/test_music.py 2014-10-24 12:56:33 +0000
158@@ -66,11 +66,10 @@
159 def test_play_pause_library(self):
160 """ Test playing and pausing a track (Music Library must exist) """
161
162- now_playing_page = self.app.get_now_playing_page()
163 toolbar = self.app.get_toolbar()
164
165 # get number of tracks in queue before queuing a track
166- initial_tracks_count = now_playing_page.get_count()
167+ initial_tracks_count = self.app.get_queue_count()
168
169 # switch to albums tab and select the album
170 self.app.get_albums_page().click_album(0)
171@@ -82,9 +81,9 @@
172 track.click_add_to_queue_action() # add track to the queue
173
174 # wait for track to be queued
175- now_playing_page.get_count().wait_for(initial_tracks_count + 1)
176+ self.app.get_queue_count().wait_for(initial_tracks_count + 1)
177
178- end_tracks_count = now_playing_page.get_count()
179+ end_tracks_count = self.app.get_queue_count()
180
181 # Assert that the song added to the list is not playing
182 self.assertThat(self.player.currentIndex,
183@@ -318,11 +317,10 @@
184 def test_add_song_to_queue_from_albums_page(self):
185 """tests navigating to the Albums tab and adding a song to queue"""
186
187- now_playing_page = self.app.get_now_playing_page()
188 toolbar = self.app.get_toolbar()
189
190 # get number of tracks in queue before queuing a track
191- initial_tracks_count = now_playing_page.get_count()
192+ initial_tracks_count = self.app.get_queue_count()
193
194 # switch to albums tab
195 albums_page = self.app.get_albums_page()
196@@ -341,7 +339,7 @@
197 track.click_add_to_queue_action() # add track to the queue
198
199 # verify track queue has added one to initial value
200- self.assertThat(now_playing_page.get_count(),
201+ self.assertThat(self.app.get_queue_count(),
202 Eventually(Equals(initial_tracks_count + 1)))
203
204 # Assert that the song added to the list is not playing
205@@ -370,10 +368,8 @@
206 """tests navigating to the Songs tab and adding the library to the
207 queue with the selected item being played. """
208
209- now_playing_page = self.app.get_now_playing_page()
210-
211 # get number of tracks in queue before queuing a track
212- initial_tracks_count = now_playing_page.get_count()
213+ initial_tracks_count = self.app.get_queue_count()
214
215 self.app.populate_queue() # populate queue
216
217@@ -401,11 +397,10 @@
218 """tests navigating to the Songs tab and adding a song from the library
219 to the queue via the expandable list view item. """
220
221- now_playing_page = self.app.get_now_playing_page()
222 toolbar = self.app.get_toolbar()
223
224 # get number of tracks in queue before queuing a track
225- initial_tracks_count = now_playing_page.get_count()
226+ initial_tracks_count = self.app.get_queue_count()
227
228 # switch to tracks page
229 tracks_page = self.app.get_tracks_page()
230@@ -417,12 +412,12 @@
231 track.click_add_to_queue_action() # add track to queue
232
233 # verify track queue has added all songs to initial value
234- self.assertThat(now_playing_page.get_count(),
235+ self.assertThat(self.app.get_queue_count(),
236 Eventually(Equals(initial_tracks_count + 1)))
237
238 # Assert that the song added to the list is not playing
239 self.assertThat(self.player.currentIndex,
240- Eventually(NotEquals(now_playing_page.get_count())))
241+ Eventually(NotEquals(self.app.get_queue_count())))
242 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
243
244 toolbar.switch_to_now_playing() # Switch to the now playing page
245@@ -490,10 +485,8 @@
246 def test_artists_tab_album(self):
247 """tests navigating to the Artists tab and playing an album"""
248
249- now_playing_page = self.app.get_now_playing_page()
250-
251 # get number of tracks in queue before queuing a track
252- initial_tracks_count = now_playing_page.get_count()
253+ initial_tracks_count = self.app.get_queue_count()
254
255 # switch to artists tab
256 artists_page = self.app.get_artists_page()

Subscribers

People subscribed via source and target branches