summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-16 03:00:30 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-16 03:00:30 +0100
commitcc615e02420769e61993e6183897087992a47d6c (patch)
treece00b8ad8318e9a36c4df69a769d8d07f07087d4 /tests/auto
parenta3ffef76acdd4ea4b81bde481948ed4b953289af (diff)
parent1b19d7981610c2a9587544da654b4ca783e1bf6b (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
index ae8cf5d0..10c4bd3b 100644
--- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
+++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
@@ -61,6 +61,8 @@ private slots:
void tst_assignment();
void tst_serviceClassUuids();
+
+ void tst_writeByteArray();
};
tst_QBluetoothServiceInfo::tst_QBluetoothServiceInfo()
@@ -385,6 +387,49 @@ void tst_QBluetoothServiceInfo::tst_serviceClassUuids()
QCOMPARE(svclids.at(1), QBluetoothUuid(QBluetoothUuid::SerialPort));
}
+static QByteArray debugOutput;
+
+void debugHandler(QtMsgType type, const QMessageLogContext &, const QString &msg)
+{
+ switch (type) {
+ case QtDebugMsg :
+ debugOutput = msg.toLocal8Bit();
+ break;
+ default:
+ break;
+ }
+}
+
+void tst_QBluetoothServiceInfo::tst_writeByteArray()
+{
+ // We cannot directly test the produced XML output for Bluez
+ // as there no public API to retrieve it and it would be Bluez specific.
+ // However we can check the debug output.
+ // It should contain a qbyteArray rather than a string. In the XML the QByteArray
+ // is converted to a text tag with hex encoding.
+
+ const QByteArray expected("\n (518)\tSequence\n (518)\t\tSequence\n (518)\t\t\tuchar 34\n (518)\t\t\tbytearray 05010906a101850105079508750119e029e7150025018102950175088103050795067508150026ff00190029ff8100050895057501190129059102950175039103c005010902a10185020901a1000509190129031500250175019503810275059501810105010930093109381581257f750895038106c0c0\n");
+
+ const QByteArray hidDescriptor =
+ QByteArray::fromHex("05010906a101850105079508750119e029e7150025018102950175088103050795067508150026FF00190029FF8100050895057501190129059102950175039103c005010902a10185020901a1000509190129031500250175019503810275059501810105010930093109381581257f750895038106c0c0");
+ const QBluetoothServiceInfo::Sequence hidDescriptorList({
+ QVariant::fromValue(quint8(0x22)), // Report type
+ QByteArray(hidDescriptor) // Descriptor array
+ });
+ const QBluetoothServiceInfo::Sequence hidDescriptorListSeq({
+ QVariant::fromValue(hidDescriptorList)
+ });
+ QBluetoothServiceInfo srvInfo;
+ srvInfo.setAttribute(0x0206, QVariant::fromValue(hidDescriptorListSeq));
+
+ const QVariant attribute = srvInfo.attribute(0x0206);
+ debugOutput.clear();
+ qInstallMessageHandler(debugHandler);
+ qDebug() << srvInfo;
+ qInstallMessageHandler(nullptr);
+ QCOMPARE(debugOutput, expected);
+}
+
QTEST_MAIN(tst_QBluetoothServiceInfo)
#include "tst_qbluetoothserviceinfo.moc"