diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-05-07 14:42:53 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-05-07 13:04:55 +0000 |
commit | 1b8094a5fd83a7d14bc2f9fb4cf9c33af3a58d92 (patch) | |
tree | f2bd7187062273179a60dbb680a02a81ee738be9 /tests | |
parent | b8cf9cae1baafc6a6ca8ba853aac6025834c3a36 (diff) |
Some API and doc fixes for QAudioDecoder
Change-Id: I0f839896c9f813939b99b01242b54a00796731a8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
3 files changed, 37 insertions, 36 deletions
diff --git a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp index 74d5653ac..a59bd1701 100644 --- a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp +++ b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp @@ -102,15 +102,15 @@ void tst_QAudioDecoderBackend::fileTest() QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QString("")); QVERIFY(d.audioFormat() == QAudioFormat()); // Test local file QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME)); - d.setSourceFilename(fileInfo.absoluteFilePath()); + d.setSource(fileInfo.absoluteFilePath()); QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(!d.bufferAvailable()); - QCOMPARE(d.sourceFilename(), fileInfo.absoluteFilePath()); + QCOMPARE(d.source(), fileInfo.absoluteFilePath()); QSignalSpy readySpy(&d, SIGNAL(bufferReady())); QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); @@ -279,15 +279,15 @@ void tst_QAudioDecoderBackend::unsupportedFileTest() QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QString("")); QVERIFY(d.audioFormat() == QAudioFormat()); // Test local file QFileInfo fileInfo(QFINDTESTDATA(TEST_UNSUPPORTED_FILE_NAME)); - d.setSourceFilename(fileInfo.absoluteFilePath()); + d.setSource(fileInfo.absoluteFilePath()); QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(!d.bufferAvailable()); - QCOMPARE(d.sourceFilename(), fileInfo.absoluteFilePath()); + QCOMPARE(d.source(), fileInfo.absoluteFilePath()); QSignalSpy readySpy(&d, SIGNAL(bufferReady())); QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); @@ -357,15 +357,15 @@ void tst_QAudioDecoderBackend::corruptedFileTest() QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QString("")); QVERIFY(d.audioFormat() == QAudioFormat()); // Test local file QFileInfo fileInfo(QFINDTESTDATA(TEST_CORRUPTED_FILE_NAME)); - d.setSourceFilename(fileInfo.absoluteFilePath()); + d.setSource(fileInfo.absoluteFilePath()); QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(!d.bufferAvailable()); - QCOMPARE(d.sourceFilename(), fileInfo.absoluteFilePath()); + QCOMPARE(d.source(), fileInfo.absoluteFilePath()); QSignalSpy readySpy(&d, SIGNAL(bufferReady())); QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); @@ -444,7 +444,7 @@ void tst_QAudioDecoderBackend::deviceTest() QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QString("")); QVERIFY(d.audioFormat() == QAudioFormat()); QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME)); @@ -453,7 +453,7 @@ void tst_QAudioDecoderBackend::deviceTest() d.setSourceDevice(&file); QVERIFY(d.sourceDevice() == &file); - QVERIFY(d.sourceFilename().isEmpty()); + QVERIFY(d.source().isEmpty()); // We haven't set the format yet QVERIFY(d.audioFormat() == QAudioFormat()); diff --git a/tests/auto/unit/mockbackend/qmockaudiodecoder.h b/tests/auto/unit/mockbackend/qmockaudiodecoder.h index a43db18cc..1e1dca514 100644 --- a/tests/auto/unit/mockbackend/qmockaudiodecoder.h +++ b/tests/auto/unit/mockbackend/qmockaudiodecoder.h @@ -32,6 +32,7 @@ #include "private/qplatformaudiodecoder_p.h" #include <QtCore/qpair.h> +#include <QtCore/qurl.h> #include "qaudiobuffer.h" #include <QTimer> @@ -63,7 +64,7 @@ public: return mState; } - QString sourceFilename() const + QUrl source() const { return mSource; } @@ -81,7 +82,7 @@ public: } } - void setSourceFilename(const QString &fileName) + void setSource(const QUrl &fileName) { mSource = fileName; mDevice = 0; @@ -189,7 +190,7 @@ private slots: public: QAudioDecoder::State mState; - QString mSource; + QUrl mSource; QIODevice *mDevice; QAudioFormat mFormat; qint64 mPosition; diff --git a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp index 1015bd4ce..cd404d448 100644 --- a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp +++ b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp @@ -63,12 +63,12 @@ void tst_QAudioDecoder::ctors() QAudioDecoder d; QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QString("")); - d.setSourceFilename(""); + d.setSource(QUrl()); QVERIFY(d.state() == QAudioDecoder::StoppedState); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.sourceFilename(), QString("")); + QCOMPARE(d.source(), QUrl()); } void tst_QAudioDecoder::read() @@ -92,8 +92,8 @@ void tst_QAudioDecoder::read() QCOMPARE(errorSpy.count(), 1); // Set the source to something - d.setSourceFilename("Blah"); - QCOMPARE(d.sourceFilename(), QString("Blah")); + d.setSource(QUrl::fromLocalFile("Blah")); + QCOMPARE(d.source(), QUrl::fromLocalFile("Blah")); readySpy.clear(); errorSpy.clear(); @@ -153,8 +153,8 @@ void tst_QAudioDecoder::stop() QCOMPARE(errorSpy.count(), 1); // Set the source to something - d.setSourceFilename("Blah"); - QCOMPARE(d.sourceFilename(), QString("Blah")); + d.setSource(QUrl::fromLocalFile("Blah")); + QCOMPARE(d.source(), QUrl::fromLocalFile("Blah")); readySpy.clear(); errorSpy.clear(); @@ -195,8 +195,8 @@ void tst_QAudioDecoder::format() QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error))); // Set the source to something - d.setSourceFilename("Blah"); - QCOMPARE(d.sourceFilename(), QString("Blah")); + d.setSource(QUrl::fromLocalFile("Blah")); + QCOMPARE(d.source(), QUrl::fromLocalFile("Blah")); readySpy.clear(); errorSpy.clear(); @@ -246,35 +246,35 @@ void tst_QAudioDecoder::source() { QAudioDecoder d; - QVERIFY(d.sourceFilename().isEmpty()); + QVERIFY(d.source().isEmpty()); QVERIFY(d.sourceDevice() == nullptr); QFile f; d.setSourceDevice(&f); - QVERIFY(d.sourceFilename().isEmpty()); + QVERIFY(d.source().isEmpty()); QVERIFY(d.sourceDevice() == &f); - d.setSourceFilename("Foo"); - QVERIFY(d.sourceFilename() == QString("Foo")); + d.setSource(QUrl::fromLocalFile("Foo")); + QVERIFY(d.source() == QUrl::fromLocalFile("Foo")); QVERIFY(d.sourceDevice() == nullptr); d.setSourceDevice(nullptr); - QVERIFY(d.sourceFilename().isEmpty()); + QVERIFY(d.source().isEmpty()); QVERIFY(d.sourceDevice() == nullptr); - d.setSourceFilename("Foo"); - QVERIFY(d.sourceFilename() == QString("Foo")); + d.setSource(QUrl::fromLocalFile("Foo")); + QVERIFY(d.source() == QUrl::fromLocalFile("Foo")); QVERIFY(d.sourceDevice() == nullptr); - d.setSourceFilename(QString()); - QVERIFY(d.sourceFilename() == QString()); + d.setSource(QString()); + QVERIFY(d.source() == QString()); QVERIFY(d.sourceDevice() == nullptr); } void tst_QAudioDecoder::readAll() { QAudioDecoder d; - d.setSourceFilename("Foo"); + d.setSource(QUrl::fromLocalFile("Foo")); QVERIFY(d.state() == QAudioDecoder::StoppedState); QSignalSpy durationSpy(&d, SIGNAL(durationChanged(qint64))); @@ -326,9 +326,9 @@ void tst_QAudioDecoder::nullControl() QVERIFY(d.state() == QAudioDecoder::StoppedState); - QVERIFY(d.sourceFilename().isEmpty()); - d.setSourceFilename("test"); - QVERIFY(d.sourceFilename().isEmpty()); + QVERIFY(d.source().isEmpty()); + d.setSource(QUrl::fromLocalFile("test")); + QVERIFY(d.source().isEmpty()); QFile f; QVERIFY(d.sourceDevice() == nullptr); |