summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-21 13:55:39 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-29 08:50:03 +0000
commit4b720199c379b90b160a7b9632388ebbc44e55c3 (patch)
tree3e9d098edd85881c82ffdffc6cbe940131372a56 /tests
parent8b749d4fc21a3a94afb58e86f384221e4ccaee66 (diff)
Move QAudioDecoder over to use the new platform infrastructure
And remove the hasSupport() method for now as with QMediaPlayer and QMediaRecorder. Also adjust the auto test to use the new mock infrastructure. Change-Id: I84a8587f273525d1ee1ed26ded6822bb92448e01 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration.cpp10
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration_p.h7
-rw-r--r--tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp56
3 files changed, 20 insertions, 53 deletions
diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp
index 0a79b5729..9e82515c2 100644
--- a/tests/auto/unit/mockbackend/qmockintegration.cpp
+++ b/tests/auto/unit/mockbackend/qmockintegration.cpp
@@ -40,6 +40,7 @@
#include "qmockintegration_p.h"
#include "qmockdevicemanager_p.h"
#include "mockmediaplayerservice.h"
+#include "mockaudiodecodercontrol.h"
QT_BEGIN_NAMESPACE
@@ -61,6 +62,15 @@ QMediaPlatformDeviceManager *QMockIntegration::deviceManager()
return m_manager;
}
+QAudioDecoderControl *QMockIntegration::createAudioDecoder()
+{
+ if (m_flags & NoAudioDecoderInterface)
+ m_lastAudioDecoderControl = nullptr;
+ else
+ m_lastAudioDecoderControl = new MockAudioDecoderControl;
+ return m_lastAudioDecoderControl;
+}
+
QMediaPlatformPlayerInterface *QMockIntegration::createPlayerInterface()
{
if (m_flags & NoPlayerInterface)
diff --git a/tests/auto/unit/mockbackend/qmockintegration_p.h b/tests/auto/unit/mockbackend/qmockintegration_p.h
index 8390b54f1..7db2aee14 100644
--- a/tests/auto/unit/mockbackend/qmockintegration_p.h
+++ b/tests/auto/unit/mockbackend/qmockintegration_p.h
@@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
class QMockDeviceManager;
class MockMediaPlayerService;
+class MockAudioDecoderControl;
class QMockIntegration : public QMediaPlatformIntegration
{
@@ -66,10 +67,12 @@ public:
QMediaPlatformDeviceManager *deviceManager() override;
+ QAudioDecoderControl *createAudioDecoder() override;
QMediaPlatformPlayerInterface *createPlayerInterface() override;
enum Flag {
- NoPlayerInterface = 1
+ NoPlayerInterface = 0x1,
+ NoAudioDecoderInterface = 0x2,
};
Q_DECLARE_FLAGS(Flags, Flag);
@@ -77,11 +80,13 @@ public:
Flags flags() const { return m_flags; }
MockMediaPlayerService *lastPlayerService() const { return m_lastPlayerService; }
+ MockAudioDecoderControl *lastAudioDecoder() const { return m_lastAudioDecoderControl; }
private:
Flags m_flags = {};
QMockDeviceManager *m_manager = nullptr;
MockMediaPlayerService *m_lastPlayerService = nullptr;
+ MockAudioDecoderControl *m_lastAudioDecoderControl = nullptr;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QMockIntegration::Flags);
diff --git a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp
index 2ab712e21..9601d129a 100644
--- a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp
+++ b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp
@@ -32,7 +32,7 @@
#include "qaudiodecoder.h"
#include "mockaudiodecoderservice.h"
-#include "mockmediaserviceprovider.h"
+#include "qmockintegration_p.h"
class tst_QAudioDecoder : public QObject
{
@@ -50,11 +50,9 @@ private Q_SLOTS:
void source();
void readAll();
void nullControl();
- void nullService();
private:
- MockAudioDecoderService *mockAudioDecoderService;
- MockMediaServiceProvider *mockProvider;
+ QMockIntegration *mockIntegration;
};
tst_QAudioDecoder::tst_QAudioDecoder()
@@ -63,10 +61,7 @@ tst_QAudioDecoder::tst_QAudioDecoder()
void tst_QAudioDecoder::init()
{
- mockAudioDecoderService = new MockAudioDecoderService(this);
- mockProvider = new MockMediaServiceProvider(mockAudioDecoderService);
-
- QMediaServiceProvider::setDefaultServiceProvider(mockProvider);
+ mockIntegration = new QMockIntegration;
}
void tst_QAudioDecoder::ctors()
@@ -329,55 +324,12 @@ void tst_QAudioDecoder::readAll()
void tst_QAudioDecoder::nullControl()
{
- mockAudioDecoderService->setControlNull();
- QAudioDecoder d;
-
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
-
- QVERIFY(d.hasSupport("MIME") == QMultimedia::MaybeSupported);
-
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
-
- QVERIFY(d.sourceFilename().isEmpty());
- d.setSourceFilename("test");
- QVERIFY(d.sourceFilename().isEmpty());
-
- QFile f;
- QVERIFY(d.sourceDevice() == nullptr);
- d.setSourceDevice(&f);
- QVERIFY(d.sourceDevice() == nullptr);
-
- QAudioFormat format;
- format.setChannelCount(2);
- QVERIFY(!d.audioFormat().isValid());
- d.setAudioFormat(format);
- QVERIFY(!d.audioFormat().isValid());
-
- QVERIFY(!d.read().isValid());
- QVERIFY(!d.bufferAvailable());
-
- QVERIFY(d.position() == -1);
- QVERIFY(d.duration() == -1);
-
- d.start();
- QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
- QVERIFY(!d.errorString().isEmpty());
- QVERIFY(d.state() == QAudioDecoder::StoppedState);
- d.stop();
-}
-
-
-void tst_QAudioDecoder::nullService()
-{
- mockProvider->service = nullptr;
+ mockIntegration->setFlags(QMockIntegration::NoAudioDecoderInterface);
QAudioDecoder d;
QVERIFY(d.error() == QAudioDecoder::ServiceMissingError);
QVERIFY(!d.errorString().isEmpty());
- QVERIFY(d.hasSupport("MIME") == QMultimedia::MaybeSupported);
-
QVERIFY(d.state() == QAudioDecoder::StoppedState);
QVERIFY(d.sourceFilename().isEmpty());