summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-09-30 17:12:02 +0200
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-10-01 15:07:07 +0200
commit2917e641defac2302e8204bb0570a5150b9923d4 (patch)
treeb6d4b45cb38e560c41ed12d94558b15e4d1f5be6
parentf835812b24b47f1d5a6766fd227ca32559295129 (diff)
QtBluetooth - enable auto tests on OS X.
The first patch to enable tests - does not require any modifications in tests, just enabling the test. Add fix for publishedRecordWithDictioinary - this function is new in 10.9, deprecating withSDPRe..., but it crashed the test on 10.7 (and the same must happen on 10.8). Change-Id: I38e92cbc6f72fcaf8034824ef734148111139e0a Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/bluetooth/osx/osxbtutility_p.h5
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_osx.mm45
-rw-r--r--src/bluetooth/qbluetoothsocket_osx_p.h2
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro3
-rw-r--r--tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro5
-rw-r--r--tests/auto/qbluetoothsocket/qbluetoothsocket.pro1
6 files changed, 54 insertions, 7 deletions
diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/osx/osxbtutility_p.h
index 1a69e485..1c20c91a 100644
--- a/src/bluetooth/osx/osxbtutility_p.h
+++ b/src/bluetooth/osx/osxbtutility_p.h
@@ -154,6 +154,11 @@ public:
{
return m_ptr;
}
+
+ T *data() const
+ {
+ return m_ptr;
+ }
private:
T *m_ptr;
};
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm
index 59a631b0..2ab2c9f1 100644
--- a/src/bluetooth/qbluetoothserviceinfo_osx.mm
+++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm
@@ -57,6 +57,29 @@
QT_BEGIN_NAMESPACE
+namespace {
+
+// This is not in osxbtutility_p, since it's not required
+// in general and just fixes the problem with SDK < 10.9,
+// where we have to care about about IOBluetoothSDPServiceRecordRef.
+class ServiceRecordDeleter
+{
+public:
+ ServiceRecordDeleter(IOBluetoothSDPServiceRecordRef r)
+ : recordRef(r)
+ {
+ }
+ ~ServiceRecordDeleter()
+ {
+ if (recordRef) // Requires non-NULL pointers.
+ CFRelease(recordRef);
+ }
+
+ IOBluetoothSDPServiceRecordRef recordRef;
+};
+
+}
+
class QBluetoothServiceInfoPrivate
{
public:
@@ -119,8 +142,26 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
return false;
}
- SDPRecord newRecord([[IOBluetoothSDPServiceRecord
- publishedServiceRecordWithDictionary:serviceDict] retain]);
+ SDPRecord newRecord;
+
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_NA)
+ newRecord.reset([[IOBluetoothSDPServiceRecord
+ publishedServiceRecordWithDictionary:serviceDict] retain]);
+
+#else
+ IOBluetoothSDPServiceRecordRef recordRef = Q_NULLPTR;
+ // With ARC this will require a different cast?
+ const IOReturn status = IOBluetoothAddServiceDict((CFDictionaryRef)serviceDict.data(), &recordRef);
+ if (status != kIOReturnSuccess) {
+ qCWarning(QT_BT_OSX) << "QBluetoothServiceInfoPrivate::registerService(), "
+ "failed to create register a service record";
+ return false;
+ }
+
+ const ServiceRecordDeleter refGuard(recordRef);
+ newRecord.reset([[IOBluetoothSDPServiceRecord withSDPServiceRecordRef:recordRef] retain]);
+ // It's weird, but ... it's not possible to release a record ref yet!
+#endif
if (!newRecord) {
qCWarning(QT_BT_OSX) << "QBluetoothServiceInfoPrivate::registerService(), "
diff --git a/src/bluetooth/qbluetoothsocket_osx_p.h b/src/bluetooth/qbluetoothsocket_osx_p.h
index 2823c4f0..31389ec0 100644
--- a/src/bluetooth/qbluetoothsocket_osx_p.h
+++ b/src/bluetooth/qbluetoothsocket_osx_p.h
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
class QBluetoothServiceDiscoveryAgent;
class QBluetoothAddress;
-class QBluetoothSocketPrivate : public QObject, public OSXBluetooth::ChannelDelegate
+class QBluetoothSocketPrivate : public QBluetoothSocketPrivateBase, public OSXBluetooth::ChannelDelegate
{
friend class QBluetoothSocket;
friend class QBluetoothServer;
diff --git a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
index 680a5e6b..8d3d3669 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
+++ b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
@@ -3,9 +3,10 @@ TARGET = tst_qbluetoothservicediscoveryagent
CONFIG += testcase
QT = core concurrent bluetooth testlib
+osx:QT += widgets
+
blackberry {
LIBS += -lbtapi
}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-osx:CONFIG += insignificant_test
diff --git a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
index f0b4e5e8..0fa8f86d 100644
--- a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
+++ b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
@@ -3,7 +3,6 @@ TARGET = tst_qbluetoothserviceinfo
CONFIG += testcase
QT = core concurrent bluetooth testlib
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-osx:CONFIG += insignificant_test
+osx:QT += widgets
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
index 34f6e527..3c0f9e44 100644
--- a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
+++ b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
@@ -4,6 +4,7 @@ CONFIG += testcase
testcase.timeout = 250 # this test is slow
QT = core concurrent network bluetooth testlib
+osx:QT += widgets
OTHER_FILES += \
README.txt