40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <QtTest/QtTest> |
42 #include <QtTest/QtTest> |
43 #include <QtCore> |
43 #include <QtCore> |
44 #include <QtGui> |
44 #include <QtGui> |
45 #include <QFile> |
45 #include <QFile> |
46 |
46 |
47 #include <qmediaplayer.h> |
47 #include <QMediaPlayer> |
48 #include <qmediaplayercontrol.h> |
48 #include <QMediaPlayerControl> |
49 #include <qmediaplaylist.h> |
49 #include <QMediaPlaylist> |
50 #include <qmediaservice.h> |
50 #include <QMediaService> |
51 #include <qmediastreamscontrol.h> |
51 #include <QMediaStreamsControl> |
52 #include <qvideowidget.h> |
52 #include <QVideoWidget> |
53 |
53 |
54 QT_USE_NAMESPACE |
54 QT_USE_NAMESPACE |
55 |
55 |
56 #define WAIT_FOR_CONDITION(a,e) \ |
56 #define WAIT_FOR_CONDITION(a,e) \ |
57 for (int _i = 0; _i < 500; _i += 1) { \ |
57 for (int _i = 0; _i < 500; _i += 1) { \ |
557 { |
557 { |
558 m_player = new QMediaPlayer(); |
558 m_player = new QMediaPlayer(); |
559 |
559 |
560 // Symbian back end needs coecontrol for creation. |
560 // Symbian back end needs coecontrol for creation. |
561 m_widget = new QVideoWidget(); |
561 m_widget = new QVideoWidget(); |
562 m_widget->setMediaObject(m_player); |
562 //FIXME m_widget->setMediaObject(m_player); |
563 m_widget->show(); |
563 m_widget->show(); |
564 runonce = false; |
564 runonce = false; |
565 } |
565 } |
566 |
566 |
567 void tst_QMediaPlayer::cleanupTestCase() |
567 void tst_QMediaPlayer::cleanupTestCase() |
665 player.setPlaybackRate(playbackRate); |
665 player.setPlaybackRate(playbackRate); |
666 QCOMPARE(player.playbackRate(), qreal(0)); |
666 QCOMPARE(player.playbackRate(), qreal(0)); |
667 QCOMPARE(spy.count(), 0); |
667 QCOMPARE(spy.count(), 0); |
668 } { |
668 } { |
669 QMediaPlaylist playlist; |
669 QMediaPlaylist playlist; |
670 playlist.setMediaObject(&player); |
670 //FIXME playlist.setMediaObject(&player); |
671 |
671 |
672 QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent))); |
672 QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent))); |
673 QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); |
673 QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); |
674 |
674 |
675 playlist.addMedia(QUrl("http://example.com/stream")); |
675 playlist.addMedia(QUrl("http://example.com/stream")); |
687 QCOMPARE(mediaSpy.count(), 0); |
687 QCOMPARE(mediaSpy.count(), 0); |
688 QCOMPARE(statusSpy.count(), 0); |
688 QCOMPARE(statusSpy.count(), 0); |
689 } |
689 } |
690 runonce = true; |
690 runonce = true; |
691 } |
691 } |
692 |
692 */ |
693 void tst_QMediaPlayer::testMedia() |
693 void tst_QMediaPlayer::testMedia() |
694 { |
694 { |
695 QFETCH_GLOBAL(QMediaContent, mediaContent); |
695 QFETCH_GLOBAL(QMediaContent, mediaContent); |
696 m_player->setMedia(mediaContent); |
696 m_player->setMedia(mediaContent); |
697 QTest::qWait(500); |
697 QTest::qWait(500); |
1364 } |
1364 } |
1365 |
1365 |
1366 m_player->stop(); |
1366 m_player->stop(); |
1367 QCOMPARE(m_player->state(), QMediaPlayer::StoppedState); |
1367 QCOMPARE(m_player->state(), QMediaPlayer::StoppedState); |
1368 } |
1368 } |
1369 |
1369 /*FIXME |
1370 void tst_QMediaPlayer::testPlaylist() |
1370 void tst_QMediaPlayer::testPlaylist() |
1371 { |
1371 { |
1372 if(!runonce) { |
1372 if(!runonce) { |
1373 QMediaContent content0(QUrl(QLatin1String("file:///C:/data/testfiles/test_mp4.mp4"))); |
1373 QMediaContent content0(QUrl(QLatin1String("file:///C:/data/testfiles/test_mp4.mp4"))); |
1374 QMediaContent content1(QUrl(QLatin1String("file:///C:/data/testfiles/test_WAV.dat"))); |
1374 QMediaContent content1(QUrl(QLatin1String("file:///C:/data/testfiles/test_WAV.dat"))); |
1375 QMediaContent content2(QUrl(QLatin1String("file:///C:/data/testfiles/test_mp4.mp4"))); |
1375 QMediaContent content2(QUrl(QLatin1String("file:///C:/data/testfiles/test_mp4.mp4"))); |
1376 QMediaContent content3(QUrl(QLatin1String("file:///C:/data/testfiles/test_WAV.dat"))); |
1376 QMediaContent content3(QUrl(QLatin1String("file:///C:/data/testfiles/test_WAV.dat"))); |
1377 QMediaContent content4(QUrl(QLatin1String("file:///C:/data/testfiles/test_MIDI.dat"))); |
1377 QMediaContent content4(QUrl(QLatin1String("file:///C:/data/testfiles/test_MIDI.dat"))); |
1378 |
1378 |
1379 QMediaPlaylist *playlist = new QMediaPlaylist(m_player); |
1379 QMediaPlaylist *playlist = new QMediaPlaylist(m_player); |
1380 playlist->setMediaObject(m_player); |
1380 //FIXME playlist->setMediaObject(m_player); |
1381 |
1381 |
1382 QSignalSpy stateSpy(m_player, SIGNAL(stateChanged(QMediaPlayer::State))); |
1382 QSignalSpy stateSpy(m_player, SIGNAL(stateChanged(QMediaPlayer::State))); |
1383 QSignalSpy mediaSpy(m_player, SIGNAL(mediaChanged(QMediaContent))); |
1383 QSignalSpy mediaSpy(m_player, SIGNAL(mediaChanged(QMediaContent))); |
1384 |
1384 |
1385 // Test the player does nothing with an empty playlist attached. |
1385 // Test the player does nothing with an empty playlist attached. |
1537 QCOMPARE(mediaSpy.count(), 9); |
1537 QCOMPARE(mediaSpy.count(), 9); |
1538 m_player->stop(); |
1538 m_player->stop(); |
1539 runonce = true; |
1539 runonce = true; |
1540 } |
1540 } |
1541 } |
1541 } |
1542 |
1542 */ |
1543 void tst_QMediaPlayer::testPlaybackRate() |
1543 void tst_QMediaPlayer::testPlaybackRate() |
1544 { |
1544 { |
1545 QFETCH_GLOBAL(bool, valid); |
1545 QFETCH_GLOBAL(bool, valid); |
1546 QFETCH_GLOBAL(qreal, playbackRate); |
1546 QFETCH_GLOBAL(qreal, playbackRate); |
1547 QFETCH_GLOBAL(QMediaContent, mediaContent); |
1547 QFETCH_GLOBAL(QMediaContent, mediaContent); |