summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2023-03-27 10:15:18 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2023-04-03 10:59:34 +0200
commit55abcc47ee36e901b6f14d08d9a2ea0483b40dab (patch)
tree26da3974d92269d1e2b8059ee9cc0420f43574f3 /tests
parent913fb687a2f59003e81a42785b02450ffd3788cd (diff)
downloadqtconnectivity-55abcc47ee36e901b6f14d08d9a2ea0483b40dab.tar.gz
QBluetoothUuid - add platform-specific conversion functions
Namely: fromCBUUID and toCBUUID, similar to fromNSUUID and toNSUUID that we already have. [ChangeLog][QtBluetooth] Add CoreBluetooth-specific conversion to QBluetoothUuid class, to get CBUUID out of QBluetoothUuid and convert CBUUID to QBluetoothUuid. Fixes: QTBUG-112303 Change-Id: I4ca0b13395b4346f7c830a0e042a16f976998a33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothuuid/CMakeLists.txt1
-rw-r--r--tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp21
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qbluetoothuuid/CMakeLists.txt b/tests/auto/qbluetoothuuid/CMakeLists.txt
index 214323a3..f9414100 100644
--- a/tests/auto/qbluetoothuuid/CMakeLists.txt
+++ b/tests/auto/qbluetoothuuid/CMakeLists.txt
@@ -10,4 +10,5 @@ qt_internal_add_test(tst_qbluetoothuuid
tst_qbluetoothuuid.cpp
LIBRARIES
Qt::Bluetooth
+ Qt::CorePrivate
)
diff --git a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
index 1c58e60c..e31b0667 100644
--- a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
+++ b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
@@ -8,6 +8,10 @@
#include <qbluetoothuuid.h>
+#if defined(Q_OS_DARWIN)
+#include <QtCore/private/qcore_mac_p.h>
+#endif
+
#if defined(Q_OS_UNIX)
# include <arpa/inet.h>
# include <netinet/in.h>
@@ -229,6 +233,16 @@ void tst_QBluetoothUuid::tst_conversion()
else if (constructUuid32)
minimumSize = 4;
+#if defined(Q_OS_DARWIN)
+#define CHECK_PLATFORM_CONVERSION(qtUuid) \
+ const QMacAutoReleasePool pool; \
+ CBUUID *nativeUuid = qtUuid.toCBUUID(); \
+ QVERIFY(nativeUuid); \
+ QCOMPARE(qtUuid, QBluetoothUuid::fromCBUUID(nativeUuid));
+#else
+#define CHECK_PLATFORM_CONVERSION(qtUuid)
+#endif // Q_OS_DARWIN
+
if (constructUuid16) {
QBluetoothUuid uuid(uuid16);
@@ -245,6 +259,8 @@ void tst_QBluetoothUuid::tst_conversion()
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
QCOMPARE(uuid.minimumSize(), minimumSize);
+
+ CHECK_PLATFORM_CONVERSION(uuid)
}
if (constructUuid32) {
@@ -266,6 +282,8 @@ void tst_QBluetoothUuid::tst_conversion()
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
QCOMPARE(uuid.minimumSize(), minimumSize);
+
+ CHECK_PLATFORM_CONVERSION(uuid)
}
if (constructUuid128) {
@@ -288,7 +306,10 @@ void tst_QBluetoothUuid::tst_conversion()
QCOMPARE(uuid.toString().toUpper(), uuidS.toUpper());
QCOMPARE(uuid.minimumSize(), minimumSize);
+
+ CHECK_PLATFORM_CONVERSION(uuid)
}
+#undef CHECK_PLATFORM_CONVERSION
}
void tst_QBluetoothUuid::tst_comparison_data()