summaryrefslogtreecommitdiffstats
path: root/tests/auto/integration/qaudiosource/tst_qaudiosource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/integration/qaudiosource/tst_qaudiosource.cpp')
-rw-r--r--tests/auto/integration/qaudiosource/tst_qaudiosource.cpp238
1 files changed, 143 insertions, 95 deletions
diff --git a/tests/auto/integration/qaudiosource/tst_qaudiosource.cpp b/tests/auto/integration/qaudiosource/tst_qaudiosource.cpp
index d343fb8a8..ae100a08b 100644
--- a/tests/auto/integration/qaudiosource/tst_qaudiosource.cpp
+++ b/tests/auto/integration/qaudiosource/tst_qaudiosource.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 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) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtCore/qlocale.h>
@@ -40,8 +15,6 @@
#include <qwavedecoder.h>
-//TESTED_COMPONENT=src/multimedia
-
#define RANGE_ERR 0.5
template<typename T> inline bool qTolerantCompare(T value, T expected)
@@ -101,7 +74,7 @@ private:
QScopedPointer<QByteArray> m_byteArray;
QScopedPointer<QBuffer> m_buffer;
- bool m_inCISystem;
+ bool m_inCISystem = false;
};
void tst_QAudioSource::generate_audiofile_testrows()
@@ -109,8 +82,8 @@ void tst_QAudioSource::generate_audiofile_testrows()
QTest::addColumn<FilePtr>("audioFile");
QTest::addColumn<QAudioFormat>("audioFormat");
- for (int i=0; i<audioFiles.count(); i++) {
- QTest::newRow(QString("%1").arg(i).toUtf8().constData())
+ for (int i=0; i<audioFiles.size(); i++) {
+ QTest::newRow(QStringLiteral("%1").arg(i).toUtf8().constData())
<< audioFiles.at(i) << testFormats.at(i);
// Only run first format in CI system to reduce test times
@@ -121,16 +94,30 @@ void tst_QAudioSource::generate_audiofile_testrows()
QString tst_QAudioSource::formatToFileName(const QAudioFormat &format)
{
- return QString("%1_%2_%3")
- .arg(format.sampleRate())
- .arg(format.bytesPerSample())
- .arg(format.channelCount());
+ return QStringLiteral("%1_%2_%3")
+ .arg(format.sampleRate())
+ .arg(format.bytesPerSample())
+ .arg(format.channelCount());
}
void tst_QAudioSource::initTestCase()
{
- // Only perform tests if audio output device exists
- const QList<QAudioDevice> devices = QMediaDevices::audioOutputs();
+#ifdef Q_OS_ANDROID
+ // The test might fail because libOpenSLES cannot create AudioRecorder for that emulator. The
+ // Android documentation states that the emulator doesn't support this at all all
+ // https://developer.android.com/media/platform/mediarecorder. However, in practice this test
+ // fails only prior to Android 10.
+ if (QNativeInterface::QAndroidApplication::sdkVersion() < __ANDROID_API_Q__)
+ QSKIP("Emulated Android version doesn't support audio recording");
+#endif
+
+ m_inCISystem = qEnvironmentVariable("QTEST_ENVIRONMENT").toLower() == "ci";
+
+ if (m_inCISystem)
+ QSKIP("SKIP initTestCase on CI. To be fixed");
+
+ // Only perform tests if audio input device exists
+ const QList<QAudioDevice> devices = QMediaDevices::audioInputs();
if (devices.size() <= 0)
QSKIP("No audio backend");
@@ -184,11 +171,10 @@ void tst_QAudioSource::initTestCase()
QVERIFY(m_temporaryDir->isValid());
const QString temporaryAudioPath = m_temporaryDir->path() + slash;
- for (const QAudioFormat &format : qAsConst(testFormats)) {
+ for (const QAudioFormat &format : std::as_const(testFormats)) {
const QString fileName = temporaryAudioPath + formatToFileName(format) + QStringLiteral(".wav");
audioFiles.append(FilePtr::create(fileName));
}
- qgetenv("QT_TEST_CI").toInt(&m_inCISystem,10);
}
void tst_QAudioSource::format()
@@ -199,11 +185,23 @@ void tst_QAudioSource::format()
QAudioFormat actual = audioInput.format();
QVERIFY2((requested.channelCount() == actual.channelCount()),
- QString("channels: requested=%1, actual=%2").arg(requested.channelCount()).arg(actual.channelCount()).toUtf8().constData());
+ QStringLiteral("channels: requested=%1, actual=%2")
+ .arg(requested.channelCount())
+ .arg(actual.channelCount())
+ .toUtf8()
+ .constData());
QVERIFY2((requested.sampleRate() == actual.sampleRate()),
- QString("sampleRate: requested=%1, actual=%2").arg(requested.sampleRate()).arg(actual.sampleRate()).toUtf8().constData());
+ QStringLiteral("sampleRate: requested=%1, actual=%2")
+ .arg(requested.sampleRate())
+ .arg(actual.sampleRate())
+ .toUtf8()
+ .constData());
QVERIFY2((requested.sampleFormat() == actual.sampleFormat()),
- QString("sampleFormat: requested=%1, actual=%2").arg((ushort)requested.sampleFormat()).arg((ushort)actual.sampleFormat()).toUtf8().constData());
+ QStringLiteral("sampleFormat: requested=%1, actual=%2")
+ .arg((ushort)requested.sampleFormat())
+ .arg((ushort)actual.sampleFormat())
+ .toUtf8()
+ .constData());
QCOMPARE(actual, requested);
}
@@ -260,17 +258,26 @@ void tst_QAudioSource::bufferSize()
audioInput.setBufferSize(512);
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after setBufferSize(512)");
QVERIFY2((audioInput.bufferSize() == 512),
- QString("bufferSize: requested=512, actual=%2").arg(audioInput.bufferSize()).toUtf8().constData());
+ QStringLiteral("bufferSize: requested=512, actual=%2")
+ .arg(audioInput.bufferSize())
+ .toUtf8()
+ .constData());
audioInput.setBufferSize(4096);
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after setBufferSize(4096)");
QVERIFY2((audioInput.bufferSize() == 4096),
- QString("bufferSize: requested=4096, actual=%2").arg(audioInput.bufferSize()).toUtf8().constData());
+ QStringLiteral("bufferSize: requested=4096, actual=%2")
+ .arg(audioInput.bufferSize())
+ .toUtf8()
+ .constData());
audioInput.setBufferSize(8192);
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after setBufferSize(8192)");
QVERIFY2((audioInput.bufferSize() == 8192),
- QString("bufferSize: requested=8192, actual=%2").arg(audioInput.bufferSize()).toUtf8().constData());
+ QStringLiteral("bufferSize: requested=8192, actual=%2")
+ .arg(audioInput.bufferSize())
+ .toUtf8()
+ .constData());
}
void tst_QAudioSource::stopWhileStopped()
@@ -285,11 +292,11 @@ void tst_QAudioSource::stopWhileStopped()
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
audioInput.stop();
// Check that no state transition occurred
- QVERIFY2((stateSignal.count() == 0), "stop() while stopped is emitting a signal and it shouldn't");
+ QVERIFY2((stateSignal.size() == 0), "stop() while stopped is emitting a signal and it shouldn't");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError after stop()");
}
@@ -305,11 +312,11 @@ void tst_QAudioSource::suspendWhileStopped()
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
audioInput.suspend();
// Check that no state transition occurred
- QVERIFY2((stateSignal.count() == 0), "stop() while suspended is emitting a signal and it shouldn't");
+ QVERIFY2((stateSignal.size() == 0), "stop() while suspended is emitting a signal and it shouldn't");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError after stop()");
}
@@ -325,11 +332,11 @@ void tst_QAudioSource::resumeWhileStopped()
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
audioInput.resume();
// Check that no state transition occurred
- QVERIFY2((stateSignal.count() == 0), "resume() while stopped is emitting a signal and it shouldn't");
+ QVERIFY2((stateSignal.size() == 0), "resume() while stopped is emitting a signal and it shouldn't");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError after resume()");
}
@@ -340,7 +347,7 @@ void tst_QAudioSource::pull()
QAudioSource audioInput(audioFormat, this);
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -360,7 +367,7 @@ void tst_QAudioSource::pull()
audioInput.start(audioFile.data());
// Check that QAudioSource immediately transitions to ActiveState or IdleState
- QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
+ QTRY_VERIFY2((stateSignal.size() > 0),"didn't emit signals on start()");
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
"didn't transition to ActiveState or IdleState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -371,17 +378,25 @@ void tst_QAudioSource::pull()
QTRY_VERIFY2((audioInput.processedUSecs() > 0), "elapsedUSecs() is still zero after start()");
// Allow some recording to happen
- QTest::qWait(300); // .3 seconds should be plenty
+ QTest::qWait(3000); // 3 seconds should be plenty
stateSignal.clear();
qint64 processedUs = audioInput.processedUSecs();
- QVERIFY2(qTolerantCompare(processedUs, 300000LL),
- QString("processedUSecs() doesn't fall in acceptable range, should be 300000 (%1)").arg(processedUs).toUtf8().constData());
+ QVERIFY2(qTolerantCompare(processedUs, 3000000LL),
+ QStringLiteral(
+ "processedUSecs() doesn't fall in acceptable range, should be 3000000 (%1)")
+ .arg(processedUs)
+ .toUtf8()
+ .constData());
audioInput.stop();
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral("didn't emit StoppedState signal after stop(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
@@ -396,16 +411,12 @@ void tst_QAudioSource::pull()
void tst_QAudioSource::pullSuspendResume()
{
-#ifdef Q_OS_LINUX
- if (m_inCISystem)
- QSKIP("QTBUG-26504 Fails 20% of time with pulseaudio backend");
-#endif
QFETCH(FilePtr, audioFile);
QFETCH(QAudioFormat, audioFormat);
QAudioSource audioInput(audioFormat, this);
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -425,7 +436,7 @@ void tst_QAudioSource::pullSuspendResume()
audioInput.start(audioFile.data());
// Check that QAudioSource immediately transitions to ActiveState or IdleState
- QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
+ QTRY_VERIFY2((stateSignal.size() > 0),"didn't emit signals on start()");
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
"didn't transition to ActiveState or IdleState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -436,7 +447,7 @@ void tst_QAudioSource::pullSuspendResume()
QTRY_VERIFY2((audioInput.processedUSecs() > 0), "elapsedUSecs() is still zero after start()");
// Allow some recording to happen
- QTest::qWait(300); // .3 seconds should be plenty
+ QTest::qWait(3000); // 3 seconds should be plenty
QVERIFY2((audioInput.state() == QAudio::ActiveState),
"didn't transition to ActiveState after some recording");
@@ -446,8 +457,13 @@ void tst_QAudioSource::pullSuspendResume()
audioInput.suspend();
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit SuspendedState signal after suspend(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral(
+ "didn't emit SuspendedState signal after suspend(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::SuspendedState), "didn't transitions to SuspendedState after stop()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
stateSignal.clear();
@@ -455,24 +471,35 @@ void tst_QAudioSource::pullSuspendResume()
// Check that only 'elapsed', and not 'processed' increases while suspended
qint64 elapsedUs = audioInput.elapsedUSecs();
qint64 processedUs = audioInput.processedUSecs();
- QVERIFY2(qTolerantCompare(processedUs, 300000LL),
- QString("processedUSecs() doesn't fall in acceptable range, should be 300000 (%1)").arg(processedUs).toUtf8().constData());
+ QVERIFY2(qTolerantCompare(processedUs, 3000000LL),
+ QStringLiteral(
+ "processedUSecs() doesn't fall in acceptable range, should be 3000000 (%1)")
+ .arg(processedUs)
+ .toUtf8()
+ .constData());
QTRY_VERIFY(audioInput.elapsedUSecs() > elapsedUs);
QVERIFY(audioInput.processedUSecs() == processedUs);
audioInput.resume();
// Check that QAudioSource immediately transitions to ActiveState
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit signal after resume(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2((stateSignal.size() == 1),
+ QStringLiteral("didn't emit signal after resume(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::ActiveState), "didn't transition to ActiveState after resume()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after resume()");
stateSignal.clear();
audioInput.stop();
QTest::qWait(40);
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral("didn't emit StoppedState signal after stop(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
@@ -491,7 +518,7 @@ void tst_QAudioSource::push()
QAudioSource audioInput(audioFormat, this);
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -514,7 +541,7 @@ void tst_QAudioSource::push()
QIODevice* feed = audioInput.start();
// Check that QAudioSource immediately transitions to IdleState
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit IdleState signal on start()");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit IdleState signal on start()");
QVERIFY2((audioInput.state() == QAudio::IdleState),
"didn't transition to IdleState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -534,7 +561,7 @@ void tst_QAudioSource::push()
totalBytesRead += buffer.size();
if (firstBuffer && buffer.size()) {
// Check for transition to ActiveState when data is provided
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit ActiveState signal on data");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit ActiveState signal on data");
QVERIFY2((audioInput.state() == QAudio::ActiveState),
"didn't transition to ActiveState after data");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -547,12 +574,20 @@ void tst_QAudioSource::push()
qint64 processedUs = audioInput.processedUSecs();
audioInput.stop();
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral("didn't emit StoppedState signal after stop(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
QVERIFY2(qTolerantCompare(processedUs, 500000LL),
- QString("processedUSecs() doesn't fall in acceptable range, should be 500000 (%1)").arg(processedUs).toUtf8().constData());
+ QStringLiteral(
+ "processedUSecs() doesn't fall in acceptable range, should be 500000 (%1)")
+ .arg(processedUs)
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");
@@ -574,7 +609,7 @@ void tst_QAudioSource::pushSuspendResume()
audioInput.setBufferSize(audioFormat.bytesForDuration(100000));
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -594,7 +629,7 @@ void tst_QAudioSource::pushSuspendResume()
QIODevice* feed = audioInput.start();
// Check that QAudioSource immediately transitions to IdleState
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit IdleState signal on start()");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit IdleState signal on start()");
QVERIFY2((audioInput.state() == QAudio::IdleState),
"didn't transition to IdleState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -613,7 +648,7 @@ void tst_QAudioSource::pushSuspendResume()
totalBytesRead += buffer.size();
if (firstBuffer && buffer.size()) {
// Check for transition to ActiveState when data is provided
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit ActiveState signal on data");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit ActiveState signal on data");
QVERIFY2((audioInput.state() == QAudio::ActiveState),
"didn't transition to ActiveState after data");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
@@ -624,8 +659,13 @@ void tst_QAudioSource::pushSuspendResume()
audioInput.suspend();
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit SuspendedState signal after suspend(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral(
+ "didn't emit SuspendedState signal after suspend(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::SuspendedState), "didn't transitions to SuspendedState after stop()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
stateSignal.clear();
@@ -644,7 +684,7 @@ void tst_QAudioSource::pushSuspendResume()
audioInput.resume();
// Check that QAudioSource immediately transitions to Active or IdleState
- QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on resume()");
+ QTRY_VERIFY2((stateSignal.size() > 0),"didn't emit signals on resume()");
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
"didn't transition to ActiveState or IdleState after resume()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after resume()");
@@ -665,12 +705,20 @@ void tst_QAudioSource::pushSuspendResume()
processedUs = audioInput.processedUSecs();
audioInput.stop();
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toUtf8().constData());
+ QTRY_VERIFY2(
+ (stateSignal.size() == 1),
+ QStringLiteral("didn't emit StoppedState signal after stop(), got %1 signals instead")
+ .arg(stateSignal.size())
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
QVERIFY2(qTolerantCompare(processedUs, 1000000LL),
- QString("processedUSecs() doesn't fall in acceptable range, should be 2040000 (%1)").arg(processedUs).toUtf8().constData());
+ QStringLiteral(
+ "processedUSecs() doesn't fall in acceptable range, should be 2040000 (%1)")
+ .arg(processedUs)
+ .toUtf8()
+ .constData());
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");
//WavHeader::writeDataLength(*audioFile,audioFile->pos()-WavHeader::headerLength());
@@ -687,7 +735,7 @@ void tst_QAudioSource::reset()
{
QAudioSource audioInput(audioFormat, this);
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -696,7 +744,7 @@ void tst_QAudioSource::reset()
QIODevice* device = audioInput.start();
// Check that QAudioSource immediately transitions to IdleState
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit IdleState signal on start()");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit IdleState signal on start()");
QVERIFY2((audioInput.state() == QAudio::IdleState), "didn't transition to IdleState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
QTRY_VERIFY2_WITH_TIMEOUT((audioInput.bytesAvailable() > 0), "no bytes available after starting", 10000);
@@ -707,7 +755,7 @@ void tst_QAudioSource::reset()
stateSignal.clear();
audioInput.reset();
- QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit StoppedState signal after reset()");
+ QTRY_VERIFY2((stateSignal.size() == 1),"didn't emit StoppedState signal after reset()");
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after reset()");
QVERIFY2((audioInput.bytesAvailable() == 0), "buffer not cleared after reset()");
}
@@ -717,7 +765,7 @@ void tst_QAudioSource::reset()
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
- QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
+ QSignalSpy stateSignal(&audioInput, &QAudioSource::stateChanged);
// Check that we are in the default state before calling start
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
@@ -727,13 +775,13 @@ void tst_QAudioSource::reset()
audioInput.start(&buffer);
// Check that QAudioSource immediately transitions to ActiveState
- QTRY_VERIFY2((stateSignal.count() >= 1),"didn't emit state changed signal on start()");
+ QTRY_VERIFY2((stateSignal.size() >= 1),"didn't emit state changed signal on start()");
QTRY_VERIFY2((audioInput.state() == QAudio::ActiveState), "didn't transition to ActiveState after start()");
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
stateSignal.clear();
audioInput.reset();
- QTRY_VERIFY2((stateSignal.count() >= 1),"didn't emit StoppedState signal after reset()");
+ QTRY_VERIFY2((stateSignal.size() >= 1),"didn't emit StoppedState signal after reset()");
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after reset()");
QVERIFY2((audioInput.bytesAvailable() == 0), "buffer not cleared after reset()");
}