summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-02-27 11:34:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-27 16:14:01 +0100
commit10e636b4e5a001ed2ffbb8e5c0a672904accc817 (patch)
tree85ba48f7fc554628dba493f74e803c8154776f7e /src
parentf45fd334face5532de827052c4dbb1749c709582 (diff)
Fix qbluetoothsocket unit test
Task-number: QTBUG-22017 Change-Id: I876b8a052873d198e8991b7eab3ca70714eb0dcc Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qbluetoothsocket_p.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothsocket_p.cpp b/src/bluetooth/qbluetoothsocket_p.cpp
index bacf7490..d64e7ecf 100644
--- a/src/bluetooth/qbluetoothsocket_p.cpp
+++ b/src/bluetooth/qbluetoothsocket_p.cpp
@@ -45,6 +45,10 @@
QT_BEGIN_NAMESPACE
QBluetoothSocketPrivate::QBluetoothSocketPrivate()
+ : socket(-1),
+ socketType(QBluetoothServiceInfo::UnknownProtocol),
+ state(QBluetoothSocket::UnconnectedState),
+ socketError(QBluetoothSocket::NoSocketError)
{
}
@@ -54,7 +58,7 @@ QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol type)
{
- Q_UNUSED(type);
+ socketType = type;
return false;
}
@@ -111,6 +115,14 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
{
Q_UNUSED(data);
Q_UNUSED(maxSize);
+
+ Q_Q(QBluetoothSocket);
+
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QBluetoothSocket::tr("Cannot write while not connected");
+ q->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
return 0;
}
@@ -118,6 +130,15 @@ qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize)
{
Q_UNUSED(data);
Q_UNUSED(maxSize);
+
+ Q_Q(QBluetoothSocket);
+
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QBluetoothSocket::tr("Cannot write while not connected");
+ q->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+
return 0;
}