summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2009-08-05 04:26:56 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2009-08-05 04:26:56 (GMT)
commite7052de274f6a201be628441d144dbbef5868948 (patch)
tree2456ce91e33a13d49666213e722a12f32d196e0a /tests/auto
parentbd51c3010e78925a2074122b281de53f01be9ef9 (diff)
downloadQt-e7052de274f6a201be628441d144dbbef5868948.zip
Qt-e7052de274f6a201be628441d144dbbef5868948.tar.gz
Qt-e7052de274f6a201be628441d144dbbef5868948.tar.bz2
Merge AudioServices into mainline.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/qaudiodeviceid/qaudiodeviceid.pro7
-rw-r--r--tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp98
-rw-r--r--tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro7
-rw-r--r--tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp159
-rw-r--r--tests/auto/qaudioformat/qaudioformat.pro7
-rw-r--r--tests/auto/qaudioformat/tst_qaudioformat.cpp180
-rw-r--r--tests/auto/qaudioinput/qaudioinput.pro7
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp120
-rw-r--r--tests/auto/qaudiooutput/4.wavbin0 -> 5538 bytes
-rw-r--r--tests/auto/qaudiooutput/qaudiooutput.pro12
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp156
-rw-r--r--tests/auto/tests.xml8
13 files changed, 765 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index b4a6600..2550dcd 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -284,6 +284,10 @@ SUBDIRS += _networkselftest \
qsocks5socketengine \
qsortfilterproxymodel \
qsound \
+ qaudiodeviceid \
+ qaudioformat \
+ qaudiooutput \
+ qaudioinput \
qspinbox \
qsplitter \
qsql \
diff --git a/tests/auto/qaudiodeviceid/qaudiodeviceid.pro b/tests/auto/qaudiodeviceid/qaudiodeviceid.pro
new file mode 100644
index 0000000..e0c7d4d
--- /dev/null
+++ b/tests/auto/qaudiodeviceid/qaudiodeviceid.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiodeviceid.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
new file mode 100644
index 0000000..d40118b
--- /dev/null
+++ b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiodeviceid.h>
+#include <qaudiodeviceinfo.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioDeviceId : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkNull();
+ void checkEquality();
+};
+
+void tst_QAudioDeviceId::checkNull()
+{
+ // Default constructed is null.
+ QAudioDeviceId deviceId0;
+ QVERIFY(deviceId0.isNull());
+
+ // Null is transferred
+ QAudioDeviceId deviceId1(deviceId0);
+ QVERIFY(deviceId1.isNull());
+}
+
+void tst_QAudioDeviceId::checkEquality()
+{
+ QAudioDeviceId deviceId0;
+ QAudioDeviceId deviceId1;
+
+ // Null ids are equivalent
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+
+ deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
+
+ // Different
+ QVERIFY(deviceId0 != deviceId1);
+ QVERIFY(!(deviceId0 == deviceId1));
+
+ // Same
+ deviceId0 = deviceId1;
+
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+}
+
+QTEST_MAIN(tst_QAudioDeviceId)
+
+#include "tst_qaudiodeviceid.moc"
diff --git a/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
new file mode 100644
index 0000000..695987c
--- /dev/null
+++ b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiodeviceinfo.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
new file mode 100644
index 0000000..c2cd97e
--- /dev/null
+++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiodeviceinfo.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioDeviceInfo : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkAvailableDefaultInput();
+ void checkAvailableDefaultOutput();
+ void outputList();
+ void codecs();
+ void channels();
+ void sampleSizes();
+ void byteOrders();
+ void sampleTypes();
+ void frequencies();
+ void isformat();
+ void preferred();
+ void nearest();
+
+private:
+ QAudioDeviceInfo* device;
+};
+
+void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
+{
+ QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
+}
+
+void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
+{
+ QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
+}
+
+void tst_QAudioDeviceInfo::outputList()
+{
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QVERIFY(devices.size() > 0);
+ device = new QAudioDeviceInfo(devices.at(0), this);
+}
+
+void tst_QAudioDeviceInfo::codecs()
+{
+ QStringList avail = device->supportedCodecs();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::channels()
+{
+ QList<int> avail = device->supportedChannels();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::sampleSizes()
+{
+ QList<int> avail = device->supportedSampleSizes();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::byteOrders()
+{
+ QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::sampleTypes()
+{
+ QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::frequencies()
+{
+ QList<int> avail = device->supportedFrequencies();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::isformat()
+{
+ QAudioFormat format;
+ format.setFrequency(44100);
+ format.setChannels(2);
+ format.setSampleType(QAudioFormat::SignedInt);
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleSize(16);
+ format.setCodec("audio/pcm");
+
+ // Should always be true for these format
+ QVERIFY(device->isFormatSupported(format));
+}
+
+void tst_QAudioDeviceInfo::preferred()
+{
+ QAudioFormat format = device->preferredFormat();
+ QVERIFY(format.frequency() == 44100);
+ QVERIFY(format.channels() == 2);
+}
+
+void tst_QAudioDeviceInfo::nearest()
+{
+ QAudioFormat format1, format2;
+ format1.setFrequency(8000);
+ format2 = device->nearestFormat(format1);
+ QVERIFY(format2.frequency() == 44100);
+}
+
+QTEST_MAIN(tst_QAudioDeviceInfo)
+
+#include "tst_qaudiodeviceinfo.moc"
diff --git a/tests/auto/qaudioformat/qaudioformat.pro b/tests/auto/qaudioformat/qaudioformat.pro
new file mode 100644
index 0000000..78962d7
--- /dev/null
+++ b/tests/auto/qaudioformat/qaudioformat.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudioformat.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp
new file mode 100644
index 0000000..bcfc78f
--- /dev/null
+++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudioformat.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioFormat : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAudioFormat(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkNull();
+ void checkFrequency();
+ void checkChannels();
+ void checkSampleSize();
+ void checkCodec();
+ void checkByteOrder();
+ void checkSampleType();
+ void checkEquality();
+ void checkAssignment();
+};
+
+void tst_QAudioFormat::checkNull()
+{
+ // Default constructed QAudioFormat is null.
+ QAudioFormat audioFormat0;
+ QVERIFY(audioFormat0.isNull());
+
+ // Null is transferred
+ QAudioFormat audioFormat1(audioFormat0);
+ QVERIFY(audioFormat1.isNull());
+
+ // Null is voided on activity
+ audioFormat0.setFrequency(44100);
+ QVERIFY(!audioFormat0.isNull());
+}
+
+void tst_QAudioFormat::checkFrequency()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setFrequency(44100);
+ QVERIFY(audioFormat.frequency() == 44100);
+}
+
+void tst_QAudioFormat::checkChannels()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setChannels(2);
+ QVERIFY(audioFormat.channels() == 2);
+}
+
+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);
+}
+
+void tst_QAudioFormat::checkSampleType()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setSampleType(QAudioFormat::SignedInt);
+ QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
+}
+
+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);
+}
+
+QTEST_MAIN(tst_QAudioFormat)
+
+#include "tst_qaudioformat.moc"
diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro
new file mode 100644
index 0000000..8a03749
--- /dev/null
+++ b/tests/auto/qaudioinput/qaudioinput.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudioinput.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
new file mode 100644
index 0000000..6e16320
--- /dev/null
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudioinput.h>
+#include <qaudiodeviceinfo.h>
+#include <qaudio.h>
+#include <qaudioformat.h>
+
+
+class tst_QAudioInput : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioInput(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void initTestCase();
+ void settings();
+ void notifyInterval();
+ void pullFile();
+
+private:
+ QAudioFormat format;
+ QAudioInput* audio;
+};
+
+void tst_QAudioInput::initTestCase()
+{
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ audio = new QAudioInput(format, this);
+}
+
+void tst_QAudioInput::settings()
+{
+ QAudioFormat f = audio->format();
+
+ QVERIFY(format.channels() == f.channels());
+ QVERIFY(format.frequency() == f.frequency());
+ QVERIFY(format.sampleSize() == f.sampleSize());
+ QVERIFY(format.codec() == f.codec());
+ QVERIFY(format.byteOrder() == f.byteOrder());
+ QVERIFY(format.sampleType() == f.sampleType());
+}
+
+void tst_QAudioInput::notifyInterval()
+{
+ QVERIFY(audio->notifyInterval() == 1000); // Default
+
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
+
+ audio->setNotifyInterval(1000); // reset
+}
+
+void tst_QAudioInput::pullFile()
+{
+ QFile filename(SRCDIR "test.raw");
+ filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
+
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->start(&filename);
+
+ QTest::qWait(5000);
+
+ QVERIFY(readSignal.count() > 0);
+ QVERIFY(audio->totalTime() > 0);
+
+ audio->stop();
+ filename.close();
+}
+
+QTEST_MAIN(tst_QAudioInput)
+
+#include "tst_qaudioinput.moc"
diff --git a/tests/auto/qaudiooutput/4.wav b/tests/auto/qaudiooutput/4.wav
new file mode 100644
index 0000000..e31b0609
--- /dev/null
+++ b/tests/auto/qaudiooutput/4.wav
Binary files differ
diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro
new file mode 100644
index 0000000..6c07c64
--- /dev/null
+++ b/tests/auto/qaudiooutput/qaudiooutput.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiooutput.cpp
+
+QT = core multimedia
+
+wince*: {
+ deploy.sources += 4.wav
+ DEPLOYMENT = deploy
+}
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
new file mode 100644
index 0000000..0f94faa
--- /dev/null
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiooutput.h>
+#include <qaudiodeviceinfo.h>
+#include <qaudio.h>
+#include <qaudioformat.h>
+
+
+class tst_QAudioOutput : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioOutput(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void initTestCase();
+ void settings();
+ void notifyInterval();
+ void pullFile();
+ void pushFile();
+
+private:
+ QAudioFormat format;
+ QAudioOutput* audio;
+};
+
+void tst_QAudioOutput::initTestCase()
+{
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ audio = new QAudioOutput(format, this);
+}
+
+void tst_QAudioOutput::settings()
+{
+ QAudioFormat f = audio->format();
+
+ QVERIFY(format.channels() == f.channels());
+ QVERIFY(format.frequency() == f.frequency());
+ QVERIFY(format.sampleSize() == f.sampleSize());
+ QVERIFY(format.codec() == f.codec());
+ QVERIFY(format.byteOrder() == f.byteOrder());
+ QVERIFY(format.sampleType() == f.sampleType());
+}
+
+void tst_QAudioOutput::notifyInterval()
+{
+ QVERIFY(audio->notifyInterval() == 1000); // Default
+
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
+
+ audio->setNotifyInterval(1000); // reset
+}
+
+void tst_QAudioOutput::pullFile()
+{
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->setNotifyInterval(100);
+ audio->start(&filename);
+
+ QTestEventLoop::instance().enterLoop(1);
+ // 4.wav is a little less than 700ms, so notify should fire 6 times!
+ QVERIFY(readSignal.count() >= 6);
+ QVERIFY(audio->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+}
+
+void tst_QAudioOutput::pushFile()
+{
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ const qint64 fileSize = filename.size();
+
+ QIODevice* feed = audio->start(0);
+
+ char* buffer = new char[fileSize];
+ filename.read(buffer, fileSize);
+
+ qint64 counter=0;
+ qint64 written=0;
+ while(written < fileSize) {
+ written+=feed->write(buffer+written,fileSize-written);
+ QTest::qWait(20);
+ counter++;
+ }
+ QTestEventLoop::instance().enterLoop(1);
+
+ QVERIFY(written == fileSize);
+ QVERIFY(audio->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+ delete [] buffer;
+ delete audio;
+}
+
+QTEST_MAIN(tst_QAudioOutput)
+
+#include "tst_qaudiooutput.moc"
diff --git a/tests/auto/tests.xml b/tests/auto/tests.xml
index a5386b2..ccfc380 100644
--- a/tests/auto/tests.xml
+++ b/tests/auto/tests.xml
@@ -271,6 +271,10 @@
<Test name="qsocks5socketengine" location="tests/auto/qsocks5socketengine/tst_qsocks5socketengine" />
<Test name="qsortfilterproxymodel" location="tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel" />
<Test name="qsound" location="tests/auto/qsound/tst_qsound" />
+ <Test name="qaudiodeviceid" location="tests/auto/qaudiodeviceid/tst_qaudiodeviceid" />
+ <Test name="qaudioformat" location="tests/auto/qaudioformat/tst_qaudioformat" />
+ <Test name="qaudiooutput" location="tests/auto/qaudiooutput/tst_qaudiooutput" />
+ <Test name="qaudioinput" location="tests/auto/qaudioinput/tst_qaudioinput" />
<Test name="qsourcelocation" location="tests/auto/qsourcelocation/tst_qsourcelocation" />
<Test name="qspinbox" location="tests/auto/qspinbox/tst_qspinbox" />
<Test name="qsplitter" location="tests/auto/qsplitter/tst_qsplitter" />
@@ -676,6 +680,10 @@
<Test id="qsocks5socketengine" />
<Test id="qsortfilterproxymodel" />
<Test id="qsound" />
+ <Test id="qaudiodeviceid" />
+ <Test id="qaudioformat" />
+ <Test id="qaudiooutput" />
+ <Test id="qaudioinput" />
<Test id="qsourcelocation" />
<Test id="qspinbox" />
<Test id="qsplitter" />