summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-08-13 22:59:56 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-08-13 22:59:56 (GMT)
commit5a3d956ae19ad411d13c7db28eb7705f4ffaad9d (patch)
tree8a5e5f2e8972efda09acb81709c9a2fd4f99dbd0 /tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
parent47603b9873071fa9463ce2bed01b4998ed340d7e (diff)
downloadQt-5a3d956ae19ad411d13c7db28eb7705f4ffaad9d.zip
Qt-5a3d956ae19ad411d13c7db28eb7705f4ffaad9d.tar.gz
Qt-5a3d956ae19ad411d13c7db28eb7705f4ffaad9d.tar.bz2
Fixed audio auto tests.
Handle platforms that don't have backends. Reviewed-by: Bill King
Diffstat (limited to 'tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp')
-rw-r--r--tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp60
1 files changed, 40 insertions, 20 deletions
diff --git a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
index 8f8d6a6..f87500c 100644
--- a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
+++ b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
@@ -56,41 +56,61 @@ public:
tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {}
private slots:
+ void initTestCase();
void checkNull();
void checkEquality();
+
+private:
+ bool available;
};
-void tst_QAudioDeviceId::checkNull()
+void tst_QAudioDeviceId::initTestCase()
{
- // Default constructed is null.
- QAudioDeviceId deviceId0;
- QVERIFY(deviceId0.isNull());
+ // Only perform tests if audio output device exists!
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ if(devices.size() > 0)
+ available = true;
+ else {
+ qWarning()<<"NOTE: no audio output device found, no test will be performed";
+ available = false;
+ }
+}
- // Null is transferred
- QAudioDeviceId deviceId1(deviceId0);
- QVERIFY(deviceId1.isNull());
+void tst_QAudioDeviceId::checkNull()
+{
+ if(available) {
+ // Default constructed is null.
+ QAudioDeviceId deviceId0;
+ QVERIFY(deviceId0.isNull());
+
+ // Null is transferred
+ QAudioDeviceId deviceId1(deviceId0);
+ QVERIFY(deviceId1.isNull());
+ }
}
void tst_QAudioDeviceId::checkEquality()
{
- QAudioDeviceId deviceId0;
- QAudioDeviceId deviceId1;
+ if(available) {
+ QAudioDeviceId deviceId0;
+ QAudioDeviceId deviceId1;
- // Null ids are equivalent
- QVERIFY(deviceId0 == deviceId1);
- QVERIFY(!(deviceId0 != deviceId1));
+ // Null ids are equivalent
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
- deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
+ deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
- // Different
- QVERIFY(deviceId0 != deviceId1);
- QVERIFY(!(deviceId0 == deviceId1));
+ // Different
+ QVERIFY(deviceId0 != deviceId1);
+ QVERIFY(!(deviceId0 == deviceId1));
- // Same
- deviceId0 = deviceId1;
+ // Same
+ deviceId0 = deviceId1;
- QVERIFY(deviceId0 == deviceId1);
- QVERIFY(!(deviceId0 != deviceId1));
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+ }
}
QTEST_MAIN(tst_QAudioDeviceId)