Add QNAM tests to wavedecoder as well, to simulate slow sources.
Change-Id: Ic65659bfdf72aea2cea5ae97de50a1e661db189b Reviewed-on: http://codereview.qt-project.org/6404 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: derick hawcroft <derick.hawcroft@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
0da05239d2
commit
01e1f91e64
@@ -3,7 +3,7 @@ HEADERS += ../../../src/multimedia/effects/qwavedecoder_p.h
|
||||
SOURCES += tst_qwavedecoder.cpp \
|
||||
../../../src/multimedia/effects/qwavedecoder_p.cpp
|
||||
|
||||
QT += multimedia-private testlib
|
||||
QT += multimedia-private testlib network
|
||||
CONFIG += no_private_qt_headers_warning testcase
|
||||
|
||||
data.files = data
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <private/qwavedecoder_p.h>
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#ifndef QTRY_COMPARE
|
||||
#define QTRY_COMPARE(__expr, __expected) \
|
||||
do { \
|
||||
@@ -85,6 +89,9 @@ private slots:
|
||||
void file_data();
|
||||
void file();
|
||||
|
||||
void http_data() {file_data();}
|
||||
void http();
|
||||
|
||||
void readAllAtOnce();
|
||||
void readPerByte();
|
||||
};
|
||||
@@ -198,6 +205,69 @@ void tst_QWaveDecoder::file()
|
||||
stream.close();
|
||||
}
|
||||
|
||||
void tst_QWaveDecoder::http()
|
||||
{
|
||||
QFETCH(QString, file);
|
||||
QFETCH(tst_QWaveDecoder::Corruption, corruption);
|
||||
QFETCH(int, channels);
|
||||
QFETCH(int, samplesize);
|
||||
QFETCH(int, samplerate);
|
||||
QFETCH(QAudioFormat::Endian, byteorder);
|
||||
|
||||
QFile stream;
|
||||
stream.setFileName(QString("data/") + file);
|
||||
stream.open(QIODevice::ReadOnly);
|
||||
|
||||
QVERIFY(stream.isOpen());
|
||||
|
||||
QNetworkAccessManager nam;
|
||||
|
||||
QNetworkReply *reply = nam.get(QNetworkRequest(QUrl::fromLocalFile(QString::fromLatin1("data/") + file)));
|
||||
|
||||
QWaveDecoder waveDecoder(reply);
|
||||
QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
|
||||
QSignalSpy parsingErrorSpy(&waveDecoder, SIGNAL(parsingError()));
|
||||
|
||||
if (corruption == NotAWav) {
|
||||
QSKIP("Not all failures detected correctly yet", SkipSingle);
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
} else if (corruption == NoSampleData) {
|
||||
QTRY_COMPARE(validFormatSpy.count(), 1);
|
||||
QCOMPARE(parsingErrorSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.audioFormat().isValid());
|
||||
QVERIFY(waveDecoder.size() == 0);
|
||||
QVERIFY(waveDecoder.duration() == 0);
|
||||
} else if (corruption == FormatDescriptor) {
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
} else if (corruption == FormatString) {
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
QVERIFY(!waveDecoder.audioFormat().isValid());
|
||||
} else if (corruption == DataDescriptor) {
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.size() == 0);
|
||||
} else if (corruption == None) {
|
||||
QTRY_COMPARE(validFormatSpy.count(), 1);
|
||||
QCOMPARE(parsingErrorSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.audioFormat().isValid());
|
||||
QVERIFY(waveDecoder.size() > 0);
|
||||
QVERIFY(waveDecoder.duration() == 250);
|
||||
QAudioFormat format = waveDecoder.audioFormat();
|
||||
QVERIFY(format.isValid());
|
||||
QVERIFY(format.channels() == channels);
|
||||
QVERIFY(format.sampleSize() == samplesize);
|
||||
QVERIFY(format.sampleRate() == samplerate);
|
||||
if (format.sampleSize() != 8) {
|
||||
QVERIFY(format.byteOrder() == byteorder);
|
||||
}
|
||||
}
|
||||
|
||||
delete reply;
|
||||
}
|
||||
|
||||
void tst_QWaveDecoder::readAllAtOnce()
|
||||
{
|
||||
QFile stream;
|
||||
|
||||
Reference in New Issue
Block a user