diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2011-11-04 13:38:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-04 08:19:17 +0100 |
commit | e3a8c165eabe139d71a762089ab396e5b492c70b (patch) | |
tree | 16d9960d2d20d65e0a5d1becc181c0a7b095d0aa /tests/auto/unit/qaudioformat | |
parent | 7dfb883df639f8d80cec7bd2c51eb37561bc4522 (diff) | |
download | qtmultimedia-e3a8c165eabe139d71a762089ab396e5b492c70b.tar.gz |
Rearrange the automatic tests.
Split them into unit and integration tests. Integration tests really
need to be run on the real platform (not in a VM etc) since they are
somewhat unstable or nonfunctional otherwise.
A few tests were previously broken by QUrl changes and they were repaired.
Removed one test since it was not providing a lot of value.
There are still a number of tests that rely on Q_AUTOTEST_EXPORT symbols.
Change-Id: Ic402abf0af946baa5945075d975b3f584f9ef280
Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
Diffstat (limited to 'tests/auto/unit/qaudioformat')
-rw-r--r-- | tests/auto/unit/qaudioformat/qaudioformat.pro | 8 | ||||
-rw-r--r-- | tests/auto/unit/qaudioformat/tst_qaudioformat.cpp | 271 |
2 files changed, 279 insertions, 0 deletions
diff --git a/tests/auto/unit/qaudioformat/qaudioformat.pro b/tests/auto/unit/qaudioformat/qaudioformat.pro new file mode 100644 index 000000000..59ba5c38f --- /dev/null +++ b/tests/auto/unit/qaudioformat/qaudioformat.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qaudioformat + +QT += core multimedia-private testlib +CONFIG += no_private_qt_headers_warning + +SOURCES += tst_qaudioformat.cpp + diff --git a/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp b/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp new file mode 100644 index 000000000..cdfa4766c --- /dev/null +++ b/tests/auto/unit/qaudioformat/tst_qaudioformat.cpp @@ -0,0 +1,271 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> +#include <QtCore/qlocale.h> +#include <qaudioformat.h> + +#include <QStringList> +#include <QList> + +//TESTED_COMPONENT=src/multimedia + +class tst_QAudioFormat : public QObject +{ + Q_OBJECT + +public: + tst_QAudioFormat(QObject* parent=0) : QObject(parent) {} + +private slots: + void checkNull(); + void checkFrequency(); + void checkSampleSize(); + void checkCodec(); + void checkByteOrder(); + void checkSampleType(); + void checkEquality(); + void checkAssignment(); + void checkSampleRate(); + void checkChannelCount(); + + void debugOperator(); + void debugOperator_data(); +}; + +void tst_QAudioFormat::checkNull() +{ + // Default constructed QAudioFormat is invalid. + QAudioFormat audioFormat0; + QVERIFY(!audioFormat0.isValid()); + + // validity is transferred + QAudioFormat audioFormat1(audioFormat0); + QVERIFY(!audioFormat1.isValid()); + + audioFormat0.setFrequency(44100); + audioFormat0.setChannels(2); + audioFormat0.setSampleSize(16); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setSampleType(QAudioFormat::SignedInt); + QVERIFY(audioFormat0.isValid()); +} + +void tst_QAudioFormat::checkFrequency() +{ + QAudioFormat audioFormat; + audioFormat.setFrequency(44100); + QVERIFY(audioFormat.frequency() == 44100); +} + +void tst_QAudioFormat::checkSampleSize() +{ + QAudioFormat audioFormat; + audioFormat.setSampleSize(16); + QVERIFY(audioFormat.sampleSize() == 16); +} + +void tst_QAudioFormat::checkCodec() +{ + QAudioFormat audioFormat; + audioFormat.setCodec(QString::fromLatin1("audio/pcm")); + QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm")); +} + +void tst_QAudioFormat::checkByteOrder() +{ + QAudioFormat audioFormat; + audioFormat.setByteOrder(QAudioFormat::LittleEndian); + QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian); + + QTest::ignoreMessage(QtDebugMsg, "LittleEndian"); + qDebug() << QAudioFormat::LittleEndian; + + audioFormat.setByteOrder(QAudioFormat::BigEndian); + QVERIFY(audioFormat.byteOrder() == QAudioFormat::BigEndian); + + QTest::ignoreMessage(QtDebugMsg, "BigEndian"); + qDebug() << QAudioFormat::BigEndian; +} + +void tst_QAudioFormat::checkSampleType() +{ + QAudioFormat audioFormat; + audioFormat.setSampleType(QAudioFormat::SignedInt); + QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt); + QTest::ignoreMessage(QtDebugMsg, "SignedInt"); + qDebug() << QAudioFormat::SignedInt; + + audioFormat.setSampleType(QAudioFormat::Unknown); + QVERIFY(audioFormat.sampleType() == QAudioFormat::Unknown); + QTest::ignoreMessage(QtDebugMsg, "Unknown"); + qDebug() << QAudioFormat::Unknown; + + audioFormat.setSampleType(QAudioFormat::UnSignedInt); + QVERIFY(audioFormat.sampleType() == QAudioFormat::UnSignedInt); + QTest::ignoreMessage(QtDebugMsg, "UnSignedInt"); + qDebug() << QAudioFormat::UnSignedInt; + + audioFormat.setSampleType(QAudioFormat::Float); + QVERIFY(audioFormat.sampleType() == QAudioFormat::Float); + QTest::ignoreMessage(QtDebugMsg, "Float"); + qDebug() << QAudioFormat::Float; +} + +void tst_QAudioFormat::checkEquality() +{ + QAudioFormat audioFormat0; + QAudioFormat audioFormat1; + + // Null formats are equivalent + QVERIFY(audioFormat0 == audioFormat1); + QVERIFY(!(audioFormat0 != audioFormat1)); + + // on filled formats + audioFormat0.setFrequency(8000); + audioFormat0.setChannels(1); + audioFormat0.setSampleSize(8); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setByteOrder(QAudioFormat::LittleEndian); + audioFormat0.setSampleType(QAudioFormat::UnSignedInt); + + audioFormat1.setFrequency(8000); + audioFormat1.setChannels(1); + audioFormat1.setSampleSize(8); + audioFormat1.setCodec("audio/pcm"); + audioFormat1.setByteOrder(QAudioFormat::LittleEndian); + audioFormat1.setSampleType(QAudioFormat::UnSignedInt); + + QVERIFY(audioFormat0 == audioFormat1); + QVERIFY(!(audioFormat0 != audioFormat1)); + + audioFormat0.setFrequency(44100); + QVERIFY(audioFormat0 != audioFormat1); + QVERIFY(!(audioFormat0 == audioFormat1)); +} + +void tst_QAudioFormat::checkAssignment() +{ + QAudioFormat audioFormat0; + QAudioFormat audioFormat1; + + audioFormat0.setFrequency(8000); + audioFormat0.setChannels(1); + audioFormat0.setSampleSize(8); + audioFormat0.setCodec("audio/pcm"); + audioFormat0.setByteOrder(QAudioFormat::LittleEndian); + audioFormat0.setSampleType(QAudioFormat::UnSignedInt); + + audioFormat1 = audioFormat0; + QVERIFY(audioFormat1 == audioFormat0); + + QAudioFormat audioFormat2(audioFormat0); + QVERIFY(audioFormat2 == audioFormat0); +} + +/* sampleRate() API property test. */ +void tst_QAudioFormat::checkSampleRate() +{ + QAudioFormat audioFormat; + QVERIFY(audioFormat.sampleRate() == -1); + + audioFormat.setSampleRate(123); + QVERIFY(audioFormat.sampleRate() == 123); +} + +/* channelCount() API property test. */ +void tst_QAudioFormat::checkChannelCount() +{ + // channels is the old name for channelCount, so + // they should always be equal + QAudioFormat audioFormat; + QVERIFY(audioFormat.channelCount() == -1); + QVERIFY(audioFormat.channels() == -1); + + audioFormat.setChannelCount(123); + QVERIFY(audioFormat.channelCount() == 123); + QVERIFY(audioFormat.channels() == 123); + + audioFormat.setChannels(5); + QVERIFY(audioFormat.channelCount() == 5); + QVERIFY(audioFormat.channels() == 5); +} + +void tst_QAudioFormat::debugOperator_data() +{ + QTest::addColumn<QAudioFormat>("format"); + QTest::addColumn<QString>("stringized"); + + // A small sampling + QAudioFormat f; + QTest::newRow("plain") << f << QString::fromLatin1("QAudioFormat(-1Hz, -1bit, channelCount=-1, sampleType=Unknown, byteOrder=LittleEndian, codec=\"\") "); + + f.setSampleRate(22050); + f.setByteOrder(QAudioFormat::LittleEndian); + f.setChannelCount(4); + f.setCodec("audio/pcm"); + f.setSampleType(QAudioFormat::Float); + + QTest::newRow("float") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=Float, byteOrder=LittleEndian, codec=\"audio/pcm\") "); + + f.setSampleType(QAudioFormat::UnSignedInt); + QTest::newRow("unsigned") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") "); + + f.setSampleRate(44100); + QTest::newRow("44.1 unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") "); + + f.setByteOrder(QAudioFormat::BigEndian); + QTest::newRow("44.1 big unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=BigEndian, codec=\"audio/pcm\") "); +} + +void tst_QAudioFormat::debugOperator() +{ + QFETCH(QAudioFormat, format); + QFETCH(QString, stringized); + + QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); + qDebug() << format; +} + +QTEST_MAIN(tst_QAudioFormat) + +#include "tst_qaudioformat.moc" |