summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/qaudiodecoderbackend.pro15
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/testdata/test.wavbin0 -> 88232 bytes
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp151
3 files changed, 166 insertions, 0 deletions
diff --git a/tests/auto/integration/qaudiodecoderbackend/qaudiodecoderbackend.pro b/tests/auto/integration/qaudiodecoderbackend/qaudiodecoderbackend.pro
new file mode 100644
index 000000000..7548b8983
--- /dev/null
+++ b/tests/auto/integration/qaudiodecoderbackend/qaudiodecoderbackend.pro
@@ -0,0 +1,15 @@
+TARGET = tst_qaudiodecoderbackend
+
+QT += multimedia multimedia-private testlib
+CONFIG += no_private_qt_headers_warning
+
+# This is more of a system test
+# CONFIG += testcase
+
+INCLUDEPATH += \
+ ../../../../src/multimedia/audio
+
+DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\"
+
+SOURCES += \
+ tst_qaudiodecoderbackend.cpp
diff --git a/tests/auto/integration/qaudiodecoderbackend/testdata/test.wav b/tests/auto/integration/qaudiodecoderbackend/testdata/test.wav
new file mode 100644
index 000000000..4dd022661
--- /dev/null
+++ b/tests/auto/integration/qaudiodecoderbackend/testdata/test.wav
Binary files differ
diff --git a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
new file mode 100644
index 000000000..cf4e89a7a
--- /dev/null
+++ b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part 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 <QDebug>
+#include "qaudiodecoder_p.h"
+
+#define TEST_FILE_NAME "testdata/test.wav"
+
+QT_USE_NAMESPACE
+
+/*
+ This is the backend conformance test.
+
+ Since it relies on platform media framework and sound hardware
+ it may be less stable.
+*/
+
+class tst_QAudioDecoderBackend : public QObject
+{
+ Q_OBJECT
+public slots:
+ void init();
+ void cleanup();
+ void initTestCase();
+
+private slots:
+ void decoderTest();
+};
+
+void tst_QAudioDecoderBackend::init()
+{
+}
+
+void tst_QAudioDecoderBackend::initTestCase()
+{
+}
+
+void tst_QAudioDecoderBackend::cleanup()
+{
+}
+
+void tst_QAudioDecoderBackend::decoderTest()
+{
+ QAudioDecoder d;
+ QVERIFY(d.state() == QAudioDecoder::StoppedState);
+ QVERIFY(d.bufferAvailable() == false);
+ QCOMPARE(d.sourceFilename(), QString(""));
+
+ // Test local file
+ QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME));
+ d.setSourceFilename(fileInfo.absoluteFilePath());
+ QVERIFY(d.state() == QAudioDecoder::StoppedState);
+ QVERIFY(!d.bufferAvailable());
+ QCOMPARE(d.sourceFilename(), fileInfo.absoluteFilePath());
+
+ QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
+ QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
+ QSignalSpy errorSpy(&d, SIGNAL(error(QAudioDecoder::Error)));
+ QSignalSpy stateSpy(&d, SIGNAL(stateChanged(QAudioDecoder::State)));
+
+ d.start();
+ QTRY_VERIFY(!stateSpy.isEmpty());
+ QTRY_VERIFY(!readySpy.isEmpty());
+ QTRY_VERIFY(!bufferChangedSpy.isEmpty());
+ QVERIFY(d.bufferAvailable());
+
+ bool ok;
+ QAudioBuffer buffer = d.read(&ok);
+ QVERIFY(ok);
+ QVERIFY(buffer.isValid());
+ QCOMPARE(buffer.format(), d.audioFormat());
+
+ QVERIFY(errorSpy.isEmpty());
+
+ d.stop();
+ QTRY_COMPARE(d.state(), QAudioDecoder::StoppedState);
+ QVERIFY(!d.bufferAvailable());
+ readySpy.clear();
+ bufferChangedSpy.clear();
+ stateSpy.clear();
+
+ // Test source device
+ QFile file(fileInfo.absoluteFilePath());
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ d.setSourceDevice(&file);
+
+ // change output audio format
+ QAudioFormat format;
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setFrequency(8000);
+ format.setCodec("audio/pcm");
+ format.setSampleType(QAudioFormat::SignedInt);
+ d.setAudioFormat(format);
+
+ d.start();
+ QTRY_VERIFY(!stateSpy.isEmpty());
+ QTRY_VERIFY(!readySpy.isEmpty());
+ QTRY_VERIFY(!bufferChangedSpy.isEmpty());
+ QVERIFY(d.bufferAvailable());
+
+ buffer = d.read(&ok);
+ QVERIFY(ok);
+ QVERIFY(buffer.isValid());
+ QCOMPARE(buffer.format(), d.audioFormat());
+
+ QVERIFY(errorSpy.isEmpty());
+}
+
+QTEST_MAIN(tst_QAudioDecoderBackend)
+
+#include "tst_qaudiodecoderbackend.moc"