Merge lp:~phablet-team/qtubuntu-media/enable-mpris-controls into lp:qtubuntu-media/stable
- enable-mpris-controls
- Merge into stable
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | no longer in the source branch. |
Merged at revision: | 86 |
Proposed branch: | lp:~phablet-team/qtubuntu-media/enable-mpris-controls |
Merge into: | lp:qtubuntu-media/stable |
Diff against target: |
413 lines (+128/-68) 8 files modified
README (+4/-0) debian/control (+1/-1) src/aal/aalmediaplayerservice.cpp (+52/-21) src/aal/aalmediaplayerservice.h (+4/-2) tests/integration/tst_mediaplaylist.cpp (+58/-44) tests/integration/tst_mediaplaylist.h (+4/-0) tests/unit/service.cpp (+4/-0) tests/unit/service.h (+1/-0) |
To merge this branch: | bzr merge lp:~phablet-team/qtubuntu-media/enable-mpris-controls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
Review via email: mp+270445@code.launchpad.net |
Commit message
Make sure the that the current player instance is controlable by MPRIS controls if the type of player is appropriate for playlist control. Also, don't add a track to the tracklist when AalMediaPlayerS
Description of the change
Make sure the that the current player instance is controlable by MPRIS controls if the type of player is appropriate for playlist control. Also, don't add a track to the tracklist when AalMediaPlayerS
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Jim Hodapp (jhodapp) wrote : | # |
Comments addresses.
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
- 86. By Alfonso Sanchez-Beato
-
Make sure the that the current player instance is controlable by MPRIS controls
if the type of player is appropriate for playlist control. Also, don't add a
track to the tracklist when AalMediaPlayerService: :setMedia( ) is called. - 87. By Alfonso Sanchez-Beato
-
Do not detach from media-hub when we are inactive, as that is needed only
when the application terminates. - 88. By Alfonso Sanchez-Beato
-
Fix and add integration tests
- 89. By Jim Hodapp
-
Make sure the current player is set when the client app regains focus.
Preview Diff
1 | === added file 'README' | |||
2 | --- README 1970-01-01 00:00:00 +0000 | |||
3 | +++ README 2015-10-14 20:56:01 +0000 | |||
4 | @@ -0,0 +1,4 @@ | |||
5 | 1 | Coding Convention: | ||
6 | 2 | ------------------ | ||
7 | 3 | |||
8 | 4 | This project follows the Qt coding style as detailed here: https://wiki.qt.io/Qt_Coding_Style | ||
9 | 0 | 5 | ||
10 | === modified file 'debian/control' | |||
11 | --- debian/control 2015-08-04 01:56:17 +0000 | |||
12 | +++ debian/control 2015-10-14 20:56:01 +0000 | |||
13 | @@ -9,7 +9,7 @@ | |||
14 | 9 | libgl1-mesa-dev | libgl-dev, | 9 | libgl1-mesa-dev | libgl-dev, |
15 | 10 | libgles2-mesa-dev, | 10 | libgles2-mesa-dev, |
16 | 11 | libhybris-dev (>= 0.1.0+git20131207+e452e83-0ubuntu13), | 11 | libhybris-dev (>= 0.1.0+git20131207+e452e83-0ubuntu13), |
18 | 12 | libmedia-hub-dev (>= 3.1.0), | 12 | libmedia-hub-dev (>= 3.2.0), |
19 | 13 | libpulse-dev, | 13 | libpulse-dev, |
20 | 14 | libqt5opengl5-dev, | 14 | libqt5opengl5-dev, |
21 | 15 | libqtubuntu-media-signals-dev (>= 0.3+15.04.20150618.1-0ubuntu1), | 15 | libqtubuntu-media-signals-dev (>= 0.3+15.04.20150618.1-0ubuntu1), |
22 | 16 | 16 | ||
23 | === modified file 'src/aal/aalmediaplayerservice.cpp' | |||
24 | --- src/aal/aalmediaplayerservice.cpp 2015-08-18 15:49:35 +0000 | |||
25 | +++ src/aal/aalmediaplayerservice.cpp 2015-10-14 20:56:01 +0000 | |||
26 | @@ -35,7 +35,10 @@ | |||
27 | 35 | 35 | ||
28 | 36 | #include <qtubuntu_media_signals.h> | 36 | #include <qtubuntu_media_signals.h> |
29 | 37 | 37 | ||
31 | 38 | // Uncomment to re-enable media-hub Player session detach/reattach functionality | 38 | // Uncomment to re-enable media-hub Player session detach/reattach functionality. |
32 | 39 | // It is not clear at all whether we should do this or not, as detaching | ||
33 | 40 | // is probably something that should be done when the app finishes, not when it | ||
34 | 41 | // simply moves to the background. | ||
35 | 39 | //#define DO_PLAYER_ATTACH_DETACH | 42 | //#define DO_PLAYER_ATTACH_DETACH |
36 | 40 | 43 | ||
37 | 41 | // Defined in aalvideorenderercontrol.h | 44 | // Defined in aalvideorenderercontrol.h |
38 | @@ -86,7 +89,7 @@ | |||
39 | 86 | 89 | ||
40 | 87 | // As core::Connection doesn't allow us to start with a disconnected connection | 90 | // As core::Connection doesn't allow us to start with a disconnected connection |
41 | 88 | // instance we have to connect it first with a dummy signal and then disconnect | 91 | // instance we have to connect it first with a dummy signal and then disconnect |
43 | 89 | // it again. If we don't do this connect_signals() will never be able to attach | 92 | // it again. If we don't do this connectSignals() will never be able to attach |
44 | 90 | // to the relevant signals. | 93 | // to the relevant signals. |
45 | 91 | m_endOfStreamConnection.disconnect(); | 94 | m_endOfStreamConnection.disconnect(); |
46 | 92 | 95 | ||
47 | @@ -271,7 +274,7 @@ | |||
48 | 271 | 274 | ||
49 | 272 | void AalMediaPlayerService::setMedia(const QUrl &url) | 275 | void AalMediaPlayerService::setMedia(const QUrl &url) |
50 | 273 | { | 276 | { |
52 | 274 | if (m_hubPlayerSession == NULL) | 277 | if (m_hubPlayerSession == nullptr) |
53 | 275 | { | 278 | { |
54 | 276 | qWarning() << "Cannot open uri without a valid media-hub player session"; | 279 | qWarning() << "Cannot open uri without a valid media-hub player session"; |
55 | 277 | return; | 280 | return; |
56 | @@ -292,16 +295,19 @@ | |||
57 | 292 | 295 | ||
58 | 293 | qDebug() << "Setting media to: " << url; | 296 | qDebug() << "Setting media to: " << url; |
59 | 294 | const media::Track::UriType uri(url.url().toStdString()); | 297 | const media::Track::UriType uri(url.url().toStdString()); |
64 | 295 | try { | 298 | if (m_mediaPlaylistProvider == nullptr) |
65 | 296 | if (m_mediaPlaylistProvider != NULL) | 299 | { |
66 | 297 | m_mediaPlaylistProvider->addMedia(QMediaContent(url)); | 300 | try { |
63 | 298 | else | ||
67 | 299 | m_hubPlayerSession->open_uri(uri); | 301 | m_hubPlayerSession->open_uri(uri); |
73 | 300 | } | 302 | } |
74 | 301 | catch (const std::runtime_error &e) { | 303 | catch (const std::runtime_error &e) { |
75 | 302 | qWarning() << "Failed to open media " << url << ": " << e.what(); | 304 | qWarning() << "Failed to set media " << url << ": " << e.what(); |
76 | 303 | return; | 305 | return; |
77 | 304 | } | 306 | } |
78 | 307 | } | ||
79 | 308 | |||
80 | 309 | // Make sure this player can be controlled by MPRIS if appropriate | ||
81 | 310 | updateCurrentPlayer(); | ||
82 | 305 | 311 | ||
83 | 306 | if (isVideoSource()) | 312 | if (isVideoSource()) |
84 | 307 | m_videoOutput->setupSurface(); | 313 | m_videoOutput->setupSurface(); |
85 | @@ -327,13 +333,18 @@ | |||
86 | 327 | 333 | ||
87 | 328 | qDebug() << "Setting media to: " << AalUtility::unescape(media); | 334 | qDebug() << "Setting media to: " << AalUtility::unescape(media); |
88 | 329 | try { | 335 | try { |
89 | 336 | // TODO: Change this to use the QUrl from QMediaContent and then call | ||
90 | 337 | // open_uri(uri) like the other version of setMedia does above | ||
91 | 330 | m_mediaPlaylistProvider->addMedia(media); | 338 | m_mediaPlaylistProvider->addMedia(media); |
92 | 331 | } | 339 | } |
93 | 332 | catch (const std::runtime_error &e) { | 340 | catch (const std::runtime_error &e) { |
95 | 333 | qWarning() << "Failed to open media " << AalUtility::unescape(media) << ": " << e.what(); | 341 | qWarning() << "Failed to set media " << AalUtility::unescape(media) << ": " << e.what(); |
96 | 334 | return; | 342 | return; |
97 | 335 | } | 343 | } |
98 | 336 | 344 | ||
99 | 345 | // Make sure this player can be controlled by MPRIS if appropriate | ||
100 | 346 | updateCurrentPlayer(); | ||
101 | 347 | |||
102 | 337 | if (isVideoSource()) | 348 | if (isVideoSource()) |
103 | 338 | m_videoOutput->setupSurface(); | 349 | m_videoOutput->setupSurface(); |
104 | 339 | } | 350 | } |
105 | @@ -546,7 +557,7 @@ | |||
106 | 546 | return; | 557 | return; |
107 | 547 | 558 | ||
108 | 548 | m_mediaPlayerControl = new AalMediaPlayerControl(this); | 559 | m_mediaPlayerControl = new AalMediaPlayerControl(this); |
110 | 549 | connect_signals(); | 560 | connectSignals(); |
111 | 550 | } | 561 | } |
112 | 551 | 562 | ||
113 | 552 | void AalMediaPlayerService::createVideoRendererControl() | 563 | void AalMediaPlayerService::createVideoRendererControl() |
114 | @@ -704,7 +715,7 @@ | |||
115 | 704 | case Qt::ApplicationInactive: | 715 | case Qt::ApplicationInactive: |
116 | 705 | qDebug() << "** Application is now inactive"; | 716 | qDebug() << "** Application is now inactive"; |
117 | 706 | #ifdef DO_PLAYER_ATTACH_DETACH | 717 | #ifdef DO_PLAYER_ATTACH_DETACH |
119 | 707 | disconnect_signals(); | 718 | disconnectSignals(); |
120 | 708 | m_hubService->detach_session(m_sessionUuid, media::Player::Client::default_configuration()); | 719 | m_hubService->detach_session(m_sessionUuid, media::Player::Client::default_configuration()); |
121 | 709 | m_doReattachSession = true; | 720 | m_doReattachSession = true; |
122 | 710 | #endif | 721 | #endif |
123 | @@ -716,13 +727,16 @@ | |||
124 | 716 | // will break video playback | 727 | // will break video playback |
125 | 717 | if (m_doReattachSession) | 728 | if (m_doReattachSession) |
126 | 718 | { | 729 | { |
130 | 719 | m_hubPlayerSession = m_hubService->reattach_session(m_sessionUuid, media::Player::Client::default_configuration()); | 730 | m_hubPlayerSession = m_hubService-> |
131 | 720 | // Make sure the client's status (position, duraiton, state, etc) are all correct when reattaching | 731 | reattach_session(m_sessionUuid, |
132 | 721 | // to the media-hub Player session | 732 | media::Player::Client::default_configuration()); |
133 | 733 | // Make sure the client's status (position, duraiton, state, etc) are all | ||
134 | 734 | // correct when reattaching to the media-hub Player session | ||
135 | 722 | updateClientSignals(); | 735 | updateClientSignals(); |
137 | 723 | connect_signals(); | 736 | connectSignals(); |
138 | 724 | } | 737 | } |
139 | 725 | #endif | 738 | #endif |
140 | 739 | updateCurrentPlayer(); | ||
141 | 726 | break; | 740 | break; |
142 | 727 | default: | 741 | default: |
143 | 728 | qDebug() << "Unknown ApplicationState"; | 742 | qDebug() << "Unknown ApplicationState"; |
144 | @@ -758,7 +772,7 @@ | |||
145 | 758 | } | 772 | } |
146 | 759 | } | 773 | } |
147 | 760 | 774 | ||
149 | 761 | void AalMediaPlayerService::connect_signals() | 775 | void AalMediaPlayerService::connectSignals() |
150 | 762 | { | 776 | { |
151 | 763 | if (!m_endOfStreamConnection.is_connected()) | 777 | if (!m_endOfStreamConnection.is_connected()) |
152 | 764 | { | 778 | { |
153 | @@ -770,12 +784,29 @@ | |||
154 | 770 | } | 784 | } |
155 | 771 | } | 785 | } |
156 | 772 | 786 | ||
158 | 773 | void AalMediaPlayerService::disconnect_signals() | 787 | void AalMediaPlayerService::disconnectSignals() |
159 | 774 | { | 788 | { |
160 | 775 | if (m_endOfStreamConnection.is_connected()) | 789 | if (m_endOfStreamConnection.is_connected()) |
161 | 776 | m_endOfStreamConnection.disconnect(); | 790 | m_endOfStreamConnection.disconnect(); |
162 | 777 | } | 791 | } |
163 | 778 | 792 | ||
164 | 793 | void AalMediaPlayerService::updateCurrentPlayer() | ||
165 | 794 | { | ||
166 | 795 | // If this player is a multimedia audioRole, then it should possible to | ||
167 | 796 | // use it for MPRIS control | ||
168 | 797 | if (audioRole() == QMediaPlayer::MultimediaRole) | ||
169 | 798 | { | ||
170 | 799 | qDebug() << "Setting player as current player"; | ||
171 | 800 | try { | ||
172 | 801 | const media::Player::PlayerKey key = m_hubPlayerSession->key(); | ||
173 | 802 | m_hubService->set_current_player(key); | ||
174 | 803 | } catch (const std::runtime_error &e) { | ||
175 | 804 | qWarning() << "Failed to set player as current player: " << e.what(); | ||
176 | 805 | return; | ||
177 | 806 | } | ||
178 | 807 | } | ||
179 | 808 | } | ||
180 | 809 | |||
181 | 779 | void AalMediaPlayerService::onError(const core::ubuntu::media::Player::Error &error) | 810 | void AalMediaPlayerService::onError(const core::ubuntu::media::Player::Error &error) |
182 | 780 | { | 811 | { |
183 | 781 | qWarning() << "** Media playback error: " << error; | 812 | qWarning() << "** Media playback error: " << error; |
184 | 782 | 813 | ||
185 | === modified file 'src/aal/aalmediaplayerservice.h' | |||
186 | --- src/aal/aalmediaplayerservice.h 2015-08-18 15:48:31 +0000 | |||
187 | +++ src/aal/aalmediaplayerservice.h 2015-10-14 20:56:01 +0000 | |||
188 | @@ -114,8 +114,9 @@ | |||
189 | 114 | 114 | ||
190 | 115 | protected: | 115 | protected: |
191 | 116 | void updateClientSignals(); | 116 | void updateClientSignals(); |
194 | 117 | void connect_signals(); | 117 | void connectSignals(); |
195 | 118 | void disconnect_signals(); | 118 | void disconnectSignals(); |
196 | 119 | void updateCurrentPlayer(); | ||
197 | 119 | #ifdef MEASURE_PERFORMANCE | 120 | #ifdef MEASURE_PERFORMANCE |
198 | 120 | void measurePerformance(); | 121 | void measurePerformance(); |
199 | 121 | #endif | 122 | #endif |
200 | @@ -153,6 +154,7 @@ | |||
201 | 153 | const QMediaPlaylist* m_mediaPlaylist; | 154 | const QMediaPlaylist* m_mediaPlaylist; |
202 | 154 | 155 | ||
203 | 155 | core::ubuntu::media::Player::PlaybackStatus m_newStatus; | 156 | core::ubuntu::media::Player::PlaybackStatus m_newStatus; |
204 | 157 | |||
205 | 156 | std::string m_sessionUuid; | 158 | std::string m_sessionUuid; |
206 | 157 | bool m_doReattachSession; | 159 | bool m_doReattachSession; |
207 | 158 | 160 | ||
208 | 159 | 161 | ||
209 | === modified file 'tests/integration/tst_mediaplaylist.cpp' | |||
210 | --- tests/integration/tst_mediaplaylist.cpp 2015-07-10 14:49:05 +0000 | |||
211 | +++ tests/integration/tst_mediaplaylist.cpp 2015-10-14 20:56:01 +0000 | |||
212 | @@ -215,23 +215,11 @@ | |||
213 | 215 | 215 | ||
214 | 216 | QCOMPARE(playlist->mediaCount(), 3); | 216 | QCOMPARE(playlist->mediaCount(), 3); |
215 | 217 | 217 | ||
216 | 218 | QMediaContent current_media; | ||
217 | 219 | std::promise<QMediaContent> promise; | ||
218 | 220 | std::future<QMediaContent> future{promise.get_future()}; | ||
219 | 221 | QMetaObject::Connection c = connect(playlist, &QMediaPlaylist::currentMediaChanged, [&](const QMediaContent& content) | ||
220 | 222 | { | ||
221 | 223 | qDebug() << "currentMediaChanged to: " << content.canonicalUrl().toString(); | ||
222 | 224 | current_media = content; | ||
223 | 225 | promise.set_value(current_media); | ||
224 | 226 | // Make sure the promise is not fulfilled twice | ||
225 | 227 | QObject::disconnect(c); | ||
226 | 228 | }); | ||
227 | 229 | |||
228 | 230 | qDebug() << "Setting current index to be 1"; | 218 | qDebug() << "Setting current index to be 1"; |
229 | 231 | playlist->setCurrentIndex(1); | 219 | playlist->setCurrentIndex(1); |
230 | 232 | 220 | ||
231 | 233 | // Wait for the currentMediaChanged signal to be emited | 221 | // Wait for the currentMediaChanged signal to be emited |
233 | 234 | wait_for_signal(future); | 222 | waitTrackChange(playlist); |
234 | 235 | 223 | ||
235 | 236 | qDebug() << "Checking if current index is 1"; | 224 | qDebug() << "Checking if current index is 1"; |
236 | 237 | QCOMPARE(playlist->currentIndex(), 1); | 225 | QCOMPARE(playlist->currentIndex(), 1); |
237 | @@ -312,30 +300,16 @@ | |||
238 | 312 | 300 | ||
239 | 313 | QCOMPARE(playlist->mediaCount(), 2); | 301 | QCOMPARE(playlist->mediaCount(), 2); |
240 | 314 | 302 | ||
241 | 315 | QMediaContent current_media; | ||
242 | 316 | std::promise<QMediaContent> promise; | ||
243 | 317 | std::future<QMediaContent> future{promise.get_future()}; | ||
244 | 318 | QMetaObject::Connection c = connect(playlist, &QMediaPlaylist::currentMediaChanged, [&](const QMediaContent& content) | ||
245 | 319 | { | ||
246 | 320 | qDebug() << "currentMediaChanged to: " << content.canonicalUrl().toString(); | ||
247 | 321 | current_media = content; | ||
248 | 322 | promise.set_value(current_media); | ||
249 | 323 | // Make sure the promise is not fulfilled twice | ||
250 | 324 | QObject::disconnect(c); | ||
251 | 325 | }); | ||
252 | 326 | |||
253 | 327 | playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); | 303 | playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); |
254 | 328 | 304 | ||
255 | 329 | qDebug() << "Call player->play()"; | 305 | qDebug() << "Call player->play()"; |
256 | 330 | player->play(); | 306 | player->play(); |
257 | 331 | 307 | ||
258 | 332 | // Wait for the currentMediaChanged signal to be emited | 308 | // Wait for the currentMediaChanged signal to be emited |
260 | 333 | wait_for_signal(future); | 309 | waitTrackChange(playlist); |
261 | 334 | 310 | ||
262 | 335 | QCOMPARE(playlist->currentIndex(), 0); | 311 | QCOMPARE(playlist->currentIndex(), 0); |
263 | 336 | 312 | ||
264 | 337 | QObject::disconnect(c); | ||
265 | 338 | |||
266 | 339 | delete playlist; | 313 | delete playlist; |
267 | 340 | delete player; | 314 | delete player; |
268 | 341 | } | 315 | } |
269 | @@ -346,19 +320,6 @@ | |||
270 | 346 | QMediaPlaylist *playlist = new QMediaPlaylist; | 320 | QMediaPlaylist *playlist = new QMediaPlaylist; |
271 | 347 | player->setPlaylist(playlist); | 321 | player->setPlaylist(playlist); |
272 | 348 | 322 | ||
273 | 349 | QMediaContent current_media; | ||
274 | 350 | std::promise<QMediaContent> promise; | ||
275 | 351 | std::future<QMediaContent> future{promise.get_future()}; | ||
276 | 352 | |||
277 | 353 | QMetaObject::Connection c = connect(playlist, &QMediaPlaylist::currentMediaChanged, [&](const QMediaContent& content) | ||
278 | 354 | { | ||
279 | 355 | qDebug() << "currentMediaChanged to: " << content.canonicalUrl().toString(); | ||
280 | 356 | current_media = content; | ||
281 | 357 | promise.set_value(current_media); | ||
282 | 358 | // Make sure the promise is not fulfilled twice | ||
283 | 359 | QObject::disconnect(c); | ||
284 | 360 | }); | ||
285 | 361 | |||
286 | 362 | QList<QMediaContent> content; | 323 | QList<QMediaContent> content; |
287 | 363 | content.push_back(QUrl("file://" + QFINDTESTDATA("testdata/testfile.ogg"))); | 324 | content.push_back(QUrl("file://" + QFINDTESTDATA("testdata/testfile.ogg"))); |
288 | 364 | content.push_back(QUrl("file://" + QFINDTESTDATA("testdata/testfile.ogg"))); | 325 | content.push_back(QUrl("file://" + QFINDTESTDATA("testdata/testfile.ogg"))); |
289 | @@ -368,14 +329,48 @@ | |||
290 | 368 | 329 | ||
291 | 369 | playlist->setPlaybackMode(QMediaPlaylist::Sequential); | 330 | playlist->setPlaybackMode(QMediaPlaylist::Sequential); |
292 | 370 | 331 | ||
293 | 332 | // Wait until the first track is set as the current one | ||
294 | 333 | waitTrackChange(playlist); | ||
295 | 334 | |||
296 | 371 | player->play(); | 335 | player->play(); |
297 | 372 | 336 | ||
300 | 373 | // Wait for the currentMediaChanged signal to be emited | 337 | // Wait until the second track is selected |
301 | 374 | wait_for_signal(future); | 338 | waitTrackChange(playlist); |
302 | 375 | 339 | ||
303 | 376 | QCOMPARE(playlist->currentIndex(), 1); | 340 | QCOMPARE(playlist->currentIndex(), 1); |
304 | 377 | 341 | ||
306 | 378 | QObject::disconnect(c); | 342 | delete playlist; |
307 | 343 | delete player; | ||
308 | 344 | } | ||
309 | 345 | |||
310 | 346 | void tst_MediaPlaylist::playReusePlayTrackList() | ||
311 | 347 | { | ||
312 | 348 | QMediaPlayer *player = new QMediaPlayer; | ||
313 | 349 | QMediaPlaylist *playlist = new QMediaPlaylist; | ||
314 | 350 | player->setPlaylist(playlist); | ||
315 | 351 | |||
316 | 352 | const QUrl audio(QUrl("file://" + QFINDTESTDATA("testdata/testfile.ogg"))); | ||
317 | 353 | const QUrl video(QUrl("file://" + QFINDTESTDATA("testdata/testfile.mp4"))); | ||
318 | 354 | |||
319 | 355 | for (int i = 0; i < 5; ++i) { | ||
320 | 356 | playlist->addMedia(audio); | ||
321 | 357 | playlist->addMedia(video); | ||
322 | 358 | playlist->addMedia(audio); | ||
323 | 359 | QCOMPARE(playlist->mediaCount(), 3); | ||
324 | 360 | |||
325 | 361 | player->play(); | ||
326 | 362 | QCoreApplication::processEvents(); | ||
327 | 363 | |||
328 | 364 | const QUrl audioToVerify(playlist->currentMedia().canonicalUrl()); | ||
329 | 365 | QCOMPARE(audioToVerify, audio); | ||
330 | 366 | |||
331 | 367 | player->stop(); | ||
332 | 368 | QCoreApplication::processEvents(); | ||
333 | 369 | |||
334 | 370 | playlist->clear(); | ||
335 | 371 | |||
336 | 372 | QCOMPARE(playlist->mediaCount(), 0); | ||
337 | 373 | } | ||
338 | 379 | 374 | ||
339 | 380 | delete playlist; | 375 | delete playlist; |
340 | 381 | delete player; | 376 | delete player; |
341 | @@ -393,4 +388,23 @@ | |||
342 | 393 | } | 388 | } |
343 | 394 | } | 389 | } |
344 | 395 | 390 | ||
345 | 391 | void tst_MediaPlaylist::waitTrackChange(QMediaPlaylist *playlist) | ||
346 | 392 | { | ||
347 | 393 | QMediaContent current_media; | ||
348 | 394 | std::promise<QMediaContent> promise; | ||
349 | 395 | std::future<QMediaContent> future{promise.get_future()}; | ||
350 | 396 | |||
351 | 397 | QMetaObject::Connection c = connect(playlist, &QMediaPlaylist::currentMediaChanged, | ||
352 | 398 | [&](const QMediaContent& content) | ||
353 | 399 | { | ||
354 | 400 | qDebug() << "currentMediaChanged to: " << content.canonicalUrl().toString(); | ||
355 | 401 | current_media = content; | ||
356 | 402 | promise.set_value(current_media); | ||
357 | 403 | // Make sure the promise is not fulfilled twice | ||
358 | 404 | QObject::disconnect(c); | ||
359 | 405 | }); | ||
360 | 406 | |||
361 | 407 | wait_for_signal(future); | ||
362 | 408 | } | ||
363 | 409 | |||
364 | 396 | QTEST_GUILESS_MAIN(tst_MediaPlaylist) | 410 | QTEST_GUILESS_MAIN(tst_MediaPlaylist) |
365 | 397 | 411 | ||
366 | === modified file 'tests/integration/tst_mediaplaylist.h' | |||
367 | --- tests/integration/tst_mediaplaylist.h 2015-07-10 14:49:05 +0000 | |||
368 | +++ tests/integration/tst_mediaplaylist.h 2015-10-14 20:56:01 +0000 | |||
369 | @@ -63,6 +63,8 @@ | |||
370 | 63 | void verifyPlaybackModeCurrentItemInLoop(); | 63 | void verifyPlaybackModeCurrentItemInLoop(); |
371 | 64 | void verifyPlaybackModeSequential(); | 64 | void verifyPlaybackModeSequential(); |
372 | 65 | 65 | ||
373 | 66 | void playReusePlayTrackList(); | ||
374 | 67 | |||
375 | 66 | private: | 68 | private: |
376 | 67 | template<typename R> | 69 | template<typename R> |
377 | 68 | bool is_ready(std::future<R> const& f) | 70 | bool is_ready(std::future<R> const& f) |
378 | @@ -70,6 +72,8 @@ | |||
379 | 70 | 72 | ||
380 | 71 | template<typename R> | 73 | template<typename R> |
381 | 72 | void wait_for_signal(std::future<R> const& f); | 74 | void wait_for_signal(std::future<R> const& f); |
382 | 75 | |||
383 | 76 | void waitTrackChange(QMediaPlaylist *playlist); | ||
384 | 73 | }; | 77 | }; |
385 | 74 | 78 | ||
386 | 75 | #endif // TST_MEDIAPLAYLIST_H | 79 | #endif // TST_MEDIAPLAYLIST_H |
387 | 76 | 80 | ||
388 | === modified file 'tests/unit/service.cpp' | |||
389 | --- tests/unit/service.cpp 2015-06-08 19:15:43 +0000 | |||
390 | +++ tests/unit/service.cpp 2015-10-14 20:56:01 +0000 | |||
391 | @@ -54,6 +54,10 @@ | |||
392 | 54 | return 0; | 54 | return 0; |
393 | 55 | } | 55 | } |
394 | 56 | 56 | ||
395 | 57 | void TestService::set_current_player(Player::PlayerKey) | ||
396 | 58 | { | ||
397 | 59 | } | ||
398 | 60 | |||
399 | 57 | void TestService::pause_other_sessions(Player::PlayerKey) | 61 | void TestService::pause_other_sessions(Player::PlayerKey) |
400 | 58 | { | 62 | { |
401 | 59 | } | 63 | } |
402 | 60 | 64 | ||
403 | === modified file 'tests/unit/service.h' | |||
404 | --- tests/unit/service.h 2015-06-08 19:15:43 +0000 | |||
405 | +++ tests/unit/service.h 2015-10-14 20:56:01 +0000 | |||
406 | @@ -50,6 +50,7 @@ | |||
407 | 50 | virtual void destroy_session(const std::string& uuid, const Player::Configuration&); | 50 | virtual void destroy_session(const std::string& uuid, const Player::Configuration&); |
408 | 51 | virtual std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); | 51 | virtual std::shared_ptr<Player> create_fixed_session(const std::string& name, const Player::Configuration&); |
409 | 52 | virtual std::shared_ptr<Player> resume_session(Player::PlayerKey); | 52 | virtual std::shared_ptr<Player> resume_session(Player::PlayerKey); |
410 | 53 | virtual void set_current_player(Player::PlayerKey key); | ||
411 | 53 | virtual void pause_other_sessions(Player::PlayerKey); | 54 | virtual void pause_other_sessions(Player::PlayerKey); |
412 | 54 | }; | 55 | }; |
413 | 55 | } | 56 | } |
Looks good, some minor issues detected. I would also like to have a branch for trunk too.