aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/debugger/shared')
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp85
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.pri10
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h74
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.cpp511
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.h110
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp29
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.h29
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp129
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.h42
-rw-r--r--tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp119
-rw-r--r--tests/auto/qml/debugger/shared/qqmlinspectorclient.h60
11 files changed, 311 insertions, 887 deletions
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index 51d706b818..7b9e935678 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -33,10 +28,12 @@
#include "debugutil_p.h"
-#include <QEventLoop>
-#include <QTimer>
-#include <QFileInfo>
-#include <QDir>
+#include <private/qqmldebugconnection_p.h>
+
+#include <QtCore/qeventloop.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
@@ -51,6 +48,46 @@ bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int tim
return timer.isActive();
}
+QList<QQmlDebugClient *> QQmlDebugTest::createOtherClients(QQmlDebugConnection *connection)
+{
+ QList<QQmlDebugClient *> ret;
+ foreach (const QString &service, QQmlDebuggingEnabler::debuggerServices()) {
+ if (!connection->client(service))
+ ret << new QQmlDebugClient(service, connection);
+ }
+ foreach (const QString &service, QQmlDebuggingEnabler::inspectorServices()) {
+ if (!connection->client(service))
+ ret << new QQmlDebugClient(service, connection);
+ }
+ foreach (const QString &service, QQmlDebuggingEnabler::profilerServices()) {
+ if (!connection->client(service))
+ ret << new QQmlDebugClient(service, connection);
+ }
+ return ret;
+}
+
+QString QQmlDebugTest::clientStateString(const QQmlDebugClient *client)
+{
+ if (!client)
+ return QLatin1String("null");
+
+ switch (client->state()) {
+ case QQmlDebugClient::NotConnected: return QLatin1String("Not connected");
+ case QQmlDebugClient::Unavailable: return QLatin1String("Unavailable");
+ case QQmlDebugClient::Enabled: return QLatin1String("Enabled");
+ default: return QLatin1String("Invalid");
+ }
+
+}
+
+QString QQmlDebugTest::connectionStateString(const QQmlDebugConnection *connection)
+{
+ if (!connection)
+ return QLatin1String("null");
+
+ return connection->isConnected() ? QLatin1String("connected") : QLatin1String("not connected");
+}
+
QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c)
: QQmlDebugClient(s, c)
{
@@ -134,7 +171,7 @@ void QQmlDebugProcess::start(const QStringList &arguments)
#endif
m_mutex.lock();
m_port = 0;
- m_process.setEnvironment(m_environment);
+ m_process.setEnvironment(QProcess::systemEnvironment() + m_environment);
m_process.start(m_executable, arguments);
if (!m_process.waitForStarted()) {
qWarning() << "QML Debug Client: Could not launch app " << m_executable
@@ -192,9 +229,9 @@ QProcess::ExitStatus QQmlDebugProcess::exitStatus() const
return m_process.exitStatus();
}
-void QQmlDebugProcess::setEnvironment(const QStringList &environment)
+void QQmlDebugProcess::addEnvironment(const QString &environment)
{
- m_environment = environment;
+ m_environment.append(environment);
}
QString QQmlDebugProcess::output() const
diff --git a/tests/auto/qml/debugger/shared/debugutil.pri b/tests/auto/qml/debugger/shared/debugutil.pri
index cb9c761395..1983f3583e 100644
--- a/tests/auto/qml/debugger/shared/debugutil.pri
+++ b/tests/auto/qml/debugger/shared/debugutil.pri
@@ -1,8 +1,4 @@
-HEADERS += $$PWD/debugutil_p.h \
- $$PWD/qqmldebugclient.h \
- $$PWD/../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h
-
-SOURCES += $$PWD/debugutil.cpp \
- $$PWD/qqmldebugclient.cpp \
- $$PWD/../../../../../src/plugins/qmltooling/shared/qpacketprotocol.cpp
+QT += qmldebug-private
+HEADERS += $$PWD/debugutil_p.h
+SOURCES += $$PWD/debugutil.cpp
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index d544a89ff2..6fe5d897e0 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -1,39 +1,34 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef DEBUGUTIL_H
-#define DEBUGUTIL_H
+#ifndef DEBUGUTIL_P_H
+#define DEBUGUTIL_P_H
//
// W A R N I N G
@@ -46,21 +41,23 @@
// We mean it.
//
-#include <QEventLoop>
-#include <QTimer>
-#include <QThread>
-#include <QTest>
-#include <QProcess>
-#include <QMutex>
+#include <private/qqmldebugclient_p.h>
+#include <QtCore/qeventloop.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qprocess.h>
+#include <QtCore/qmutex.h>
+#include <QtTest/qtest.h>
#include <QtQml/qqmlengine.h>
-#include "qqmldebugclient.h"
-
class QQmlDebugTest
{
public:
static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+ static QList<QQmlDebugClient *> createOtherClients(QQmlDebugConnection *connection);
+ static QString clientStateString(const QQmlDebugClient *client);
+ static QString connectionStateString(const QQmlDebugConnection *connection);
};
class QQmlDebugTestClient : public QQmlDebugClient
@@ -92,7 +89,7 @@ public:
QString state();
- void setEnvironment(const QStringList &environment);
+ void addEnvironment(const QString &environment);
void start(const QStringList &arguments);
bool waitForSessionStart();
@@ -128,4 +125,23 @@ private:
int m_receivedBindErrors;
};
-#endif // DEBUGUTIL_H
+class QQmlInspectorResultRecipient : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlInspectorResultRecipient(QObject *parent = 0) :
+ QObject(parent), lastResponseId(-1), lastResult(false) {}
+
+ int lastResponseId;
+ bool lastResult;
+
+public slots:
+
+ void recordResponse(int requestId, bool result)
+ {
+ lastResponseId = requestId;
+ lastResult = result;
+ }
+};
+
+#endif // DEBUGUTIL_P_H
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
deleted file mode 100644
index 0f7e572e02..0000000000
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
+++ /dev/null
@@ -1,511 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtQml 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 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 "qqmldebugclient.h"
-#include "../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qeventloop.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qtimer.h>
-#include <QtNetwork/qnetworkproxy.h>
-#include <QtNetwork/qlocalserver.h>
-#include <QtNetwork/qlocalsocket.h>
-
-const int protocolVersion = 1;
-const QString serverId = QLatin1String("QDeclarativeDebugServer");
-const QString clientId = QLatin1String("QDeclarativeDebugClient");
-
-class QQmlDebugClientPrivate
-{
-public:
- QQmlDebugClientPrivate();
-
- QString name;
- QQmlDebugConnection *connection;
-};
-
-class QQmlDebugConnectionPrivate : public QObject
-{
- Q_OBJECT
-public:
- QQmlDebugConnectionPrivate(QQmlDebugConnection *c);
- QQmlDebugConnection *q;
- QPacketProtocol *protocol;
- QIODevice *device;
- QLocalServer *server;
- QEventLoop handshakeEventLoop;
- QTimer handshakeTimer;
-
- bool gotHello;
- QHash <QString, float> serverPlugins;
- QHash<QString, QQmlDebugClient *> plugins;
-
- void advertisePlugins();
- void connectDeviceSignals();
-
-public Q_SLOTS:
- void forwardStateChange(QLocalSocket::LocalSocketState state);
- void forwardError(QLocalSocket::LocalSocketError error);
-
- void newConnection();
- void connected();
- void readyRead();
- void deviceAboutToClose();
- void handshakeTimeout();
-};
-
-QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate(QQmlDebugConnection *c)
- : QObject(c), q(c), protocol(0), device(0), server(0), gotHello(false)
-{
- protocol = new QPacketProtocol(q, this);
- QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
- QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
-
- handshakeTimer.setSingleShot(true);
- handshakeTimer.setInterval(3000);
- connect(&handshakeTimer, SIGNAL(timeout()), SLOT(handshakeTimeout()));
-}
-
-void QQmlDebugConnectionPrivate::advertisePlugins()
-{
- if (!q->isConnected())
- return;
-
- QPacket pack;
- pack << serverId << 1 << plugins.keys();
- protocol->send(pack);
- q->flush();
-}
-
-void QQmlDebugConnectionPrivate::connected()
-{
- QPacket pack;
- pack << serverId << 0 << protocolVersion << plugins.keys()
- << q->m_dataStreamVersion;
- protocol->send(pack);
- q->flush();
-}
-
-void QQmlDebugConnectionPrivate::readyRead()
-{
- if (!gotHello) {
- QPacket pack = protocol->read();
- QString name;
-
- pack >> name;
-
- bool validHello = false;
- if (name == clientId) {
- int op = -1;
- pack >> op;
- if (op == 0) {
- int version = -1;
- pack >> version;
- if (version == protocolVersion) {
- QStringList pluginNames;
- QList<float> pluginVersions;
- pack >> pluginNames;
- if (!pack.isEmpty())
- pack >> pluginVersions;
-
- const int pluginNamesSize = pluginNames.size();
- const int pluginVersionsSize = pluginVersions.size();
- for (int i = 0; i < pluginNamesSize; ++i) {
- float pluginVersion = 1.0;
- if (i < pluginVersionsSize)
- pluginVersion = pluginVersions.at(i);
- serverPlugins.insert(pluginNames.at(i), pluginVersion);
- }
-
- pack >> q->m_dataStreamVersion;
- validHello = true;
- }
- }
- }
-
- if (!validHello) {
- qWarning("QQmlDebugConnection: Invalid hello message");
- QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
- return;
- }
- gotHello = true;
-
- QHash<QString, QQmlDebugClient *>::Iterator iter = plugins.begin();
- for (; iter != plugins.end(); ++iter) {
- QQmlDebugClient::State newState = QQmlDebugClient::Unavailable;
- if (serverPlugins.contains(iter.key()))
- newState = QQmlDebugClient::Enabled;
- iter.value()->stateChanged(newState);
- }
-
- handshakeTimer.stop();
- handshakeEventLoop.quit();
- }
-
- while (protocol->packetsAvailable()) {
- QPacket pack = protocol->read();
- QString name;
- pack >> name;
-
- if (name == clientId) {
- int op = -1;
- pack >> op;
-
- if (op == 1) {
- // Service Discovery
- QHash<QString, float> oldServerPlugins = serverPlugins;
- serverPlugins.clear();
-
- QStringList pluginNames;
- QList<float> pluginVersions;
- pack >> pluginNames;
- if (!pack.isEmpty())
- pack >> pluginVersions;
-
- const int pluginNamesSize = pluginNames.size();
- const int pluginVersionsSize = pluginVersions.size();
- for (int i = 0; i < pluginNamesSize; ++i) {
- float pluginVersion = 1.0;
- if (i < pluginVersionsSize)
- pluginVersion = pluginVersions.at(i);
- serverPlugins.insert(pluginNames.at(i), pluginVersion);
- }
-
- QHash<QString, QQmlDebugClient *>::Iterator iter = plugins.begin();
- for (; iter != plugins.end(); ++iter) {
- const QString pluginName = iter.key();
- QQmlDebugClient::State newSate = QQmlDebugClient::Unavailable;
- if (serverPlugins.contains(pluginName))
- newSate = QQmlDebugClient::Enabled;
-
- if (oldServerPlugins.contains(pluginName)
- != serverPlugins.contains(pluginName)) {
- iter.value()->stateChanged(newSate);
- }
- }
- } else {
- qWarning() << "QQmlDebugConnection: Unknown control message id" << op;
- }
- } else {
- QByteArray message;
- pack >> message;
-
- QHash<QString, QQmlDebugClient *>::Iterator iter =
- plugins.find(name);
- if (iter == plugins.end()) {
- qWarning() << "QQmlDebugConnection: Message received for missing plugin" << name;
- } else {
- (*iter)->messageReceived(message);
- }
- }
- }
-}
-
-void QQmlDebugConnectionPrivate::deviceAboutToClose()
-{
- // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close())
- // without calling the underlying device close fn as that would cause an infinite loop
- q->QIODevice::close();
-}
-
-void QQmlDebugConnectionPrivate::handshakeTimeout()
-{
- if (!gotHello) {
- qWarning() << "Qml Debug Client: Did not get handshake answer in time";
- handshakeEventLoop.quit();
- }
-}
-
-QQmlDebugConnection::QQmlDebugConnection(QObject *parent)
- : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this)),
- m_dataStreamVersion(QDataStream::Qt_5_0)
-{
-}
-
-QQmlDebugConnection::~QQmlDebugConnection()
-{
- QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- iter.value()->d->connection = 0;
- iter.value()->stateChanged(QQmlDebugClient::NotConnected);
- }
-}
-
-void QQmlDebugConnection::setDataStreamVersion(int dataStreamVersion)
-{
- m_dataStreamVersion = dataStreamVersion;
-}
-
-int QQmlDebugConnection::dataStreamVersion()
-{
- return m_dataStreamVersion;
-}
-
-bool QQmlDebugConnection::isConnected() const
-{
- return state() == QAbstractSocket::ConnectedState;
-}
-
-qint64 QQmlDebugConnection::readData(char *data, qint64 maxSize)
-{
- return d->device->read(data, maxSize);
-}
-
-qint64 QQmlDebugConnection::writeData(const char *data, qint64 maxSize)
-{
- return d->device->write(data, maxSize);
-}
-
-qint64 QQmlDebugConnection::bytesAvailable() const
-{
- return d->device->bytesAvailable();
-}
-
-bool QQmlDebugConnection::isSequential() const
-{
- return true;
-}
-
-void QQmlDebugConnection::close()
-{
- if (isOpen()) {
- QIODevice::close();
- d->device->close();
- emit stateChanged(QAbstractSocket::UnconnectedState);
-
- QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
- for (; iter != d->plugins.end(); ++iter) {
- iter.value()->stateChanged(QQmlDebugClient::NotConnected);
- }
- }
-}
-
-bool QQmlDebugConnection::waitForConnected(int msecs)
-{
- QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (!socket) {
- if (!d->server || (!d->server->hasPendingConnections() &&
- !d->server->waitForNewConnection(msecs)))
- return false;
- } else if (!socket->waitForConnected(msecs)) {
- return false;
- }
- // wait for handshake
- d->handshakeTimer.start();
- d->handshakeEventLoop.exec();
- return d->gotHello;
-}
-
-QString QQmlDebugConnection::stateString() const
-{
- QString state;
-
- if (isConnected())
- state = "Connected";
- else
- state = "Not connected";
-
- if (d->gotHello)
- state += ", got hello";
- else
- state += ", did not get hello!";
-
- return state;
-}
-
-QAbstractSocket::SocketState QQmlDebugConnection::state() const
-{
- QAbstractSocket *abstractSocket = qobject_cast<QAbstractSocket*>(d->device);
- if (abstractSocket)
- return abstractSocket->state();
-
- QLocalSocket *localSocket = qobject_cast<QLocalSocket*>(d->device);
- if (localSocket)
- return static_cast<QAbstractSocket::SocketState>(localSocket->state());
-
- return QAbstractSocket::UnconnectedState;
-}
-
-void QQmlDebugConnection::flush()
-{
- QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (socket) {
- socket->flush();
- return;
- }
-}
-
-void QQmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
-{
- QTcpSocket *socket = new QTcpSocket(d);
- socket->setProxy(QNetworkProxy::NoProxy);
- d->device = socket;
- d->connectDeviceSignals();
- d->gotHello = false;
- connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError)));
- connect(socket, SIGNAL(connected()), this, SIGNAL(connected()));
- socket->connectToHost(hostName, port);
- QIODevice::open(ReadWrite | Unbuffered);
-}
-
-void QQmlDebugConnection::startLocalServer(const QString &fileName)
-{
- d->gotHello = false;
- d->server = new QLocalServer(d);
- // QueuedConnection so that waitForNewConnection() returns true.
- connect(d->server, SIGNAL(newConnection()), d, SLOT(newConnection()), Qt::QueuedConnection);
- d->server->listen(fileName);
- QIODevice::open(ReadWrite | Unbuffered);
-}
-
-void QQmlDebugConnectionPrivate::newConnection()
-{
- QLocalSocket *socket = server->nextPendingConnection();
- server->close();
- device = socket;
- connectDeviceSignals();
- connect(socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)),
- this, SLOT(forwardStateChange(QLocalSocket::LocalSocketState)));
- connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
- this, SLOT(forwardError(QLocalSocket::LocalSocketError)));
- emit q->connected();
-}
-
-void QQmlDebugConnectionPrivate::connectDeviceSignals()
-{
- connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)));
- connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
- connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose()));
-}
-
-void QQmlDebugConnectionPrivate::forwardStateChange(QLocalSocket::LocalSocketState state)
-{
- emit q->stateChanged(static_cast<QAbstractSocket::SocketState>(state));
-}
-
-void QQmlDebugConnectionPrivate::forwardError(QLocalSocket::LocalSocketError error)
-{
- emit q->error(static_cast<QAbstractSocket::SocketError>(error));
-}
-
-QQmlDebugClientPrivate::QQmlDebugClientPrivate()
- : connection(0)
-{
-}
-
-QQmlDebugClient::QQmlDebugClient(const QString &name,
- QQmlDebugConnection *parent)
- : QObject(parent),
- d(new QQmlDebugClientPrivate)
-{
- d->name = name;
- d->connection = parent;
-
- if (!d->connection)
- return;
-
- if (d->connection->d->plugins.contains(name)) {
- qWarning() << "QQmlDebugClient: Conflicting plugin name" << name;
- d->connection = 0;
- } else {
- d->connection->d->plugins.insert(name, this);
- d->connection->d->advertisePlugins();
- }
-}
-
-QQmlDebugClient::~QQmlDebugClient()
-{
- if (d->connection && d->connection->d) {
- d->connection->d->plugins.remove(d->name);
- d->connection->d->advertisePlugins();
- }
- delete d;
-}
-
-QString QQmlDebugClient::name() const
-{
- return d->name;
-}
-
-float QQmlDebugClient::serviceVersion() const
-{
- if (d->connection->d->serverPlugins.contains(d->name))
- return d->connection->d->serverPlugins.value(d->name);
- return -1;
-}
-
-QQmlDebugClient::State QQmlDebugClient::state() const
-{
- if (!d->connection
- || !d->connection->isConnected()
- || !d->connection->d->gotHello)
- return NotConnected;
-
- if (d->connection->d->serverPlugins.contains(d->name))
- return Enabled;
-
- return Unavailable;
-}
-
-QString QQmlDebugClient::stateString() const
-{
- switch (state()) {
- case NotConnected: return QLatin1String("Not connected");
- case Unavailable: return QLatin1String("Unavailable");
- case Enabled: return QLatin1String("Enabled");
- }
- return QLatin1String("Invalid");
-}
-
-void QQmlDebugClient::sendMessage(const QByteArray &message)
-{
- if (state() != Enabled)
- return;
-
- QPacket pack;
- pack << d->name << message;
- d->connection->d->protocol->send(pack);
- d->connection->flush();
-}
-
-void QQmlDebugClient::stateChanged(State)
-{
-}
-
-void QQmlDebugClient::messageReceived(const QByteArray &)
-{
-}
-
-#include <qqmldebugclient.moc>
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h
deleted file mode 100644
index fe9da693c8..0000000000
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtQml 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 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$
-**
-****************************************************************************/
-
-#ifndef QQMLDEBUGCLIENT_H
-#define QQMLDEBUGCLIENT_H
-
-#include <QtNetwork/qtcpsocket.h>
-
-class QQmlDebugConnectionPrivate;
-class QQmlDebugConnection : public QIODevice
-{
- Q_OBJECT
- Q_DISABLE_COPY(QQmlDebugConnection)
-public:
- QQmlDebugConnection(QObject * = 0);
- ~QQmlDebugConnection();
-
- void connectToHost(const QString &hostName, quint16 port);
- void startLocalServer(const QString &fileName);
-
- void setDataStreamVersion(int dataStreamVersion);
- int dataStreamVersion();
-
- qint64 bytesAvailable() const;
- bool isConnected() const;
- QAbstractSocket::SocketState state() const;
- void flush();
- bool isSequential() const;
- void close();
- bool waitForConnected(int msecs = 30000);
-
- QString stateString() const;
-
-signals:
- void connected();
- void stateChanged(QAbstractSocket::SocketState socketState);
- void error(QAbstractSocket::SocketError socketError);
-
-protected:
- qint64 readData(char *data, qint64 maxSize);
- qint64 writeData(const char *data, qint64 maxSize);
-
-private:
- QQmlDebugConnectionPrivate *d;
- int m_dataStreamVersion;
- friend class QQmlDebugClient;
- friend class QQmlDebugClientPrivate;
- friend class QQmlDebugConnectionPrivate;
-};
-
-class QQmlDebugClientPrivate;
-class QQmlDebugClient : public QObject
-{
- Q_OBJECT
- Q_DISABLE_COPY(QQmlDebugClient)
-
-public:
- enum State { NotConnected, Unavailable, Enabled };
-
- QQmlDebugClient(const QString &, QQmlDebugConnection *parent);
- ~QQmlDebugClient();
-
- QString name() const;
- float serviceVersion() const;
- State state() const;
- QString stateString() const;
-
- virtual void sendMessage(const QByteArray &);
-
-protected:
- virtual void stateChanged(State);
- virtual void messageReceived(const QByteArray &);
-
-private:
- QQmlDebugClientPrivate *d;
- friend class QQmlDebugConnection;
- friend class QQmlDebugConnectionPrivate;
-};
-
-#endif // QQMLDEBUGCLIENT_H
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
index e62aa2ce61..4dce07d824 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
index cc24f3c119..37b4a9f98c 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
@@ -1,32 +1,27 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
index 9b48b40c07..3ad7beb7ff 100644
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
@@ -1,38 +1,33 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qqmlenginedebugclient.h"
-#include "qdatastream.h"
+#include <private/qqmldebugconnection_p.h>
struct QmlObjectData {
QUrl url;
@@ -46,7 +41,7 @@ struct QmlObjectData {
int parentId;
};
-QDataStream &operator>>(QDataStream &ds, QmlObjectData &data)
+QPacket &operator>>(QPacket &ds, QmlObjectData &data)
{
ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
>> data.objectName >> data.objectType >> data.objectId >> data.contextId
@@ -64,7 +59,7 @@ struct QmlObjectProperty {
bool hasNotifySignal;
};
-QDataStream &operator>>(QDataStream &ds, QmlObjectProperty &data)
+QPacket &operator>>(QPacket &ds, QmlObjectProperty &data)
{
int type;
ds >> type >> data.name >> data.value >> data.valueTypeName
@@ -77,8 +72,7 @@ QQmlEngineDebugClient::QQmlEngineDebugClient(
QQmlDebugConnection *connection)
: QQmlDebugClient(QLatin1String("QmlDebugger"), connection),
m_nextId(0),
- m_valid(false),
- m_connection(connection)
+ m_valid(false)
{
}
@@ -89,11 +83,10 @@ quint32 QQmlEngineDebugClient::addWatch(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("WATCH_PROPERTY") << id << property.objectDebugId
<< property.name.toUtf8();
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -115,10 +108,9 @@ quint32 QQmlEngineDebugClient::addWatch(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.debugId << expr;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -131,10 +123,9 @@ quint32 QQmlEngineDebugClient::addWatch(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("WATCH_OBJECT") << id << object.debugId;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -152,10 +143,9 @@ void QQmlEngineDebugClient::removeWatch(quint32 id, bool *success)
{
*success = false;
if (state() == QQmlDebugClient::Enabled) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("NO_WATCH") << id;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
}
@@ -167,10 +157,9 @@ quint32 QQmlEngineDebugClient::queryAvailableEngines(bool *success)
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("LIST_ENGINES") << id;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -184,10 +173,9 @@ quint32 QQmlEngineDebugClient::queryRootContexts(
*success = false;
if (state() == QQmlDebugClient::Enabled && engine.debugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("LIST_OBJECTS") << id << engine.debugId;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -201,11 +189,9 @@ quint32 QQmlEngineDebugClient::queryObject(
*success = false;
if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << id << object.debugId << false <<
- true;
- sendMessage(message);
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("FETCH_OBJECT") << id << object.debugId << false << true;
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -219,11 +205,10 @@ quint32 QQmlEngineDebugClient::queryObjectsForLocation(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
<< columnNumber << false << true;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -237,11 +222,9 @@ quint32 QQmlEngineDebugClient::queryObjectRecursive(
*success = false;
if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << id << object.debugId << true <<
- true;
- sendMessage(message);
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("FETCH_OBJECT") << id << object.debugId << true << true;
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -255,11 +238,10 @@ quint32 QQmlEngineDebugClient::queryObjectsForLocationRecursive(const QString &f
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
<< columnNumber << true << true;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -273,11 +255,10 @@ quint32 QQmlEngineDebugClient::queryExpressionResult(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr
<< engines()[0].debugId;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -291,10 +272,9 @@ quint32 QQmlEngineDebugClient::queryExpressionResultBC(
*success = false;
if (state() == QQmlDebugClient::Enabled) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -312,11 +292,10 @@ quint32 QQmlEngineDebugClient::setBindingForObject(
*success = false;
if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
<< bindingExpression << isLiteralValue << source << line;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -331,10 +310,9 @@ quint32 QQmlEngineDebugClient::resetBindingForObject(
*success = false;
if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
@@ -348,17 +326,16 @@ quint32 QQmlEngineDebugClient::setMethodBody(
*success = false;
if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
id = getId();
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
+ QPacket ds(connection()->currentDataStreamVersion());
ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
<< methodName << methodBody;
- sendMessage(message);
+ sendMessage(ds.data());
*success = true;
}
return id;
}
-void QQmlEngineDebugClient::decode(QDataStream &ds,
+void QQmlEngineDebugClient::decode(QPacket &ds,
QmlDebugObjectReference &o,
bool simple)
{
@@ -419,7 +396,7 @@ void QQmlEngineDebugClient::decode(QDataStream &ds,
}
}
-void QQmlEngineDebugClient::decode(QDataStream &ds,
+void QQmlEngineDebugClient::decode(QPacket &ds,
QList<QmlDebugObjectReference> &o,
bool simple)
{
@@ -432,7 +409,7 @@ void QQmlEngineDebugClient::decode(QDataStream &ds,
}
}
-void QQmlEngineDebugClient::decode(QDataStream &ds,
+void QQmlEngineDebugClient::decode(QPacket &ds,
QmlDebugContextReference &c)
{
ds >> c.name >> c.debugId;
@@ -460,9 +437,7 @@ void QQmlEngineDebugClient::decode(QDataStream &ds,
void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
{
m_valid = false;
- QDataStream ds(data);
- ds.setVersion(m_connection->dataStreamVersion());
-
+ QPacket ds(connection()->currentDataStreamVersion(), data);
int queryId;
QByteArray type;
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
index 28adb8b159..a64a77e13e 100644
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
+++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -34,13 +29,12 @@
#ifndef QQMLENGINEDEBUGCLIENT_H
#define QQMLENGINEDEBUGCLIENT_H
-#include "qqmldebugclient.h"
+#include <private/qqmldebugclient_p.h>
+#include <private/qpacket_p.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
-class QQmlDebugConnection;
-
struct QmlDebugPropertyReference
{
QmlDebugPropertyReference()
@@ -207,9 +201,9 @@ public:
quint32 getId() { return m_nextId++; }
- void decode(QDataStream &, QmlDebugContextReference &);
- void decode(QDataStream &, QmlDebugObjectReference &, bool simple);
- void decode(QDataStream &ds, QList<QmlDebugObjectReference> &o, bool simple);
+ void decode(QPacket &ds, QmlDebugContextReference &);
+ void decode(QPacket &ds, QmlDebugObjectReference &, bool simple);
+ void decode(QPacket &ds, QList<QmlDebugObjectReference> &o, bool simple);
QList<QmlDebugEngineReference> engines() { return m_engines; }
QmlDebugContextReference rootContext() { return m_rootContext; }
@@ -234,8 +228,6 @@ private:
QmlDebugObjectReference m_object;
QList<QmlDebugObjectReference> m_objects;
QVariant m_exprResult;
-
- QQmlDebugConnection *m_connection;
};
#endif // QQMLENGINEDEBUGCLIENT_H
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
index a46bd9012b..20faef177e 100644
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
@@ -1,64 +1,114 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qqmlinspectorclient.h"
-#include "qdatastream.h"
-void QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
+#include <private/qpacket_p.h>
+#include <private/qqmldebugconnection_p.h>
+#include <QtCore/qdebug.h>
+
+QQmlInspectorClient::QQmlInspectorClient(QQmlDebugConnection *connection) :
+ QQmlDebugClient(QLatin1String("QmlInspector"), connection),
+ m_lastRequestId(-1)
+{
+}
+
+int QQmlInspectorClient::setInspectToolEnabled(bool enabled)
{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("request") << m_requestId++
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray(enabled ? "enable" : "disable");
+
+ sendMessage(ds.data());
+ return m_lastRequestId;
+}
+
+int QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
+{
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
<< QByteArray("showAppOnTop") << showOnTop;
- sendMessage(message);
+ sendMessage(ds.data());
+ return m_lastRequestId;
}
-void QQmlInspectorClient::reloadQml(const QHash<QString, QByteArray> &changesHash)
+int QQmlInspectorClient::setAnimationSpeed(qreal speed)
{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- m_reloadRequestId = m_requestId;
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray("setAnimationSpeed") << speed;
- ds << QByteArray("request") << m_requestId++
- << QByteArray("reload") << changesHash;
+ sendMessage(ds.data());
+ return m_lastRequestId;
+}
- sendMessage(message);
+int QQmlInspectorClient::select(const QList<int> &objectIds)
+{
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray("select") << objectIds;
+
+ sendMessage(ds.data());
+ return m_lastRequestId;
+}
+
+int QQmlInspectorClient::createObject(const QString &qml, int parentId, const QStringList &imports,
+ const QString &filename)
+{
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray("createObject") << qml << parentId << imports << filename;
+ sendMessage(ds.data());
+ return m_lastRequestId;
+}
+
+int QQmlInspectorClient::moveObject(int childId, int newParentId)
+{
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray("moveObject") << childId << newParentId;
+ sendMessage(ds.data());
+ return m_lastRequestId;
+}
+
+int QQmlInspectorClient::destroyObject(int objectId)
+{
+ QPacket ds(connection()->currentDataStreamVersion());
+ ds << QByteArray("request") << ++m_lastRequestId
+ << QByteArray("destroyObject") << objectId;
+ sendMessage(ds.data());
+ return m_lastRequestId;
}
void QQmlInspectorClient::messageReceived(const QByteArray &message)
{
- QDataStream ds(message);
+ QPacket ds(connection()->currentDataStreamVersion(), message);
QByteArray type;
ds >> type;
@@ -67,7 +117,8 @@ void QQmlInspectorClient::messageReceived(const QByteArray &message)
return;
}
- m_requestResult = false;
- ds >> m_responseId >> m_requestResult;
- emit responseReceived();
+ int responseId;
+ bool result;
+ ds >> responseId >> result;
+ emit responseReceived(responseId, result);
}
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h b/tests/auto/qml/debugger/shared/qqmlinspectorclient.h
index a8b42c8430..bfb489c8f7 100644
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h
+++ b/tests/auto/qml/debugger/shared/qqmlinspectorclient.h
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -33,39 +28,32 @@
#ifndef QQMLINSPECTORCLIENT_H
#define QQMLINSPECTORCLIENT_H
-#include "qqmldebugclient.h"
+#include <private/qqmldebugclient_p.h>
class QQmlInspectorClient : public QQmlDebugClient
{
Q_OBJECT
public:
- QQmlInspectorClient(QQmlDebugConnection *connection)
- : QQmlDebugClient(QLatin1String("QmlInspector"), connection)
- , m_showAppOnTop(false)
- , m_requestId(0)
- , m_requestResult(false)
- , m_responseId(-1)
- {
- }
+ QQmlInspectorClient(QQmlDebugConnection *connection);
- void setShowAppOnTop(bool showOnTop);
- void reloadQml(const QHash<QString, QByteArray> &changesHash);
+ int setInspectToolEnabled(bool enabled);
+ int setShowAppOnTop(bool showOnTop);
+ int setAnimationSpeed(qreal speed);
+ int select(const QList<int> &objectIds);
+ int createObject(const QString &qml, int parentId, const QStringList &imports,
+ const QString &filename);
+ int moveObject(int childId, int newParentId);
+ int destroyObject(int objectId);
signals:
- void responseReceived();
+ void responseReceived(int requestId, bool result);
protected:
void messageReceived(const QByteArray &message);
private:
- bool m_showAppOnTop;
- int m_requestId;
-
-public:
- bool m_requestResult;
- int m_responseId;
- int m_reloadRequestId;
+ int m_lastRequestId;
};
#endif // QQMLINSPECTORCLIENT_H