summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaudiooutput
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-09-28 01:17:45 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-09-28 01:17:45 (GMT)
commit2f132101fbc1b9f988e1cd3baf79408d54a69a14 (patch)
tree5e2864e46fbfabafea1533c68aff884bf8b9c91c /tests/auto/qaudiooutput
parent310b993657988220ce45dfd7dbab2ccac34c00e9 (diff)
downloadQt-2f132101fbc1b9f988e1cd3baf79408d54a69a14.zip
Qt-2f132101fbc1b9f988e1cd3baf79408d54a69a14.tar.gz
Qt-2f132101fbc1b9f988e1cd3baf79408d54a69a14.tar.bz2
Improved audio unit tests
Added more checking in each step of the playback or recording tests. Reviewed-by:Justin McPherson
Diffstat (limited to 'tests/auto/qaudiooutput')
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index b45a57e..f1c75dc 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -58,6 +58,7 @@ public:
private slots:
void initTestCase();
void settings();
+ void buffers();
void notifyInterval();
void pullFile();
void pushFile();
@@ -91,6 +92,7 @@ void tst_QAudioOutput::initTestCase()
void tst_QAudioOutput::settings()
{
if(available) {
+ // Confirm the setting we added in the init function.
QAudioFormat f = audio->format();
QVERIFY(format.channels() == f.channels());
@@ -102,6 +104,18 @@ void tst_QAudioOutput::settings()
}
}
+void tst_QAudioOutput::buffers()
+{
+ if(available) {
+ // Should always have a buffer size greater than zero.
+ int store = audio->bufferSize();
+ audio->setBufferSize(4096);
+ QVERIFY(audio->bufferSize() > 0);
+ audio->setBufferSize(store);
+ QVERIFY(audio->bufferSize() == store);
+ }
+}
+
void tst_QAudioOutput::notifyInterval()
{
if(available) {
@@ -122,15 +136,33 @@ void tst_QAudioOutput::pullFile()
file.open(QIODevice::ReadOnly);
QSignalSpy readSignal(audio, SIGNAL(notify()));
+ QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State)));
audio->setNotifyInterval(100);
- audio->start(&file);
+ // Always have default states, before start
+ QVERIFY(audio->state() == QAudio::StopState);
+ QVERIFY(audio->error() == QAudio::NoError);
+
+ audio->start(&file);
+ QTest::qWait(20); // wait 20ms
+ // Check state, bytesFree() and periodSize() are valid non-zero values.
+ QVERIFY(audio->state() == QAudio::ActiveState);
+ QVERIFY(audio->error() == QAudio::NoError);
+ QVERIFY(audio->periodSize() > 0);
+ QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
+
+ // Wait until finished...
QTestEventLoop::instance().enterLoop(1);
QCOMPARE(audio->totalTime(), qint64(692250));
// 4.wav is a little less than 700ms, so notify should fire 6 times!
QVERIFY(readSignal.count() >= 6);
audio->stop();
+ QTest::qWait(20); // wait 20ms
+ QVERIFY(audio->state() == QAudio::StopState);
+ // Can only check to make sure we got at least 1 more signal, but can be more.
+ QVERIFY(stateSignal.count() > 1);
+
file.close();
}
}