Rename the parsing error signal to parsingError.
Refactor the error handling code a little. Change-Id: I717b3aaacb24660b3f26769f19ac718b73106473 Reviewed-on: http://codereview.qt-project.org/6401 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
8943111428
commit
0da05239d2
1
tests/auto/qwavedecoder/data/onebyte.wav
Normal file
1
tests/auto/qwavedecoder/data/onebyte.wav
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -48,7 +48,7 @@
|
||||
#define QTRY_COMPARE(__expr, __expected) \
|
||||
do { \
|
||||
const int __step = 50; \
|
||||
const int __timeout = 10000; \
|
||||
const int __timeout = 1000; \
|
||||
if (!(__expr)) { \
|
||||
QTest::qWait(0); \
|
||||
} \
|
||||
@@ -82,8 +82,8 @@ public slots:
|
||||
|
||||
private slots:
|
||||
|
||||
void integrity_data();
|
||||
void integrity();
|
||||
void file_data();
|
||||
void file();
|
||||
|
||||
void readAllAtOnce();
|
||||
void readPerByte();
|
||||
@@ -105,7 +105,7 @@ void tst_QWaveDecoder::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QWaveDecoder::integrity_data()
|
||||
void tst_QWaveDecoder::file_data()
|
||||
{
|
||||
QTest::addColumn<QString>("file");
|
||||
QTest::addColumn<tst_QWaveDecoder::Corruption>("corruption");
|
||||
@@ -115,6 +115,7 @@ void tst_QWaveDecoder::integrity_data()
|
||||
QTest::addColumn<QAudioFormat::Endian>("byteorder");
|
||||
|
||||
QTest::newRow("File is empty") << QString("empty.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
|
||||
QTest::newRow("File is one byte") << QString("onebyte.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
|
||||
QTest::newRow("File is not a wav(text)") << QString("notawav.wav") << tst_QWaveDecoder::NotAWav << -1 << -1 << -1 << QAudioFormat::LittleEndian;
|
||||
QTest::newRow("Wav file has no sample data") << QString("nosampledata.wav") << tst_QWaveDecoder::NoSampleData << -1 << -1 << -1 << QAudioFormat::LittleEndian;
|
||||
QTest::newRow("corrupt fmt chunk descriptor") << QString("corrupt_fmtdesc_1_16_8000.le.wav") << tst_QWaveDecoder::FormatDescriptor << -1 << -1 << -1 << QAudioFormat::LittleEndian;
|
||||
@@ -138,7 +139,7 @@ void tst_QWaveDecoder::integrity_data()
|
||||
QTest::newRow("File isawav_2_32_44100_be.wav") << QString("isawav_2_32_44100_be.wav") << tst_QWaveDecoder::FormatDescriptor << 2 << 32 << 44100 << QAudioFormat::BigEndian;
|
||||
}
|
||||
|
||||
void tst_QWaveDecoder::integrity()
|
||||
void tst_QWaveDecoder::file()
|
||||
{
|
||||
QFETCH(QString, file);
|
||||
QFETCH(tst_QWaveDecoder::Corruption, corruption);
|
||||
@@ -147,7 +148,6 @@ void tst_QWaveDecoder::integrity()
|
||||
QFETCH(int, samplerate);
|
||||
QFETCH(QAudioFormat::Endian, byteorder);
|
||||
|
||||
|
||||
QFile stream;
|
||||
stream.setFileName(QString("data/") + file);
|
||||
stream.open(QIODevice::ReadOnly);
|
||||
@@ -156,31 +156,32 @@ void tst_QWaveDecoder::integrity()
|
||||
|
||||
QWaveDecoder waveDecoder(&stream);
|
||||
QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
|
||||
QSignalSpy invalidFormatSpy(&waveDecoder, SIGNAL(invalidFormat()));
|
||||
QSignalSpy parsingErrorSpy(&waveDecoder, SIGNAL(parsingError()));
|
||||
|
||||
if (corruption == NotAWav) {
|
||||
QTRY_COMPARE(validFormatSpy.count(), 0);
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 0);
|
||||
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);
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 0);
|
||||
QCOMPARE(parsingErrorSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.audioFormat().isValid());
|
||||
QVERIFY(waveDecoder.size() == 0);
|
||||
QVERIFY(waveDecoder.duration() == 0);
|
||||
} else if (corruption == FormatDescriptor) {
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 1);
|
||||
QTRY_COMPARE(validFormatSpy.count(), 0);
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
} else if (corruption == FormatString) {
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 1);
|
||||
QTRY_COMPARE(validFormatSpy.count(), 0);
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
QVERIFY(!waveDecoder.audioFormat().isValid());
|
||||
} else if (corruption == DataDescriptor) {
|
||||
QTRY_COMPARE(validFormatSpy.count(), 0);
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 1);
|
||||
QTRY_COMPARE(parsingErrorSpy.count(), 1);
|
||||
QCOMPARE(validFormatSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.size() == 0);
|
||||
} else if (corruption == None) {
|
||||
QTRY_COMPARE(validFormatSpy.count(), 1);
|
||||
QTRY_COMPARE(invalidFormatSpy.count(), 0);
|
||||
QCOMPARE(parsingErrorSpy.count(), 0);
|
||||
QVERIFY(waveDecoder.audioFormat().isValid());
|
||||
QVERIFY(waveDecoder.size() > 0);
|
||||
QVERIFY(waveDecoder.duration() == 250);
|
||||
|
||||
Reference in New Issue
Block a user