QmlEngineDebug: Rename to QmlEngineDebugClient in AutoTest
authorAurindam Jana <aurindam.jana@nokia.com>
Tue, 13 Mar 2012 16:16:16 +0000 (17:16 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Mar 2012 16:07:15 +0000 (17:07 +0100)
Change-Id: If20b53d2e47cdc4ed54df0d9360ae1b0566489c6
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp [moved from tests/auto/qml/debugger/shared/qqmlenginedebug.cpp with 80% similarity]
tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h [moved from tests/auto/qml/debugger/shared/qqmlenginedebug_p.h with 85% similarity]
tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
tests/auto/qml/debugger/shared/debugutil.pri

@@ -39,9 +39,7 @@
 **
 ****************************************************************************/
 
-#include "qqmlenginedebug_p.h"
-
-#include "qqmldebugclient.h"
+#include "qqmlenginedebugclient.h"
 
 struct QmlObjectData {
     QUrl url;
@@ -80,42 +78,26 @@ QDataStream &operator>>(QDataStream &ds, QmlObjectProperty &data)
     return ds;
 }
 
-class QQmlEngineDebugClient : public QQmlDebugClient
+class QQmlEngineDebugClientPrivate
 {
 public:
-    QQmlEngineDebugClient(QQmlDebugConnection *client, QQmlEngineDebugPrivate *p);
-
-protected:
-    virtual void stateChanged(State state);
-    virtual void messageReceived(const QByteArray &);
+    QQmlEngineDebugClientPrivate(QQmlEngineDebugClient *);
+    ~QQmlEngineDebugClientPrivate();
 
-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;
+    QQmlEngineDebugClient *q;
     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 *);
+    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<int, QQmlDebugEnginesQuery *> enginesQuery;
     QHash<int, QQmlDebugRootContextQuery *> rootContextQuery;
@@ -125,36 +107,24 @@ public:
     QHash<int, QQmlDebugWatch *> watched;
 };
 
-QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client,
-                                                             QQmlEngineDebugPrivate *p)
-    : QQmlDebugClient(QLatin1String("QmlDebugger"), client), priv(p)
-{
-}
-
 void QQmlEngineDebugClient::stateChanged(State status)
 {
-    if (priv)
-        priv->stateChanged(static_cast<QQmlEngineDebug::State>(status));
+    emit newState(status);
 }
 
 void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
 {
-    if (priv)
-        priv->message(data);
+    d->message(data);
 }
 
-QQmlEngineDebugPrivate::QQmlEngineDebugPrivate(QQmlEngineDebug *p, QQmlDebugConnection *c)
+QQmlEngineDebugClientPrivate::QQmlEngineDebugClientPrivate(QQmlEngineDebugClient *p)
     : q(p),
-      client(new QQmlEngineDebugClient(c, this)), nextId(0)
+      nextId(0)
 {
 }
 
-QQmlEngineDebugPrivate::~QQmlEngineDebugPrivate()
+QQmlEngineDebugClientPrivate::~QQmlEngineDebugClientPrivate()
 {
-    if (client)
-        client->priv = 0;
-    delete client;
-
     QHash<int, QQmlDebugEnginesQuery*>::iterator enginesIter = enginesQuery.begin();
     for (; enginesIter != enginesQuery.end(); ++enginesIter) {
         enginesIter.value()->m_client = 0;
@@ -190,53 +160,53 @@ QQmlEngineDebugPrivate::~QQmlEngineDebugPrivate()
     }
 }
 
-int QQmlEngineDebugPrivate::getId()
+int QQmlEngineDebugClientPrivate::getId()
 {
     return nextId++;
 }
 
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugEnginesQuery *q)
+void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugEnginesQuery *q)
 {
     if (c && q) {
-        QQmlEngineDebugPrivate *p = c->getPrivate();
+        QQmlEngineDebugClientPrivate *p = c->getPrivate();
         p->enginesQuery.remove(q->m_queryId);
     }
 }
 
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, 
+void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c,
                                             QQmlDebugRootContextQuery *q)
 {
     if (c && q) {
-        QQmlEngineDebugPrivate *p = c->getPrivate();
+        QQmlEngineDebugClientPrivate *p = c->getPrivate();
         p->rootContextQuery.remove(q->m_queryId);
     }
 }
 
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugObjectQuery *q)
+void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugObjectQuery *q)
 {
     if (c && q) {
-        QQmlEngineDebugPrivate *p = c->getPrivate();
+        QQmlEngineDebugClientPrivate *p = c->getPrivate();
         p->objectQuery.remove(q->m_queryId);
     }
 }
 
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugExpressionQuery *q)
+void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugExpressionQuery *q)
 {
     if (c && q) {
-        QQmlEngineDebugPrivate *p = c->getPrivate();
+        QQmlEngineDebugClientPrivate *p = c->getPrivate();
         p->expressionQuery.remove(q->m_queryId);
     }
 }
 
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugWatch *w)
+void QQmlEngineDebugClientPrivate::remove(QQmlEngineDebugClient *c, QQmlDebugWatch *w)
 {
     if (c && w) {
-        QQmlEngineDebugPrivate *p = c->getPrivate();
+        QQmlEngineDebugClientPrivate *p = c->getPrivate();
         p->watched.remove(w->m_queryId);
     }
 }
 
-void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o,
+void QQmlEngineDebugClientPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o,
                                             bool simple)
 {
     QmlObjectData data;
@@ -296,7 +266,7 @@ void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o
     }
 }
 
-void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugContextReference &c)
+void QQmlEngineDebugClientPrivate::decode(QDataStream &ds, QQmlDebugContextReference &c)
 {
     ds >> c.m_name >> c.m_debugId;
 
@@ -320,12 +290,7 @@ void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugContextReference &
     }
 }
 
-void QQmlEngineDebugPrivate::stateChanged(QQmlEngineDebug::State status)
-{
-    emit q->stateChanged(status);
-}
-
-void QQmlEngineDebugPrivate::message(const QByteArray &data)
+void QQmlEngineDebugClientPrivate::message(const QByteArray &data)
 {
     QDataStream ds(data);
 
@@ -448,26 +413,21 @@ void QQmlEngineDebugPrivate::message(const QByteArray &data)
     }
 }
 
-QQmlEngineDebug::QQmlEngineDebug(QQmlDebugConnection *client, QObject *parent)
-    : QObject(parent),
-      d(new QQmlEngineDebugPrivate(this, client))
+QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client)
+    : QQmlDebugClient(QLatin1String("QmlDebugger"), client),
+      d(new QQmlEngineDebugClientPrivate(this))
 {
 }
 
-QQmlEngineDebug::~QQmlEngineDebug()
+QQmlEngineDebugClient::~QQmlEngineDebugClient()
 {
     delete d;
 }
 
-QQmlEngineDebug::State QQmlEngineDebug::state() const
-{
-    return static_cast<QQmlEngineDebug::State>(d->client->state());
-}
-
-QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReference &property, QObject *parent)
+QQmlDebugPropertyWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugPropertyReference &property, QObject *parent)
 {
     QQmlDebugPropertyWatch *watch = new QQmlDebugPropertyWatch(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled) {
+    if (state() == QQmlDebugClient::Enabled) {
         int queryId = d->getId();
         watch->m_queryId = queryId;
         watch->m_client = this;
@@ -478,7 +438,7 @@ QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReferen
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8();
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         watch->m_state = QQmlDebugWatch::Dead;
     }
@@ -486,16 +446,16 @@ QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReferen
     return watch;
 }
 
-QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugContextReference &, const QString &, QObject *)
+QQmlDebugWatch *QQmlEngineDebugClient::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 *QQmlEngineDebugClient::addWatch(const QQmlDebugObjectReference &object, const QString &expr, QObject *parent)
 {
     QQmlDebugObjectExpressionWatch *watch = new QQmlDebugObjectExpressionWatch(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled) {
+    if (state() == QQmlDebugClient::Enabled) {
         int queryId = d->getId();
         watch->m_queryId = queryId;
         watch->m_client = this;
@@ -506,17 +466,17 @@ QQmlDebugObjectExpressionWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectR
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         watch->m_state = QQmlDebugWatch::Dead;
     }
     return watch;
 }
 
-QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object, QObject *parent)
+QQmlDebugWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugObjectReference &object, QObject *parent)
 {
     QQmlDebugWatch *watch = new QQmlDebugWatch(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled) {
+    if (state() == QQmlDebugClient::Enabled) {
         int queryId = d->getId();
         watch->m_queryId = queryId;
         watch->m_client = this;
@@ -526,7 +486,7 @@ QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         watch->m_state = QQmlDebugWatch::Dead;
     }
@@ -534,13 +494,13 @@ QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugObjectReference &object
     return watch;
 }
 
-QQmlDebugWatch *QQmlEngineDebug::addWatch(const QQmlDebugFileReference &, QObject *)
+QQmlDebugWatch *QQmlEngineDebugClient::addWatch(const QQmlDebugFileReference &, QObject *)
 {
     qWarning("QQmlEngineDebug::addWatch(): Not implemented");
     return 0;
 }
 
-void QQmlEngineDebug::removeWatch(QQmlDebugWatch *watch)
+void QQmlEngineDebugClient::removeWatch(QQmlDebugWatch *watch)
 {
     if (!watch || !watch->m_client)
         return;
@@ -550,18 +510,18 @@ void QQmlEngineDebug::removeWatch(QQmlDebugWatch *watch)
     
     d->watched.remove(watch->queryId());
 
-    if (d->client && d->client->state() == QQmlDebugClient::Enabled) {
+    if (state() == QQmlDebugClient::Enabled) {
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("NO_WATCH") << watch->queryId();
-        d->client->sendMessage(message);
+        sendMessage(message);
     }
 }
 
-QQmlDebugEnginesQuery *QQmlEngineDebug::queryAvailableEngines(QObject *parent)
+QQmlDebugEnginesQuery *QQmlEngineDebugClient::queryAvailableEngines(QObject *parent)
 {
     QQmlDebugEnginesQuery *query = new QQmlDebugEnginesQuery(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled) {
+    if (state() == QQmlDebugClient::Enabled) {
         query->m_client = this;
         int queryId = d->getId();
         query->m_queryId = queryId;
@@ -570,7 +530,7 @@ QQmlDebugEnginesQuery *QQmlEngineDebug::queryAvailableEngines(QObject *parent)
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("LIST_ENGINES") << queryId;
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         query->m_state = QQmlDebugQuery::Error;
     }
@@ -578,10 +538,10 @@ QQmlDebugEnginesQuery *QQmlEngineDebug::queryAvailableEngines(QObject *parent)
     return query;
 }
 
-QQmlDebugRootContextQuery *QQmlEngineDebug::queryRootContexts(const QQmlDebugEngineReference &engine, QObject *parent)
+QQmlDebugRootContextQuery *QQmlEngineDebugClient::queryRootContexts(const QQmlDebugEngineReference &engine, QObject *parent)
 {
     QQmlDebugRootContextQuery *query = new QQmlDebugRootContextQuery(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled && engine.debugId() != -1) {
+    if (state() == QQmlDebugClient::Enabled && engine.debugId() != -1) {
         query->m_client = this;
         int queryId = d->getId();
         query->m_queryId = queryId;
@@ -590,7 +550,7 @@ QQmlDebugRootContextQuery *QQmlEngineDebug::queryRootContexts(const QQmlDebugEng
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId();
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         query->m_state = QQmlDebugQuery::Error;
     }
@@ -598,10 +558,10 @@ QQmlDebugRootContextQuery *QQmlEngineDebug::queryRootContexts(const QQmlDebugEng
     return query;
 }
 
-QQmlDebugObjectQuery *QQmlEngineDebug::queryObject(const QQmlDebugObjectReference &object, QObject *parent)
+QQmlDebugObjectQuery *QQmlEngineDebugClient::queryObject(const QQmlDebugObjectReference &object, QObject *parent)
 {
     QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
+    if (state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
         query->m_client = this;
         int queryId = d->getId();
         query->m_queryId = queryId;
@@ -611,7 +571,7 @@ QQmlDebugObjectQuery *QQmlEngineDebug::queryObject(const QQmlDebugObjectReferenc
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
            << false << true;
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         query->m_state = QQmlDebugQuery::Error;
     }
@@ -619,10 +579,10 @@ QQmlDebugObjectQuery *QQmlEngineDebug::queryObject(const QQmlDebugObjectReferenc
     return query;
 }
 
-QQmlDebugObjectQuery *QQmlEngineDebug::queryObjectRecursive(const QQmlDebugObjectReference &object, QObject *parent)
+QQmlDebugObjectQuery *QQmlEngineDebugClient::queryObjectRecursive(const QQmlDebugObjectReference &object, QObject *parent)
 {
     QQmlDebugObjectQuery *query = new QQmlDebugObjectQuery(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
+    if (state() == QQmlDebugClient::Enabled && object.debugId() != -1) {
         query->m_client = this;
         int queryId = d->getId();
         query->m_queryId = queryId;
@@ -632,7 +592,7 @@ QQmlDebugObjectQuery *QQmlEngineDebug::queryObjectRecursive(const QQmlDebugObjec
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
            << true << true;
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         query->m_state = QQmlDebugQuery::Error;
     }
@@ -640,10 +600,10 @@ QQmlDebugObjectQuery *QQmlEngineDebug::queryObjectRecursive(const QQmlDebugObjec
     return query;
 }
 
-QQmlDebugExpressionQuery *QQmlEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
+QQmlDebugExpressionQuery *QQmlEngineDebugClient::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
 {
     QQmlDebugExpressionQuery *query = new QQmlDebugExpressionQuery(parent);
-    if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+    if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
         query->m_client = this;
         query->m_expr = expr;
         int queryId = d->getId();
@@ -653,7 +613,7 @@ QQmlDebugExpressionQuery *QQmlEngineDebug::queryExpressionResult(int objectDebug
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr;
-        d->client->sendMessage(message);
+        sendMessage(message);
     } else {
         query->m_state = QQmlDebugQuery::Error;
     }
@@ -661,43 +621,43 @@ QQmlDebugExpressionQuery *QQmlEngineDebug::queryExpressionResult(int objectDebug
     return query;
 }
 
-bool QQmlEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName,
+bool QQmlEngineDebugClient::setBindingForObject(int objectDebugId, const QString &propertyName,
                                                   const QVariant &bindingExpression,
                                                   bool isLiteralValue,
                                                   QString source, int line)
 {
-    if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+    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;
-        d->client->sendMessage(message);
+        sendMessage(message);
         return true;
     } else {
         return false;
     }
 }
 
-bool QQmlEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName)
+bool QQmlEngineDebugClient::resetBindingForObject(int objectDebugId, const QString &propertyName)
 {
-    if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+    if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
         QByteArray message;
         QDataStream ds(&message, QIODevice::WriteOnly);
         ds << QByteArray("RESET_BINDING") << d->getId() << objectDebugId << propertyName;
-        d->client->sendMessage(message);
+        sendMessage(message);
         return true;
     } else {
         return false;
     }
 }
 
-bool QQmlEngineDebug::setMethodBody(int objectDebugId, const QString &methodName,
+bool QQmlEngineDebugClient::setMethodBody(int objectDebugId, const QString &methodName,
                                             const QString &methodBody)
 {
-    if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+    if (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);
+        sendMessage(message);
         return true;
     } else {
         return false;
@@ -712,7 +672,7 @@ QQmlDebugWatch::QQmlDebugWatch(QObject *parent)
 QQmlDebugWatch::~QQmlDebugWatch()
 {
     if (m_client && m_queryId != -1)
-        QQmlEngineDebugPrivate::remove(m_client, this);
+        QQmlEngineDebugClientPrivate::remove(m_client, this);
 }
 
 int QQmlDebugWatch::queryId() const
@@ -791,7 +751,7 @@ QQmlDebugEnginesQuery::QQmlDebugEnginesQuery(QObject *parent)
 QQmlDebugEnginesQuery::~QQmlDebugEnginesQuery()
 {
     if (m_client && m_queryId != -1)
-        QQmlEngineDebugPrivate::remove(m_client, this);
+        QQmlEngineDebugClientPrivate::remove(m_client, this);
 }
 
 QList<QQmlDebugEngineReference> QQmlDebugEnginesQuery::engines() const
@@ -807,7 +767,7 @@ QQmlDebugRootContextQuery::QQmlDebugRootContextQuery(QObject *parent)
 QQmlDebugRootContextQuery::~QQmlDebugRootContextQuery()
 {
     if (m_client && m_queryId != -1)
-        QQmlEngineDebugPrivate::remove(m_client, this);
+        QQmlEngineDebugClientPrivate::remove(m_client, this);
 }
 
 QQmlDebugContextReference QQmlDebugRootContextQuery::rootContext() const
@@ -823,7 +783,7 @@ QQmlDebugObjectQuery::QQmlDebugObjectQuery(QObject *parent)
 QQmlDebugObjectQuery::~QQmlDebugObjectQuery()
 {
     if (m_client && m_queryId != -1)
-        QQmlEngineDebugPrivate::remove(m_client, this);
+        QQmlEngineDebugClientPrivate::remove(m_client, this);
 }
 
 QQmlDebugObjectReference QQmlDebugObjectQuery::object() const
@@ -839,7 +799,7 @@ QQmlDebugExpressionQuery::QQmlDebugExpressionQuery(QObject *parent)
 QQmlDebugExpressionQuery::~QQmlDebugExpressionQuery()
 {
     if (m_client && m_queryId != -1)
-        QQmlEngineDebugPrivate::remove(m_client, this);
+        QQmlEngineDebugClientPrivate::remove(m_client, this);
 }
 
 QVariant QQmlDebugExpressionQuery::expression() const
 **
 ****************************************************************************/
 
-#ifndef QQMLENGINEDEBUG_H
-#define QQMLENGINEDEBUG_H
+#ifndef QQMLENGINEDEBUGCLIENT_H
+#define QQMLENGINEDEBUGCLIENT_H
+
+#include "qqmldebugclient.h"
 
-#include <QtCore/qobject.h>
 #include <QtCore/qurl.h>
 #include <QtCore/qvariant.h>
 
@@ -59,17 +60,13 @@ class QQmlDebugContextReference;
 class QQmlDebugObjectReference;
 class QQmlDebugFileReference;
 class QQmlDebugEngineReference;
-class QQmlEngineDebugPrivate;
-class QQmlEngineDebug : public QObject
+class QQmlEngineDebugClientPrivate;
+class QQmlEngineDebugClient : public QQmlDebugClient
 {
     Q_OBJECT
 public:
-    enum State { NotConnected, Unavailable, Enabled };
-
-    explicit QQmlEngineDebug(QQmlDebugConnection *, QObject * = 0);
-    ~QQmlEngineDebug();
-
-    State state() const;
+    explicit QQmlEngineDebugClient(QQmlDebugConnection *);
+    ~QQmlEngineDebugClient();
 
     QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &,
                                              QObject *parent = 0);
@@ -100,14 +97,18 @@ public:
     bool resetBindingForObject(int objectDebugId, const QString &propertyName);
     bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
 
-    QQmlEngineDebugPrivate *getPrivate() const { return d; }
+    QQmlEngineDebugClientPrivate *getPrivate() const { return d; }
 
 Q_SIGNALS:
     void newObjects();
-    void stateChanged(State state);
+    void newState(State state);
+
+protected:
+    void stateChanged(State status);
+    void messageReceived(const QByteArray &data);
 
 private:
-    QQmlEngineDebugPrivate *d;
+    QQmlEngineDebugClientPrivate *d;
 };
 
 class QQmlDebugWatch : public QObject
@@ -132,12 +133,12 @@ Q_SIGNALS:
     void valueChanged(const QByteArray &name, const QVariant &value);
 
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     void setState(State);
     State m_state;
     int m_queryId;
-    QQmlEngineDebug *m_client;
+    QQmlEngineDebugClient *m_client;
     int m_objectDebugId;
 };
 
@@ -150,7 +151,7 @@ public:
     QString name() const;
 
 private:
-    friend class QQmlEngineDebug;
+    friend class QQmlEngineDebugClient;
     QString m_name;
 };
 
@@ -163,7 +164,7 @@ public:
     QString expression() const;
 
 private:
-    friend class QQmlEngineDebug;
+    friend class QQmlEngineDebugClient;
     QString m_expr;
     int m_debugId;
 };
@@ -185,8 +186,8 @@ protected:
     QQmlDebugQuery(QObject *);
 
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     void setState(State);
     State m_state;
 };
@@ -206,7 +207,7 @@ public:
     void setColumnNumber(int);
 
 private:
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClientPrivate;
     QUrl m_url;
     int m_lineNumber;
     int m_columnNumber;
@@ -224,7 +225,7 @@ public:
     QString name() const;
 
 private:
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClientPrivate;
     int m_debugId;
     QString m_name;
 };
@@ -249,7 +250,7 @@ public:
     QList<QQmlDebugObjectReference> children() const;
 
 private:
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClientPrivate;
     int m_debugId;
     QString m_class;
     QString m_idString;
@@ -274,7 +275,7 @@ public:
     QList<QQmlDebugContextReference> contexts() const;
 
 private:
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClientPrivate;
     int m_debugId;
     QString m_name;
     QList<QQmlDebugObjectReference> m_objects;
@@ -296,7 +297,7 @@ public:
     bool hasNotifySignal() const;
 
 private:
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClientPrivate;
     int m_objectDebugId;
     QString m_name;
     QVariant m_value;
@@ -313,10 +314,10 @@ public:
     virtual ~QQmlDebugEnginesQuery();
     QList<QQmlDebugEngineReference> engines() const;
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     QQmlDebugEnginesQuery(QObject *);
-    QQmlEngineDebug *m_client;
+    QQmlEngineDebugClient *m_client;
     int m_queryId;
     QList<QQmlDebugEngineReference> m_engines;
 };
@@ -328,10 +329,10 @@ public:
     virtual ~QQmlDebugRootContextQuery();
     QQmlDebugContextReference rootContext() const;
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     QQmlDebugRootContextQuery(QObject *);
-    QQmlEngineDebug *m_client;
+    QQmlEngineDebugClient *m_client;
     int m_queryId;
     QQmlDebugContextReference m_context;
 };
@@ -343,10 +344,10 @@ public:
     virtual ~QQmlDebugObjectQuery();
     QQmlDebugObjectReference object() const;
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     QQmlDebugObjectQuery(QObject *);
-    QQmlEngineDebug *m_client;
+    QQmlEngineDebugClient *m_client;
     int m_queryId;
     QQmlDebugObjectReference m_object;
 
@@ -360,10 +361,10 @@ public:
     QVariant expression() const;
     QVariant result() const;
 private:
-    friend class QQmlEngineDebug;
-    friend class QQmlEngineDebugPrivate;
+    friend class QQmlEngineDebugClient;
+    friend class QQmlEngineDebugClientPrivate;
     QQmlDebugExpressionQuery(QObject *);
-    QQmlEngineDebug *m_client;
+    QQmlEngineDebugClient *m_client;
     int m_queryId;
     QVariant m_expr;
     QVariant m_result;
@@ -374,4 +375,4 @@ Q_DECLARE_METATYPE(QQmlDebugObjectReference)
 Q_DECLARE_METATYPE(QQmlDebugContextReference)
 Q_DECLARE_METATYPE(QQmlDebugPropertyReference)
 
-#endif // QQMLENGINEDEBUG_H
+#endif // QQMLENGINEDEBUGCLIENT_H
index 0b92a72..20fcd6d 100644 (file)
@@ -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)
index e409f3c..cbb7e0f 100644 (file)
@@ -59,7 +59,7 @@
 #include <private/qqmlproperty_p.h>
 
 #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()
index ddce647..cb9c761 100644 (file)
@@ -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