summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-12-03 14:21:49 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2014-12-04 14:22:06 +0100
commit13ad39d1b1512ed352718050a58a35c7f6e85d0b (patch)
tree82788086a306bf4c0303fda0cd1f6035c9fe9d04 /tests
parent02e69e4ee1b45761bb7240afd5a6a897ff80f3f2 (diff)
Make QLEController unit test pass on Android
1.) Android needs some time in between disconnect/connect attempts. 2.) Adjust unit test to modified charWritten/charChanged signals 3.) Make tst pass on Android when using WriteWithoutResponse mode when writing characteristics. Android seems to ignore this property as the platform keeps sending characteristicWritten() signals. Change-Id: I9879af989471b32ff28acc64c9897da018910515 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.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 67ae1872..80c3e532 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -74,6 +74,7 @@ public:
private slots:
void initTestCase();
+ void init();
void cleanupTestCase();
void tst_emptyCtor();
void tst_connect();
@@ -159,6 +160,20 @@ void tst_QLowEnergyController::initTestCase()
foundServices << QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000"));
}
+/*
+ * Executed in between each test function call.
+ */
+void tst_QLowEnergyController::init()
+{
+#ifdef Q_OS_ANDROID
+ /*
+ * Add a delay to give Android stack time to catch up in between
+ * the multiple connect/disconnects within each test function.
+ */
+ QTest::qWait(2000);
+#endif
+}
+
void tst_QLowEnergyController::cleanupTestCase()
{
@@ -2119,7 +2134,7 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QLowEnergyCharacteristic second = entry[0].value<QLowEnergyCharacteristic>();
QByteArray val2 = entry[1].toByteArray();
QCOMPARE(imageIdentityChar, second);
- QCOMPARE(val2, QByteArray::fromHex("0"));
+ QVERIFY(val2 == QByteArray::fromHex("0") || val2 == val1);
charChangedSpy.clear();
charWrittenSpy.clear();
@@ -2145,7 +2160,12 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
second = entry[0].value<QLowEnergyCharacteristic>();
val2 = entry[1].toByteArray();
QCOMPARE(imageIdentityChar, second);
- QCOMPARE(val2, QByteArray::fromHex("1"));
+
+ /* Bluez resends the last confirmed write value, other platforms
+ * send the value received by the change notification value.
+ */
+ qDebug() << "Image B(1):" << val1.toHex() << val2.toHex();
+ QVERIFY(val2 == QByteArray::fromHex("1") || val2 == val1);
QVERIFY2(foundOneImage, "The SensorTag doesn't have a valid image? (1)");
@@ -2168,6 +2188,10 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
first = entry[0].value<QLowEnergyCharacteristic>();
val1 = entry[1].toByteArray();
+#ifdef Q_OS_ANDROID
+ QEXPECT_FAIL("", "Android sends write confirmation when using WriteWithoutResponse",
+ Continue);
+#endif
QVERIFY(charWrittenSpy.isEmpty());
if (val1.size() == 8) {
QCOMPARE(first, imageIdentityChar);
@@ -2193,6 +2217,10 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
first = entry[0].value<QLowEnergyCharacteristic>();
val1 = entry[1].toByteArray();
+#ifdef Q_OS_ANDROID
+ QEXPECT_FAIL("", "Android sends write confirmation when using WriteWithoutResponse",
+ Continue);
+#endif
QVERIFY(charWrittenSpy.isEmpty());
if (val1.size() == 8) {
QCOMPARE(first, imageIdentityChar);