diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-12-20 12:31:36 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2022-01-12 09:06:26 +0000 |
commit | e10dd9d526565b294bddbf4af4aac015b94709ae (patch) | |
tree | 270fc40abd5e43837ec7ca41f798c2d3476834d5 /tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp | |
parent | ba38f64e22c98ba6b0d3bdccbd00ea5a643404f8 (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.
Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-98817
Change-Id: I91405beb68b6a716c553789b82f76275e897036f
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
Diffstat (limited to 'tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp')
-rw-r--r-- | tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 99f1642e..646aadcf 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -121,10 +121,8 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase() QSignalSpy errorSpy(&discoveryAgent, SIGNAL(errorOccurred(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); @@ -363,7 +360,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()); @@ -383,8 +380,6 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QSignalSpy errorSpy(&discoveryAgent, SIGNAL(errorOccurred(QBluetoothServiceDiscoveryAgent::Error))); QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo))); -// connect(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), -// this, SLOT(serviceDiscoveryDebug(QBluetoothServiceInfo))); connect(&discoveryAgent, SIGNAL(errorOccurred(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error))); @@ -397,7 +392,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; @@ -412,7 +407,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){ |