diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-06-29 20:24:40 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-06-30 16:26:08 +0200 |
commit | c55e385f1f70f11d3ffd0f8372ccb8e7405018c5 (patch) | |
tree | a04c2e84b43830ecf9c8817f830055bfcf64cc0d | |
parent | a3e0fe474c20eb526af9668c5cc97cf7055c77fa (diff) | |
parent | 086f3722777ee61f3c019ca064d4a844cf0f6fe4 (diff) | |
download | qtwebsockets-c55e385f1f70f11d3ffd0f8372ccb8e7405018c5.tar.gz |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
.qmake.conf
src/websockets/qwebsocket_p.cpp
Change-Id: Ibcc1898263cc8bc80066370f045df6a217e46574
42 files changed, 584 insertions, 36 deletions
@@ -56,4 +56,3 @@ include tests/auto/cmake/build lib/ mkspecs/ -qml/ diff --git a/dist/changes-5.5.0 b/dist/changes-5.5.0 new file mode 100644 index 0000000..b32634b --- /dev/null +++ b/dist/changes-5.5.0 @@ -0,0 +1,49 @@ +Qt 5.5 introduces many new features and improvements as well as bugfixes +over the 5.4.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.5 series is binary compatible with the 5.4.x series. +Applications compiled for 5.4 will continue to run with 5.5. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* QML * +**************************************************************************** + + - The import statement has changed from "import Qt.WebSockets 1.0" to + "import QtWebSockets 1.0". The old statement is still supported, but it + cannot be mixed with the new statement within the same project. + +**************************************************************************** +* QtWebSockets * +**************************************************************************** + + - QWebSocket: + * [QTBUG-41285] Fixed QWebSocket's handling of query parameters with + encoded characters + * [QTBUG-42298] Added masking of ping from client side based on RFC 6455, + Section 5.1. + * [QTBUG-44893] Fixed spurious error signals on first connection + * [QTBUG-44889] Fixed handling of url paths with encoded characters + * [QTBUG-46055] Corrected the default port of secure hand shake request + + - QWebSocketServer: + * [QTBUG-44866] Avoid hanging after an invalid SSL request + * [QTBUG-45331] Fixed a crash when destroying the QWebSocketServer + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +WinRT +----- + - [QTBUG-44491] Fixed the build for WinRT/ARM diff --git a/examples/websockets/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml b/examples/websockets/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml index 6d2749c..35d64e0 100644 --- a/examples/websockets/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml +++ b/examples/websockets/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml @@ -31,7 +31,7 @@ ** ****************************************************************************/ import QtQuick 2.0 -import Qt.WebSockets 1.0 +import QtWebSockets 1.0 Rectangle { width: 360 diff --git a/examples/websockets/qmlwebsocketserver/qml/qmlwebsocketserver/main.qml b/examples/websockets/qmlwebsocketserver/qml/qmlwebsocketserver/main.qml index 6c3433f..c0178ba 100644 --- a/examples/websockets/qmlwebsocketserver/qml/qmlwebsocketserver/main.qml +++ b/examples/websockets/qmlwebsocketserver/qml/qmlwebsocketserver/main.qml @@ -32,7 +32,7 @@ ****************************************************************************/ import QtQuick 2.0 -import Qt.WebSockets 1.0 +import QtWebSockets 1.0 Rectangle { width: 360 diff --git a/src/imports/qmlwebsockets/plugins.qmltypes b/src/imports/qmlwebsockets/plugins.qmltypes index 5b8d1f9..5df4b5c 100644 --- a/src/imports/qmlwebsockets/plugins.qmltypes +++ b/src/imports/qmlwebsockets/plugins.qmltypes @@ -1,4 +1,4 @@ -import QtQuick.tooling 1.1 +import QtQuick.tooling 1.2 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. @@ -7,6 +7,7 @@ import QtQuick.tooling 1.1 // 'qmlplugindump -notrelocatable QtWebSockets 1.0' Module { + dependencies: [] Component { name: "QQmlWebSocket" prototype: "QObject" @@ -51,7 +52,7 @@ Module { Component { name: "QQmlWebSocketServer" prototype: "QObject" - exports: ["Qt.WebSockets/WebSocketServer 1.0"] + exports: ["QtWebSockets/WebSocketServer 1.0"] exportMetaObjectRevisions: [0] Property { name: "url"; type: "QUrl"; isReadonly: true } Property { name: "host"; type: "string" } diff --git a/src/imports/qmlwebsockets_compat/plugins.qmltypes b/src/imports/qmlwebsockets_compat/plugins.qmltypes new file mode 100644 index 0000000..ff8d976 --- /dev/null +++ b/src/imports/qmlwebsockets_compat/plugins.qmltypes @@ -0,0 +1,97 @@ +import QtQuick.tooling 1.2 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -notrelocatable Qt.WebSockets 1.0' + +Module { + dependencies: [] + Component { + name: "QQmlWebSocket" + prototype: "QObject" + exports: ["Qt.WebSockets/WebSocket 1.0"] + exportMetaObjectRevisions: [0] + Enum { + name: "Status" + values: { + "Connecting": 0, + "Open": 1, + "Closing": 2, + "Closed": 3, + "Error": 4 + } + } + Property { name: "url"; type: "QUrl" } + Property { name: "status"; type: "Status"; isReadonly: true } + Property { name: "errorString"; type: "string"; isReadonly: true } + Property { name: "active"; type: "bool" } + Signal { + name: "textMessageReceived" + Parameter { name: "message"; type: "string" } + } + Signal { + name: "statusChanged" + Parameter { name: "status"; type: "Status" } + } + Signal { + name: "activeChanged" + Parameter { name: "isActive"; type: "bool" } + } + Signal { + name: "errorStringChanged" + Parameter { name: "errorString"; type: "string" } + } + Method { + name: "sendTextMessage" + type: "qlonglong" + Parameter { name: "message"; type: "string" } + } + } + Component { + name: "QQmlWebSocketServer" + prototype: "QObject" + exports: ["Qt.WebSockets/WebSocketServer 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "url"; type: "QUrl"; isReadonly: true } + Property { name: "host"; type: "string" } + Property { name: "port"; type: "ushort" } + Property { name: "name"; type: "string" } + Property { name: "errorString"; type: "string"; isReadonly: true } + Property { name: "listen"; type: "bool" } + Property { name: "accept"; type: "bool" } + Signal { + name: "clientConnected" + Parameter { name: "webSocket"; type: "QQmlWebSocket"; isPointer: true } + } + Signal { + name: "errorStringChanged" + Parameter { name: "errorString"; type: "string" } + } + Signal { + name: "urlChanged" + Parameter { name: "url"; type: "QUrl" } + } + Signal { + name: "portChanged" + Parameter { name: "port"; type: "ushort" } + } + Signal { + name: "nameChanged" + Parameter { name: "name"; type: "string" } + } + Signal { + name: "hostChanged" + Parameter { name: "host"; type: "string" } + } + Signal { + name: "listenChanged" + Parameter { name: "listen"; type: "bool" } + } + Signal { + name: "acceptChanged" + Parameter { name: "accept"; type: "bool" } + } + } +} diff --git a/src/imports/qmlwebsockets_compat/qmldir b/src/imports/qmlwebsockets_compat/qmldir index 8541103..a4310d9 100644 --- a/src/imports/qmlwebsockets_compat/qmldir +++ b/src/imports/qmlwebsockets_compat/qmldir @@ -1,4 +1,4 @@ module Qt.WebSockets -plugin ../../QtWebSockets/declarative_qmlwebsockets +plugin declarative_qmlwebsockets ../../QtWebSockets/ classname QtWebSocketsDeclarativeModule -typeinfo ../../QtWebSockets/plugins.qmltypes +typeinfo plugins.qmltypes diff --git a/src/websockets/doc/images/websockets-pictorial-representation.jpg b/src/websockets/doc/images/websockets-pictorial-representation.jpg Binary files differnew file mode 100644 index 0000000..5308fdd --- /dev/null +++ b/src/websockets/doc/images/websockets-pictorial-representation.jpg diff --git a/src/websockets/doc/qtwebsockets.qdocconf b/src/websockets/doc/qtwebsockets.qdocconf index 2e1e15b..002898c 100644 --- a/src/websockets/doc/qtwebsockets.qdocconf +++ b/src/websockets/doc/qtwebsockets.qdocconf @@ -44,7 +44,8 @@ headerdirs += .. \ sourcedirs += .. \ src \ - ../../imports + ../../imports \ + ../../../tests/doc exampledirs += ../../../examples/websockets \ @@ -52,7 +53,8 @@ exampledirs += ../../../examples/websock examples.fileextensions += "*.html" -imagedirs += ../../../examples/websockets/doc/images +imagedirs += ../../../examples/websockets/doc/images \ + images manifestmeta.thumbnail.names += "QtWebSockets/*" diff --git a/src/websockets/doc/src/index.qdoc b/src/websockets/doc/src/index.qdoc index 0d28036..e0f219c 100644 --- a/src/websockets/doc/src/index.qdoc +++ b/src/websockets/doc/src/index.qdoc @@ -37,11 +37,9 @@ the solution for applications that struggle to get real-time data feeds with less network latency and minimum data exchange. - The Qt WebSockets module implements the WebSocket protocol as specified in - \l {http://tools.ietf.org/html/rfc6455} {RFC 6455}. It provides C++ and QML - interfaces that enable Qt applications to act as a server that can process - WebSocket-based requests, or a client that can consume data received from - the server, or both. + The Qt WebSockets module provides C++ and QML interfaces that enable + Qt applications to act as a server that can process WebSocket requests, + or a client that can consume data received from the server, or both. To use this module in your application, use the following include statement: @@ -57,8 +55,9 @@ QT += websockets \endcode - \section1 Reference documentation + \section1 Reference Documentation \list + \li \l{Qt WebSockets Overview}{Overview} \li \l{Qt WebSockets C++ Classes}{C++ Classes} \li \l{Qt WebSockets QML Types}{QML Types} \endlist @@ -67,4 +66,22 @@ The module provides the following \l{Qt WebSockets Examples}{Examples} as a guide to using the API. + + \section1 Conformance + \list + \li \l {Testing Qt WebSockets} + \endlist +*/ + +/*! + \page qtwebsockets-testing.html + \title Testing Qt WebSockets + + \l {http://autobahn.ws/testsuite/}{Autobahn|Testsuite}, a standard test + suite for WebSocket Protocol (RFC 6455), can be used for testing the + conformance of Qt WebSockets. Refer to Autobahn|Testsuite + \l {http://autobahn.ws/testsuite/installation.html}{installation documentation} + to set up the test suite. + + \include README testsuite */ diff --git a/src/websockets/doc/src/overview.qdoc b/src/websockets/doc/src/overview.qdoc new file mode 100644 index 0000000..df080c1 --- /dev/null +++ b/src/websockets/doc/src/overview.qdoc @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page websockets-overview.html +\title Qt WebSockets Overview +\brief Provides insight into the WebSocket protocol and the Qt WebSockets module. + +Qt WebSockets enables you to build WebSocket-aware applications. It +provides an implementation for the WebSocket protocol, which is offered by IETF +(Internet Engineering Task Force) as a better alternative for bidirectional +communication using the existing web infrastructure. + +Historically, web applications that needed bidirectional communication or +push notifications had to use one of the HTTP-based solutions available. These +solutions employed different techniques such as polling, long-polling, and +streaming, to overcome the limitations of HTTP protocol, which is not designed +for such use cases. As a result, high network latency, unnecessary data +exchange, and stale or old data. The WebSocket offering by IETF helps to +overcome these problems to a large extent. + +\section1 How does it Work? + +\image websockets-pictorial-representation.jpg + +As you can see in the pictorial representation, WebSocket-based solution +consists of a client-side and server-side. The native client-side support for +WebSocket is available on most of the popular web browsers such as Google +Chrome, Internet Explorer, Safari, and so on. The server-side support for +WebSocket makes it a complete solution, enabling bidirectional communication. +Any browser with native WebSocket support should let you run a simple HTML and +JavaScript-based client application using the HTML5 WebSocket API. + +A WebSocket connection begins with a initial HTTP-compatible handshake, +which ensures backwards compatibility so that the WebSocket connections can +share the default HTTP (80) and HTTPS (443) ports. On successful handshake, +the connection is open for data exchange, until one of the two entities end +the connection. + +The WebSocket protocol uses \c ws: and \c wss: URL schemes to represent +unsecure and secure WebSocket requests, respectively. During the initial +handshake, if a proxy server is detected, the protocol tries to set up a tunnel +by issuing an \c{HTTP CONNECT} statement to the proxy. The tunnel approach to +handle proxies is used irrespective of the request type, although it is proved +to work better with TLS (Transport Layer Security) in secure connections. + +\section1 Typical Use Cases + +WebSocket suits best for scenarios where, +\list + \li data presented must be up-to-date, + \li low network latency and minimal data exchange is crucial. +\endlist + +A few example applications where we struggle to achieve these using the +traditional approach are, instant messaging, online gaming, online stock +trading, and so on. + +\section1 Role of Qt WebSockets + +The Qt WebSockets module provides APIs to develop WebSocket-based server and +client applications. An example of where these APIs can be used is a server +application that provides stock data, and a client application that registers +for push notification when there is a change in price of a few stocks. + +The module provides both C++ and QML versions of the API, so you can choose +the alternative that suits your need. + +\section2 Qt WebSockets with Qt Cloud Services + +The client application usually depends on an external service for data. Most of +these service providers do not support WebSocket yet, so you end up developing +a WebSocket-aware server application to bridge the gap. You can choose to run +the server on an enterprise WebSocket gateway service such as Qt Cloud +Services, avoiding the hassle of maintaining the necessary infrastructure +required to host such a service. + +The Qt Cloud Services provides a Managed Application Runtime (MAR) backend, +which enables deploying and running an instance of server application on the +cloud. The server instance running on MAR gets a WebSocket URL, which can be +used by the client applications to connect and receive data. + +\section2 Related Information +\list +\li \l {http://tools.ietf.org/html/rfc6455}{WebSocket RFC 6455} +\li \l {https://qtcloudservices.com}{Qt Cloud Services} +\endlist +*/ diff --git a/src/websockets/doc/src/qtwebsockets-module.qdoc b/src/websockets/doc/src/qtwebsockets-module.qdoc index acbe2ac..6c717f4 100644 --- a/src/websockets/doc/src/qtwebsockets-module.qdoc +++ b/src/websockets/doc/src/qtwebsockets-module.qdoc @@ -58,4 +58,9 @@ \code import QtWebSockets 1.0 \endcode + + \note Prior to Qt 5.5, the import statement was \c{import Qt.WebSockets 1.0} + (notice the dot between \c Qt and \c WebSockets). The old statement is still + supported for backwards compatibility, but it cannot be mixed with the new + statement within the same project. */ diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 3ed8d8d..b9504f8 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -1045,6 +1045,10 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS Q_ASSERT(m_pSocket); Q_Q(QWebSocket); QAbstractSocket::SocketState webSocketState = this->state(); + int port = 80; + if (m_request.url().scheme() == QStringLiteral("wss")) + port = 443; + switch (socketState) { case QAbstractSocket::ConnectedState: if (webSocketState == QAbstractSocket::ConnectingState) { @@ -1059,7 +1063,7 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS createHandShakeRequest(m_resourceName, m_request.url().host() % QStringLiteral(":") - % QString::number(m_request.url().port(80)), + % QString::number(m_request.url().port(port)), origin(), QString(), QString(), diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 73ca9d7..bc23674 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -370,13 +370,15 @@ void QWebSocketServerPrivate::setError(QWebSocketProtocol::CloseCode code, const */ void QWebSocketServerPrivate::onNewConnection() { - QTcpSocket *pTcpSocket = m_pTcpServer->nextPendingConnection(); - //use a queued connection because a QSslSocket - //needs the event loop to process incoming data - //if not queued, data is incomplete when handshakeReceived is called - QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead, - this, &QWebSocketServerPrivate::handshakeReceived, - Qt::QueuedConnection); + while (m_pTcpServer->hasPendingConnections()) { + QTcpSocket *pTcpSocket = m_pTcpServer->nextPendingConnection(); + //use a queued connection because a QSslSocket + //needs the event loop to process incoming data + //if not queued, data is incomplete when handshakeReceived is called + QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead, + this, &QWebSocketServerPrivate::handshakeReceived, + Qt::QueuedConnection); + } } /*! diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 4698cd0..d96c4a5 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,16 +1,7 @@ TEMPLATE = subdirs -SUBDIRS = \ - qwebsocketcorsauthenticator +SUBDIRS += cmake websockets -contains(QT_CONFIG, private_tests): SUBDIRS += \ - websocketprotocol \ - dataprocessor \ - websocketframe \ - handshakerequest \ - handshakeresponse \ - qdefaultmaskgenerator - -SUBDIRS += \ - qwebsocket \ - qwebsocketserver +qtHaveModule(quick) { + SUBDIRS += qml +} diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro new file mode 100644 index 0000000..24941ad --- /dev/null +++ b/tests/auto/qml/qml.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += qmlwebsockets qmlwebsockets_compat diff --git a/tests/auto/qml/qmlwebsockets/qmlwebsockets.pro b/tests/auto/qml/qmlwebsockets/qmlwebsockets.pro new file mode 100644 index 0000000..9405f37 --- /dev/null +++ b/tests/auto/qml/qmlwebsockets/qmlwebsockets.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = tst_qmlwebsockets +CONFIG += qmltestcase +CONFIG += console +SOURCES += tst_qmlwebsockets.cpp + +importFiles.path = . +DEPLOYMENT += importFiles + diff --git a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.cpp b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.cpp new file mode 100644 index 0000000..c230bf5 --- /dev/null +++ b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qmlwebsockets) diff --git a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml new file mode 100644 index 0000000..6018037 --- /dev/null +++ b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 +import QtWebSockets 1.0 + +Rectangle { + width: 360 + height: 360 + + function appendMessage(message) { + messageBox.text += "\n" + message + } + + WebSocketServer { + id: server + } + + WebSocket { + id: socket + } +} diff --git a/tests/auto/qml/qmlwebsockets_compat/qmlwebsockets_compat.pro b/tests/auto/qml/qmlwebsockets_compat/qmlwebsockets_compat.pro new file mode 100644 index 0000000..104e6de --- /dev/null +++ b/tests/auto/qml/qmlwebsockets_compat/qmlwebsockets_compat.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = tst_qmlwebsockets_compat +CONFIG += qmltestcase +CONFIG += console +SOURCES += tst_qmlwebsockets_compat.cpp + +importFiles.path = . +DEPLOYMENT += importFiles + diff --git a/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.cpp b/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.cpp new file mode 100644 index 0000000..0ce5bce --- /dev/null +++ b/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qmlwebsockets_compat) diff --git a/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.qml b/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.qml new file mode 100644 index 0000000..fa2a992 --- /dev/null +++ b/tests/auto/qml/qmlwebsockets_compat/tst_qmlwebsockets_compat.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 +import Qt.WebSockets 1.0 + +Rectangle { + width: 360 + height: 360 + + function appendMessage(message) { + messageBox.text += "\n" + message + } + + WebSocketServer { + id: server + } + + WebSocket { + id: socket + } +} diff --git a/tests/auto/dataprocessor/dataprocessor.pro b/tests/auto/websockets/dataprocessor/dataprocessor.pro index ac5ba5c..ac5ba5c 100644 --- a/tests/auto/dataprocessor/dataprocessor.pro +++ b/tests/auto/websockets/dataprocessor/dataprocessor.pro diff --git a/tests/auto/dataprocessor/tst_dataprocessor.cpp b/tests/auto/websockets/dataprocessor/tst_dataprocessor.cpp index c1dd9a1..c1dd9a1 100644 --- a/tests/auto/dataprocessor/tst_dataprocessor.cpp +++ b/tests/auto/websockets/dataprocessor/tst_dataprocessor.cpp diff --git a/tests/auto/handshakerequest/handshakerequest.pro b/tests/auto/websockets/handshakerequest/handshakerequest.pro index d887cd6..d887cd6 100644 --- a/tests/auto/handshakerequest/handshakerequest.pro +++ b/tests/auto/websockets/handshakerequest/handshakerequest.pro diff --git a/tests/auto/handshakerequest/tst_handshakerequest.cpp b/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp index 9c579bd..9c579bd 100644 --- a/tests/auto/handshakerequest/tst_handshakerequest.cpp +++ b/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp diff --git a/tests/auto/handshakeresponse/handshakeresponse.pro b/tests/auto/websockets/handshakeresponse/handshakeresponse.pro index 4d7cd50..4d7cd50 100644 --- a/tests/auto/handshakeresponse/handshakeresponse.pro +++ b/tests/auto/websockets/handshakeresponse/handshakeresponse.pro diff --git a/tests/auto/handshakeresponse/tst_handshakeresponse.cpp b/tests/auto/websockets/handshakeresponse/tst_handshakeresponse.cpp index b5f103b..b5f103b 100644 --- a/tests/auto/handshakeresponse/tst_handshakeresponse.cpp +++ b/tests/auto/websockets/handshakeresponse/tst_handshakeresponse.cpp diff --git a/tests/auto/qdefaultmaskgenerator/qdefaultmaskgenerator.pro b/tests/auto/websockets/qdefaultmaskgenerator/qdefaultmaskgenerator.pro index 3a951a7..3a951a7 100644 --- a/tests/auto/qdefaultmaskgenerator/qdefaultmaskgenerator.pro +++ b/tests/auto/websockets/qdefaultmaskgenerator/qdefaultmaskgenerator.pro diff --git a/tests/auto/qdefaultmaskgenerator/tst_defaultmaskgenerator.cpp b/tests/auto/websockets/qdefaultmaskgenerator/tst_defaultmaskgenerator.cpp index f5fc5c4..f5fc5c4 100644 --- a/tests/auto/qdefaultmaskgenerator/tst_defaultmaskgenerator.cpp +++ b/tests/auto/websockets/qdefaultmaskgenerator/tst_defaultmaskgenerator.cpp diff --git a/tests/auto/qwebsocket/qwebsocket.pro b/tests/auto/websockets/qwebsocket/qwebsocket.pro index 0155d08..0155d08 100644 --- a/tests/auto/qwebsocket/qwebsocket.pro +++ b/tests/auto/websockets/qwebsocket/qwebsocket.pro diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp index f993f84..f993f84 100644 --- a/tests/auto/qwebsocket/tst_qwebsocket.cpp +++ b/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp diff --git a/tests/auto/qwebsocketcorsauthenticator/qwebsocketcorsauthenticator.pro b/tests/auto/websockets/qwebsocketcorsauthenticator/qwebsocketcorsauthenticator.pro index aa485fc..aa485fc 100644 --- a/tests/auto/qwebsocketcorsauthenticator/qwebsocketcorsauthenticator.pro +++ b/tests/auto/websockets/qwebsocketcorsauthenticator/qwebsocketcorsauthenticator.pro diff --git a/tests/auto/qwebsocketcorsauthenticator/tst_qwebsocketcorsauthenticator.cpp b/tests/auto/websockets/qwebsocketcorsauthenticator/tst_qwebsocketcorsauthenticator.cpp index 225adc8..225adc8 100644 --- a/tests/auto/qwebsocketcorsauthenticator/tst_qwebsocketcorsauthenticator.cpp +++ b/tests/auto/websockets/qwebsocketcorsauthenticator/tst_qwebsocketcorsauthenticator.cpp diff --git a/tests/auto/qwebsocketserver/qwebsocketserver.pro b/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro index 25216d3..25216d3 100644 --- a/tests/auto/qwebsocketserver/qwebsocketserver.pro +++ b/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro diff --git a/tests/auto/qwebsocketserver/tst_qwebsocketserver.cpp b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp index c2ba842..c2ba842 100644 --- a/tests/auto/qwebsocketserver/tst_qwebsocketserver.cpp +++ b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp diff --git a/tests/auto/websocketframe/tst_websocketframe.cpp b/tests/auto/websockets/websocketframe/tst_websocketframe.cpp index 5db82d5..5db82d5 100644 --- a/tests/auto/websocketframe/tst_websocketframe.cpp +++ b/tests/auto/websockets/websocketframe/tst_websocketframe.cpp diff --git a/tests/auto/websocketframe/websocketframe.pro b/tests/auto/websockets/websocketframe/websocketframe.pro index 9682348..9682348 100644 --- a/tests/auto/websocketframe/websocketframe.pro +++ b/tests/auto/websockets/websocketframe/websocketframe.pro diff --git a/tests/auto/websocketprotocol/tst_websocketprotocol.cpp b/tests/auto/websockets/websocketprotocol/tst_websocketprotocol.cpp index 94816de..94816de 100644 --- a/tests/auto/websocketprotocol/tst_websocketprotocol.cpp +++ b/tests/auto/websockets/websocketprotocol/tst_websocketprotocol.cpp diff --git a/tests/auto/websocketprotocol/websocketprotocol.pro b/tests/auto/websockets/websocketprotocol/websocketprotocol.pro index c21bb64..c21bb64 100644 --- a/tests/auto/websocketprotocol/websocketprotocol.pro +++ b/tests/auto/websockets/websocketprotocol/websocketprotocol.pro diff --git a/tests/auto/websockets/websockets.pro b/tests/auto/websockets/websockets.pro new file mode 100644 index 0000000..4698cd0 --- /dev/null +++ b/tests/auto/websockets/websockets.pro @@ -0,0 +1,16 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + qwebsocketcorsauthenticator + +contains(QT_CONFIG, private_tests): SUBDIRS += \ + websocketprotocol \ + dataprocessor \ + websocketframe \ + handshakerequest \ + handshakeresponse \ + qdefaultmaskgenerator + +SUBDIRS += \ + qwebsocket \ + qwebsocketserver diff --git a/tests/doc/README b/tests/doc/README new file mode 100644 index 0000000..da9b2b5 --- /dev/null +++ b/tests/doc/README @@ -0,0 +1,58 @@ +This directory contains autotests and manual tests for the Qt WebSockets +module. + +In addition, Autobahn|Testsuite, a standard test suite for WebSocket +Protocol (RFC 6455), can be used for testing the conformance of Qt +WebSockets. + +http://autobahn.ws/testsuite/ + +Refer to Autobahn|Testsuite installation documentation at +http://autobahn.ws/testsuite/installation.html + +//! [testsuite] +\section1 Testing Qt WebSockets with Autobahn|Testsuite + + +\section2 wstest - fuzzingserver mode + +\code + cd your_build_dir/tests/manual/compliance + qmake your_src_dir/tests/manual/compliance/compliance.pro + make + + cd ~ + wstest -m fuzzingserver +\endcode + +Then, in another terminal: + +\code + cd your_build_dir/tests/manual/compliance + ./tst_compliance +\endcode + +Test results will be generated under ~/reports/clients directory. +Point your browser to ~/reports/clients/index.html. + + +\section2 wstest - fuzzingclient mode + +\code + cd your_build_dir/examples/websockets/echoserver + qmake your_src_dir/examples/websockets/echoserver/echoserver.pro + make + + ./echoserver -p 9001 +\endcode + +Then, in another terminal: + +\code + cd ~ + wstest -m fuzzingclient +\endcode + +Test results will be generated under ~/reports/servers directory. +Point your browser to ~/reports/servers/index.html. +//! [testsuite] |