diff options
Diffstat (limited to 'tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp')
-rw-r--r-- | tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp | 95 |
1 files changed, 36 insertions, 59 deletions
diff --git a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp index 6049bd4a2..77e161fda 100644 --- a/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp +++ b/tests/auto/unit/multimedia/qaudiodecoder/tst_qaudiodecoder.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/QString> @@ -32,13 +7,18 @@ #include "qaudiodecoder.h" #include "qmockaudiodecoder.h" -#include "qmockintegration_p.h" +#include "qmockintegration.h" + +QT_USE_NAMESPACE + +Q_ENABLE_MOCK_MULTIMEDIA_PLUGIN class tst_QAudioDecoder : public QObject { Q_OBJECT public: + tst_QAudioDecoder(); private Q_SLOTS: @@ -49,9 +29,6 @@ private Q_SLOTS: void source(); void readAll(); void nullControl(); - -private: - QMockIntegration mockIntegration; }; tst_QAudioDecoder::tst_QAudioDecoder() @@ -63,7 +40,7 @@ void tst_QAudioDecoder::ctors() QAudioDecoder d; QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(d.source(), QString("")); + QCOMPARE(d.source(), QStringLiteral("")); d.setSource(QUrl()); QVERIFY(!d.isDecoding()); @@ -77,8 +54,8 @@ void tst_QAudioDecoder::read() QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QSignalSpy readySpy(&d, SIGNAL(bufferReady())); - QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); + QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady); + QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged); QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error))); // Starting with empty source == error @@ -87,9 +64,9 @@ void tst_QAudioDecoder::read() QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(readySpy.count(), 0); - QCOMPARE(bufferChangedSpy.count(), 0); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(readySpy.size(), 0); + QCOMPARE(bufferChangedSpy.size(), 0); + QCOMPARE(errorSpy.size(), 1); // Set the source to something d.setSource(QUrl::fromLocalFile("Blah")); @@ -122,13 +99,13 @@ void tst_QAudioDecoder::read() QVERIFY(b.format().channelCount() == 1); QVERIFY(b.sampleCount() == 4); - QVERIFY(readySpy.count() >= 1); - QVERIFY(errorSpy.count() == 0); + QVERIFY(readySpy.size() >= 1); + QVERIFY(errorSpy.size() == 0); if (d.bufferAvailable()) { - QVERIFY(bufferChangedSpy.count() == 1); + QVERIFY(bufferChangedSpy.size() == 1); } else { - QVERIFY(bufferChangedSpy.count() == 2); + QVERIFY(bufferChangedSpy.size() == 2); } } @@ -138,8 +115,8 @@ void tst_QAudioDecoder::stop() QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QSignalSpy readySpy(&d, SIGNAL(bufferReady())); - QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); + QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady); + QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged); QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error))); // Starting with empty source == error @@ -148,9 +125,9 @@ void tst_QAudioDecoder::stop() QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QCOMPARE(readySpy.count(), 0); - QCOMPARE(bufferChangedSpy.count(), 0); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(readySpy.size(), 0); + QCOMPARE(bufferChangedSpy.size(), 0); + QCOMPARE(errorSpy.size(), 1); // Set the source to something d.setSource(QUrl::fromLocalFile("Blah")); @@ -190,8 +167,8 @@ void tst_QAudioDecoder::format() QVERIFY(!d.isDecoding()); QVERIFY(d.bufferAvailable() == false); - QSignalSpy readySpy(&d, SIGNAL(bufferReady())); - QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool))); + QSignalSpy readySpy(&d, &QAudioDecoder::bufferReady); + QSignalSpy bufferChangedSpy(&d, &QAudioDecoder::bufferAvailableChanged); QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error))); // Set the source to something @@ -278,19 +255,19 @@ void tst_QAudioDecoder::readAll() d.setSource(QUrl::fromLocalFile("Foo")); QVERIFY(!d.isDecoding()); - QSignalSpy durationSpy(&d, SIGNAL(durationChanged(qint64))); - QSignalSpy positionSpy(&d, SIGNAL(positionChanged(qint64))); - QSignalSpy isDecodingSpy(&d, SIGNAL(isDecodingChanged(bool))); - QSignalSpy finishedSpy(&d, SIGNAL(finished())); - QSignalSpy bufferAvailableSpy(&d, SIGNAL(bufferAvailableChanged(bool))); + QSignalSpy durationSpy(&d, &QAudioDecoder::durationChanged); + QSignalSpy positionSpy(&d, &QAudioDecoder::positionChanged); + QSignalSpy isDecodingSpy(&d, &QAudioDecoder::isDecodingChanged); + QSignalSpy finishedSpy(&d, &QAudioDecoder::finished); + QSignalSpy bufferAvailableSpy(&d, &QAudioDecoder::bufferAvailableChanged); d.start(); int i = 0; forever { QVERIFY(d.isDecoding()); - QCOMPARE(isDecodingSpy.count(), 1); - QCOMPARE(durationSpy.count(), 1); + QCOMPARE(isDecodingSpy.size(), 1); + QCOMPARE(durationSpy.size(), 1); QVERIFY(finishedSpy.isEmpty()); - QTRY_VERIFY(bufferAvailableSpy.count() >= 1); + QTRY_VERIFY(bufferAvailableSpy.size() >= 1); if (d.bufferAvailable()) { QAudioBuffer b = d.read(); QVERIFY(b.isValid()); @@ -301,8 +278,8 @@ void tst_QAudioDecoder::readAll() i++; if (i == MOCK_DECODER_MAX_BUFFERS) { - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(isDecodingSpy.count(), 2); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(isDecodingSpy.size(), 2); QVERIFY(!d.isDecoding()); QList<QVariant> arguments = isDecodingSpy.takeLast(); QVERIFY(arguments.at(0).toBool() == false); @@ -319,7 +296,7 @@ void tst_QAudioDecoder::readAll() void tst_QAudioDecoder::nullControl() { - mockIntegration.setFlags(QMockIntegration::NoAudioDecoderInterface); + QMockIntegration::instance()->setFlags(QMockIntegration::NoAudioDecoderInterface); QAudioDecoder d; QVERIFY(d.error() == QAudioDecoder::NotSupportedError); |