summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaudioinput
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qaudioinput')
-rw-r--r--tests/auto/qaudioinput/qaudioinput.pro2
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp47
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro
index 5eb1613..922c3e4 100644
--- a/tests/auto/qaudioinput/qaudioinput.pro
+++ b/tests/auto/qaudioinput/qaudioinput.pro
@@ -5,7 +5,7 @@ SOURCES += tst_qaudioinput.cpp
QT = core multimedia
wince* {
- deploy.sources += 4.wav
+ deploy.files += 4.wav
DEPLOYMENT = deploy
DEFINES += SRCDIR=\\\"\\\"
QT += gui
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) {