diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:57:01 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:57:01 +0200 |
commit | 3dcb548bd6fe4aa488ca0bac95e65a7a366c3eca (patch) | |
tree | d8e263e0341880d970832326c7c7cecfd05e67cd /tests/auto | |
parent | e957d4810b05d8453e163d7bcdcab42d3c60a7bb (diff) | |
parent | 2b3b5c899ebdb0fc11273af7370804f5f03ad9e8 (diff) | |
download | qtconnectivity-3dcb548bd6fe4aa488ca0bac95e65a7a366c3eca.tar.gz |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl5.15
Change-Id: I6f5b5789b64c033f10223c2147ce7a312d868230
Diffstat (limited to 'tests/auto')
11 files changed, 92 insertions, 4 deletions
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro index 900bb5e9..e221ba74 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro +++ b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro @@ -2,5 +2,7 @@ SOURCES += tst_qbluetoothdevicediscoveryagent.cpp TARGET=tst_qbluetoothdevicediscoveryagent CONFIG += testcase +macos: QMAKE_INFO_PLIST = ../shared/Info.macos.plist + QT = core concurrent bluetooth-private testlib osx:QT += widgets diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp index cbce5042..f403f4ea 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp +++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp @@ -597,7 +597,9 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryMethods() const QBluetoothDeviceInfo info = qvariant_cast<QBluetoothDeviceInfo>(discoveredSpy.takeFirst().at(0)); QVERIFY(info.isValid()); - QVERIFY(info.coreConfigurations() & expectedConfiguration); + // on Android we do find devices with unknown configuration + if (info.coreConfigurations() != QBluetoothDeviceInfo::UnknownCoreConfiguration) + QVERIFY(info.coreConfigurations() & expectedConfiguration); } } diff --git a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro index 7d4eba6f..4fd115bf 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro +++ b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro @@ -2,6 +2,8 @@ SOURCES += tst_qbluetoothservicediscoveryagent.cpp TARGET = tst_qbluetoothservicediscoveryagent CONFIG += testcase +macos: QMAKE_INFO_PLIST = ../shared/Info.macos.plist + QT = core concurrent bluetooth testlib osx:QT += widgets diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 94a065bc..52a0c8bd 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -64,6 +64,7 @@ private slots: void tst_invalidBtAddress(); void tst_serviceDiscovery_data(); void tst_serviceDiscovery(); + void tst_serviceDiscoveryStop(); void tst_serviceDiscoveryAdapters(); private: @@ -141,6 +142,28 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase() } } +void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryStop() +{ + if (!localDeviceAvailable) + QSKIP("This test requires Bluetooth adapter in powered ON state"); + + QBluetoothServiceDiscoveryAgent discoveryAgent; + QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished())); + QSignalSpy canceledSpy(&discoveryAgent, SIGNAL(canceled())); + + // Verify we get the correct signals on start-stop + discoveryAgent.start(QBluetoothServiceDiscoveryAgent::FullDiscovery); + QVERIFY(discoveryAgent.isActive()); + discoveryAgent.stop(); + QTRY_COMPARE(canceledSpy.count(), 1); + QVERIFY(!discoveryAgent.isActive()); + // Wait a bit to see that there are no latent signals + QTest::qWait(200); + QCOMPARE(canceledSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 0); +} + + void tst_QBluetoothServiceDiscoveryAgent::tst_invalidBtAddress() { #ifdef Q_OS_OSX diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp index f89802d2..895529c7 100644 --- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp +++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp @@ -38,6 +38,8 @@ #include <qbluetoothuuid.h> #include <QtBluetooth/QBluetoothServer> +#include <QtCore/qoperatingsystemversion.h> + QT_USE_NAMESPACE Q_DECLARE_METATYPE(QBluetoothUuid::ProtocolUuid) @@ -187,6 +189,11 @@ void tst_QBluetoothServiceInfo::tst_assignment_data() #if defined(QT_ANDROID_BLUETOOTH) || defined(Q_OS_WIN) l2cpSupported = false; #endif + +#if defined(Q_OS_MACOS) + l2cpSupported = QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSBigSur; +#endif + QTest::newRow("assignment_data_l2cp") << QUuid(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee) << QBluetoothUuid::L2cap << QBluetoothServiceInfo::L2capProtocol << l2cpSupported; @@ -348,6 +355,19 @@ void tst_QBluetoothServiceInfo::tst_assignment() serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList); +#if defined(Q_OS_MACOS) + // bluetoothd on Monterey does not want to register a record if there is no + // ServiceClassIDList provided. + if (QOperatingSystemVersion::current() > QOperatingSystemVersion::MacOSBigSur) { + // Nothing seems to help with L2CAP though: + if (serviceInfoProtocol == QBluetoothServiceInfo::RfcommProtocol) { + QBluetoothServiceInfo::Sequence classIds; + classIds << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort)); + copyInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classIds); + } + } +#endif // Q_OS_MACOS + QVERIFY(copyInfo.registerService()); QVERIFY(copyInfo.isRegistered()); QVERIFY(serviceInfo.isRegistered()); diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp index 05bc1a0f..9e0dfc54 100644 --- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp +++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp @@ -35,6 +35,9 @@ #include <qbluetoothserviceinfo.h> #include <qbluetoothservicediscoveryagent.h> #include <qbluetoothlocaldevice.h> +#if QT_CONFIG(bluez) +#include <QtBluetooth/private/bluez5_helper_p.h> +#endif QT_USE_NAMESPACE @@ -142,7 +145,7 @@ void tst_QBluetoothSocket::initTestCase() qDebug() << "Starting discovery"; sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID))); - sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery); + sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000) QTest::qWait(1000); @@ -506,7 +509,12 @@ void tst_QBluetoothSocket::tst_preferredSecurityFlags() #if defined(QT_ANDROID_BLUETOOTH) | defined(QT_OSX_BLUETOOTH) QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Secure); #elif QT_CONFIG(bluez) - QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Authorization); + // The bluezdbus socket uses "NoSecurity" by default, whereas the non-dbus bluez + // socket uses "Authorization" by default + if (bluetoothdVersion() >= QVersionNumber(5, 42)) + QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Security::NoSecurity); + else + QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Security::Authorization); #else QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::NoSecurity); #endif diff --git a/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro index 24106573..98562724 100644 --- a/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro +++ b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro @@ -2,6 +2,8 @@ SOURCES += tst_qlowenergycharacteristic.cpp TARGET = tst_qlowenergycharacteristic CONFIG += testcase +macos: QMAKE_INFO_PLIST = ../shared/Info.macos.plist + QT = core bluetooth testlib diff --git a/tests/auto/qlowenergycontroller/qlowenergycontroller.pro b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro index 7a67e8e4..a3d67ec9 100644 --- a/tests/auto/qlowenergycontroller/qlowenergycontroller.pro +++ b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro @@ -8,6 +8,8 @@ CONFIG += testcase SOURCES += tst_qlowenergycontroller.cpp +macos: QMAKE_INFO_PLIST = ../shared/Info.macos.plist + osx|ios { QT += widgets } diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index bc74c693..08590a31 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -176,7 +176,8 @@ void tst_QLowEnergyController::initTestCase() } } - QVERIFY2(deviceFound, "Cannot find remote device."); + if (!deviceFound) + qWarning() << "Unable to find the TI sensor tag device, will skip most of the test"; // These are the services exported by the TI SensorTag #ifndef Q_OS_MAC diff --git a/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro index 81ec9566..00ebe5c2 100644 --- a/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro +++ b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro @@ -2,5 +2,7 @@ SOURCES += tst_qlowenergydescriptor.cpp TARGET = tst_qlowenergydescriptor CONFIG += testcase +macos: QMAKE_INFO_PLIST = ../shared/Info.macos.plist + QT = core bluetooth testlib diff --git a/tests/auto/shared/Info.macos.plist b/tests/auto/shared/Info.macos.plist new file mode 100644 index 00000000..e447b77c --- /dev/null +++ b/tests/auto/shared/Info.macos.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>${PRODUCT_BUNDLE_IDENTIFIER}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>LSMinimumSystemVersion</key> + <string>${MACOSX_DEPLOYMENT_TARGET}</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSBluetoothAlwaysUsageDescription</key> + <string>Qt BT test wants to access your Bluetooth adapter</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> |