summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-10-16 16:14:04 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-10-16 16:14:50 +0200
commit41745e90de30c250e64c2b66c8d88f40550f651f (patch)
treeb9c5cd1fa8436930c8d9a543f4150f345573b826 /tests
parente417b7036e35744daa1978cd236798e3ee1693c0 (diff)
parent8b42497996549bccbbaabdf35756e1b8f2e6642b (diff)
Merge remote-tracking branch 'gerrit/5.4' into HEAD
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro4
-rw-r--r--tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp58
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp77
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp16
-rw-r--r--tests/nfctestserver/main.cpp54
-rw-r--r--tests/nfctestserver/nfctestserver.pro21
-rw-r--r--tests/nfctestserver/servercontroller.cpp151
-rw-r--r--tests/nfctestserver/servercontroller.h70
-rw-r--r--tests/nfctestserver/servicenames.h44
-rw-r--r--tests/nfctestserver/socketcontroller.cpp187
-rw-r--r--tests/nfctestserver/socketcontroller.h80
-rw-r--r--tests/tests.pro2
12 files changed, 129 insertions, 635 deletions
diff --git a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
index 0fa8f86d..e55bac3a 100644
--- a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
+++ b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
@@ -6,3 +6,7 @@ QT = core concurrent bluetooth testlib
osx:QT += widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+android:!android-no-sdk {
+ DEFINES += QT_ANDROID_BLUETOOTH
+}
diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
index cc51b007..61bad7c5 100644
--- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
+++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
@@ -41,6 +41,7 @@
#include <qbluetoothaddress.h>
#include <qbluetoothlocaldevice.h>
#include <qbluetoothuuid.h>
+#include <QtBluetooth/QBluetoothServer>
QT_USE_NAMESPACE
@@ -182,10 +183,20 @@ void tst_QBluetoothServiceInfo::tst_assignment_data()
QTest::addColumn<QUuid>("uuid");
QTest::addColumn<QBluetoothUuid::ProtocolUuid>("protocolUuid");
QTest::addColumn<QBluetoothServiceInfo::Protocol>("serviceInfoProtocol");
-
- QTest::newRow("assignment_data")
+ QTest::addColumn<bool>("protocolSupported");
+
+ bool l2cpSupported = true;
+ //some platforms don't support L2CP
+#ifdef QT_ANDROID_BLUETOOTH
+ l2cpSupported = false;
+#endif
+ QTest::newRow("assignment_data_l2cp")
+ << QUuid(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
+ << QBluetoothUuid::L2cap << QBluetoothServiceInfo::L2capProtocol << l2cpSupported;
+ QTest::newRow("assignment_data_rfcomm")
<< QUuid(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee)
- << QBluetoothUuid::L2cap << QBluetoothServiceInfo::L2capProtocol;
+ << QBluetoothUuid::Rfcomm << QBluetoothServiceInfo::RfcommProtocol << true;
+
}
void tst_QBluetoothServiceInfo::tst_assignment()
@@ -193,6 +204,7 @@ void tst_QBluetoothServiceInfo::tst_assignment()
QFETCH(QUuid, uuid);
QFETCH(QBluetoothUuid::ProtocolUuid, protocolUuid);
QFETCH(QBluetoothServiceInfo::Protocol, serviceInfoProtocol);
+ QFETCH(bool, protocolSupported);
const QString serviceName("My Service");
const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
@@ -294,20 +306,51 @@ void tst_QBluetoothServiceInfo::tst_assignment()
protocolDescriptorList.append(QVariant::fromValue(protocol));
copyInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
protocolDescriptorList);
- QVERIFY(copyInfo.serverChannel() == -1);
- QVERIFY(copyInfo.protocolServiceMultiplexer() != -1);
+ if (serviceInfoProtocol == QBluetoothServiceInfo::L2capProtocol) {
+ QVERIFY(copyInfo.serverChannel() == -1);
+ QVERIFY(copyInfo.protocolServiceMultiplexer() != -1);
+ } else if (serviceInfoProtocol == QBluetoothServiceInfo::RfcommProtocol) {
+ QVERIFY(copyInfo.serverChannel() != -1);
+ QVERIFY(copyInfo.protocolServiceMultiplexer() == -1);
+ }
+
QVERIFY(copyInfo.socketProtocol() == serviceInfoProtocol);
}
{
QBluetoothServiceInfo copyInfo;
+
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
+ copyInfo.setServiceUuid(QBluetoothUuid::SerialPort);
QVERIFY(!copyInfo.isRegistered());
if (!QBluetoothLocalDevice::allDevices().count()) {
QSKIP("Skipping test due to missing Bluetooth device");
- } else {
+ } else if (protocolSupported) {
+ QBluetoothServer server(serviceInfoProtocol);
+ QVERIFY(server.listen());
+ QTRY_VERIFY_WITH_TIMEOUT(server.isListening(), 5000);
+ QVERIFY(server.serverPort() > 0);
+
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
+
+ if (serviceInfoProtocol == QBluetoothServiceInfo::L2capProtocol) {
+ protocol << QVariant::fromValue(server.serverPort());
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ } else if (serviceInfoProtocol == QBluetoothServiceInfo::RfcommProtocol) {
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ protocol.clear();
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
+ << QVariant::fromValue(quint8(server.serverPort()));
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ }
+
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+
QVERIFY(copyInfo.registerService());
QVERIFY(copyInfo.isRegistered());
QVERIFY(serviceInfo.isRegistered());
@@ -319,6 +362,9 @@ void tst_QBluetoothServiceInfo::tst_assignment()
QVERIFY(!copyInfo.isRegistered());
QVERIFY(!secondCopy.isRegistered());
QVERIFY(!serviceInfo.isRegistered());
+ QVERIFY(server.isListening());
+ server.close();
+ QVERIFY(!server.isListening());
}
}
}
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 3a577db1..6290f075 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -213,24 +213,17 @@ void tst_QBluetoothSocket::tst_construction()
QCOMPARE(socket.atEnd(), true);
QCOMPARE(socket.pos(), 0);
QCOMPARE(socket.size(), 0);
-
- QSignalSpy spy(&socket, SIGNAL(error(QBluetoothSocket::SocketError)));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(socket.isOpen(), false);
+ QCOMPARE(socket.isReadable(), false);
+ QCOMPARE(socket.isWritable(), false);
+ QCOMPARE(socket.openMode(), QIODevice::NotOpen);
QByteArray array = socket.readAll();
QVERIFY(array.isEmpty());
- QCOMPARE(socket.error(), QBluetoothSocket::OperationError);
- QCOMPARE(spy.count(), 1);
char buffer[10];
int returnValue = socket.read((char*)&buffer, 10);
QCOMPARE(returnValue, -1);
- QCOMPARE(socket.error(), QBluetoothSocket::OperationError);
- QVERIFY(spy.count() >= 2);
- while (spy.count()) {
- QBluetoothSocket::SocketError er = spy.takeFirst().at(0).value<QBluetoothSocket::SocketError>();
- QVERIFY(er == QBluetoothSocket::OperationError);
- }
}
{
@@ -256,6 +249,11 @@ void tst_QBluetoothSocket::tst_serviceConnection()
QSignalSpy connectedSpy(&socket, SIGNAL(connected()));
QSignalSpy errorSpy(&socket, SIGNAL(error(QBluetoothSocket::SocketError)));
+ QCOMPARE(socket.openMode(), QIODevice::NotOpen);
+ QCOMPARE(socket.isWritable(), false);
+ QCOMPARE(socket.isReadable(), false);
+ QCOMPARE(socket.isOpen(), false);
+
socket.connectToService(remoteServiceInfo);
QCOMPARE(stateSpy.count(), 1);
@@ -279,6 +277,10 @@ void tst_QBluetoothSocket::tst_serviceConnection()
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::ConnectedState);
QCOMPARE(socket.state(), QBluetoothSocket::ConnectedState);
+ QCOMPARE(socket.isWritable(), true);
+ QCOMPARE(socket.isReadable(), true);
+ QCOMPARE(socket.isOpen(), true);
+
stateSpy.clear();
//check the peer & local info
@@ -290,7 +292,11 @@ void tst_QBluetoothSocket::tst_serviceConnection()
/* Disconnection */
QSignalSpy disconnectedSpy(&socket, SIGNAL(disconnected()));
- socket.disconnectFromService();
+ socket.abort(); // close() tested by other functions
+ QCOMPARE(socket.isWritable(), false);
+ QCOMPARE(socket.isReadable(), false);
+ QCOMPARE(socket.isOpen(), false);
+ QCOMPARE(socket.openMode(), QIODevice::NotOpen);
QVERIFY(stateSpy.count() >= 1);
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::ClosingState);
@@ -339,6 +345,10 @@ void tst_QBluetoothSocket::tst_clientCommunication()
/* Connection */
QSignalSpy connectedSpy(&socket, SIGNAL(connected()));
+ QCOMPARE(socket.isWritable(), false);
+ QCOMPARE(socket.isReadable(), false);
+ QCOMPARE(socket.isOpen(), false);
+ QCOMPARE(socket.openMode(), QIODevice::NotOpen);
socket.connectToService(remoteServiceInfo);
QCOMPARE(stateSpy.count(), 1);
@@ -353,6 +363,10 @@ void tst_QBluetoothSocket::tst_clientCommunication()
connectTime -= 1000;
}
+ QCOMPARE(socket.isWritable(), true);
+ QCOMPARE(socket.isReadable(), true);
+ QCOMPARE(socket.isOpen(), true);
+
QCOMPARE(connectedSpy.count(), 1);
QCOMPARE(stateSpy.count(), 1);
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::ConnectedState);
@@ -370,10 +384,14 @@ void tst_QBluetoothSocket::tst_clientCommunication()
QSignalSpy readyReadSpy(&socket, SIGNAL(readyRead()));
QSignalSpy bytesWrittenSpy(&socket, SIGNAL(bytesWritten(qint64)));
- socket.write(line.toUtf8());
+ qint64 dataWritten = socket.write(line.toUtf8());
+
+ if (socket.openMode() & QIODevice::Unbuffered)
+ QCOMPARE(socket.bytesToWrite(), qint64(0));
+ else
+ QCOMPARE(socket.bytesToWrite(), qint64(line.length()));
-// QEXPECT_FAIL("", "TODO: need to implement write buffering", Continue);
- QCOMPARE(socket.bytesToWrite(), qint64(line.length()));
+ QCOMPARE(dataWritten, qint64(line.length()));
int readWriteTime = MaxReadWriteTime;
while ((bytesWrittenSpy.count() == 0 || readyReadSpy.count() == 0) && readWriteTime > 0) {
@@ -392,7 +410,10 @@ void tst_QBluetoothSocket::tst_clientCommunication()
QCOMPARE(readyReadSpy.count(), 1);
- QCOMPARE(socket.bytesAvailable(), qint64(line.length()));
+ if (socket.openMode() & QIODevice::Unbuffered)
+ QVERIFY(socket.bytesAvailable() <= qint64(line.length()));
+ else
+ QCOMPARE(socket.bytesAvailable(), qint64(line.length()));
QVERIFY(socket.canReadLine());
@@ -402,16 +423,24 @@ void tst_QBluetoothSocket::tst_clientCommunication()
}
}
+ QCOMPARE(socket.isWritable(), true);
+ QCOMPARE(socket.isReadable(), true);
+ QCOMPARE(socket.isOpen(), true);
+
{
/* Send all at once */
QSignalSpy readyReadSpy(&socket, SIGNAL(readyRead()));
QSignalSpy bytesWrittenSpy(&socket, SIGNAL(bytesWritten(qint64)));
QString joined = data.join(QString());
- socket.write(joined.toUtf8());
+ qint64 dataWritten = socket.write(joined.toUtf8());
-// QEXPECT_FAIL("", "TODO: need to implement write buffering", Continue);
- QCOMPARE(socket.bytesToWrite(), qint64(joined.length()));
+ if (socket.openMode() & QIODevice::Unbuffered)
+ QCOMPARE(socket.bytesToWrite(), qint64(0));
+ else
+ QCOMPARE(socket.bytesToWrite(), qint64(joined.length()));
+
+ QCOMPARE(dataWritten, qint64(joined.length()));
int readWriteTime = MaxReadWriteTime;
while ((bytesWrittenSpy.count() == 0 || readyReadSpy.count() == 0) && readWriteTime > 0) {
@@ -423,7 +452,10 @@ void tst_QBluetoothSocket::tst_clientCommunication()
QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(joined.length()));
QVERIFY(readyReadSpy.count() > 0);
- QCOMPARE(socket.bytesAvailable(), qint64(joined.length()));
+ if (socket.openMode() & QIODevice::Unbuffered)
+ QVERIFY(socket.bytesAvailable() <= qint64(joined.length()));
+ else
+ QCOMPARE(socket.bytesAvailable(), qint64(joined.length()));
QVERIFY(socket.canReadLine());
@@ -437,6 +469,11 @@ void tst_QBluetoothSocket::tst_clientCommunication()
socket.disconnectFromService();
+ QCOMPARE(socket.isWritable(), false);
+ QCOMPARE(socket.isReadable(), false);
+ QCOMPARE(socket.isOpen(), false);
+ QCOMPARE(socket.openMode(), QIODevice::NotOpen);
+
int disconnectTime = MaxConnectTime;
while (disconnectedSpy.count() == 0 && disconnectTime > 0) {
QTest::qWait(1000);
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index b2c55da5..b39e6292 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -84,6 +84,8 @@ private slots:
void tst_sendBuffer_data();
void tst_sendBuffer();
+
+ void tst_sendNullPointer();
private:
QBluetoothAddress remoteAddress;
};
@@ -344,6 +346,20 @@ void tst_QBluetoothTransferManager::tst_sendBuffer()
QVERIFY(!reply->isRunning());
}
+void tst_QBluetoothTransferManager::tst_sendNullPointer()
+{
+ QBluetoothTransferRequest request(remoteAddress);
+ QBluetoothTransferManager manager;
+ QBluetoothTransferReply *reply = manager.put(request, 0);
+
+ QVERIFY(reply);
+ QCOMPARE(reply->isFinished(), true);
+ QCOMPARE(reply->isRunning(), false);
+ QCOMPARE(reply->manager(), &manager);
+ QCOMPARE(reply->request(), request);
+ QCOMPARE(reply->error(), QBluetoothTransferReply::FileNotFoundError);
+}
+
QTEST_MAIN(tst_QBluetoothTransferManager)
#include "tst_qbluetoothtransfermanager.moc"
diff --git a/tests/nfctestserver/main.cpp b/tests/nfctestserver/main.cpp
deleted file mode 100644
index 19c7eed8..00000000
--- a/tests/nfctestserver/main.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QCoreApplication>
-
-#include "socketcontroller.h"
-#include "servercontroller.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // Connection oriented sockets
- new ServerController(ServerController::StreamConnection, &app);
- new ServerController(ServerController::DatagramConnection, &app);
- new SocketController(SocketController::StreamConnection, &app);
- new SocketController(SocketController::DatagramConnection, &app);
-
- // Connectionless sockets
- new SocketController(SocketController::BoundSocket, &app);
- new SocketController(SocketController::ConnectionlessSocket, &app);
-
- return app.exec();
-}
diff --git a/tests/nfctestserver/nfctestserver.pro b/tests/nfctestserver/nfctestserver.pro
deleted file mode 100644
index 42dc5c62..00000000
--- a/tests/nfctestserver/nfctestserver.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-
-INCLUDEPATH += $$PWD/../../src/nfc
-
-TARGET = nfctestserver
-
-CONFIG += console strict_flags
-CONFIG -= app_bundle
-
-QT = core nfc
-
-TEMPLATE = app
-
-SOURCES += main.cpp \
- socketcontroller.cpp \
- servercontroller.cpp
-
-HEADERS += \
- socketcontroller.h \
- servercontroller.h \
- servicenames.h
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/nfctestserver/servercontroller.cpp b/tests/nfctestserver/servercontroller.cpp
deleted file mode 100644
index 32337b58..00000000
--- a/tests/nfctestserver/servercontroller.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "servercontroller.h"
-#include "servicenames.h"
-
-ServerController::ServerController(ConnectionType type, QObject *parent)
-: QObject(parent), m_server(new QLlcpServer(this)), m_socket(0), m_connectionType(type)
-{
- connect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
-
- switch (m_connectionType) {
- case StreamConnection:
- m_service = commandServer + streamSuffix;
- break;
- case DatagramConnection:
- m_service = commandServer + datagramSuffix;
- break;
- }
-
- m_server->listen(m_service);
-
- if (m_server->isListening())
- qDebug() << "Server listening on" << m_service;
-}
-
-ServerController::~ServerController()
-{
- delete m_socket;
- delete m_server;
-}
-
-void ServerController::newConnection()
-{
- m_socket = m_server->nextPendingConnection();
-
- qDebug() << "Server got new connection";
-
- connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
- connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
- connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
-}
-
-void ServerController::socketReadyRead()
-{
- switch (m_connectionType) {
- case StreamConnection:
- while (m_socket->canReadLine()) {
- const QByteArray line = m_socket->readLine().trimmed();
-
- qDebug() << "Server read line:" << line;
-
- QByteArray command;
- QByteArray parameter;
-
- int index = line.indexOf(' ');
- if (index >= 0) {
- command = line.left(index);
- parameter = line.mid(index + 1);
- } else {
- command = line;
- }
-
- if (command == "ECHO") {
- m_socket->write(parameter + '\n');
- } else if (command == "DISCONNECT") {
- m_socket->disconnectFromService();
- break;
- } else if (command == "CLOSE") {
- m_socket->close();
- break;
- } else if (command == "URI") {
- m_socket->write(m_service.toLatin1());
- m_socket->write("\n");
- }
- }
- break;
- case DatagramConnection:
- while (m_socket->hasPendingDatagrams()) {
- qint64 size = m_socket->pendingDatagramSize();
- QByteArray data;
- data.resize(size);
- m_socket->readDatagram(data.data(), data.size());
-
- QByteArray command;
- QByteArray parameter;
-
- int index = data.indexOf(' ');
- if (index >= 0) {
- command = data.left(index);
- parameter = data.mid(index + 1);
- } else {
- command = data;
- }
-
- if (command == "ECHO") {
- m_socket->writeDatagram(parameter);
- } else if (command == "DISCONNECT") {
- m_socket->disconnectFromService();
- break;
- } else if (command == "CLOSE") {
- m_socket->close();
- break;
- } else if (command == "URI") {
- m_socket->writeDatagram(m_service.toLatin1());
- }
- }
- break;
- }
-}
-
-void ServerController::socketBytesWritten(qint64 bytes)
-{
- Q_UNUSED(bytes);
-}
-
-void ServerController::socketDisconnected()
-{
- m_socket->deleteLater();
- m_socket = 0;
-}
diff --git a/tests/nfctestserver/servercontroller.h b/tests/nfctestserver/servercontroller.h
deleted file mode 100644
index 7f18dd47..00000000
--- a/tests/nfctestserver/servercontroller.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SERVERCONTROLLER_H
-#define SERVERCONTROLLER_H
-
-#include <QtCore/QObject>
-
-#include <qllcpserver_p.h>
-
-QT_USE_NAMESPACE
-
-class ServerController : public QObject
-{
- Q_OBJECT
-
-public:
- enum ConnectionType {
- StreamConnection,
- DatagramConnection
- };
-
- ServerController(ConnectionType type, QObject *parent = 0);
- ~ServerController();
-
-private slots:
- void newConnection();
-
- void socketReadyRead();
- void socketBytesWritten(qint64 bytes);
- void socketDisconnected();
-
-private:
- QLlcpServer *m_server;
- QLlcpSocket *m_socket;
- ConnectionType m_connectionType;
- QString m_service;
-};
-
-#endif // SERVERCONTROLLER_H
diff --git a/tests/nfctestserver/servicenames.h b/tests/nfctestserver/servicenames.h
deleted file mode 100644
index d8ad5088..00000000
--- a/tests/nfctestserver/servicenames.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SERVICENAMES_H
-#define SERVICENAMES_H
-
-static const QLatin1String commandServer("urn:nfc:sn:com.nokia.qt.commandserver");
-static const QLatin1String helloServer("urn:nfc:sn:com.nokia.qt.helloserver");
-static const QLatin1String streamSuffix(".stream");
-static const QLatin1String datagramSuffix(".datagram");
-
-static const quint8 boundSocketPort = 63;
-
-#endif // SERVICENAMES_H
diff --git a/tests/nfctestserver/socketcontroller.cpp b/tests/nfctestserver/socketcontroller.cpp
deleted file mode 100644
index 3b9567c2..00000000
--- a/tests/nfctestserver/socketcontroller.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "socketcontroller.h"
-#include "servicenames.h"
-
-SocketController::SocketController(ConnectionType type, QObject *parent)
-: QObject(parent), m_manager(0), m_socket(new QLlcpSocket(this)), m_connectionType(type),
- m_timerId(-1)
-{
- connect(m_socket, SIGNAL(connected()), this, SLOT(connected()));
- connect(m_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
- connect(m_socket, SIGNAL(error(QLlcpSocket::SocketError)),
- this, SLOT(error(QLlcpSocket::SocketError)));
- connect(m_socket, SIGNAL(stateChanged(QLlcpSocket::SocketState)),
- this, SLOT(stateChanged(QLlcpSocket::SocketState)));
- connect(m_socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
-
- switch (m_connectionType) {
- case StreamConnection:
- m_service = helloServer + streamSuffix;
- qDebug() << "Client connecting to" << m_service;
- m_socket->connectToService(0, m_service);
- break;
- case DatagramConnection:
- m_service = helloServer + datagramSuffix;
- qDebug() << "Client connecting to" << m_service;
- m_socket->connectToService(0, m_service);
- break;
- case BoundSocket:
- m_port = boundSocketPort;
- qDebug() << "Client binding to" << m_port;
- if (!m_socket->bind(m_port))
- qDebug() << "Failed to bind to port" << m_port;
- break;
- case ConnectionlessSocket:
- qDebug() << "Client binding to arbitrary port";
- if (!m_socket->bind(0)) {
- qDebug() << "Failed to bind to arbitrary port";
- } else {
- m_manager = new QNearFieldManager(this);
- connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
- this, SLOT(targetDetected(QNearFieldTarget*)));
- connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
- this, SLOT(targetLost(QNearFieldTarget*)));
- m_manager->startTargetDetection();
- }
- break;
- default:
- qFatal("Unknown connection type");
- }
-}
-
-SocketController::~SocketController()
-{
- delete m_socket;
-}
-
-void SocketController::connected()
-{
- qDebug() << "Client connected";
- const QString data = QStringLiteral("HELLO ") + m_service;
- switch (m_connectionType) {
- case StreamConnection:
- m_socket->write(data.toUtf8() + '\n');
- break;
- case DatagramConnection:
- m_socket->writeDatagram(data.toUtf8());
- break;
- default:
- ;
- }
-}
-
-void SocketController::disconnected()
-{
- qDebug() << "Client disconnected, reconnecting";
-
- m_socket->connectToService(0, m_service);
-}
-
-void SocketController::error(QLlcpSocket::SocketError socketError)
-{
- qDebug() << "Client got error:" << socketError;
-}
-
-void SocketController::stateChanged(QLlcpSocket::SocketState socketState)
-{
- qDebug() << "Client state changed to" << socketState;
-}
-
-void SocketController::readyRead()
-{
- switch (m_connectionType) {
- case StreamConnection:
- while (m_socket->canReadLine()) {
- const QByteArray line = m_socket->readLine().trimmed();
-
- qDebug() << "Client read line:" << line;
-
- if (line == "DISCONNECT") {
- m_socket->disconnectFromService();
- break;
- } else if (line == "CLOSE") {
- m_socket->close();
- break;
- }
- }
- break;
- case DatagramConnection:
- while (m_socket->hasPendingDatagrams()) {
- qint64 size = m_socket->pendingDatagramSize();
- QByteArray data;
- data.resize(size);
- m_socket->readDatagram(data.data(), data.size());
-
- if (data == "DISCONNECT") {
- m_socket->disconnectFromService();
- break;
- } else if (data == "CLOSE") {
- m_socket->close();
- break;
- }
- }
- case BoundSocket:
- case ConnectionlessSocket:
- while (m_socket->hasPendingDatagrams()) {
- qint64 size = m_socket->pendingDatagramSize();
- QByteArray data;
- data.resize(size);
- m_socket->readDatagram(data.data(), data.size());
-
- qDebug() << data;
- }
- }
-}
-
-void SocketController::targetDetected(QNearFieldTarget *target)
-{
- Q_UNUSED(target);
-
- m_timerId = startTimer(500);
-}
-
-void SocketController::targetLost(QNearFieldTarget *target)
-{
- Q_UNUSED(target);
-
- killTimer(m_timerId);
-}
-
-void SocketController::timerEvent(QTimerEvent *event)
-{
- Q_UNUSED(event);
-
- m_socket->writeDatagram("Test message", 12, 0, boundSocketPort);
-}
diff --git a/tests/nfctestserver/socketcontroller.h b/tests/nfctestserver/socketcontroller.h
deleted file mode 100644
index 02fc3e4f..00000000
--- a/tests/nfctestserver/socketcontroller.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtNfc module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SOCKETCONTROLLER_H
-#define SOCKETCONTROLLER_H
-
-#include <QtCore/QObject>
-
-#include <qnearfieldmanager.h>
-#include <qllcpsocket_p.h>
-
-QT_USE_NAMESPACE
-
-class SocketController : public QObject
-{
- Q_OBJECT
-
-public:
- enum ConnectionType {
- StreamConnection,
- DatagramConnection,
- BoundSocket,
- ConnectionlessSocket
- };
-
- SocketController(ConnectionType type, QObject *parent = 0);
- ~SocketController();
-
-public slots:
- void connected();
- void disconnected();
- void error(QLlcpSocket::SocketError socketError);
- void stateChanged(QLlcpSocket::SocketState socketState);
- void readyRead();
- void targetDetected(QNearFieldTarget *target);
- void targetLost(QNearFieldTarget *target);
-
-protected:
- void timerEvent(QTimerEvent *event);
-
-private:
- QNearFieldManager *m_manager;
- QLlcpSocket *m_socket;
- ConnectionType m_connectionType;
- QString m_service;
- quint8 m_port;
- int m_timerId;
-};
-
-#endif // SOCKETCONTROLLER_H
diff --git a/tests/tests.pro b/tests/tests.pro
index 96db8fd3..e96b928c 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -2,5 +2,3 @@ TEMPLATE = subdirs
SUBDIRS += auto
qtHaveModule(bluetooth):qtHaveModule(quick): SUBDIRS += bttestui
-
-qtHaveModule(nfc): SUBDIRS += nfctestserver