summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/qbluetoothsocket_bluezdbus.cpp6
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp11
2 files changed, 14 insertions, 3 deletions
diff --git a/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
index 58510036..3e74a55c 100644
--- a/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
@@ -280,7 +280,7 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
qCWarning(QT_BT_BLUEZ) << "Cannot find appropriate serviceUuid"
<< "or SerialPort service class uuid";
errorString = QBluetoothSocket::tr("Missing serviceUuid or Serial Port service class uuid");
- q->setSocketError(QBluetoothSocket::SocketError::OperationError);
+ q->setSocketError(QBluetoothSocket::SocketError::UnsupportedProtocolError);
return;
}
@@ -299,7 +299,7 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
if (address.isNull()) {
qCWarning(QT_BT_BLUEZ) << "Invalid address to remote address passed.";
errorString = QBluetoothSocket::tr("Invalid Bluetooth address passed to connectToService()");
- q->setSocketError(QBluetoothSocket::SocketError::OperationError);
+ q->setSocketError(QBluetoothSocket::SocketError::UnsupportedProtocolError);
return;
}
@@ -307,7 +307,7 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
qCWarning(QT_BT_BLUEZ) << "Cannot find appropriate serviceUuid"
<< "or SerialPort service class uuid";
errorString = QBluetoothSocket::tr("Missing serviceUuid or Serial Port service class uuid");
- q->setSocketError(QBluetoothSocket::SocketError::OperationError);
+ q->setSocketError(QBluetoothSocket::SocketError::UnsupportedProtocolError);
return;
}
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 75dd814a..653dde4a 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -561,7 +561,18 @@ void tst_QBluetoothSocket::tst_unsupportedProtocolError()
socket.connectToService(QBluetoothAddress(), 1, QIODevice::ReadWrite);
QTRY_COMPARE_WITH_TIMEOUT(errorSpy.size(), 1, 1000);
QCOMPARE(errorSpy.size(), 1);
+#if QT_CONFIG(bluez)
+ // Bluez dbus socket does not support connecting to port and gives different error code
+ if (bluetoothdVersion() >= QVersionNumber(5, 42)) {
+ QCOMPARE(errorSpy.takeFirst().at(0).toInt(),
+ int(QBluetoothSocket::SocketError::ServiceNotFoundError));
+ } else {
+ QCOMPARE(errorSpy.takeFirst().at(0).toInt(),
+ int(QBluetoothSocket::SocketError::UnsupportedProtocolError));
+ }
+#else
QCOMPARE(errorSpy.takeFirst().at(0).toInt(), int(QBluetoothSocket::SocketError::UnsupportedProtocolError));
+#endif
QVERIFY(socket.errorString().size() != 0);
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::UnconnectedState);