summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2022-01-25 09:40:53 +0200
committerJuha Vuolle <juha.vuolle@insta.fi>2022-01-27 14:38:14 +0200
commit30390a1285c631b766d98fc8dd79d9d9ec6a5eb0 (patch)
tree0937adb058af604369e6a9d16f0af2422f88fb1d /tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
parentf00ea686c841e14a89bd776ac3b86766a4980bb3 (diff)
Make Windows bluetooth to scan all found devices for services
The service scan is split in two phases. First we discover the available devices and then we scan each discovered device for their services. The problem was that the Windows bluetooth backend scanned only the device that was discovered the last and then stopped. This patch addresses this by making the scanning logic to follow that of the other backends (Bluez, macOS, and Android). The change required also some adjustments to the stop() logic where the Windows backend did not send the canceled() signal. The worker "cancel logic" is nonexistent and does not produce the signal. A related issue was that the stop() function is called both by the baseclass and the windows specialization itself for slightly differing purposes => needed to be split in two: releaseWorker() and stop(). Fixes: QTBUG-99687 Pick-to: 6.2 6.3 5.15 Change-Id: Ie9e25cf0261c5259125dd0f4c6305ef1a99051e7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp')
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index 646aadcf..3a58de2a 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:
@@ -139,6 +140,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