From 7f963aa41dc995cc2ccbc9f5f3fb3ccb40647a04 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Tue, 13 Mar 2012 17:16:16 +0100 Subject: [PATCH] QmlEngineDebug: Rename to QmlEngineDebugClient in AutoTest Change-Id: If20b53d2e47cdc4ed54df0d9360ae1b0566489c6 Reviewed-by: Kai Koehne --- .../qqmlenginedebugclient.cpp | 1045 +++++++++++++++++++ .../qqmlenginedebugservice/qqmlenginedebugclient.h | 378 +++++++ .../qqmlenginedebugservice.pro | 6 +- .../tst_qqmlenginedebugservice.cpp | 31 +- tests/auto/qml/debugger/shared/debugutil.pri | 2 - tests/auto/qml/debugger/shared/qqmlenginedebug.cpp | 1085 -------------------- tests/auto/qml/debugger/shared/qqmlenginedebug_p.h | 377 ------- 7 files changed, 1443 insertions(+), 1481 deletions(-) create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h delete mode 100644 tests/auto/qml/debugger/shared/qqmlenginedebug.cpp delete mode 100644 tests/auto/qml/debugger/shared/qqmlenginedebug_p.h diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp new file mode 100644 index 0000000..db3ab19 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp @@ -0,0 +1,1045 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt 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.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlenginedebugclient.h" + +struct QmlObjectData { + QUrl url; + int lineNumber; + int columnNumber; + QString idString; + QString objectName; + QString objectType; + int objectId; + int contextId; +}; + +QDataStream &operator>>(QDataStream &ds, QmlObjectData &data) +{ + ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString + >> data.objectName >> data.objectType >> data.objectId >> data.contextId; + return ds; +} + +struct QmlObjectProperty { + enum Type { Unknown, Basic, Object, List, SignalProperty }; + Type type; + QString name; + QVariant value; + QString valueTypeName; + QString binding; + bool hasNotifySignal; +}; + +QDataStream &operator>>(QDataStream &ds, QmlObjectProperty &data) +{ + int type; + ds >> type >> data.name >> data.value >> data.valueTypeName + >> data.binding >> data.hasNotifySignal; + data.type = (QmlObjectProperty::Type)type; + return ds; +} + +class QQmlEngineDebugClientPrivate +{ +public: + QQmlEngineDebugClientPrivate(QQmlEngineDebugClient *); + ~QQmlEngineDebugClientPrivate(); + + void message(const QByteArray &); + + QQmlEngineDebugClient *q; + int nextId; + int getId(); + + void decode(QDataStream &, QQmlDebugContextReference &); + void decode(QDataStream &, QQmlDebugObjectReference &, bool simple); + + static void remove(QQmlEngineDebugClient *, QQmlDebugEnginesQuery *); + static void remove(QQmlEngineDebugClient *, QQmlDebugRootContextQuery *); + static void remove(QQmlEngineDebugClient *, QQmlDebugObjectQuery *); + static void remove(QQmlEngineDebugClient *, QQmlDebugExpressionQuery *); + static void remove(QQmlEngineDebugClient *, QQmlDebugWatch *); + + QHash enginesQuery; + QHash rootContextQuery; + QHash objectQuery; + QHash expressionQuery; + + QHash watched; +}; + +void QQmlEngineDebugClient::stateChanged(State status) +{ + emit newState(status); +} + +void QQmlEngineDebugClient::messageReceived(const QByteArray &data) +{ + d->message(data); +} + +QQmlEngineDebugClientPrivate::QQmlEngineDebugClientPrivate(QQmlEngineDebugClient *p) + : q(p), + nextId(0) +{ +} + +QQmlEngineDebugClientPrivate::~QQmlEngineDebugClientPrivate() +{ + QHash::iterator enginesIter = enginesQuery.begin(); + for (; enginesIter != enginesQuery.end(); ++enginesIter) { + enginesIter.value()->m_client = 0; + if (enginesIter.value()->state() == QQmlDebugQuery::Waiting) + enginesIter.value()->setState(QQmlDebugQuery::Error); + } + + QHash::iterator rootContextIter = rootContextQuery.begin(); + for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { + rootContextIter.value()->m_client = 0; + if (rootContextIter.value()->state() == QQmlDebugQuery::Waiting) + rootContextIter.value()->setState(QQmlDebugQuery::Error); + } + + QHash::iterator objectIter = objectQuery.begin(); + for (; objectIter != objectQuery.end(); ++objectIter) { + objectIter.value()->m_client = 0; + if (objectIter.value()->state() == QQmlDebugQuery::Waiting) + objectIter.value()->setState(QQmlDebugQuery::Error); + } + + QHash::iterator exprIter = expressionQuery.begin(); + for (; exprIter != expressionQuery.end(); ++exprIter) { + exprIter.value()->m_client = 0; + if (exprIter.value()->state() == QQmlDebugQuery::Waiting) + exprIter.value()->setState(QQmlDebugQuery::Error); + } + + QHash::iterator watchIter = watched.begin(); + for (; watchIter != watched.end(); ++watchIter) { + watchIter.value()->m_client = 0; + watchIter.value()->setState(QQmlDebugWatch::Dead); + } +} + +int QQmlEngineDebugClientPrivate::getId() +{ + return nextId++; +} + +void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugEnginesQuery *q) +{ + if (c && q) { + QQmlEngineDebugClientPrivate *p = c->getPrivate(); + p->enginesQuery.remove(q->m_queryId); + } +} + +void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, + QQmlDebugRootContextQuery *q) +{ + if (c && q) { + QQmlEngineDebugClientPrivate *p = c->getPrivate(); + p->rootContextQuery.remove(q->m_queryId); + } +} + +void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugObjectQuery *q) +{ + if (c && q) { + QQmlEngineDebugClientPrivate *p = c->getPrivate(); + p->objectQuery.remove(q->m_queryId); + } +} + +void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugExpressionQuery *q) +{ + if (c && q) { + QQmlEngineDebugClientPrivate *p = c->getPrivate(); + p->expressionQuery.remove(q->m_queryId); + } +} + +void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugWatch *w) +{ + if (c && w) { + QQmlEngineDebugClientPrivate *p = c->getPrivate(); + p->watched.remove(w->m_queryId); + } +} + +void QQmlEngineDebugClientPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o, + bool simple) +{ + QmlObjectData data; + ds >> data; + o.m_debugId = data.objectId; + o.m_class = data.objectType; + o.m_idString = data.idString; + o.m_name = data.objectName; + o.m_source.m_url = data.url; + o.m_source.m_lineNumber = data.lineNumber; + o.m_source.m_columnNumber = data.columnNumber; + o.m_contextDebugId = data.contextId; + + if (simple) + return; + + int childCount; + bool recur; + ds >> childCount >> recur; + + for (int ii = 0; ii < childCount; ++ii) { + o.m_children.append(QQmlDebugObjectReference()); + decode(ds, o.m_children.last(), !recur); + } + + int propCount; + ds >> propCount; + + for (int ii = 0; ii < propCount; ++ii) { + QmlObjectProperty data; + ds >> data; + QQmlDebugPropertyReference prop; + prop.m_objectDebugId = o.m_debugId; + prop.m_name = data.name; + prop.m_binding = data.binding; + prop.m_hasNotifySignal = data.hasNotifySignal; + prop.m_valueTypeName = data.valueTypeName; + switch (data.type) { + case QmlObjectProperty::Basic: + case QmlObjectProperty::List: + case QmlObjectProperty::SignalProperty: + { + prop.m_value = data.value; + break; + } + case QmlObjectProperty::Object: + { + QQmlDebugObjectReference obj; + obj.m_debugId = prop.m_value.toInt(); + prop.m_value = QVariant::fromValue(obj); + break; + } + case QmlObjectProperty::Unknown: + break; + } + o.m_properties << prop; + } +} + +void QQmlEngineDebugClientPrivate::decode(QDataStream &ds, QQmlDebugContextReference &c) +{ + ds >> c.m_name >> c.m_debugId; + + int contextCount; + ds >> contextCount; + + for (int ii = 0; ii < contextCount; ++ii) { + c.m_contexts.append(QQmlDebugContextReference()); + decode(ds, c.m_contexts.last()); + } + + int objectCount; + ds >> objectCount; + + for (int ii = 0; ii < objectCount; ++ii) { + QQmlDebugObjectReference obj; + decode(ds, obj, true); + + obj.m_contextDebugId = c.m_debugId; + c.m_objects << obj; + } +} + +void QQmlEngineDebugClientPrivate::message(const QByteArray &data) +{ + QDataStream ds(data); + + QByteArray type; + ds >> type; + + //qDebug() << "QQmlEngineDebugPrivate::message()" << type; + + if (type == "LIST_ENGINES_R") { + int queryId; + ds >> queryId; + + QQmlDebugEnginesQuery *query = enginesQuery.value(queryId); + if (!query) + return; + enginesQuery.remove(queryId); + + int count; + ds >> count; + + for (int ii = 0; ii < count; ++ii) { + QQmlDebugEngineReference ref; + ds >> ref.m_name; + ds >> ref.m_debugId; + query->m_engines << ref; + } + + query->m_client = 0; + query->setState(QQmlDebugQuery::Completed); + } else if (type == "LIST_OBJECTS_R") { + int queryId; + ds >> queryId; + + QQmlDebugRootContextQuery *query = rootContextQuery.value(queryId); + if (!query) + return; + rootContextQuery.remove(queryId); + + if (!ds.atEnd()) + decode(ds, query->m_context); + + query->m_client = 0; + query->setState(QQmlDebugQuery::Completed); + } else if (type == "FETCH_OBJECT_R") { + int queryId; + ds >> queryId; + + QQmlDebugObjectQuery *query = objectQuery.value(queryId); + if (!query) + return; + objectQuery.remove(queryId); + + if (!ds.atEnd()) + decode(ds, query->m_object, false); + + query->m_client = 0; + query->setState(QQmlDebugQuery::Completed); + } else if (type == "EVAL_EXPRESSION_R") { + int queryId; + QVariant result; + ds >> queryId >> result; + + QQmlDebugExpressionQuery *query = expressionQuery.value(queryId); + if (!query) + return; + expressionQuery.remove(queryId); + + query->m_result = result; + query->m_client = 0; + query->setState(QQmlDebugQuery::Completed); + } else if (type == "WATCH_PROPERTY_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QQmlDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); + } else if (type == "WATCH_OBJECT_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QQmlDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); + } else if (type == "WATCH_EXPR_OBJECT_R") { + int queryId; + bool ok; + ds >> queryId >> ok; + + QQmlDebugWatch *watch = watched.value(queryId); + if (!watch) + return; + + watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); + } else if (type == "UPDATE_WATCH") { + int queryId; + int debugId; + QByteArray name; + QVariant value; + ds >> queryId >> debugId >> name >> value; + + QQmlDebugWatch *watch = watched.value(queryId, 0); + if (!watch) + return; + emit watch->valueChanged(name, value); + } else if (type == "OBJECT_CREATED") { + emit q->newObjects(); + } else if (type == "SET_BINDING_R" || + type == "RESET_BINDING_R" || + type == "SET_METHOD_BODY_R" || + type == "NO_WATCH_R") { + bool valid; + ds >> valid; + } +} + +QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client) + : QQmlDebugClient(QLatin1String("QmlDebugger"), client), + d(new QQmlEngineDebugClientPrivate(this)) +{ +} + +QQmlEngineDebugClient::~QQmlEngineDebugClient() +{ + delete d; +} + +QQmlDebugPropertyWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugPropertyReference &property, QObject *parent) +{ + QQmlDebugPropertyWatch *watch = new QQmlDebugPropertyWatch(parent); + if (state() == QQmlDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = property.objectDebugId(); + watch->m_name = property.name(); + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); + sendMessage(message); + } else { + watch->m_state = QQmlDebugWatch::Dead; + } + + return watch; +} + +QQmlDebugWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugContextReference &, const QString &, QObject *) +{ + qWarning("QQmlEngineDebug::addWatch(): Not implemented"); + return 0; +} + +QQmlDebugObjectExpressionWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugObjectReference &object, const QString &expr, QObject *parent) +{ + QQmlDebugObjectExpressionWatch *watch = new QQmlDebugObjectExpressionWatch(parent); + if (state() == QQmlDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = object.debugId(); + watch->m_expr = expr; + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; + sendMessage(message); + } else { + watch->m_state = QQmlDebugWatch::Dead; + } + return watch; +} + +QQmlDebugWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugObjectReference &object, QObject *parent) +{ + QQmlDebugWatch *watch = new QQmlDebugWatch(parent); + if (state() == QQmlDebugClient::Enabled) { + int queryId = d->getId(); + watch->m_queryId = queryId; + watch->m_client = this; + watch->m_objectDebugId = object.debugId(); + d->watched.insert(queryId, watch); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); + sendMessage(message); + } else { + watch->m_state = QQmlDebugWatch::Dead; + } + + return watch; +} + +QQmlDebugWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugFileReference &, QObject *) +{ + qWarning("QQmlEngineDebug::addWatch(): Not implemented"); + return 0; +} + +void QQmlEngineDebugClient::removeWatch(QQmlDebugWatch *watch) +{ + if (!watch || !watch->m_client) + return; + + watch->m_client = 0; + watch->setState(QQmlDebugWatch::Inactive); + + d->watched.remove(watch->queryId()); + + if (state() == QQmlDebugClient::Enabled) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("NO_WATCH") << watch->queryId(); + sendMessage(message); + } +} + +QQmlDebugEnginesQuery *QQmlEngineDebugClient::queryAvailableEngines(QObject *parent) +{ + QQmlDebugEnginesQuery *query = new QQmlDebugEnginesQuery(parent); + if (state() == QQmlDebugClient::Enabled) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->enginesQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("LIST_ENGINES") << queryId; + sendMessage(message); + } else { + query->m_state = QQmlDebugQuery::Error; + } + + return query; +} + +QQmlDebugRootContextQuery *QQmlEngineDebugClient::queryRootContexts(const QQmlDebugEngineReference &engine, QObject *parent) +{ + QQmlDebugRootContextQuery *query = new QQmlDebugRootContextQuery(parent); + if (state() == QQmlDebugClient::Enabled && engine.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->rootContextQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); + sendMessage(message); + } else { + query->m_state = QQmlDebugQuery::Error; + } + + return query; +} + +QQmlDebugObjectQuery *QQmlEngineDebugClient::queryObject(const QQmlDebugObjectReference &object, QObject *parent) +{ + QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent); + if (state() == QQmlDebugClient::Enabled && object.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->objectQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() + << false << true; + sendMessage(message); + } else { + query->m_state = QQmlDebugQuery::Error; + } + + return query; +} + +QQmlDebugObjectQuery *QQmlEngineDebugClient::queryObjectRecursive(const QQmlDebugObjectReference &object, QObject *parent) +{ + QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent); + if (state() == QQmlDebugClient::Enabled && object.debugId() != -1) { + query->m_client = this; + int queryId = d->getId(); + query->m_queryId = queryId; + d->objectQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() + << true << true; + sendMessage(message); + } else { + query->m_state = QQmlDebugQuery::Error; + } + + return query; +} + +QQmlDebugExpressionQuery *QQmlEngineDebugClient::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) +{ + QQmlDebugExpressionQuery *query = new QQmlDebugExpressionQuery(parent); + if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) { + query->m_client = this; + query->m_expr = expr; + int queryId = d->getId(); + query->m_queryId = queryId; + d->expressionQuery.insert(queryId, query); + + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; + sendMessage(message); + } else { + query->m_state = QQmlDebugQuery::Error; + } + + return query; +} + +bool QQmlEngineDebugClient::setBindingForObject(int objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, + bool isLiteralValue, + QString source, int line) +{ + if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("SET_BINDING") << d->getId() << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; + sendMessage(message); + return true; + } else { + return false; + } +} + +bool QQmlEngineDebugClient::resetBindingForObject(int objectDebugId, const QString &propertyName) +{ + if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("RESET_BINDING") << d->getId() << objectDebugId << propertyName; + sendMessage(message); + return true; + } else { + return false; + } +} + +bool QQmlEngineDebugClient::setMethodBody(int objectDebugId, const QString &methodName, + const QString &methodBody) +{ + if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) { + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << QByteArray("SET_METHOD_BODY") << d->getId() << objectDebugId << methodName << methodBody; + sendMessage(message); + return true; + } else { + return false; + } +} + +QQmlDebugWatch::QQmlDebugWatch(QObject *parent) + : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) +{ +} + +QQmlDebugWatch::~QQmlDebugWatch() +{ + if (m_client && m_queryId != -1) + QQmlEngineDebugClientPrivate::remove(m_client, this); +} + +int QQmlDebugWatch::queryId() const +{ + return m_queryId; +} + +int QQmlDebugWatch::objectDebugId() const +{ + return m_objectDebugId; +} + +QQmlDebugWatch::State QQmlDebugWatch::state() const +{ + return m_state; +} + +void QQmlDebugWatch::setState(State s) +{ + if (m_state == s) + return; + m_state = s; + emit stateChanged(m_state); +} + +QQmlDebugPropertyWatch::QQmlDebugPropertyWatch(QObject *parent) + : QQmlDebugWatch(parent) +{ +} + +QString QQmlDebugPropertyWatch::name() const +{ + return m_name; +} + + +QQmlDebugObjectExpressionWatch::QQmlDebugObjectExpressionWatch(QObject *parent) + : QQmlDebugWatch(parent) +{ +} + +QString QQmlDebugObjectExpressionWatch::expression() const +{ + return m_expr; +} + + +QQmlDebugQuery::QQmlDebugQuery(QObject *parent) + : QObject(parent), m_state(Waiting) +{ +} + +QQmlDebugQuery::State QQmlDebugQuery::state() const +{ + return m_state; +} + +bool QQmlDebugQuery::isWaiting() const +{ + return m_state == Waiting; +} + +void QQmlDebugQuery::setState(State s) +{ + if (m_state == s) + return; + m_state = s; + emit stateChanged(m_state); +} + +QQmlDebugEnginesQuery::QQmlDebugEnginesQuery(QObject *parent) + : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QQmlDebugEnginesQuery::~QQmlDebugEnginesQuery() +{ + if (m_client && m_queryId != -1) + QQmlEngineDebugClientPrivate::remove(m_client, this); +} + +QList QQmlDebugEnginesQuery::engines() const +{ + return m_engines; +} + +QQmlDebugRootContextQuery::QQmlDebugRootContextQuery(QObject *parent) + : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QQmlDebugRootContextQuery::~QQmlDebugRootContextQuery() +{ + if (m_client && m_queryId != -1) + QQmlEngineDebugClientPrivate::remove(m_client, this); +} + +QQmlDebugContextReference QQmlDebugRootContextQuery::rootContext() const +{ + return m_context; +} + +QQmlDebugObjectQuery::QQmlDebugObjectQuery(QObject *parent) + : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QQmlDebugObjectQuery::~QQmlDebugObjectQuery() +{ + if (m_client && m_queryId != -1) + QQmlEngineDebugClientPrivate::remove(m_client, this); +} + +QQmlDebugObjectReference QQmlDebugObjectQuery::object() const +{ + return m_object; +} + +QQmlDebugExpressionQuery::QQmlDebugExpressionQuery(QObject *parent) + : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) +{ +} + +QQmlDebugExpressionQuery::~QQmlDebugExpressionQuery() +{ + if (m_client && m_queryId != -1) + QQmlEngineDebugClientPrivate::remove(m_client, this); +} + +QVariant QQmlDebugExpressionQuery::expression() const +{ + return m_expr; +} + +QVariant QQmlDebugExpressionQuery::result() const +{ + return m_result; +} + +QQmlDebugEngineReference::QQmlDebugEngineReference() + : m_debugId(-1) +{ +} + +QQmlDebugEngineReference::QQmlDebugEngineReference(int debugId) + : m_debugId(debugId) +{ +} + +QQmlDebugEngineReference::QQmlDebugEngineReference(const QQmlDebugEngineReference &o) + : m_debugId(o.m_debugId), m_name(o.m_name) +{ +} + +QQmlDebugEngineReference & +QQmlDebugEngineReference::operator=(const QQmlDebugEngineReference &o) +{ + m_debugId = o.m_debugId; m_name = o.m_name; + return *this; +} + +int QQmlDebugEngineReference::debugId() const +{ + return m_debugId; +} + +QString QQmlDebugEngineReference::name() const +{ + return m_name; +} + +QQmlDebugObjectReference::QQmlDebugObjectReference() + : m_debugId(-1), m_contextDebugId(-1) +{ +} + +QQmlDebugObjectReference::QQmlDebugObjectReference(int debugId) + : m_debugId(debugId), m_contextDebugId(-1) +{ +} + +QQmlDebugObjectReference::QQmlDebugObjectReference(const QQmlDebugObjectReference &o) + : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), + m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), + m_properties(o.m_properties), m_children(o.m_children) +{ +} + +QQmlDebugObjectReference & +QQmlDebugObjectReference::operator=(const QQmlDebugObjectReference &o) +{ + m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; + m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; + m_properties = o.m_properties; m_children = o.m_children; + return *this; +} + +int QQmlDebugObjectReference::debugId() const +{ + return m_debugId; +} + +QString QQmlDebugObjectReference::className() const +{ + return m_class; +} + +QString QQmlDebugObjectReference::idString() const +{ + return m_idString; +} + +QString QQmlDebugObjectReference::name() const +{ + return m_name; +} + +QQmlDebugFileReference QQmlDebugObjectReference::source() const +{ + return m_source; +} + +int QQmlDebugObjectReference::contextDebugId() const +{ + return m_contextDebugId; +} + +QList QQmlDebugObjectReference::properties() const +{ + return m_properties; +} + +QList QQmlDebugObjectReference::children() const +{ + return m_children; +} + +QQmlDebugContextReference::QQmlDebugContextReference() + : m_debugId(-1) +{ +} + +QQmlDebugContextReference::QQmlDebugContextReference(const QQmlDebugContextReference &o) + : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) +{ +} + +QQmlDebugContextReference &QQmlDebugContextReference::operator=(const QQmlDebugContextReference &o) +{ + m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; + m_contexts = o.m_contexts; + return *this; +} + +int QQmlDebugContextReference::debugId() const +{ + return m_debugId; +} + +QString QQmlDebugContextReference::name() const +{ + return m_name; +} + +QList QQmlDebugContextReference::objects() const +{ + return m_objects; +} + +QList QQmlDebugContextReference::contexts() const +{ + return m_contexts; +} + +QQmlDebugFileReference::QQmlDebugFileReference() + : m_lineNumber(-1), m_columnNumber(-1) +{ +} + +QQmlDebugFileReference::QQmlDebugFileReference(const QQmlDebugFileReference &o) + : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) +{ +} + +QQmlDebugFileReference &QQmlDebugFileReference::operator=(const QQmlDebugFileReference &o) +{ + m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; + return *this; +} + +QUrl QQmlDebugFileReference::url() const +{ + return m_url; +} + +void QQmlDebugFileReference::setUrl(const QUrl &u) +{ + m_url = u; +} + +int QQmlDebugFileReference::lineNumber() const +{ + return m_lineNumber; +} + +void QQmlDebugFileReference::setLineNumber(int l) +{ + m_lineNumber = l; +} + +int QQmlDebugFileReference::columnNumber() const +{ + return m_columnNumber; +} + +void QQmlDebugFileReference::setColumnNumber(int c) +{ + m_columnNumber = c; +} + +QQmlDebugPropertyReference::QQmlDebugPropertyReference() + : m_objectDebugId(-1), m_hasNotifySignal(false) +{ +} + +QQmlDebugPropertyReference::QQmlDebugPropertyReference(const QQmlDebugPropertyReference &o) + : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), + m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), + m_hasNotifySignal(o.m_hasNotifySignal) +{ +} + +QQmlDebugPropertyReference &QQmlDebugPropertyReference::operator=(const QQmlDebugPropertyReference &o) +{ + m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; + m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; + m_hasNotifySignal = o.m_hasNotifySignal; + return *this; +} + +int QQmlDebugPropertyReference::objectDebugId() const +{ + return m_objectDebugId; +} + +QString QQmlDebugPropertyReference::name() const +{ + return m_name; +} + +QString QQmlDebugPropertyReference::valueTypeName() const +{ + return m_valueTypeName; +} + +QVariant QQmlDebugPropertyReference::value() const +{ + return m_value; +} + +QString QQmlDebugPropertyReference::binding() const +{ + return m_binding; +} + +bool QQmlDebugPropertyReference::hasNotifySignal() const +{ + return m_hasNotifySignal; +} + diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h new file mode 100644 index 0000000..bf610af --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h @@ -0,0 +1,378 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt 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.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLENGINEDEBUGCLIENT_H +#define QQMLENGINEDEBUGCLIENT_H + +#include "qqmldebugclient.h" + +#include +#include + +class QQmlDebugConnection; +class QQmlDebugWatch; +class QQmlDebugPropertyWatch; +class QQmlDebugObjectExpressionWatch; +class QQmlDebugEnginesQuery; +class QQmlDebugRootContextQuery; +class QQmlDebugObjectQuery; +class QQmlDebugExpressionQuery; +class QQmlDebugPropertyReference; +class QQmlDebugContextReference; +class QQmlDebugObjectReference; +class QQmlDebugFileReference; +class QQmlDebugEngineReference; +class QQmlEngineDebugClientPrivate; +class QQmlEngineDebugClient : public QQmlDebugClient +{ + Q_OBJECT +public: + explicit QQmlEngineDebugClient(QQmlDebugConnection *); + ~QQmlEngineDebugClient(); + + QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &, + QObject *parent = 0); + QQmlDebugWatch *addWatch(const QQmlDebugContextReference &, const QString &, + QObject *parent = 0); + QQmlDebugObjectExpressionWatch *addWatch(const QQmlDebugObjectReference &, const QString &, + QObject *parent = 0); + QQmlDebugWatch *addWatch(const QQmlDebugObjectReference &, + QObject *parent = 0); + QQmlDebugWatch *addWatch(const QQmlDebugFileReference &, + QObject *parent = 0); + + void removeWatch(QQmlDebugWatch *watch); + + QQmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); + QQmlDebugRootContextQuery *queryRootContexts(const QQmlDebugEngineReference &, + QObject *parent = 0); + QQmlDebugObjectQuery *queryObject(const QQmlDebugObjectReference &, + QObject *parent = 0); + QQmlDebugObjectQuery *queryObjectRecursive(const QQmlDebugObjectReference &, + QObject *parent = 0); + QQmlDebugExpressionQuery *queryExpressionResult(int objectDebugId, + const QString &expr, + QObject *parent = 0); + bool setBindingForObject(int objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, bool isLiteralValue, + QString source = QString(), int line = -1); + bool resetBindingForObject(int objectDebugId, const QString &propertyName); + bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); + + QQmlEngineDebugClientPrivate *getPrivate() const { return d; } + +Q_SIGNALS: + void newObjects(); + void newState(State state); + +protected: + void stateChanged(State status); + void messageReceived(const QByteArray &data); + +private: + QQmlEngineDebugClientPrivate *d; +}; + +class QQmlDebugWatch : public QObject +{ + Q_OBJECT +public: + enum State { Waiting, Active, Inactive, Dead }; + + QQmlDebugWatch(QObject *); + ~QQmlDebugWatch(); + + int queryId() const; + int objectDebugId() const; + State state() const; + +Q_SIGNALS: + void stateChanged(QQmlDebugWatch::State); + //void objectChanged(int, const QQmlDebugObjectReference &); + //void valueChanged(int, const QVariant &); + + // Server sends value as string if it is a user-type variant + void valueChanged(const QByteArray &name, const QVariant &value); + +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + void setState(State); + State m_state; + int m_queryId; + QQmlEngineDebugClient *m_client; + int m_objectDebugId; +}; + +class QQmlDebugPropertyWatch : public QQmlDebugWatch +{ + Q_OBJECT +public: + QQmlDebugPropertyWatch(QObject *parent); + + QString name() const; + +private: + friend class QQmlEngineDebugClient; + QString m_name; +}; + +class QQmlDebugObjectExpressionWatch : public QQmlDebugWatch +{ + Q_OBJECT +public: + QQmlDebugObjectExpressionWatch(QObject *parent); + + QString expression() const; + +private: + friend class QQmlEngineDebugClient; + QString m_expr; + int m_debugId; +}; + + +class QQmlDebugQuery : public QObject +{ + Q_OBJECT +public: + enum State { Waiting, Error, Completed }; + + State state() const; + bool isWaiting() const; + +Q_SIGNALS: + void stateChanged(QQmlDebugQuery::State); + +protected: + QQmlDebugQuery(QObject *); + +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + void setState(State); + State m_state; +}; + +class QQmlDebugFileReference +{ +public: + QQmlDebugFileReference(); + QQmlDebugFileReference(const QQmlDebugFileReference &); + QQmlDebugFileReference &operator=(const QQmlDebugFileReference &); + + QUrl url() const; + void setUrl(const QUrl &); + int lineNumber() const; + void setLineNumber(int); + int columnNumber() const; + void setColumnNumber(int); + +private: + friend class QQmlEngineDebugClientPrivate; + QUrl m_url; + int m_lineNumber; + int m_columnNumber; +}; + +class QQmlDebugEngineReference +{ +public: + QQmlDebugEngineReference(); + QQmlDebugEngineReference(int); + QQmlDebugEngineReference(const QQmlDebugEngineReference &); + QQmlDebugEngineReference &operator=(const QQmlDebugEngineReference &); + + int debugId() const; + QString name() const; + +private: + friend class QQmlEngineDebugClientPrivate; + int m_debugId; + QString m_name; +}; + +class QQmlDebugObjectReference +{ +public: + QQmlDebugObjectReference(); + QQmlDebugObjectReference(int); + QQmlDebugObjectReference(const QQmlDebugObjectReference &); + QQmlDebugObjectReference &operator=(const QQmlDebugObjectReference &); + + int debugId() const; + QString className() const; + QString idString() const; + QString name() const; + + QQmlDebugFileReference source() const; + int contextDebugId() const; + + QList properties() const; + QList children() const; + +private: + friend class QQmlEngineDebugClientPrivate; + int m_debugId; + QString m_class; + QString m_idString; + QString m_name; + QQmlDebugFileReference m_source; + int m_contextDebugId; + QList m_properties; + QList m_children; +}; + +class QQmlDebugContextReference +{ +public: + QQmlDebugContextReference(); + QQmlDebugContextReference(const QQmlDebugContextReference &); + QQmlDebugContextReference &operator=(const QQmlDebugContextReference &); + + int debugId() const; + QString name() const; + + QList objects() const; + QList contexts() const; + +private: + friend class QQmlEngineDebugClientPrivate; + int m_debugId; + QString m_name; + QList m_objects; + QList m_contexts; +}; + +class QQmlDebugPropertyReference +{ +public: + QQmlDebugPropertyReference(); + QQmlDebugPropertyReference(const QQmlDebugPropertyReference &); + QQmlDebugPropertyReference &operator=(const QQmlDebugPropertyReference &); + + int objectDebugId() const; + QString name() const; + QVariant value() const; + QString valueTypeName() const; + QString binding() const; + bool hasNotifySignal() const; + +private: + friend class QQmlEngineDebugClientPrivate; + int m_objectDebugId; + QString m_name; + QVariant m_value; + QString m_valueTypeName; + QString m_binding; + bool m_hasNotifySignal; +}; + + +class QQmlDebugEnginesQuery : public QQmlDebugQuery +{ + Q_OBJECT +public: + virtual ~QQmlDebugEnginesQuery(); + QList engines() const; +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + QQmlDebugEnginesQuery(QObject *); + QQmlEngineDebugClient *m_client; + int m_queryId; + QList m_engines; +}; + +class QQmlDebugRootContextQuery : public QQmlDebugQuery +{ + Q_OBJECT +public: + virtual ~QQmlDebugRootContextQuery(); + QQmlDebugContextReference rootContext() const; +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + QQmlDebugRootContextQuery(QObject *); + QQmlEngineDebugClient *m_client; + int m_queryId; + QQmlDebugContextReference m_context; +}; + +class QQmlDebugObjectQuery : public QQmlDebugQuery +{ + Q_OBJECT +public: + virtual ~QQmlDebugObjectQuery(); + QQmlDebugObjectReference object() const; +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + QQmlDebugObjectQuery(QObject *); + QQmlEngineDebugClient *m_client; + int m_queryId; + QQmlDebugObjectReference m_object; + +}; + +class QQmlDebugExpressionQuery : public QQmlDebugQuery +{ + Q_OBJECT +public: + virtual ~QQmlDebugExpressionQuery(); + QVariant expression() const; + QVariant result() const; +private: + friend class QQmlEngineDebugClient; + friend class QQmlEngineDebugClientPrivate; + QQmlDebugExpressionQuery(QObject *); + QQmlEngineDebugClient *m_client; + int m_queryId; + QVariant m_expr; + QVariant m_result; +}; + +Q_DECLARE_METATYPE(QQmlDebugEngineReference) +Q_DECLARE_METATYPE(QQmlDebugObjectReference) +Q_DECLARE_METATYPE(QQmlDebugContextReference) +Q_DECLARE_METATYPE(QQmlDebugPropertyReference) + +#endif // QQMLENGINEDEBUGCLIENT_H diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro index 0b92a72..20fcd6d 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro @@ -2,7 +2,11 @@ CONFIG += testcase TARGET = tst_qqmlenginedebugservice macx:CONFIG -= app_bundle -SOURCES += tst_qqmlenginedebugservice.cpp +HEADERS += \ + qqmlenginedebugclient.h + +SOURCES += tst_qqmlenginedebugservice.cpp \ + qqmlenginedebugclient.cpp INCLUDEPATH += ../shared include(../shared/debugutil.pri) diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index e409f3c..cbb7e0f 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -59,7 +59,7 @@ #include #include "debugutil_p.h" -#include "qqmlenginedebug_p.h" +#include "qqmlenginedebugclient.h" Q_DECLARE_METATYPE(QQmlDebugWatch::State) @@ -79,7 +79,7 @@ private: void compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const; QQmlDebugConnection *m_conn; - QQmlEngineDebug *m_dbg; + QQmlEngineDebugClient *m_dbg; QQmlEngine *m_engine; QQuickItem *m_rootItem; @@ -394,13 +394,12 @@ void tst_QQmlEngineDebugService::initTestCase() bool ok = m_conn->waitForConnected(); QVERIFY(ok); QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); - m_dbg = new QQmlEngineDebug(m_conn, this); - QTRY_VERIFY(m_dbg->state() == QQmlEngineDebug::Enabled); + m_dbg = new QQmlEngineDebugClient(m_conn); + QTRY_VERIFY(m_dbg->state() == QQmlEngineDebugClient::Enabled); } void tst_QQmlEngineDebugService::cleanupTestCase() { - delete m_dbg; delete m_conn; qDeleteAll(m_components); delete m_engine; @@ -450,7 +449,7 @@ void tst_QQmlEngineDebugService::watch_property() QQmlDebugPropertyWatch *watch; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); watch = unconnected->addWatch(prop, this); QCOMPARE(watch->state(), QQmlDebugWatch::Dead); delete watch; @@ -510,7 +509,7 @@ void tst_QQmlEngineDebugService::watch_object() QQmlDebugWatch *watch; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); watch = unconnected->addWatch(obj, this); QCOMPARE(watch->state(), QQmlDebugWatch::Dead); delete watch; @@ -574,7 +573,7 @@ void tst_QQmlEngineDebugService::watch_expression() QQmlDebugObjectExpressionWatch *watch; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); watch = unconnected->addWatch(obj, expr, this); QCOMPARE(watch->state(), QQmlDebugWatch::Dead); delete watch; @@ -653,7 +652,7 @@ void tst_QQmlEngineDebugService::queryAvailableEngines() { QQmlDebugEnginesQuery *q_engines; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); q_engines = unconnected->queryAvailableEngines(0); QCOMPARE(q_engines->state(), QQmlDebugQuery::Error); delete q_engines; @@ -681,7 +680,7 @@ void tst_QQmlEngineDebugService::queryAvailableEngines() delete m_dbg; QCOMPARE(q_engines->state(), QQmlDebugQuery::Error); delete q_engines; - m_dbg = new QQmlEngineDebug(m_conn, this); + m_dbg = new QQmlEngineDebugClient(m_conn); } void tst_QQmlEngineDebugService::queryRootContexts() @@ -693,7 +692,7 @@ void tst_QQmlEngineDebugService::queryRootContexts() QQmlDebugRootContextQuery *q_context; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); q_context = unconnected->queryRootContexts(engineId, this); QCOMPARE(q_context->state(), QQmlDebugQuery::Error); delete q_context; @@ -724,7 +723,7 @@ void tst_QQmlEngineDebugService::queryRootContexts() delete m_dbg; QCOMPARE(q_context->state(), QQmlDebugQuery::Error); delete q_context; - m_dbg = new QQmlEngineDebug(m_conn, this); + m_dbg = new QQmlEngineDebugClient(m_conn); } void tst_QQmlEngineDebugService::queryObject() @@ -740,7 +739,7 @@ void tst_QQmlEngineDebugService::queryObject() QQmlDebugObjectQuery *q_obj = 0; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this); QCOMPARE(q_obj->state(), QQmlDebugQuery::Error); delete q_obj; @@ -763,7 +762,7 @@ void tst_QQmlEngineDebugService::queryObject() delete m_dbg; QCOMPARE(q_obj->state(), QQmlDebugQuery::Error); delete q_obj; - m_dbg = new QQmlEngineDebug(m_conn, this); + m_dbg = new QQmlEngineDebugClient(m_conn); // check source as defined in main() QQmlDebugFileReference source = obj.source(); @@ -821,7 +820,7 @@ void tst_QQmlEngineDebugService::queryExpressionResult() QQmlDebugExpressionQuery *q_expr; - QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); q_expr = unconnected->queryExpressionResult(objectId, expr, this); QCOMPARE(q_expr->state(), QQmlDebugQuery::Error); delete q_expr; @@ -845,7 +844,7 @@ void tst_QQmlEngineDebugService::queryExpressionResult() delete m_dbg; QCOMPARE(q_expr->state(), QQmlDebugQuery::Error); delete q_expr; - m_dbg = new QQmlEngineDebug(m_conn, this); + m_dbg = new QQmlEngineDebugClient(m_conn); } void tst_QQmlEngineDebugService::queryExpressionResult_data() diff --git a/tests/auto/qml/debugger/shared/debugutil.pri b/tests/auto/qml/debugger/shared/debugutil.pri index ddce647..cb9c761 100644 --- a/tests/auto/qml/debugger/shared/debugutil.pri +++ b/tests/auto/qml/debugger/shared/debugutil.pri @@ -1,10 +1,8 @@ HEADERS += $$PWD/debugutil_p.h \ $$PWD/qqmldebugclient.h \ - $$PWD/qqmlenginedebug_p.h \ $$PWD/../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h SOURCES += $$PWD/debugutil.cpp \ $$PWD/qqmldebugclient.cpp \ - $$PWD/qqmlenginedebug.cpp \ $$PWD/../../../../../src/plugins/qmltooling/shared/qpacketprotocol.cpp diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp deleted file mode 100644 index cfeb958..0000000 --- a/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt 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.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmlenginedebug_p.h" - -#include "qqmldebugclient.h" - -struct QmlObjectData { - QUrl url; - int lineNumber; - int columnNumber; - QString idString; - QString objectName; - QString objectType; - int objectId; - int contextId; -}; - -QDataStream &operator>>(QDataStream &ds, QmlObjectData &data) -{ - ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; - return ds; -} - -struct QmlObjectProperty { - enum Type { Unknown, Basic, Object, List, SignalProperty }; - Type type; - QString name; - QVariant value; - QString valueTypeName; - QString binding; - bool hasNotifySignal; -}; - -QDataStream &operator>>(QDataStream &ds, QmlObjectProperty &data) -{ - int type; - ds >> type >> data.name >> data.value >> data.valueTypeName - >> data.binding >> data.hasNotifySignal; - data.type = (QmlObjectProperty::Type)type; - return ds; -} - -class QQmlEngineDebugClient : public QQmlDebugClient -{ -public: - QQmlEngineDebugClient(QQmlDebugConnection *client, QQmlEngineDebugPrivate *p); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - QQmlEngineDebugPrivate *priv; - friend class QQmlEngineDebugPrivate; -}; - -class QQmlEngineDebugPrivate -{ -public: - QQmlEngineDebugPrivate(QQmlEngineDebug *, QQmlDebugConnection *); - ~QQmlEngineDebugPrivate(); - - void stateChanged(QQmlEngineDebug::State status); - void message(const QByteArray &); - - QQmlEngineDebug *q; - QQmlEngineDebugClient *client; - int nextId; - int getId(); - - void decode(QDataStream &, QQmlDebugContextReference &); - void decode(QDataStream &, QQmlDebugObjectReference &, bool simple); - - static void remove(QQmlEngineDebug *, QQmlDebugEnginesQuery *); - static void remove(QQmlEngineDebug *, QQmlDebugRootContextQuery *); - static void remove(QQmlEngineDebug *, QQmlDebugObjectQuery *); - static void remove(QQmlEngineDebug *, QQmlDebugExpressionQuery *); - static void remove(QQmlEngineDebug *, QQmlDebugWatch *); - - QHash enginesQuery; - QHash rootContextQuery; - QHash objectQuery; - QHash expressionQuery; - - QHash watched; -}; - -QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client, - QQmlEngineDebugPrivate *p) - : QQmlDebugClient(QLatin1String("QmlDebugger"), client), priv(p) -{ -} - -void QQmlEngineDebugClient::stateChanged(State status) -{ - if (priv) - priv->stateChanged(static_cast(status)); -} - -void QQmlEngineDebugClient::messageReceived(const QByteArray &data) -{ - if (priv) - priv->message(data); -} - -QQmlEngineDebugPrivate::QQmlEngineDebugPrivate(QQmlEngineDebug *p, QQmlDebugConnection *c) - : q(p), - client(new QQmlEngineDebugClient(c, this)), nextId(0) -{ -} - -QQmlEngineDebugPrivate::~QQmlEngineDebugPrivate() -{ - if (client) - client->priv = 0; - delete client; - - QHash::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QQmlDebugQuery::Waiting) - enginesIter.value()->setState(QQmlDebugQuery::Error); - } - - QHash::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QQmlDebugQuery::Waiting) - rootContextIter.value()->setState(QQmlDebugQuery::Error); - } - - QHash::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QQmlDebugQuery::Waiting) - objectIter.value()->setState(QQmlDebugQuery::Error); - } - - QHash::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QQmlDebugQuery::Waiting) - exprIter.value()->setState(QQmlDebugQuery::Error); - } - - QHash::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QQmlDebugWatch::Dead); - } -} - -int QQmlEngineDebugPrivate::getId() -{ - return nextId++; -} - -void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugEnginesQuery *q) -{ - if (c && q) { - QQmlEngineDebugPrivate *p = c->getPrivate(); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, - QQmlDebugRootContextQuery *q) -{ - if (c && q) { - QQmlEngineDebugPrivate *p = c->getPrivate(); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugObjectQuery *q) -{ - if (c && q) { - QQmlEngineDebugPrivate *p = c->getPrivate(); - p->objectQuery.remove(q->m_queryId); - } -} - -void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugExpressionQuery *q) -{ - if (c && q) { - QQmlEngineDebugPrivate *p = c->getPrivate(); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugWatch *w) -{ - if (c && w) { - QQmlEngineDebugPrivate *p = c->getPrivate(); - p->watched.remove(w->m_queryId); - } -} - -void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o, - bool simple) -{ - QmlObjectData data; - ds >> data; - o.m_debugId = data.objectId; - o.m_class = data.objectType; - o.m_idString = data.idString; - o.m_name = data.objectName; - o.m_source.m_url = data.url; - o.m_source.m_lineNumber = data.lineNumber; - o.m_source.m_columnNumber = data.columnNumber; - o.m_contextDebugId = data.contextId; - - if (simple) - return; - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QQmlDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } - - int propCount; - ds >> propCount; - - for (int ii = 0; ii < propCount; ++ii) { - QmlObjectProperty data; - ds >> data; - QQmlDebugPropertyReference prop; - prop.m_objectDebugId = o.m_debugId; - prop.m_name = data.name; - prop.m_binding = data.binding; - prop.m_hasNotifySignal = data.hasNotifySignal; - prop.m_valueTypeName = data.valueTypeName; - switch (data.type) { - case QmlObjectProperty::Basic: - case QmlObjectProperty::List: - case QmlObjectProperty::SignalProperty: - { - prop.m_value = data.value; - break; - } - case QmlObjectProperty::Object: - { - QQmlDebugObjectReference obj; - obj.m_debugId = prop.m_value.toInt(); - prop.m_value = QVariant::fromValue(obj); - break; - } - case QmlObjectProperty::Unknown: - break; - } - o.m_properties << prop; - } -} - -void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugContextReference &c) -{ - ds >> c.m_name >> c.m_debugId; - - int contextCount; - ds >> contextCount; - - for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QQmlDebugContextReference()); - decode(ds, c.m_contexts.last()); - } - - int objectCount; - ds >> objectCount; - - for (int ii = 0; ii < objectCount; ++ii) { - QQmlDebugObjectReference obj; - decode(ds, obj, true); - - obj.m_contextDebugId = c.m_debugId; - c.m_objects << obj; - } -} - -void QQmlEngineDebugPrivate::stateChanged(QQmlEngineDebug::State status) -{ - emit q->stateChanged(status); -} - -void QQmlEngineDebugPrivate::message(const QByteArray &data) -{ - QDataStream ds(data); - - QByteArray type; - ds >> type; - - //qDebug() << "QQmlEngineDebugPrivate::message()" << type; - - if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QQmlDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - - int count; - ds >> count; - - for (int ii = 0; ii < count; ++ii) { - QQmlDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; - } - - query->m_client = 0; - query->setState(QQmlDebugQuery::Completed); - } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QQmlDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QQmlDebugQuery::Completed); - } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QQmlDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QQmlDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QQmlDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QQmlDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QQmlDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QQmlDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QQmlDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QQmlDebugWatch::Active : QQmlDebugWatch::Inactive); - } else if (type == "UPDATE_WATCH") { - int queryId; - int debugId; - QByteArray name; - QVariant value; - ds >> queryId >> debugId >> name >> value; - - QQmlDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q->newObjects(); - } else if (type == "SET_BINDING_R" || - type == "RESET_BINDING_R" || - type == "SET_METHOD_BODY_R" || - type == "NO_WATCH_R") { - bool valid; - ds >> valid; - } -} - -QQmlEngineDebug::QQmlEngineDebug(QQmlDebugConnection *client, QObject *parent) - : QObject(parent), - d(new QQmlEngineDebugPrivate(this, client)) -{ -} - -QQmlEngineDebug::~QQmlEngineDebug() -{ - delete d; -} - -QQmlEngineDebug::State QQmlEngineDebug::state() const -{ - return static_cast(d->client->state()); -} - -QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReference &property, QObject *parent) -{ - QQmlDebugPropertyWatch *watch = new QQmlDebugPropertyWatch(parent); - if (d->client->state() == QQmlDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); - d->client->sendMessage(message); - } else { - watch->m_state = QQmlDebugWatch::Dead; - } - - return watch; -} - -QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugContextReference &, const QString &, QObject *) -{ - qWarning("QQmlEngineDebug::addWatch(): Not implemented"); - return 0; -} - -QQmlDebugObjectExpressionWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object, const QString &expr, QObject *parent) -{ - QQmlDebugObjectExpressionWatch *watch = new QQmlDebugObjectExpressionWatch(parent); - if (d->client->state() == QQmlDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; - d->client->sendMessage(message); - } else { - watch->m_state = QQmlDebugWatch::Dead; - } - return watch; -} - -QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object, QObject *parent) -{ - QQmlDebugWatch *watch = new QQmlDebugWatch(parent); - if (d->client->state() == QQmlDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); - d->client->sendMessage(message); - } else { - watch->m_state = QQmlDebugWatch::Dead; - } - - return watch; -} - -QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugFileReference &, QObject *) -{ - qWarning("QQmlEngineDebug::addWatch(): Not implemented"); - return 0; -} - -void QQmlEngineDebug::removeWatch(QQmlDebugWatch *watch) -{ - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QQmlDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - - if (d->client && d->client->state() == QQmlDebugClient::Enabled) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); - d->client->sendMessage(message); - } -} - -QQmlDebugEnginesQuery *QQmlEngineDebug::queryAvailableEngines(QObject *parent) -{ - QQmlDebugEnginesQuery *query = new QQmlDebugEnginesQuery(parent); - if (d->client->state() == QQmlDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; - d->client->sendMessage(message); - } else { - query->m_state = QQmlDebugQuery::Error; - } - - return query; -} - -QQmlDebugRootContextQuery *QQmlEngineDebug::queryRootContexts(const QQmlDebugEngineReference &engine, QObject *parent) -{ - QQmlDebugRootContextQuery *query = new QQmlDebugRootContextQuery(parent); - if (d->client->state() == QQmlDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); - d->client->sendMessage(message); - } else { - query->m_state = QQmlDebugQuery::Error; - } - - return query; -} - -QQmlDebugObjectQuery *QQmlEngineDebug::queryObject(const QQmlDebugObjectReference &object, QObject *parent) -{ - QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent); - if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; - d->client->sendMessage(message); - } else { - query->m_state = QQmlDebugQuery::Error; - } - - return query; -} - -QQmlDebugObjectQuery *QQmlEngineDebug::queryObjectRecursive(const QQmlDebugObjectReference &object, QObject *parent) -{ - QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent); - if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; - d->client->sendMessage(message); - } else { - query->m_state = QQmlDebugQuery::Error; - } - - return query; -} - -QQmlDebugExpressionQuery *QQmlEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) -{ - QQmlDebugExpressionQuery *query = new QQmlDebugExpressionQuery(parent); - if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; - d->client->sendMessage(message); - } else { - query->m_state = QQmlDebugQuery::Error; - } - - return query; -} - -bool QQmlEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) -{ - if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << d->getId() << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QQmlEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) -{ - if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << d->getId() << objectDebugId << propertyName; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QQmlEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) -{ - if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << d->getId() << objectDebugId << methodName << methodBody; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -QQmlDebugWatch::QQmlDebugWatch(QObject *parent) - : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QQmlDebugWatch::~QQmlDebugWatch() -{ - if (m_client && m_queryId != -1) - QQmlEngineDebugPrivate::remove(m_client, this); -} - -int QQmlDebugWatch::queryId() const -{ - return m_queryId; -} - -int QQmlDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QQmlDebugWatch::State QQmlDebugWatch::state() const -{ - return m_state; -} - -void QQmlDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QQmlDebugPropertyWatch::QQmlDebugPropertyWatch(QObject *parent) - : QQmlDebugWatch(parent) -{ -} - -QString QQmlDebugPropertyWatch::name() const -{ - return m_name; -} - - -QQmlDebugObjectExpressionWatch::QQmlDebugObjectExpressionWatch(QObject *parent) - : QQmlDebugWatch(parent) -{ -} - -QString QQmlDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QQmlDebugQuery::QQmlDebugQuery(QObject *parent) - : QObject(parent), m_state(Waiting) -{ -} - -QQmlDebugQuery::State QQmlDebugQuery::state() const -{ - return m_state; -} - -bool QQmlDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QQmlDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QQmlDebugEnginesQuery::QQmlDebugEnginesQuery(QObject *parent) - : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QQmlDebugEnginesQuery::~QQmlDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QQmlEngineDebugPrivate::remove(m_client, this); -} - -QList QQmlDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QQmlDebugRootContextQuery::QQmlDebugRootContextQuery(QObject *parent) - : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QQmlDebugRootContextQuery::~QQmlDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QQmlEngineDebugPrivate::remove(m_client, this); -} - -QQmlDebugContextReference QQmlDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QQmlDebugObjectQuery::QQmlDebugObjectQuery(QObject *parent) - : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QQmlDebugObjectQuery::~QQmlDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QQmlEngineDebugPrivate::remove(m_client, this); -} - -QQmlDebugObjectReference QQmlDebugObjectQuery::object() const -{ - return m_object; -} - -QQmlDebugExpressionQuery::QQmlDebugExpressionQuery(QObject *parent) - : QQmlDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QQmlDebugExpressionQuery::~QQmlDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QQmlEngineDebugPrivate::remove(m_client, this); -} - -QVariant QQmlDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QQmlDebugExpressionQuery::result() const -{ - return m_result; -} - -QQmlDebugEngineReference::QQmlDebugEngineReference() - : m_debugId(-1) -{ -} - -QQmlDebugEngineReference::QQmlDebugEngineReference(int debugId) - : m_debugId(debugId) -{ -} - -QQmlDebugEngineReference::QQmlDebugEngineReference(const QQmlDebugEngineReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QQmlDebugEngineReference & -QQmlDebugEngineReference::operator=(const QQmlDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QQmlDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QQmlDebugEngineReference::name() const -{ - return m_name; -} - -QQmlDebugObjectReference::QQmlDebugObjectReference() - : m_debugId(-1), m_contextDebugId(-1) -{ -} - -QQmlDebugObjectReference::QQmlDebugObjectReference(int debugId) - : m_debugId(debugId), m_contextDebugId(-1) -{ -} - -QQmlDebugObjectReference::QQmlDebugObjectReference(const QQmlDebugObjectReference &o) - : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), - m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) -{ -} - -QQmlDebugObjectReference & -QQmlDebugObjectReference::operator=(const QQmlDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QQmlDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QQmlDebugObjectReference::className() const -{ - return m_class; -} - -QString QQmlDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QQmlDebugObjectReference::name() const -{ - return m_name; -} - -QQmlDebugFileReference QQmlDebugObjectReference::source() const -{ - return m_source; -} - -int QQmlDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList QQmlDebugObjectReference::properties() const -{ - return m_properties; -} - -QList QQmlDebugObjectReference::children() const -{ - return m_children; -} - -QQmlDebugContextReference::QQmlDebugContextReference() - : m_debugId(-1) -{ -} - -QQmlDebugContextReference::QQmlDebugContextReference(const QQmlDebugContextReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) -{ -} - -QQmlDebugContextReference &QQmlDebugContextReference::operator=(const QQmlDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QQmlDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QQmlDebugContextReference::name() const -{ - return m_name; -} - -QList QQmlDebugContextReference::objects() const -{ - return m_objects; -} - -QList QQmlDebugContextReference::contexts() const -{ - return m_contexts; -} - -QQmlDebugFileReference::QQmlDebugFileReference() - : m_lineNumber(-1), m_columnNumber(-1) -{ -} - -QQmlDebugFileReference::QQmlDebugFileReference(const QQmlDebugFileReference &o) - : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) -{ -} - -QQmlDebugFileReference &QQmlDebugFileReference::operator=(const QQmlDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QQmlDebugFileReference::url() const -{ - return m_url; -} - -void QQmlDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QQmlDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QQmlDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QQmlDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QQmlDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QQmlDebugPropertyReference::QQmlDebugPropertyReference() - : m_objectDebugId(-1), m_hasNotifySignal(false) -{ -} - -QQmlDebugPropertyReference::QQmlDebugPropertyReference(const QQmlDebugPropertyReference &o) - : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), - m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), - m_hasNotifySignal(o.m_hasNotifySignal) -{ -} - -QQmlDebugPropertyReference &QQmlDebugPropertyReference::operator=(const QQmlDebugPropertyReference &o) -{ - m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; - m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; - m_hasNotifySignal = o.m_hasNotifySignal; - return *this; -} - -int QQmlDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QQmlDebugPropertyReference::name() const -{ - return m_name; -} - -QString QQmlDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QQmlDebugPropertyReference::value() const -{ - return m_value; -} - -QString QQmlDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QQmlDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; -} - diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h b/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h deleted file mode 100644 index 2644346..0000000 --- a/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt 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.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLENGINEDEBUG_H -#define QQMLENGINEDEBUG_H - -#include -#include -#include - -class QQmlDebugConnection; -class QQmlDebugWatch; -class QQmlDebugPropertyWatch; -class QQmlDebugObjectExpressionWatch; -class QQmlDebugEnginesQuery; -class QQmlDebugRootContextQuery; -class QQmlDebugObjectQuery; -class QQmlDebugExpressionQuery; -class QQmlDebugPropertyReference; -class QQmlDebugContextReference; -class QQmlDebugObjectReference; -class QQmlDebugFileReference; -class QQmlDebugEngineReference; -class QQmlEngineDebugPrivate; -class QQmlEngineDebug : public QObject -{ - Q_OBJECT -public: - enum State { NotConnected, Unavailable, Enabled }; - - explicit QQmlEngineDebug(QQmlDebugConnection *, QObject * = 0); - ~QQmlEngineDebug(); - - State state() const; - - QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &, - QObject *parent = 0); - QQmlDebugWatch *addWatch(const QQmlDebugContextReference &, const QString &, - QObject *parent = 0); - QQmlDebugObjectExpressionWatch *addWatch(const QQmlDebugObjectReference &, const QString &, - QObject *parent = 0); - QQmlDebugWatch *addWatch(const QQmlDebugObjectReference &, - QObject *parent = 0); - QQmlDebugWatch *addWatch(const QQmlDebugFileReference &, - QObject *parent = 0); - - void removeWatch(QQmlDebugWatch *watch); - - QQmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); - QQmlDebugRootContextQuery *queryRootContexts(const QQmlDebugEngineReference &, - QObject *parent = 0); - QQmlDebugObjectQuery *queryObject(const QQmlDebugObjectReference &, - QObject *parent = 0); - QQmlDebugObjectQuery *queryObjectRecursive(const QQmlDebugObjectReference &, - QObject *parent = 0); - QQmlDebugExpressionQuery *queryExpressionResult(int objectDebugId, - const QString &expr, - QObject *parent = 0); - bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue, - QString source = QString(), int line = -1); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); - - QQmlEngineDebugPrivate *getPrivate() const { return d; } - -Q_SIGNALS: - void newObjects(); - void stateChanged(State state); - -private: - QQmlEngineDebugPrivate *d; -}; - -class QQmlDebugWatch : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Active, Inactive, Dead }; - - QQmlDebugWatch(QObject *); - ~QQmlDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QQmlDebugWatch::State); - //void objectChanged(int, const QQmlDebugObjectReference &); - //void valueChanged(int, const QVariant &); - - // Server sends value as string if it is a user-type variant - void valueChanged(const QByteArray &name, const QVariant &value); - -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - void setState(State); - State m_state; - int m_queryId; - QQmlEngineDebug *m_client; - int m_objectDebugId; -}; - -class QQmlDebugPropertyWatch : public QQmlDebugWatch -{ - Q_OBJECT -public: - QQmlDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QQmlEngineDebug; - QString m_name; -}; - -class QQmlDebugObjectExpressionWatch : public QQmlDebugWatch -{ - Q_OBJECT -public: - QQmlDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QQmlEngineDebug; - QString m_expr; - int m_debugId; -}; - - -class QQmlDebugQuery : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -Q_SIGNALS: - void stateChanged(QQmlDebugQuery::State); - -protected: - QQmlDebugQuery(QObject *); - -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - void setState(State); - State m_state; -}; - -class QQmlDebugFileReference -{ -public: - QQmlDebugFileReference(); - QQmlDebugFileReference(const QQmlDebugFileReference &); - QQmlDebugFileReference &operator=(const QQmlDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QQmlEngineDebugPrivate; - QUrl m_url; - int m_lineNumber; - int m_columnNumber; -}; - -class QQmlDebugEngineReference -{ -public: - QQmlDebugEngineReference(); - QQmlDebugEngineReference(int); - QQmlDebugEngineReference(const QQmlDebugEngineReference &); - QQmlDebugEngineReference &operator=(const QQmlDebugEngineReference &); - - int debugId() const; - QString name() const; - -private: - friend class QQmlEngineDebugPrivate; - int m_debugId; - QString m_name; -}; - -class QQmlDebugObjectReference -{ -public: - QQmlDebugObjectReference(); - QQmlDebugObjectReference(int); - QQmlDebugObjectReference(const QQmlDebugObjectReference &); - QQmlDebugObjectReference &operator=(const QQmlDebugObjectReference &); - - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; - - QQmlDebugFileReference source() const; - int contextDebugId() const; - - QList properties() const; - QList children() const; - -private: - friend class QQmlEngineDebugPrivate; - int m_debugId; - QString m_class; - QString m_idString; - QString m_name; - QQmlDebugFileReference m_source; - int m_contextDebugId; - QList m_properties; - QList m_children; -}; - -class QQmlDebugContextReference -{ -public: - QQmlDebugContextReference(); - QQmlDebugContextReference(const QQmlDebugContextReference &); - QQmlDebugContextReference &operator=(const QQmlDebugContextReference &); - - int debugId() const; - QString name() const; - - QList objects() const; - QList contexts() const; - -private: - friend class QQmlEngineDebugPrivate; - int m_debugId; - QString m_name; - QList m_objects; - QList m_contexts; -}; - -class QQmlDebugPropertyReference -{ -public: - QQmlDebugPropertyReference(); - QQmlDebugPropertyReference(const QQmlDebugPropertyReference &); - QQmlDebugPropertyReference &operator=(const QQmlDebugPropertyReference &); - - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; - -private: - friend class QQmlEngineDebugPrivate; - int m_objectDebugId; - QString m_name; - QVariant m_value; - QString m_valueTypeName; - QString m_binding; - bool m_hasNotifySignal; -}; - - -class QQmlDebugEnginesQuery : public QQmlDebugQuery -{ - Q_OBJECT -public: - virtual ~QQmlDebugEnginesQuery(); - QList engines() const; -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - QQmlDebugEnginesQuery(QObject *); - QQmlEngineDebug *m_client; - int m_queryId; - QList m_engines; -}; - -class QQmlDebugRootContextQuery : public QQmlDebugQuery -{ - Q_OBJECT -public: - virtual ~QQmlDebugRootContextQuery(); - QQmlDebugContextReference rootContext() const; -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - QQmlDebugRootContextQuery(QObject *); - QQmlEngineDebug *m_client; - int m_queryId; - QQmlDebugContextReference m_context; -}; - -class QQmlDebugObjectQuery : public QQmlDebugQuery -{ - Q_OBJECT -public: - virtual ~QQmlDebugObjectQuery(); - QQmlDebugObjectReference object() const; -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - QQmlDebugObjectQuery(QObject *); - QQmlEngineDebug *m_client; - int m_queryId; - QQmlDebugObjectReference m_object; - -}; - -class QQmlDebugExpressionQuery : public QQmlDebugQuery -{ - Q_OBJECT -public: - virtual ~QQmlDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QQmlEngineDebug; - friend class QQmlEngineDebugPrivate; - QQmlDebugExpressionQuery(QObject *); - QQmlEngineDebug *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - -Q_DECLARE_METATYPE(QQmlDebugEngineReference) -Q_DECLARE_METATYPE(QQmlDebugObjectReference) -Q_DECLARE_METATYPE(QQmlDebugContextReference) -Q_DECLARE_METATYPE(QQmlDebugPropertyReference) - -#endif // QQMLENGINEDEBUG_H -- 1.7.2.5