summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-09-28 02:06:37 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-09-28 02:06:37 (GMT)
commit93e3962f3e9536d941314c02f623083f78190123 (patch)
tree31c09b3e95a81676d4c6e9b67c0f075275eb6e20 /tests
parent635beba2a236dd3028c4ae20e321b183009ae7a9 (diff)
parent2f132101fbc1b9f988e1cd3baf79408d54a69a14 (diff)
downloadQt-93e3962f3e9536d941314c02f623083f78190123.zip
Qt-93e3962f3e9536d941314c02f623083f78190123.tar.gz
Qt-93e3962f3e9536d941314c02f623083f78190123.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp34
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp34
2 files changed, 66 insertions, 2 deletions
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
index 7331072..69b507d 100644
--- a/tests/auto/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -56,6 +56,7 @@ public:
private slots:
void initTestCase();
void settings();
+ void buffers();
void notifyInterval();
void pullFile();
@@ -90,6 +91,7 @@ void tst_QAudioInput::initTestCase()
void tst_QAudioInput::settings()
{
if(available) {
+ // Confirm the setting we added in the init function.
QAudioFormat f = audio->format();
QVERIFY(format.channels() == f.channels());
@@ -101,6 +103,18 @@ void tst_QAudioInput::settings()
}
}
+void tst_QAudioInput::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_QAudioInput::notifyInterval()
{
if(available) {
@@ -120,14 +134,32 @@ void tst_QAudioInput::pullFile()
filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
QSignalSpy readSignal(audio, SIGNAL(notify()));
- audio->start(&filename);
+ QSignalSpy stateSignal(audio, SIGNAL(stateChanged(QAudio::State)));
+
+ // Always have default states, before start
+ QVERIFY(audio->state() == QAudio::StopState);
+ QVERIFY(audio->error() == QAudio::NoError);
+ audio->start(&filename);
+ QTest::qWait(20);
+ // Check state 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...
QTest::qWait(5000);
QVERIFY(readSignal.count() > 0);
QVERIFY(audio->totalTime() > 0);
audio->stop();
+ QTest::qWait(20);
+ 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);
+
filename.close();
}
}
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();
}
}