diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-12-07 12:38:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-07 06:12:31 +0100 |
commit | 6ee0dbe006a2102be9b47677a88eb96ba1d447f1 (patch) | |
tree | d806be89bfb46c7d0b47aeeee94ab876cceaed4e /tests/auto/qbluetoothlocaldevice | |
parent | 327b2e5bb95815a8bd0a732e65b0b46711c0956a (diff) |
Improve QBluetoothLocalDevice autotest.
Use standard QTRY_VERIFY instead of custom version, and check that
signal spies are valid after construction.
Change-Id: Iedb5e107d77c18dad6db0fcf46d61f030b68d7d3
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/qbluetoothlocaldevice')
-rw-r--r-- | tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp index fe79a4ac..69853bd6 100644 --- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp +++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp @@ -49,11 +49,6 @@ QTBLUETOOTH_USE_NAMESPACE -#define WAIT_FOR_CONDITION(a,e) \ - for (int _i = 0; _i < 5000; _i += 1) { \ - if ((a) == (e)) break; \ - QTest::qWait(100);} - class tst_QBluetoothLocalDevice : public QObject { Q_OBJECT @@ -145,12 +140,12 @@ void tst_QBluetoothLocalDevice::tst_powerOn() QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); // there should be no changes yet + QVERIFY(hostModeSpy.isValid()); QVERIFY(hostModeSpy.isEmpty()); localDevice.powerOn(); // async, wait for it - WAIT_FOR_CONDITION(hostModeSpy.count(),1); - QVERIFY(hostModeSpy.count() > 0); + QTRY_VERIFY(hostModeSpy.count() > 0); QBluetoothLocalDevice::HostMode hostMode= localDevice.hostMode(); // we should not be powered off QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable @@ -170,12 +165,12 @@ void tst_QBluetoothLocalDevice::tst_powerOff() QBluetoothLocalDevice localDevice; QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); // there should be no changes yet + QVERIFY(hostModeSpy.isValid()); QVERIFY(hostModeSpy.isEmpty()); localDevice.setHostMode(QBluetoothLocalDevice::HostPoweredOff); // async, wait for it - WAIT_FOR_CONDITION(hostModeSpy.count(),1); - QVERIFY(hostModeSpy.count() > 0); + QTRY_VERIFY(hostModeSpy.count() > 0); // we should not be powered off QVERIFY(localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff); @@ -188,6 +183,7 @@ void tst_QBluetoothLocalDevice::tst_hostModes() QBluetoothLocalDevice localDevice; QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); // there should be no changes yet + QVERIFY(hostModeSpy.isValid()); QVERIFY(hostModeSpy.isEmpty()); QTest::qWait(1000); @@ -196,8 +192,7 @@ void tst_QBluetoothLocalDevice::tst_hostModes() // wait for the device to switch bluetooth mode. QTest::qWait(1000); if (hostModeExpected != localDevice.hostMode()) { - WAIT_FOR_CONDITION(hostModeSpy.count(),1); - QVERIFY(hostModeSpy.count() > 0); + QTRY_VERIFY(hostModeSpy.count() > 0); } // test the actual signal values. QList<QVariant> arguments = hostModeSpy.takeFirst(); @@ -252,12 +247,12 @@ void tst_QBluetoothLocalDevice::tst_pairDevice() QSignalSpy pairingSpy(&localDevice, SIGNAL(pairingFinished(const QBluetoothAddress &,QBluetoothLocalDevice::Pairing)) ); // there should be no signals yet + QVERIFY(pairingSpy.isValid()); QVERIFY(pairingSpy.isEmpty()); localDevice.requestPairing(deviceAddress, pairingExpected); // async, wait for it - WAIT_FOR_CONDITION(pairingSpy.count(),1); - QVERIFY(pairingSpy.count() > 0); + QTRY_VERIFY(pairingSpy.count() > 0); // test the actual signal values. QList<QVariant> arguments = pairingSpy.takeFirst(); |