diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-02-27 11:34:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-27 16:14:01 +0100 |
commit | 10e636b4e5a001ed2ffbb8e5c0a672904accc817 (patch) | |
tree | 85ba48f7fc554628dba493f74e803c8154776f7e /tests/bttestui/btlocaldevice.cpp | |
parent | f45fd334face5532de827052c4dbb1749c709582 (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 'tests/bttestui/btlocaldevice.cpp')
-rw-r--r-- | tests/bttestui/btlocaldevice.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index b73a2a73..22a89275 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -413,6 +413,7 @@ void BtLocalDevice::dumpSocketInformation() << socket->peerName() << socket->peerPort(); qDebug() << "socket type:" << socket->socketType(); qDebug() << "socket state:" << socket->state(); + qDebug() << "socket bytesAvailable()" << socket->bytesAvailable(); QString tmp; switch (socket->error()) { case QBluetoothSocket::NoSocketError: tmp += "NoSocketError"; break; @@ -583,9 +584,18 @@ void BtLocalDevice::clientSocketReadyRead() return; while (socket->canReadLine()) { - QByteArray line = socket->readLine().trimmed(); + const QByteArray line = socket->readLine().trimmed(); + QString lineString = QString::fromUtf8(line.constData(), line.length()); qDebug() << ">>(" << socket->peerName() << ")>>" - << QString::fromUtf8(line.constData(), line.length()); + << lineString; + + //when using the tst_QBluetoothSocket we echo received text back + //Any line starting with "Echo:" will be echoed + if (lineString.startsWith(QStringLiteral("Echo:"))) { + qDebug() << "Assuming tst_qbluetoothsocket as client. Echoing back."; + lineString += QLatin1Char('\n'); + socket->write(lineString.toUtf8()); + } } } @@ -616,6 +626,7 @@ void BtLocalDevice::dumpServerInformation() qDebug() << "##" << client->peerAddress().toString() << client->peerName() << client->peerPort(); qDebug() << client->socketType() << client->state(); + qDebug() << "Pending bytes: " << client->bytesAvailable(); QString tmp; switch (client->error()) { case QBluetoothSocket::NoSocketError: tmp += "NoSocketError"; break; |