summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-12 15:29:21 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-16 16:32:50 +0200
commite7d159eba8a84c75ecce9f6b4b097959ebf999b7 (patch)
tree2114a20fb16d82e05ff6f16d531cd96425a6af25 /tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
parent080c096cb00aa77345a711696b4cfb7515f07327 (diff)
Fix QBluetoothDeviceDiscovery unit test for Bluez 5
Change-Id: Icae08c1963512e38ba438bd905f5629fa2e40422 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp')
-rw-r--r--tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
index 2da1a8a9..0b3c1532 100644
--- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
@@ -250,13 +250,27 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
QVERIFY(discoveryAgent.errorString().isEmpty());
-
- // Starting case 4: start-stop-start-stop, expecting only 1 cancel signal
+ /*
+ Starting case 4: start-stop-start-stop:
+ We are testing that two subsequent stop() calls reduce total number
+ of cancel() signals to 1 if the true cancellation requires
+ asynchronous function calls (signal consolidation); otherwise we
+ expect 2x cancel() signal.
+
+ Examples are:
+ - Bluez4 (event loop needs to run for cancel)
+ - Bluez5 (no event loop required)
+ */
+
+ bool immediateSignal = false;
discoveryAgent.start();
QVERIFY(discoveryAgent.isActive());
QVERIFY(errorSpy.isEmpty());
// cancel current request.
discoveryAgent.stop();
+ //should only have triggered cancel() if stop didn't involve the event loop
+ if (cancelSpy.count() == 1) immediateSignal = true;
+
// start a new one
discoveryAgent.start();
// we should be active now
@@ -264,6 +278,8 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
QVERIFY(errorSpy.isEmpty());
// stop
discoveryAgent.stop();
+ if (immediateSignal)
+ QVERIFY(cancelSpy.count() == 2);
// Wait for up to MaxWaitForCancelTime for the cancel to finish
waitTime = MaxWaitForCancelTime;
@@ -271,12 +287,15 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
QTest::qWait(100);
waitTime-=100;
}
-
// we should not be active anymore
QVERIFY(!discoveryAgent.isActive());
QVERIFY(errorSpy.isEmpty());
// should only have 1 cancel
- QVERIFY(cancelSpy.count() == 1);
+
+ if (immediateSignal)
+ QVERIFY(cancelSpy.count() == 2);
+ else
+ QVERIFY(cancelSpy.count() == 1);
cancelSpy.clear();
// Starting case 5: start-stop-start: expecting finished signal & no cancel