diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-12-20 12:31:36 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2022-03-21 13:57:04 +0100 |
commit | 438f9ca628e03461102cf757230ee735c0feb0d3 (patch) | |
tree | e32ebd64618c71609371d9393b322e746a42fd73 | |
parent | f2e3fcb6097e0119e63a0bab135957589aa227c5 (diff) |
tst_qbluetoothservicediscovery: make auto-test less evil
0 So far, it would appear, it's only ARM64 macs that are capable of running
this test at all so QSKIP on mac seems like an overkill. QSKIP deleted.
1. initTestCase: don't use full scan, since we never do in discovery agent
(we explicitly using ClassicScan internally), and since on macOS it would
now require Info.plist + explicit user interaction (clicking a button, to
allow the use of Bluetooth (LE)).
2. Make tst_serviceDiscovery less evil: the fact some devices found around
(like other mac test machines on CI??) - does not mean SDP scan either
success or failure with some error reported. It can be timeout without
any results. So no need in sitting 5 minutes for each device and then failing
in the end: reduce time-out, if it was time-out - bail out.
The test still tests at least some functionality that is testable.
Task-number: QTBUG-98817
Change-Id: I91405beb68b6a716c553789b82f76275e897036f
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
(cherry picked from commit e10dd9d526565b294bddbf4af4aac015b94709ae)
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 52a0c8bd..cd44d9d6 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -121,10 +121,8 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase() QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished())); QSignalSpy errorSpy(&discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error))); QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo))); - // connect(&discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), - // this, SLOT(deviceDiscoveryDebug(QBluetoothDeviceInfo))); - discoveryAgent.start(); + discoveryAgent.start(QBluetoothDeviceDiscoveryAgent::ClassicMethod); // Wait for up to MaxScanTime for the scan to finish int scanTime = MaxScanTime; @@ -132,7 +130,6 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase() QTest::qWait(1000); scanTime -= 1000; } - // qDebug() << "Scan time left:" << scanTime; // Expect finished signal with no error QVERIFY(finishedSpy.count() == 1); @@ -386,7 +383,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError); QBluetoothLocalDevice localDevice; - qDebug() << "Scanning address" << deviceInfo.address().toString(); + qDebug() << "Scanning address" << deviceInfo.address().toString() << deviceInfo.name(); QBluetoothServiceDiscoveryAgent discoveryAgent(localDevice.address()); bool setAddress = discoveryAgent.setRemoteAddress(deviceInfo.address()); @@ -405,10 +402,8 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished())); QSignalSpy errorSpy(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error))); QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo))); -// connect(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), -// this, SLOT(serviceDiscoveryDebug(QBluetoothServiceInfo))); - connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), - this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error))); + connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, + SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error))); discoveryAgent.start(QBluetoothServiceDiscoveryAgent::FullDiscovery); @@ -419,7 +414,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QVERIFY(discoveryAgent.isActive() || !finishedSpy.isEmpty()); // Wait for up to MaxScanTime for the scan to finish - int scanTime = MaxScanTime; + int scanTime = 20000; while (finishedSpy.count() == 0 && scanTime > 0) { QTest::qWait(1000); scanTime -= 1000; @@ -434,7 +429,9 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QVERIFY(discoveryAgent.errorString() == QString()); // Expect finished signal with no error - QVERIFY(finishedSpy.count() == 1); + if (scanTime) + QVERIFY(finishedSpy.count() == 1); + QVERIFY(errorSpy.isEmpty()); //if (discoveryAgent.discoveredServices().count() && expected_failures++ <2){ |