diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-03 15:16:27 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-04 14:22:13 +0100 |
commit | 1169df5311cf4f3c13d232ed2cba810725877e08 (patch) | |
tree | 61fba89a03456e0f9f1ced6b6edf441debbb6e3c /tests/auto | |
parent | 13ad39d1b1512ed352718050a58a35c7f6e85d0b (diff) |
Extend QLEController test to cover non-readable char updates
When characteristicWritten() and characteristicChanged() signal is emitted
for a non-readable characteristic, value() should not update.
Change-Id: I28e377e75397e2bf01df535bc8f4b55c3561cdff
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index 80c3e532..d589b61a 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -2091,6 +2091,9 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QSignalSpy charWrittenSpy(service, SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray))); + // by default the defvice enables the notificatioin bit already + // no need to enable it. If notifications fail to arrive the + // platform must check default enabled notifications. if (notification.value() != QByteArray::fromHex("0100")) { service->writeDescriptor(notification, QByteArray::fromHex("0100")); QTRY_VERIFY_WITH_TIMEOUT(!descWrittenSpy.isEmpty(), 3000); @@ -2126,6 +2129,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QCOMPARE(imageIdentityChar, first); foundOneImage = true; } else { + // we received a notification for imageBlockChar without explicitly + // enabling them. This is caused by the device's default settings. QCOMPARE(imageBlockChar, first); qWarning() << "Invalid image A ident info"; } @@ -2136,6 +2141,10 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QCOMPARE(imageIdentityChar, second); QVERIFY(val2 == QByteArray::fromHex("0") || val2 == val1); + // notifications on non-readable characteristics do not update cache + QVERIFY(imageIdentityChar.value().isEmpty()); + QVERIFY(imageBlockChar.value().isEmpty()); + charChangedSpy.clear(); charWrittenSpy.clear(); @@ -2152,6 +2161,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QCOMPARE(imageIdentityChar, first); foundOneImage = true; } else { + // we received a notification for imageBlockChar without explicitly + // enabling them. This is caused by the device's default settings. QCOMPARE(imageBlockChar, first); qWarning() << "Invalid image B ident info"; } @@ -2161,6 +2172,10 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() val2 = entry[1].toByteArray(); QCOMPARE(imageIdentityChar, second); + // notifications on non-readable characteristics do not update cache + QVERIFY(imageIdentityChar.value().isEmpty()); + QVERIFY(imageBlockChar.value().isEmpty()); + /* Bluez resends the last confirmed write value, other platforms * send the value received by the change notification value. */ @@ -2197,10 +2212,16 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QCOMPARE(first, imageIdentityChar); foundOneImage = true; } else { + // we received a notification for imageBlockChar without explicitly + // enabling them. This is caused by the device's default settings. QCOMPARE(imageBlockChar, first); qWarning() << "Image A not set?"; } + // notifications on non-readable characteristics do not update cache + QVERIFY(imageIdentityChar.value().isEmpty()); + QVERIFY(imageBlockChar.value().isEmpty()); + charChangedSpy.clear(); // Image B @@ -2226,10 +2247,17 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse() QCOMPARE(first, imageIdentityChar); foundOneImage = true; } else { + // we received a notification for imageBlockChar without explicitly + // enabling them. This is caused by the device's default settings. QCOMPARE(imageBlockChar, first); qWarning() << "Image B not set?"; } + // notifications on non-readable characteristics do not update cache + QVERIFY(imageIdentityChar.value().isEmpty()); + QVERIFY(imageBlockChar.value().isEmpty()); + + QVERIFY2(foundOneImage, "The SensorTag doesn't have a valid image? (2)"); delete service; |