diff options
author | David Boddie <dboddie@trolltech.com> | 2010-03-04 18:22:02 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2010-03-04 18:22:02 (GMT) |
commit | 2542f8b565e90378145c048b3a6982f4749c6392 (patch) | |
tree | d48a2a8988a778e16cf73aac4d0b5709b82f0082 /tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp | |
parent | 4f2203e481cc1663776e7b87b082cf0dd42849fd (diff) | |
parent | 364ba2bfeeab574d2ae940e4387d3c90b2a46dcd (diff) | |
download | Qt-2542f8b565e90378145c048b3a6982f4749c6392.zip Qt-2542f8b565e90378145c048b3a6982f4749c6392.tar.gz Qt-2542f8b565e90378145c048b3a6982f4749c6392.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp')
-rw-r--r-- | tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp index 9bca189..d839fe5 100644 --- a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp +++ b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp @@ -213,6 +213,57 @@ public: } }; +class MockServicePlugin4 : public QMediaServiceProviderPlugin, + public QMediaServiceSupportedFormatsInterface, + public QMediaServiceFeaturesInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaServiceSupportedFormatsInterface) + Q_INTERFACES(QMediaServiceFeaturesInterface) +public: + QStringList keys() const + { + return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); + } + + QMediaService* create(QString const& key) + { + if (keys().contains(key)) + return new MockMediaService("MockServicePlugin4"); + else + return 0; + } + + void release(QMediaService *service) + { + delete service; + } + + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const + { + if (codecs.contains(QLatin1String("jpeg2000"))) + return QtMultimedia::NotSupported; + + if (supportedMimeTypes().contains(mimeType)) + return QtMultimedia::ProbablySupported; + + return QtMultimedia::MaybeSupported; + } + + QStringList supportedMimeTypes() const + { + return QStringList() << "video/mp4" << "video/quicktime"; + } + + QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const + { + if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) + return QMediaServiceProviderHint::StreamPlayback; + else + return 0; + } +}; + class MockMediaServiceProvider : public QMediaServiceProvider @@ -253,6 +304,7 @@ void tst_QMediaServiceProvider::initTestCase() plugins << new MockServicePlugin1; plugins << new MockServicePlugin2; plugins << new MockServicePlugin3; + plugins << new MockServicePlugin4; QMediaPluginLoader::setStaticPlugins(QLatin1String("/mediaservices"), plugins); } @@ -312,12 +364,32 @@ void tst_QMediaServiceProvider::testHasSupport() QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimedia::ProbablySupported); + //test low latency flag support + QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), + QtMultimedia::ProbablySupported); + //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface + QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), + QtMultimedia::ProbablySupported); + //Plugin4 is not checked here, sine it's known not support low latency + QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), + QtMultimedia::MaybeSupported); + + //test streaming flag support + QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), + QtMultimedia::ProbablySupported); + //Plugin2 is not checked here, sine it's known not support streaming + QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), + QtMultimedia::MaybeSupported); + //ensure the correct media player plugin is choosen for mime type QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); QMediaPlayer mediaPlayer; QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); + + QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); + QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); } void tst_QMediaServiceProvider::testSupportedMimeTypes() |