summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-06-27 17:43:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-28 08:39:01 +0200
commit42e8371600155bcff620929d5bf4dff998f3324f (patch)
treea0b89ad51f07f50eca28903212049423bddc58c5 /tests
parent06533c66b54f2ac9a9911e093723b71e27bd677d (diff)
Fix broken QBluetoothLocalDevice::isValid() behavior
The Bluez and QNX backend always returned true. They should only return true if the local device is truly available or if the passed QBluetoothAddress is indeed one of the local bluetooth devices. The related unit test was extended to ensure common bahvior of invalid QBluetoothLocalDevice instance on all platforms. Task-number: QTBUG-32068 Change-Id: I40ab4db48dc82ba0d1c0bb5275e96a3ee812b01a Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alex <alexander.blasche@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro1
-rw-r--r--tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp33
2 files changed, 26 insertions, 8 deletions
diff --git a/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro b/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
index ec829afb..8f31fc14 100644
--- a/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
+++ b/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
@@ -4,5 +4,4 @@ CONFIG += testcase
QT = core concurrent bluetooth testlib
-CONFIG += insignificant_test # QTBUG-22017
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
index 3c97c16e..fbebc250 100644
--- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
+++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
@@ -213,15 +213,34 @@ void tst_QBluetoothLocalDevice::tst_name()
void tst_QBluetoothLocalDevice::tst_isValid()
{
QBluetoothLocalDevice localDevice;
- QVERIFY(localDevice.isValid());
+ QBluetoothAddress invalidAddress("FF:FF:FF:FF:FF:FF");
- /*
- //TODO the above should really be the following once QBluetoothLocalDevice has been fixed
- if (!QBluetoothLocalDevice::allDevices().count())
- QVERIFY(!localDevice.isValid());
- else
+ const QList<QBluetoothHostInfo> devices = QBluetoothLocalDevice::allDevices();
+ if (devices.count()) {
QVERIFY(localDevice.isValid());
- */
+ bool defaultFound = false;
+ for (int i = 0; i<devices.count(); i++) {
+ QVERIFY(devices.at(i).address() != invalidAddress);
+ if (devices.at(i).address() == localDevice.address() ) {
+ defaultFound = true;
+ } else {
+ QBluetoothLocalDevice otherDevice(devices.at(i).address());
+ QVERIFY(otherDevice.isValid());
+ }
+ }
+ QVERIFY(defaultFound);
+ } else {
+ QVERIFY(!localDevice.isValid());
+ }
+
+ //ensure common behavior of invalid local device
+ QBluetoothLocalDevice invalidLocalDevice(invalidAddress);
+ QVERIFY(!invalidLocalDevice.isValid());
+ QCOMPARE(invalidLocalDevice.address(), QBluetoothAddress());
+ QCOMPARE(invalidLocalDevice.name(), QString());
+ QCOMPARE(invalidLocalDevice.pairingStatus(QBluetoothAddress()), QBluetoothLocalDevice::Unpaired );
+ QCOMPARE(invalidLocalDevice.hostMode(), QBluetoothLocalDevice::HostPoweredOff);
+
}
void tst_QBluetoothLocalDevice::tst_allDevices()
{