summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-11-18 10:37:01 -0800
committerThiago Macieira <thiago.macieira@intel.com>2023-02-13 18:11:21 -0800
commit4157fc80e498a0a534728f711d908af96b5a39ba (patch)
treea745f1d5e70887b8e0e4bd77d40b49b9354d5ccb /tests
parentdc6bc5d5bd44b7a96f8fc40ba4e124be5dcd75a7 (diff)
QBluetoothUuid: switch from quint128 to QUuid::Id128Bytes
This is now supported by the QUuid class directly instead of being an invention of QBluetoothUuid on top. Additionally, as a trivial structure of 16 bytes in size, it should be passed by value, not by const-ref. The BluezUint128 type is used where the 128 bits of data aren't a UUID (like the Connection Signature Resolving Key). Change-Id: Id8e48e8f498c4a029619fffd1728c1af9149a561 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp23
-rw-r--r--tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp8
2 files changed, 14 insertions, 17 deletions
diff --git a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
index 63a77a84..2dbb5be1 100644
--- a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
+++ b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
@@ -15,8 +15,6 @@
QT_USE_NAMESPACE
-Q_DECLARE_METATYPE(quint128)
-
class tst_QBluetoothUuid : public QObject
{
Q_OBJECT
@@ -39,7 +37,6 @@ private slots:
tst_QBluetoothUuid::tst_QBluetoothUuid()
{
- qRegisterMetaType<quint128>();
}
tst_QBluetoothUuid::~tst_QBluetoothUuid()
@@ -155,11 +152,11 @@ void tst_QBluetoothUuid::tst_conversion_data()
QTest::addColumn<bool>("constructUuid32");
QTest::addColumn<quint32>("uuid32");
QTest::addColumn<bool>("constructUuid128");
- QTest::addColumn<quint128>("uuid128");
+ QTest::addColumn<QUuid::Id128Bytes>("uuid128");
QTest::addColumn<QString>("uuidS");
static const auto uuid128_32 = [](quint8 a, quint8 b, quint8 c, quint8 d) {
- quint128 x = {
+ QUuid::Id128Bytes x = {
{
a, b, c, d,
0x00, 0x00,
@@ -201,7 +198,7 @@ void tst_QBluetoothUuid::tst_conversion_data()
newRow32("0xffffffff", 0xff, 0xff, 0xff, 0xff, "FFFFFFFF" BASEUUID);
{
- quint128 uuid128 = {
+ QUuid::Id128Bytes uuid128 = {
{
0x00, 0x11, 0x22, 0x33,
0x44, 0x55,
@@ -224,7 +221,7 @@ void tst_QBluetoothUuid::tst_conversion()
QFETCH(bool, constructUuid32);
QFETCH(quint32, uuid32);
QFETCH(bool, constructUuid128);
- QFETCH(quint128, uuid128);
+ QFETCH(QUuid::Id128Bytes, uuid128);
QFETCH(QString, uuidS);
int minimumSize = 16;
@@ -244,7 +241,7 @@ void tst_QBluetoothUuid::tst_conversion()
QCOMPARE(uuid.toUInt32(&ok), uuid32);
QVERIFY(ok);
- QVERIFY(memcmp(uuid.toUInt128().data, uuid128.data, 16) == 0);
+ QVERIFY(memcmp(uuid.toBytes().data, uuid128.data, 16) == 0);
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
@@ -265,7 +262,7 @@ void tst_QBluetoothUuid::tst_conversion()
QCOMPARE(uuid.toUInt32(&ok), uuid32);
QVERIFY(ok);
- QVERIFY(memcmp(uuid.toUInt128().data, uuid128.data, 16) == 0);
+ QVERIFY(memcmp(uuid.toBytes().data, uuid128.data, 16) == 0);
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
@@ -287,7 +284,7 @@ void tst_QBluetoothUuid::tst_conversion()
if (ok)
QCOMPARE(tmpUuid32, uuid32);
- QVERIFY(memcmp(uuid.toUInt128().data, uuid128.data, 16) == 0);
+ QVERIFY(memcmp(uuid.toBytes().data, uuid128.data, 16) == 0);
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
@@ -307,7 +304,7 @@ void tst_QBluetoothUuid::tst_comparison()
QFETCH(bool, constructUuid32);
QFETCH(quint32, uuid32);
QFETCH(bool, constructUuid128);
- QFETCH(quint128, uuid128);
+ QFETCH(QUuid::Id128Bytes, uuid128);
QVERIFY(QBluetoothUuid() == QBluetoothUuid());
@@ -340,7 +337,7 @@ void tst_QBluetoothUuid::tst_comparison()
QBluetoothUuid quuid128(uuid128);
for (int var = 0; var < 16; ++var) {
- QVERIFY(quuid128.toUInt128().data[var] == uuid128.data[var]);
+ QVERIFY(quuid128.toBytes().data[var] == uuid128.data[var]);
}
}
}
@@ -348,7 +345,7 @@ void tst_QBluetoothUuid::tst_comparison()
void tst_QBluetoothUuid::tst_quint128ToUuid()
{
QBluetoothUuid temp(QString("{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"));
- quint128 array = temp.toUInt128();
+ QUuid::Id128Bytes array = temp.toBytes();
QBluetoothUuid u(array);
QVERIFY(temp == u);
diff --git a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
index 973785b8..715b106c 100644
--- a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
+++ b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
@@ -53,7 +53,7 @@ private:
QScopedPointer<QLowEnergyController> m_leController;
#if defined(CHECK_CMAC_SUPPORT)
- bool checkCmacSupport(const quint128& csrkMsb);
+ bool checkCmacSupport(const QUuid::Id128Bytes& csrkMsb);
#endif
};
@@ -142,7 +142,7 @@ void TestQLowEnergyControllerGattServer::cmacVerifier()
{
#if defined(CONFIG_LINUX_CRYPTO_API) && defined(QT_BUILD_INTERNAL) && defined(CONFIG_BLUEZ_LE)
// Test data comes from spec v4.2, Vol 3, Part H, Appendix D.1
- const quint128 csrk = {
+ const QUuid::Id128Bytes csrk = {
{ 0x3c, 0x4f, 0xcf, 0x09, 0x88, 0x15, 0xf7, 0xab,
0xa6, 0xd2, 0xae, 0x28, 0x16, 0x15, 0x7e, 0x2b }
};
@@ -168,11 +168,11 @@ void TestQLowEnergyControllerGattServer::cmacVerifier()
#include <linux/if_alg.h>
#include <unistd.h>
-bool TestQLowEnergyControllerGattServer::checkCmacSupport(const quint128& csrk)
+bool TestQLowEnergyControllerGattServer::checkCmacSupport(const QUuid::Id128Bytes& csrk)
{
bool retval = false;
#if defined(CONFIG_LINUX_CRYPTO_API) && defined(QT_BUILD_INTERNAL) && defined(CONFIG_BLUEZ_LE)
- quint128 csrkMsb;
+ QUuid::Id128Bytes csrkMsb;
std::reverse_copy(std::begin(csrk.data), std::end(csrk.data), std::begin(csrkMsb.data));
int testSocket = socket(AF_ALG, SOCK_SEQPACKET, 0);