summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-12 15:54:16 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-14 08:46:31 +0100
commitd113b4c0e1b070b1644810083828e23a148e7a21 (patch)
tree422de4cf9c89ac66145fa4d746eca2e4f2e8cc5e /tests
parentc01298910e6af5de369ff85e27179cbfd1278b0b (diff)
Document and test concurrent write requests
BTLE communication is serialised. However the Qt API provides the ability to issue multiple write requests while the first is still pending. The backend must enqueue the requests for later on. This behavior was already indirectly tests by a unit test but this patch adds an explicit test section for it and documents the behavior. Change-Id: I089b52940820bf0ba9c3ec872a6f1d5d6bd78a0e Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 026264d8..a91f8096 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -1875,6 +1875,28 @@ void tst_QLowEnergyController::tst_writeDescriptor()
QVERIFY(notification == signalDesc);
descWrittenSpy.clear();
+ // test concurrent writeRequests
+ // they need to be queued up
+ service->writeDescriptor(notification,QByteArray::fromHex("0100"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0000"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0100"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0000"));
+ QTRY_VERIFY_WITH_TIMEOUT(descWrittenSpy.count() == 4, 10000);
+
+ QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
+ for (int i = 0; i < descWrittenSpy.count(); i++) {
+ firstSignalData = descWrittenSpy.at(i);
+ signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
+ signalValue = firstSignalData[1].toByteArray();
+ if (i & 0x1) // odd
+ QCOMPARE(signalValue, QByteArray::fromHex("0000"));
+ else // even
+ QCOMPARE(signalValue, QByteArray::fromHex("0100"));
+ QVERIFY(notification == signalDesc);
+
+ }
+ descWrittenSpy.clear();
+
// *******************************************
// write wrong value -> error response required
QSignalSpy errorSpy(service, SIGNAL(error(QLowEnergyService::ServiceError)));