summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlowenergycontroller
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-06-13 12:22:05 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-06-16 14:17:32 +0200
commit856fa57a431077febf11fea27d8c63091623126d (patch)
tree3805c1230dc632d6f00685fe8b702b744e383bee /tests/auto/qlowenergycontroller
parent9f973ffb423b9c6721162ede29e18b7950152a08 (diff)
Discover all Bluetooth services and their handles
Change-Id: I83d88412319c34cf6c8cf0c6e841458226c9d073 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'tests/auto/qlowenergycontroller')
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 35ffe1d6..2c26ffe8 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -764,11 +764,13 @@ void tst_QLowEnergyController::tst_connectNew()
QVERIFY(control.errorString().isEmpty());
QCOMPARE(disconnectedSpy.count(), 0);
QCOMPARE(connectedSpy.count(), 0);
+ QVERIFY(control.services().isEmpty());
bool wasError = false;
control.connectToDevice();
QTRY_IMPL(control.state() != QLowEnergyControllerNew::ConnectingState,
10000);
+
QCOMPARE(disconnectedSpy.count(), 0);
if (control.error() != QLowEnergyControllerNew::NoError) {
//error during connect
@@ -780,6 +782,7 @@ void tst_QLowEnergyController::tst_connectNew()
QCOMPARE(connectedSpy.count(), 0);
QVERIFY(control.errorString().isEmpty());
QCOMPARE(control.error(), QLowEnergyControllerNew::NoError);
+ QVERIFY(control.services().isEmpty());
QSKIP("Connection to LE device cannot be established. Skipping test.");
return;
} else {
@@ -789,9 +792,34 @@ void tst_QLowEnergyController::tst_connectNew()
QVERIFY(control.errorString().isEmpty());
}
+ QVERIFY(control.services().isEmpty());
+
+ QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
+ QSignalSpy serviceFoundSpy(&control, SIGNAL(serviceDiscovered(QBluetoothUuid)));
+ control.discoverServices();
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+
+ QCOMPARE(serviceFoundSpy.count(), foundServices.count());
+ QList<QBluetoothUuid> listing;
+ for (int i = 0; i < serviceFoundSpy.count(); i++) {
+ const QVariant v = serviceFoundSpy[i].at(0);
+ listing.append(v.value<QBluetoothUuid>());
+ }
+
+ foreach (const QLowEnergyServiceInfo &info, foundServices) {
+ QVERIFY2(listing.contains(info.serviceUuid()),
+ info.serviceUuid().toString().toLatin1());
+ }
+
+ foreach (const QBluetoothUuid &uuid, control.services())
+ QVERIFY2(listing.contains(uuid), uuid.toString().toLatin1());
+
+ // Finish off
control.disconnectFromDevice();
- QTRY_VERIFY_WITH_TIMEOUT(control.state() == QLowEnergyControllerNew::UnconnectedState,
- 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(
+ control.state() == QLowEnergyControllerNew::UnconnectedState,
+ 10000);
+
if (wasError)
QCOMPARE(disconnectedSpy.count(), 0);
else