336 |
337 |
337 void tst_QMediaServiceProvider::testHasSupport() |
338 void tst_QMediaServiceProvider::testHasSupport() |
338 { |
339 { |
339 MockMediaServiceProvider mockProvider; |
340 MockMediaServiceProvider mockProvider; |
340 QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), |
341 QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), |
341 QtMediaServices::MaybeSupported); |
342 QtMultimedia::MaybeSupported); |
342 |
343 |
343 QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); |
344 QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); |
344 |
345 |
345 if (provider == 0) |
346 if (provider == 0) |
346 QSKIP("No default provider", SkipSingle); |
347 QSKIP("No default provider", SkipSingle); |
347 |
348 |
348 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), |
349 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), |
349 QtMediaServices::MaybeSupported); |
350 QtMultimedia::MaybeSupported); |
350 |
351 |
351 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), |
352 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), |
352 QtMediaServices::ProbablySupported); |
353 QtMultimedia::ProbablySupported); |
353 |
354 |
354 //while the service returns PreferredService, provider should return ProbablySupported |
355 //while the service returns PreferredService, provider should return ProbablySupported |
355 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), |
356 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), |
356 QtMediaServices::ProbablySupported); |
357 QtMultimedia::ProbablySupported); |
357 |
358 |
358 //even while all the plugins with "hasSupport" returned NotSupported, |
359 //even while all the plugins with "hasSupport" returned NotSupported, |
359 //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported |
360 //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported |
360 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", |
361 QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", |
361 QStringList() << "mpeg4"), |
362 QStringList() << "mpeg4"), |
362 QtMediaServices::MaybeSupported); |
363 QtMultimedia::MaybeSupported); |
363 |
364 |
364 QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), |
365 QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), |
365 QtMediaServices::NotSupported); |
366 QtMultimedia::NotSupported); |
366 |
367 |
367 QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMediaServices::MaybeSupported); |
368 QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMultimedia::MaybeSupported); |
368 QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMediaServices::ProbablySupported); |
369 QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimedia::ProbablySupported); |
369 QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMediaServices::ProbablySupported); |
370 QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimedia::ProbablySupported); |
370 |
371 |
371 //test low latency flag support |
372 //test low latency flag support |
372 QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), |
373 QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), |
373 QtMediaServices::ProbablySupported); |
374 QtMultimedia::ProbablySupported); |
374 //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface |
375 //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface |
375 QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), |
376 QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), |
376 QtMediaServices::ProbablySupported); |
377 QtMultimedia::ProbablySupported); |
377 //Plugin4 is not checked here, sine it's known not support low latency |
378 //Plugin4 is not checked here, sine it's known not support low latency |
378 QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), |
379 QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), |
379 QtMediaServices::MaybeSupported); |
380 QtMultimedia::MaybeSupported); |
380 |
381 |
381 //test streaming flag support |
382 //test streaming flag support |
382 QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), |
383 QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), |
383 QtMediaServices::ProbablySupported); |
384 QtMultimedia::ProbablySupported); |
384 //Plugin2 is not checked here, sine it's known not support streaming |
385 //Plugin2 is not checked here, sine it's known not support streaming |
385 QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), |
386 QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), |
386 QtMediaServices::MaybeSupported); |
387 QtMultimedia::MaybeSupported); |
387 |
388 |
388 //ensure the correct media player plugin is choosen for mime type |
389 //ensure the correct media player plugin is choosen for mime type |
389 QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); |
390 QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); |
390 QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); |
391 QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); |
391 |
392 |