diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qaudioinput/tst_qaudioinput.cpp | 47 | ||||
-rw-r--r-- | tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 47 |
2 files changed, 94 insertions, 0 deletions
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 84c3874..1808b1d 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -50,6 +50,8 @@ #define SRCDIR "" #endif +Q_DECLARE_METATYPE(QAudioFormat) + class tst_QAudioInput : public QObject { Q_OBJECT @@ -58,6 +60,8 @@ public: private slots: void initTestCase(); + void invalidFormat_data(); + void invalidFormat(); void settings(); void buffers(); void notifyInterval(); @@ -71,6 +75,8 @@ private: void tst_QAudioInput::initTestCase() { + qRegisterMetaType<QAudioFormat>(); + format.setFrequency(8000); format.setChannels(1); format.setSampleSize(8); @@ -91,6 +97,47 @@ void tst_QAudioInput::initTestCase() audio = new QAudioInput(format, this); } +void tst_QAudioInput::invalidFormat_data() +{ + QTest::addColumn<QAudioFormat>("invalidFormat"); + + QAudioFormat audioFormat; + + QTest::newRow("Null Format") + << audioFormat; + + audioFormat = format; + audioFormat.setChannels(0); + QTest::newRow("Channel count 0") + << audioFormat; + + audioFormat = format; + audioFormat.setFrequency(0); + QTest::newRow("Sample rate 0") + << audioFormat; + + audioFormat = format; + audioFormat.setSampleSize(0); + QTest::newRow("Sample size 0") + << audioFormat; +} + +void tst_QAudioInput::invalidFormat() +{ + QFETCH(QAudioFormat, invalidFormat); + + QAudioInput audioInput(invalidFormat, this); + + // Check that we are in the default state before calling start + QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()"); + QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()"); + + audioInput.start(); + + // Check that error is raised + QVERIFY2((audioInput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()"); +} + void tst_QAudioInput::settings() { if(available) { diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index 437ef5e..e6d11a6 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -52,6 +52,8 @@ #define SRCDIR "" #endif +Q_DECLARE_METATYPE(QAudioFormat) + class tst_QAudioOutput : public QObject { Q_OBJECT @@ -60,6 +62,8 @@ public: private slots: void initTestCase(); + void invalidFormat_data(); + void invalidFormat(); void settings(); void buffers(); void notifyInterval(); @@ -74,6 +78,8 @@ private: void tst_QAudioOutput::initTestCase() { + qRegisterMetaType<QAudioFormat>(); + format.setFrequency(8000); format.setChannels(1); format.setSampleSize(8); @@ -92,6 +98,47 @@ void tst_QAudioOutput::initTestCase() audio = new QAudioOutput(format, this); } +void tst_QAudioOutput::invalidFormat_data() +{ + QTest::addColumn<QAudioFormat>("invalidFormat"); + + QAudioFormat audioFormat; + + QTest::newRow("Null Format") + << audioFormat; + + audioFormat = format; + audioFormat.setChannels(0); + QTest::newRow("Channel count 0") + << audioFormat; + + audioFormat = format; + audioFormat.setFrequency(0); + QTest::newRow("Sample rate 0") + << audioFormat; + + audioFormat = format; + audioFormat.setSampleSize(0); + QTest::newRow("Sample size 0") + << audioFormat; +} + +void tst_QAudioOutput::invalidFormat() +{ + QFETCH(QAudioFormat, invalidFormat); + + QAudioOutput audioOutput(invalidFormat, this); + + // Check that we are in the default state before calling start + QVERIFY2((audioOutput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()"); + QVERIFY2((audioOutput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()"); + + audioOutput.start(); + + // Check that error is raised + QVERIFY2((audioOutput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()"); +} + void tst_QAudioOutput::settings() { if(available) { |