diff options
author | Andre de la Rocha <andre.rocha@qt.io> | 2018-11-23 18:04:40 +0100 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2019-08-05 09:16:09 +0200 |
commit | 8b7b52d66f2616040ca4aaae3f2732be96e19ab8 (patch) | |
tree | bfc38942bd95718030a142540821f28911a611ef /tests/auto | |
parent | 5a2c8a39d76d634161e87b1c55d36cbbcc778289 (diff) |
Enable the use of the Win32 Bluetooth backend
This change enables the optional use of the Win32-based Bluetooth
backend on Windows. By default, the WinRT backend is used, if
supported by the platform. The use of the Win32 backend must be
selected by the -native-win32-bluetooth configuration option.
Task-number: QTBUG-40698
Change-Id: I6904bf077467d826e3ff5ad026ebae5f955f2e37
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto')
3 files changed, 61 insertions, 33 deletions
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp index ea1abef2..af7f0354 100644 --- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp +++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp @@ -110,6 +110,9 @@ void tst_QBluetoothLocalDevice::tst_powerOn() #ifdef Q_OS_OSX QSKIP("Not possible on OS X"); #endif +#ifdef Q_OS_WIN + QSKIP("Not possible on Windows"); +#endif QBluetoothLocalDevice localDevice; @@ -135,6 +138,9 @@ void tst_QBluetoothLocalDevice::tst_powerOff() #ifdef Q_OS_OSX QSKIP("Not possible on OS X"); #endif +#ifdef Q_OS_WIN + QSKIP("Not possible on Windows"); +#endif if (!QBluetoothLocalDevice::allDevices().count()) QSKIP("Skipping test due to missing Bluetooth device"); @@ -183,6 +189,9 @@ void tst_QBluetoothLocalDevice::tst_hostModes() #ifdef Q_OS_OSX QSKIP("Not possible on OS X"); #endif +#ifdef Q_OS_WIN + QSKIP("Not possible on Windows"); +#endif QFETCH(QBluetoothLocalDevice::HostMode, hostModeExpected); QFETCH(bool, expectSignal); @@ -340,6 +349,10 @@ void tst_QBluetoothLocalDevice::tst_pairDevice_data() void tst_QBluetoothLocalDevice::tst_pairDevice() { +#ifdef Q_OS_WIN + QSKIP("Programmatic pairing not supported on Windows"); +#endif + QFETCH(QBluetoothAddress, deviceAddress); QFETCH(QBluetoothLocalDevice::Pairing, pairingExpected); QFETCH(int, pairingWaitTime); diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp index ae8cf5d0..7833495d 100644 --- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp +++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp @@ -182,7 +182,7 @@ void tst_QBluetoothServiceInfo::tst_assignment_data() bool l2cpSupported = true; //some platforms don't support L2CP -#ifdef QT_ANDROID_BLUETOOTH +#if defined(QT_ANDROID_BLUETOOTH) || defined(Q_OS_WIN) l2cpSupported = false; #endif QTest::newRow("assignment_data_l2cp") diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp index 4e82aacd..5ebb0b1d 100644 --- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp +++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp @@ -140,13 +140,18 @@ void tst_QLowEnergyDescriptor::initTestCase() const QList<QLowEnergyCharacteristic> chars = leService->characteristics(); for (const QLowEnergyCharacteristic &ch : chars) { - if (!ch.descriptors().isEmpty()) { - globalService = leService; - globalControl = controller; - qWarning() << "Found service with descriptor" << remoteDeviceInfo.address() - << globalService->serviceName() << globalService->serviceUuid(); - break; + const QList<QLowEnergyDescriptor> descriptors = ch.descriptors(); + for (const QLowEnergyDescriptor &d : descriptors) { + if (!d.value().isEmpty()) { + globalService = leService; + globalControl = controller; + qWarning() << "Found service with descriptor" << remoteDeviceInfo.address() + << globalService->serviceName() << globalService->serviceUuid(); + break; + } } + if (globalControl) + break; } if (globalControl) @@ -238,11 +243,19 @@ void tst_QLowEnergyDescriptor::tst_assignCompare() QCOMPARE(target.uuid(), QBluetoothUuid()); QCOMPARE(target.value(), QByteArray()); + int index = -1; QList<QLowEnergyDescriptor> targets; const QList<QLowEnergyCharacteristic> chars = globalService->characteristics(); for (const QLowEnergyCharacteristic &ch : chars) { if (!ch.descriptors().isEmpty()) { targets = ch.descriptors(); + for (int i = 0; i < targets.size(); ++i) { + // try to get a descriptor we can read + if (targets[i].type() == QBluetoothUuid::CharacteristicUserDescription) { + index = i; + break; + } + } break; } } @@ -250,8 +263,10 @@ void tst_QLowEnergyDescriptor::tst_assignCompare() if (targets.isEmpty()) QSKIP("No descriptor found despite prior indication."); + QVERIFY(index != -1); + // test assignment operator - target = targets.first(); + target = targets[index]; QVERIFY(target.isValid()); QVERIFY(target.type() != QBluetoothUuid::UnknownDescriptorType); QVERIFY(!target.name().isEmpty()); @@ -259,26 +274,26 @@ void tst_QLowEnergyDescriptor::tst_assignCompare() QVERIFY(!target.uuid().isNull()); QVERIFY(!target.value().isEmpty()); - QVERIFY(target == targets.first()); - QVERIFY(targets.first() == target); - QVERIFY(!(target != targets.first())); - QVERIFY(!(targets.first() != target)); + QVERIFY(target == targets[index]); + QVERIFY(targets[index] == target); + QVERIFY(!(target != targets[index])); + QVERIFY(!(targets[index] != target)); - QCOMPARE(target.isValid(), targets.first().isValid()); - QCOMPARE(target.type(), targets.first().type()); - QCOMPARE(target.name(), targets.first().name()); - QCOMPARE(target.handle(), targets.first().handle()); - QCOMPARE(target.uuid(), targets.first().uuid()); - QCOMPARE(target.value(), targets.first().value()); + QCOMPARE(target.isValid(), targets[index].isValid()); + QCOMPARE(target.type(), targets[index].type()); + QCOMPARE(target.name(), targets[index].name()); + QCOMPARE(target.handle(), targets[index].handle()); + QCOMPARE(target.uuid(), targets[index].uuid()); + QCOMPARE(target.value(), targets[index].value()); // test copy constructor QLowEnergyDescriptor copyConstructed(target); - QCOMPARE(copyConstructed.isValid(), targets.first().isValid()); - QCOMPARE(copyConstructed.type(), targets.first().type()); - QCOMPARE(copyConstructed.name(), targets.first().name()); - QCOMPARE(copyConstructed.handle(), targets.first().handle()); - QCOMPARE(copyConstructed.uuid(), targets.first().uuid()); - QCOMPARE(copyConstructed.value(), targets.first().value()); + QCOMPARE(copyConstructed.isValid(), targets[index].isValid()); + QCOMPARE(copyConstructed.type(), targets[index].type()); + QCOMPARE(copyConstructed.name(), targets[index].name()); + QCOMPARE(copyConstructed.handle(), targets[index].handle()); + QCOMPARE(copyConstructed.uuid(), targets[index].uuid()); + QCOMPARE(copyConstructed.value(), targets[index].value()); QVERIFY(copyConstructed == target); QVERIFY(target == copyConstructed); @@ -300,18 +315,18 @@ void tst_QLowEnergyDescriptor::tst_assignCompare() QVERIFY(!(invalid != target)); QVERIFY(!(target != invalid)); - QVERIFY(!(targets.first() == target)); - QVERIFY(!(target == targets.first())); - QVERIFY(targets.first() != target); - QVERIFY(target != targets.first()); + QVERIFY(!(targets[index] == target)); + QVERIFY(!(target == targets[index])); + QVERIFY(targets[index] != target); + QVERIFY(target != targets[index]); if (targets.count() >= 2) { - QLowEnergyDescriptor second = targets[1]; + QLowEnergyDescriptor second = targets[(index+1)%2]; // at least two descriptors - QVERIFY(!(targets.first() == second)); - QVERIFY(!(second == targets.first())); - QVERIFY(targets.first() != second); - QVERIFY(second != targets.first()); + QVERIFY(!(targets[index] == second)); + QVERIFY(!(second == targets[index])); + QVERIFY(targets[index] != second); + QVERIFY(second != targets[index]); } } |