summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-11-27 13:02:29 +0100
committerAndre de la Rocha <andre.rocha@qt.io>2019-11-29 02:56:52 +0100
commit37b528f082f9675583df9cf47f1f73c7b0d094c6 (patch)
treeeac530ada51a4d5522e5e252b23b79d24788ccb1
parentec9cd5ed7b2b5df0c2b08ffec59e8ed5d3ae1ac5 (diff)
Fix failing tst_qlowenergydescriptor
tst_qlowenergydescriptor::tst_assignCompare() could fail due to a dependency on a particular characteristic found in a BLE device used for development tests. It should work regardless of it. Fixes: QTBUG-79492 Change-Id: Ia0d640b547c1170523e7b9304c7de175da432886 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
index 5ebb0b1d..d121a545 100644
--- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
+++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
@@ -243,7 +243,8 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
QCOMPARE(target.uuid(), QBluetoothUuid());
QCOMPARE(target.value(), QByteArray());
- int index = -1;
+ int index = 0;
+ bool valueFound = false;
QList<QLowEnergyDescriptor> targets;
const QList<QLowEnergyCharacteristic> chars = globalService->characteristics();
for (const QLowEnergyCharacteristic &ch : chars) {
@@ -253,6 +254,7 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
// try to get a descriptor we can read
if (targets[i].type() == QBluetoothUuid::CharacteristicUserDescription) {
index = i;
+ valueFound = true;
break;
}
}
@@ -263,8 +265,6 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
if (targets.isEmpty())
QSKIP("No descriptor found despite prior indication.");
- QVERIFY(index != -1);
-
// test assignment operator
target = targets[index];
QVERIFY(target.isValid());
@@ -272,7 +272,7 @@ void tst_QLowEnergyDescriptor::tst_assignCompare()
QVERIFY(!target.name().isEmpty());
QVERIFY(target.handle() > 0);
QVERIFY(!target.uuid().isNull());
- QVERIFY(!target.value().isEmpty());
+ QVERIFY(!valueFound || !target.value().isEmpty());
QVERIFY(target == targets[index]);
QVERIFY(targets[index] == target);