summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaudiooutput
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qaudiooutput')
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp47
1 files changed, 47 insertions, 0 deletions
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) {