summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-10 15:47:41 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-16 08:28:46 +0200
commitf399837b3a723af9add6d9ea2d2e988f64f76ae0 (patch)
tree2c2a17ff5c4cfd007af98c98c70a2bf8c5fe8984 /tests
parent8bf7e9986e359df46bb351dfb76e4140d9b04da7 (diff)
Add simpler API to retrieve descriptor/characteristic for certain uuid
This new API is mostly syntactic sugar and reduces the amount of code to be written by API users. Change-Id: I51ff1ea706ac97199646d211e39e79c8140ee74b Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp13
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp25
2 files changed, 19 insertions, 19 deletions
diff --git a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
index 27c32db9..c6c408b6 100644
--- a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
+++ b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
@@ -188,6 +188,12 @@ void tst_QLowEnergyCharacteristic::tst_constructionDefault()
QVERIFY(characteristic.handle() == 0);
QCOMPARE(characteristic.name(), QString());
QCOMPARE(characteristic.descriptors().count(), 0);
+ QCOMPARE(characteristic.descriptor(QBluetoothUuid()),
+ QLowEnergyDescriptor());
+ QCOMPARE(characteristic.descriptor(QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)),
+ QLowEnergyDescriptor());
+ QCOMPARE(characteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration),
+ QLowEnergyDescriptor());
QCOMPARE(characteristic.properties(), QLowEnergyCharacteristic::Unknown);
QLowEnergyCharacteristic copyConstructed(characteristic);
@@ -244,6 +250,10 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
const QList<QLowEnergyCharacteristic> chars = globalService->characteristics();
QVERIFY(!chars.isEmpty());
for (int i = 0; i < chars.count(); i++) {
+ const QLowEnergyCharacteristic specific =
+ globalService->characteristic(chars[i].uuid());
+ QVERIFY(specific.isValid());
+ QCOMPARE(specific, chars[i]);
if (chars[i].descriptors().count() > 0) {
indexWithDescriptor = i;
break;
@@ -290,6 +300,9 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
QCOMPARE(target.descriptors()[i].handle(), ref.handle());
QCOMPARE(target.descriptors()[i].uuid(), ref.uuid());
QCOMPARE(target.descriptors()[i].value(), ref.value());
+
+ const QLowEnergyDescriptor ref2 = chars[indexWithDescriptor].descriptor(ref.uuid());
+ QCOMPARE(ref, ref2);
}
// test copy constructor
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 1fa8b9bf..bb7bd720 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -1648,17 +1648,10 @@ void tst_QLowEnergyController::tst_writeDescriptor()
// http://processors.wiki.ti.com/index.php/SensorTag_User_Guide
// 1. Find temperature data characteristic
- const QList<QLowEnergyCharacteristic> chars = service->characteristics();
- QLowEnergyCharacteristic tempData, tempConfig;
- foreach (const QLowEnergyCharacteristic &c, chars) {
- if (c.uuid() ==
- QBluetoothUuid(QStringLiteral("f000aa01-0451-4000-b000-000000000000"))) {
- tempData = c;
- } else if (c.uuid() ==
- QBluetoothUuid(QStringLiteral("f000aa02-0451-4000-b000-000000000000"))) {
- tempConfig = c;
- }
- }
+ const QLowEnergyCharacteristic tempData = service->characteristic(
+ QBluetoothUuid(QStringLiteral("f000aa01-0451-4000-b000-000000000000")));
+ const QLowEnergyCharacteristic tempConfig = service->characteristic(
+ QBluetoothUuid(QStringLiteral("f000aa02-0451-4000-b000-000000000000")));
if (!tempData.isValid()) {
delete service;
@@ -1667,14 +1660,8 @@ void tst_QLowEnergyController::tst_writeDescriptor()
}
// 2. Find temperature data notification descriptor
- const QList<QLowEnergyDescriptor> descs = tempData.descriptors();
- QLowEnergyDescriptor notification;
- foreach (const QLowEnergyDescriptor &d, descs) {
- if (d.type() == QBluetoothUuid::ClientCharacteristicConfiguration) {
- notification = d;
- break;
- }
- }
+ const QLowEnergyDescriptor notification = tempData.descriptor(
+ QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
if (!notification.isValid()) {
delete service;