diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp | 25 |
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; |