aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/debugger.pro10
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro2
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro2
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro5
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp1
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml4
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro2
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp24
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro6
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp5
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp460
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h237
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro8
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp1002
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/app.pro1
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp113
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro2
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp36
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp17
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.pri7
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h15
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.cpp3
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.h3
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp58
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.h62
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebug.cpp1068
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebug_p.h388
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp4
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp12
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.2.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.3.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.4.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.5.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.6.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignDate.qml9
-rw-r--r--tests/auto/qml/qqmlecmascript/data/componentCreation.qml52
-rw-r--r--tests/auto/qml/qqmlecmascript/data/enums.3.qml41
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml13
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir1
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ownershipConsistency.qml21
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ownershipRootObject.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp223
-rw-r--r--tests/auto/qml/qqmlerror/.gitattributes1
-rw-r--r--tests/auto/qml/qqmllanguage/data/globalEnums.qml55
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp5
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h93
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp61
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/.gitattributes3
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro2
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp2
-rw-r--r--tests/auto/qml/v4/data/objectToBool.qml16
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp1
59 files changed, 2021 insertions, 2193 deletions
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro
index 7669aaa83c..81ca29a2e0 100644
--- a/tests/auto/qml/debugger/debugger.pro
+++ b/tests/auto/qml/debugger/debugger.pro
@@ -1,9 +1,7 @@
TEMPLATE = subdirs
-PRIVATETESTS += \
+PUBLICTESTS += \
qqmlenginedebugservice \
- qqmldebugclient \
- qqmldebugservice \
qqmldebugjs \
qqmlinspector \
qqmlprofilerservice \
@@ -11,6 +9,12 @@ PRIVATETESTS += \
qv8profilerservice \
qdebugmessageservice
+PRIVATETESTS += \
+ qqmldebugclient \
+ qqmldebugservice
+
+SUBDIRS += $$PUBLICTESTS
+
contains(QT_CONFIG, private_tests) {
SUBDIRS += $$PRIVATETESTS
}
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
index 4b5bf60ace..64f7274f6f 100644
--- a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
+++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qdebugmessageservice
-QT += network qml-private testlib
+QT += qml network testlib
macx:CONFIG -= app_bundle
SOURCES += tst_qdebugmessageservice.cpp
diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
index f631929427..e6869fe5cb 100644
--- a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
+++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
@@ -8,4 +8,4 @@ INCLUDEPATH += ../shared
include(../shared/debugutil.pri)
CONFIG += parallel_test
-QT += qml-private network testlib
+QT += qml network testlib
diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
index 4a6efb469d..8a8c0e5081 100644
--- a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
+++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -46,7 +46,7 @@
#include <QDebug>
#include <QBuffer>
-#include <private/qpacketprotocol_p.h>
+#include "../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h"
#include "debugutil_p.h"
diff --git a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
index 22a4df7dc9..60355f1527 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
+++ b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
@@ -2,7 +2,10 @@ CONFIG += testcase
TARGET = tst_qqmldebugclient
macx:CONFIG -= app_bundle
-SOURCES += tst_qqmldebugclient.cpp
+HEADERS += ../shared/qqmldebugtestservice.h
+
+SOURCES += tst_qqmldebugclient.cpp \
+ ../shared/qqmldebugtestservice.cpp
INCLUDEPATH += ../shared
include(../shared/debugutil.pri)
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
index 1682913bc3..2d52ea9f50 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -48,6 +48,7 @@
#include <QtQml/qqmlengine.h>
#include "debugutil_p.h"
+#include "qqmldebugtestservice.h"
#define PORT 13770
#define STR_PORT "13770"
diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
index 1f0f9e22c9..0a1a5eb610 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
@@ -47,7 +47,9 @@ Item {
Component.onCompleted: {
//Comment
- var b = 6;
+ var x = 6;
}
+
+ width : height + 2
}
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
index 7c3a2ea042..c06fd84e58 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qqmldebugjs
-QT += qml-private testlib
+QT += qml testlib
macx:CONFIG -= app_bundle
SOURCES += tst_qqmldebugjs.cpp
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index f4a9a4add7..8293ec6cda 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -191,6 +191,7 @@ private slots:
void setBreakpointInScriptInDifferentFile();
void setBreakpointInScriptOnComment();
void setBreakpointInScriptOnEmptyLine();
+ void setBreakpointInScriptOnOptimizedBinding();
void setBreakpointInScriptWithCondition();
//void setBreakpointInFunction(); //NOT SUPPORTED
void setBreakpointOnEvent();
@@ -1019,9 +1020,6 @@ bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode)
process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
client = new QJSDebugClient(connection);
- QStringList systemEnvironment = QProcess::systemEnvironment();
- systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
- process->setEnvironment(systemEnvironment);
if (blockMode)
process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
else
@@ -1295,6 +1293,26 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
+void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 52;
+ QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+}
+
void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
diff --git a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
index dc2039615a..bbf05b177c 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
+++ b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
@@ -2,7 +2,11 @@ CONFIG += testcase
TARGET = tst_qqmldebugservice
macx:CONFIG -= app_bundle
-SOURCES += tst_qqmldebugservice.cpp
+HEADERS += ../shared/qqmldebugtestservice.h
+
+SOURCES += tst_qqmldebugservice.cpp \
+ ../shared/qqmldebugtestservice.cpp
+
INCLUDEPATH += ../shared
include(../../../shared/util.pri)
include(../shared/debugutil.pri)
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
index 6e14c03a4c..8eb1523af9 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -47,11 +47,10 @@
#include <QtQml/qqmlengine.h>
-#include <private/qqmldebugservice_p.h>
-
#include "../../../shared/util.h"
#include "debugutil_p.h"
#include "qqmldebugclient.h"
+#include "qqmldebugtestservice.h"
#define PORT 13769
#define STR_PORT "13769"
@@ -204,7 +203,7 @@ int main(int argc, char *argv[])
char **_argv = new char*[_argc];
for (int i = 0; i < argc; ++i)
_argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
+ char arg[] = "-qmljsdebugger=port:" STR_PORT ",host:127.0.0.1";
_argv[_argc - 1] = arg;
QGuiApplication app(_argc, _argv);
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp
new file mode 100644
index 0000000000..9639a36065
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp
@@ -0,0 +1,460 @@
+/****************************************************************************
+**
+** 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;
+}
+
+QQmlEngineDebugClient::QQmlEngineDebugClient(
+ QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("QmlDebugger"), connection),
+ m_nextId(0),
+ m_valid(false)
+{
+}
+
+quint32 QQmlEngineDebugClient::addWatch(
+ const QmlDebugPropertyReference &property, bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_PROPERTY") << id << property.objectDebugId
+ << property.name.toUtf8();
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::addWatch(
+ const QmlDebugContextReference &, const QString &, bool *success)
+{
+ *success = false;
+ qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
+ return 0;
+}
+
+quint32 QQmlEngineDebugClient::addWatch(
+ const QmlDebugObjectReference &object, const QString &expr,
+ bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.debugId << expr;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::addWatch(
+ const QmlDebugObjectReference &object, bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_OBJECT") << id << object.debugId;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::addWatch(
+ const QmlDebugFileReference &, bool *success)
+{
+ *success = false;
+ qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
+ return 0;
+}
+
+void QQmlEngineDebugClient::removeWatch(quint32 id, bool *success)
+{
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("NO_WATCH") << id;
+ sendMessage(message);
+ *success = true;
+ }
+}
+
+quint32 QQmlEngineDebugClient::queryAvailableEngines(bool *success)
+{
+ m_engines.clear();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_ENGINES") << id;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::queryRootContexts(
+ const QmlDebugEngineReference &engine, bool *success)
+{
+ m_rootContext = QmlDebugContextReference();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && engine.debugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("LIST_OBJECTS") << id << engine.debugId;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::queryObject(
+ const QmlDebugObjectReference &object, bool *success)
+{
+ m_object = QmlDebugObjectReference();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << id << object.debugId << false <<
+ true;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::queryObjectRecursive(
+ const QmlDebugObjectReference &object, bool *success)
+{
+ m_object = QmlDebugObjectReference();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("FETCH_OBJECT") << id << object.debugId << true <<
+ true;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::queryExpressionResult(
+ int objectDebugId, const QString &expr, bool *success)
+{
+ m_exprResult = QVariant();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::setBindingForObject(
+ int objectDebugId,
+ const QString &propertyName,
+ const QVariant &bindingExpression,
+ bool isLiteralValue,
+ QString source, int line,
+ bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
+ << bindingExpression << isLiteralValue << source << line;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::resetBindingForObject(
+ int objectDebugId,
+ const QString &propertyName,
+ bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::setMethodBody(
+ int objectDebugId, const QString &methodName,
+ const QString &methodBody, bool *success)
+{
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
+ << methodName << methodBody;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+void QQmlEngineDebugClient::decode(QDataStream &ds,
+ QmlDebugObjectReference &o,
+ bool simple)
+{
+ QmlObjectData data;
+ ds >> data;
+ o.debugId = data.objectId;
+ o.className = data.objectType;
+ o.idString = data.idString;
+ o.name = data.objectName;
+ o.source.url = data.url;
+ o.source.lineNumber = data.lineNumber;
+ o.source.columnNumber = data.columnNumber;
+ o.contextDebugId = data.contextId;
+
+ if (simple)
+ return;
+
+ int childCount;
+ bool recur;
+ ds >> childCount >> recur;
+
+ for (int ii = 0; ii < childCount; ++ii) {
+ o.children.append(QmlDebugObjectReference());
+ decode(ds, o.children.last(), !recur);
+ }
+
+ int propCount;
+ ds >> propCount;
+
+ for (int ii = 0; ii < propCount; ++ii) {
+ QmlObjectProperty data;
+ ds >> data;
+ QmlDebugPropertyReference prop;
+ prop.objectDebugId = o.debugId;
+ prop.name = data.name;
+ prop.binding = data.binding;
+ prop.hasNotifySignal = data.hasNotifySignal;
+ prop.valueTypeName = data.valueTypeName;
+ switch (data.type) {
+ case QmlObjectProperty::Basic:
+ case QmlObjectProperty::List:
+ case QmlObjectProperty::SignalProperty:
+ {
+ prop.value = data.value;
+ break;
+ }
+ case QmlObjectProperty::Object:
+ {
+ QmlDebugObjectReference obj;
+ obj.debugId = prop.value.toInt();
+ prop.value = qVariantFromValue(obj);
+ break;
+ }
+ case QmlObjectProperty::Unknown:
+ break;
+ }
+ o.properties << prop;
+ }
+}
+
+void QQmlEngineDebugClient::decode(QDataStream &ds,
+ QmlDebugContextReference &c)
+{
+ ds >> c.name >> c.debugId;
+
+ int contextCount;
+ ds >> contextCount;
+
+ for (int ii = 0; ii < contextCount; ++ii) {
+ c.contexts.append(QmlDebugContextReference());
+ decode(ds, c.contexts.last());
+ }
+
+ int objectCount;
+ ds >> objectCount;
+
+ for (int ii = 0; ii < objectCount; ++ii) {
+ QmlDebugObjectReference obj;
+ decode(ds, obj, true);
+
+ obj.contextDebugId = c.debugId;
+ c.objects << obj;
+ }
+}
+
+void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
+{
+ m_valid = false;
+ QDataStream ds(data);
+ int queryId;
+ QByteArray type;
+ ds >> type >> queryId;
+
+ //qDebug() << "QQmlEngineDebugPrivate::message()" << type;
+
+ if (type == "LIST_ENGINES_R") {
+ int count;
+ ds >> count;
+
+ m_engines.clear();
+ for (int ii = 0; ii < count; ++ii) {
+ QmlDebugEngineReference eng;
+ ds >> eng.name;
+ ds >> eng.debugId;
+ m_engines << eng;
+ }
+ } else if (type == "LIST_OBJECTS_R") {
+ if (!ds.atEnd())
+ decode(ds, m_rootContext);
+
+ } else if (type == "FETCH_OBJECT_R") {
+ if (!ds.atEnd())
+ decode(ds, m_object, false);
+
+ } else if (type == "EVAL_EXPRESSION_R") {;
+ ds >> m_exprResult;
+
+ } else if (type == "WATCH_PROPERTY_R") {
+ ds >> m_valid;
+
+ } else if (type == "WATCH_OBJECT_R") {
+ ds >> m_valid;
+
+ } else if (type == "WATCH_EXPR_OBJECT_R") {
+ ds >> m_valid;
+
+ } else if (type == "UPDATE_WATCH") {
+ int debugId;
+ QByteArray name;
+ QVariant value;
+ ds >> debugId >> name >> value;
+ emit valueChanged(name, value);
+ return;
+
+ } else if (type == "OBJECT_CREATED") {
+ emit newObjects();
+ return;
+ } else if (type == "SET_BINDING_R") {
+ ds >> m_valid;
+ } else if (type == "RESET_BINDING_R") {
+ ds >> m_valid;
+ } else if (type == "SET_METHOD_BODY_R") {
+ ds >> m_valid;
+ } else if (type == "NO_WATCH_R") {
+ ds >> m_valid;
+ }
+ emit result();
+}
+
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h
new file mode 100644
index 0000000000..62f9b15824
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** 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 <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+class QQmlDebugConnection;
+
+struct QmlDebugPropertyReference
+{
+ QmlDebugPropertyReference()
+ : objectDebugId(-1), hasNotifySignal(false)
+ {
+ }
+
+ QmlDebugPropertyReference &operator=(
+ const QmlDebugPropertyReference &o)
+ {
+ objectDebugId = o.objectDebugId; name = o.name; value = o.value;
+ valueTypeName = o.valueTypeName; binding = o.binding;
+ hasNotifySignal = o.hasNotifySignal;
+ return *this;
+ }
+
+ int objectDebugId;
+ QString name;
+ QVariant value;
+ QString valueTypeName;
+ QString binding;
+ bool hasNotifySignal;
+};
+
+struct QmlDebugFileReference
+{
+ QmlDebugFileReference()
+ : lineNumber(-1), columnNumber(-1)
+ {
+ }
+
+ QmlDebugFileReference &operator=(
+ const QmlDebugFileReference &o)
+ {
+ url = o.url; lineNumber = o.lineNumber; columnNumber = o.columnNumber;
+ return *this;
+ }
+
+ QUrl url;
+ int lineNumber;
+ int columnNumber;
+};
+
+struct QmlDebugObjectReference
+{
+ QmlDebugObjectReference()
+ : debugId(-1), contextDebugId(-1)
+ {
+ }
+
+ QmlDebugObjectReference(int id)
+ : debugId(id), contextDebugId(-1)
+ {
+ }
+
+ QmlDebugObjectReference &operator=(
+ const QmlDebugObjectReference &o)
+ {
+ debugId = o.debugId; className = o.className; idString = o.idString;
+ name = o.name; source = o.source; contextDebugId = o.contextDebugId;
+ properties = o.properties; children = o.children;
+ return *this;
+ }
+ int debugId;
+ QString className;
+ QString idString;
+ QString name;
+ QmlDebugFileReference source;
+ int contextDebugId;
+ QList<QmlDebugPropertyReference> properties;
+ QList<QmlDebugObjectReference> children;
+};
+
+Q_DECLARE_METATYPE(QmlDebugObjectReference)
+
+struct QmlDebugContextReference
+{
+ QmlDebugContextReference()
+ : debugId(-1)
+ {
+ }
+
+ QmlDebugContextReference &operator=(
+ const QmlDebugContextReference &o)
+ {
+ debugId = o.debugId; name = o.name; objects = o.objects;
+ contexts = o.contexts;
+ return *this;
+ }
+
+ int debugId;
+ QString name;
+ QList<QmlDebugObjectReference> objects;
+ QList<QmlDebugContextReference> contexts;
+};
+
+struct QmlDebugEngineReference
+{
+ QmlDebugEngineReference()
+ : debugId(-1)
+ {
+ }
+
+ QmlDebugEngineReference(int id)
+ : debugId(id)
+ {
+ }
+
+ QmlDebugEngineReference &operator=(
+ const QmlDebugEngineReference &o)
+ {
+ debugId = o.debugId; name = o.name;
+ return *this;
+ }
+
+ int debugId;
+ QString name;
+};
+
+class QQmlEngineDebugClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ explicit QQmlEngineDebugClient(QQmlDebugConnection *conn);
+
+ quint32 addWatch(const QmlDebugPropertyReference &,
+ bool *success);
+ quint32 addWatch(const QmlDebugContextReference &, const QString &,
+ bool *success);
+ quint32 addWatch(const QmlDebugObjectReference &, const QString &,
+ bool *success);
+ quint32 addWatch(const QmlDebugObjectReference &,
+ bool *success);
+ quint32 addWatch(const QmlDebugFileReference &,
+ bool *success);
+
+ void removeWatch(quint32 watch, bool *success);
+
+ quint32 queryAvailableEngines(bool *success);
+ quint32 queryRootContexts(const QmlDebugEngineReference &,
+ bool *success);
+ quint32 queryObject(const QmlDebugObjectReference &,
+ bool *success);
+ quint32 queryObjectRecursive(const QmlDebugObjectReference &,
+ bool *success);
+ quint32 queryExpressionResult(int objectDebugId,
+ const QString &expr,
+ bool *success);
+ quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
+ const QVariant &bindingExpression,
+ bool isLiteralValue,
+ QString source, int line, bool *success);
+ quint32 resetBindingForObject(int objectDebugId,
+ const QString &propertyName, bool *success);
+ quint32 setMethodBody(int objectDebugId, const QString &methodName,
+ const QString &methodBody, bool *success);
+
+ quint32 getId() { return m_nextId++; }
+
+ void decode(QDataStream &, QmlDebugContextReference &);
+ void decode(QDataStream &, QmlDebugObjectReference &, bool simple);
+
+ QList<QmlDebugEngineReference> engines() { return m_engines; }
+ QmlDebugContextReference rootContext() { return m_rootContext; }
+ QmlDebugObjectReference object() { return m_object; }
+ QVariant resultExpr() { return m_exprResult; }
+ bool valid() { return m_valid; }
+
+signals:
+ void newObjects();
+ void valueChanged(QByteArray,QVariant);
+ void result();
+
+protected:
+ void messageReceived(const QByteArray &);
+
+private:
+ quint32 m_nextId;
+ bool m_valid;
+ QList<QmlDebugEngineReference> m_engines;
+ QmlDebugContextReference m_rootContext;
+ QmlDebugObjectReference m_object;
+ QVariant m_exprResult;
+};
+
+#endif // QQMLENGINEDEBUGCLIENT_H
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
index 0b92a726b5..0212d11cd1 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
@@ -2,9 +2,15 @@ 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/util.pri)
include(../shared/debugutil.pri)
CONFIG += parallel_test declarative_debug
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index e409f3c8b6..e84e6623c1 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -59,27 +59,45 @@
#include <private/qqmlproperty_p.h>
#include "debugutil_p.h"
-#include "qqmlenginedebug_p.h"
+#include "qqmlenginedebugclient.h"
-Q_DECLARE_METATYPE(QQmlDebugWatch::State)
+#include "../../../shared/util.h"
+
+#define QVERIFYOBJECT(statement) \
+ do {\
+ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
+ return QmlDebugObjectReference();\
+ }\
+ } while (0)
+
+class NonScriptProperty : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
+public:
+ int nonScriptProp() const { return 0; }
+ void setNonScriptProp(int) {}
+signals:
+ void nonScriptPropChanged();
+};
+QML_DECLARE_TYPE(NonScriptProperty)
class tst_QQmlEngineDebugService : public QObject
{
Q_OBJECT
private:
- QQmlDebugObjectReference findRootObject(int context = 0, bool recursive = false);
- QQmlDebugPropertyReference findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const;
- void waitForQuery(QQmlDebugQuery *query);
-
- void recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const;
+ QmlDebugObjectReference findRootObject(int context = 0,
+ bool recursive = false);
+ QmlDebugPropertyReference findProperty(
+ const QList<QmlDebugPropertyReference> &props,
+ const QString &name) const;
- void recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const;
- void recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const;
- void compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const;
+ void recursiveObjectTest(QObject *o,
+ const QmlDebugObjectReference &oref,
+ bool recursive) const;
QQmlDebugConnection *m_conn;
- QQmlEngineDebug *m_dbg;
+ QQmlEngineDebugClient *m_dbg;
QQmlEngine *m_engine;
QQuickItem *m_rootItem;
@@ -103,90 +121,62 @@ private slots:
void queryExpressionResult();
void queryExpressionResult_data();
- void tst_QQmlDebugFileReference();
- void tst_QQmlDebugEngineReference();
- void tst_QQmlDebugObjectReference();
- void tst_QQmlDebugContextReference();
- void tst_QQmlDebugPropertyReference();
-
void setBindingForObject();
void setMethodBody();
void queryObjectTree();
void setBindingInStates();
};
-class NonScriptProperty : public QObject {
- Q_OBJECT
- Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
-public:
- int nonScriptProp() const { return 0; }
- void setNonScriptProp(int) {}
-signals:
- void nonScriptPropChanged();
-};
-QML_DECLARE_TYPE(NonScriptProperty)
-
-
-QQmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(int context, bool recursive)
-{
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- if (q_engines->engines().count() == 0)
- return QQmlDebugObjectReference();
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- if (q_context->rootContext().contexts().count() == 0 ||
- q_context->rootContext().contexts().last().objects().count() == 0)
- return QQmlDebugObjectReference();
-
- //Contexts are in a stack
- int count = q_context->rootContext().contexts().count();
- QQmlDebugObjectQuery *q_obj = recursive ?
- m_dbg->queryObjectRecursive(q_context->rootContext().contexts()[count - context - 1].objects()[0], this) :
- m_dbg->queryObject(q_context->rootContext().contexts()[count - context - 1].objects()[0], this);
- waitForQuery(q_obj);
-
- QQmlDebugObjectReference result = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- return result;
+QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
+ int context, bool recursive)
+{
+ bool success = false;
+ m_dbg->queryAvailableEngines(&success);
+ QVERIFYOBJECT(success);
+ QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QVERIFYOBJECT(m_dbg->engines().count());
+ m_dbg->queryRootContexts(m_dbg->engines()[0].debugId, &success);
+ QVERIFYOBJECT(success);
+ QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QVERIFYOBJECT(m_dbg->rootContext().contexts.count());
+ QVERIFYOBJECT(m_dbg->rootContext().contexts.last().objects.count());
+ int count = m_dbg->rootContext().contexts.count();
+ recursive ? m_dbg->queryObjectRecursive(m_dbg->rootContext().contexts[count - context - 1].objects[0],
+ &success) :
+ m_dbg->queryObject(m_dbg->rootContext().contexts[count - context - 1].objects[0], &success);
+ QVERIFYOBJECT(success);
+ QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ return m_dbg->object();
}
-QQmlDebugPropertyReference tst_QQmlEngineDebugService::findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const
+QmlDebugPropertyReference tst_QQmlEngineDebugService::findProperty(
+ const QList<QmlDebugPropertyReference> &props, const QString &name) const
{
- foreach(const QQmlDebugPropertyReference &p, props) {
- if (p.name() == name)
+ foreach (const QmlDebugPropertyReference &p, props) {
+ if (p.name == name)
return p;
}
- return QQmlDebugPropertyReference();
-}
-
-void tst_QQmlEngineDebugService::waitForQuery(QQmlDebugQuery *query)
-{
- QVERIFY(query);
- QCOMPARE(query->parent(), qobject_cast<QObject*>(this));
- QVERIFY(query->state() == QQmlDebugQuery::Waiting);
- if (!QQmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QQmlDebugQuery::State))))
- QFAIL("query timed out");
+ return QmlDebugPropertyReference();
}
-void tst_QQmlEngineDebugService::recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const
+void tst_QQmlEngineDebugService::recursiveObjectTest(
+ QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
{
const QMetaObject *meta = o->metaObject();
QQmlType *type = QQmlMetaType::qmlType(meta);
- QString className = type ? QString(type->qmlTypeName()) : QString(meta->className());
+ QString className = type ? QString(type->qmlTypeName())
+ : QString(meta->className());
className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
- QCOMPARE(oref.debugId(), QQmlDebugService::idForObject(o));
- QCOMPARE(oref.name(), o->objectName());
- QCOMPARE(oref.className(), className);
- QCOMPARE(oref.contextDebugId(), QQmlDebugService::idForObject(qmlContext(o)));
+ QCOMPARE(oref.debugId, QQmlDebugService::idForObject(o));
+ QCOMPARE(oref.name, o->objectName());
+ QCOMPARE(oref.className, className);
+ QCOMPARE(oref.contextDebugId, QQmlDebugService::idForObject(
+ qmlContext(o)));
const QObjectList &children = o->children();
for (int i=0; i<children.count(); i++) {
@@ -196,26 +186,27 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(QObject *o, const QQmlDebug
int debugId = QQmlDebugService::idForObject(child);
QVERIFY(debugId >= 0);
- QQmlDebugObjectReference cref;
- foreach (const QQmlDebugObjectReference &ref, oref.children()) {
- if (ref.debugId() == debugId) {
+ QmlDebugObjectReference cref;
+ foreach (const QmlDebugObjectReference &ref, oref.children) {
+ if (ref.debugId == debugId) {
cref = ref;
break;
}
}
- QVERIFY(cref.debugId() >= 0);
+ QVERIFY(cref.debugId >= 0);
if (recursive)
recursiveObjectTest(child, cref, true);
}
- foreach (const QQmlDebugPropertyReference &p, oref.properties()) {
- QCOMPARE(p.objectDebugId(), QQmlDebugService::idForObject(o));
+ foreach (const QmlDebugPropertyReference &p, oref.properties) {
+ QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
// signal properties are fake - they are generated from QQmlBoundSignal children
- if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
- QList<QQmlBoundSignal*> signalHandlers = o->findChildren<QQmlBoundSignal*>();
- QString signal = p.value().toString();
+ if (p.name.startsWith("on") && p.name.length() > 2 && p.name[2].isUpper()) {
+ QList<QQmlBoundSignal*> signalHandlers =
+ o->findChildren<QQmlBoundSignal*>();
+ QString signal = p.value.toString();
bool found = false;
for (int i = 0; i < signalHandlers.count(); ++i)
if (signalHandlers.at(i)->expression()->expression() == signal) {
@@ -223,86 +214,40 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(QObject *o, const QQmlDebug
break;
}
QVERIFY(found);
- QVERIFY(p.valueTypeName().isEmpty());
- QVERIFY(p.binding().isEmpty());
- QVERIFY(!p.hasNotifySignal());
+ QVERIFY(p.valueTypeName.isEmpty());
+ QVERIFY(p.binding.isEmpty());
+ QVERIFY(!p.hasNotifySignal);
continue;
}
- QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
+ QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name.toUtf8().constData()));
- QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
+ QCOMPARE(p.name, QString::fromUtf8(pmeta.name()));
- if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types
- QCOMPARE(p.value(), pmeta.read(o));
+ if (pmeta.type() < QVariant::UserType && pmeta.userType() !=
+ QMetaType::QVariant) // TODO test complex types
+ QCOMPARE(p.value , pmeta.read(o));
- if (p.name() == "parent")
- QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*");
+ if (p.name == "parent")
+ QVERIFY(p.valueTypeName == "QGraphicsObject*" ||
+ p.valueTypeName == "QQuickItem*");
else
- QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
+ QCOMPARE(p.valueTypeName, QString::fromUtf8(pmeta.typeName()));
- QQmlAbstractBinding *binding =
- QQmlPropertyPrivate::binding(QQmlProperty(o, p.name()));
+ QQmlAbstractBinding *binding =
+ QQmlPropertyPrivate::binding(
+ QQmlProperty(o, p.name));
if (binding)
- QCOMPARE(binding->expression(), p.binding());
+ QCOMPARE(binding->expression(), p.binding);
- QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
+ QCOMPARE(p.hasNotifySignal, pmeta.hasNotifySignal());
QVERIFY(pmeta.isValid());
}
}
-void tst_QQmlEngineDebugService::recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.className(), b.className());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.contextDebugId(), b.contextDebugId());
-
- QCOMPARE(a.source().url(), b.source().url());
- QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
- QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
-
- QCOMPARE(a.properties().count(), b.properties().count());
- QCOMPARE(a.children().count(), b.children().count());
-
- QList<QQmlDebugPropertyReference> aprops = a.properties();
- QList<QQmlDebugPropertyReference> bprops = b.properties();
-
- for (int i=0; i<aprops.count(); i++)
- compareProperties(aprops[i], bprops[i]);
-
- for (int i=0; i<a.children().count(); i++)
- recursiveCompareObjects(a.children()[i], b.children()[i]);
-}
-
-void tst_QQmlEngineDebugService::recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.objects().count(), b.objects().count());
- QCOMPARE(a.contexts().count(), b.contexts().count());
-
- for (int i=0; i<a.objects().count(); i++)
- recursiveCompareObjects(a.objects()[i], b.objects()[i]);
-
- for (int i=0; i<a.contexts().count(); i++)
- recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
-}
-
-void tst_QQmlEngineDebugService::compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const
-{
- QCOMPARE(a.objectDebugId(), b.objectDebugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.value(), b.value());
- QCOMPARE(a.valueTypeName(), b.valueTypeName());
- QCOMPARE(a.binding(), b.binding());
- QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
-}
-
void tst_QQmlEngineDebugService::initTestCase()
{
- qRegisterMetaType<QQmlDebugWatch::State>();
qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Waiting for connection on port 3768...");
@@ -394,13 +339,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;
@@ -408,7 +352,8 @@ void tst_QQmlEngineDebugService::cleanupTestCase()
void tst_QQmlEngineDebugService::setMethodBody()
{
- QQmlDebugObjectReference obj = findRootObject(2);
+ bool success;
+ QmlDebugObjectReference obj = findRootObject(2);
QObject *root = m_components.at(2);
// Without args
@@ -419,8 +364,10 @@ void tst_QQmlEngineDebugService::setMethodBody()
QVERIFY(rv == QVariant(qreal(3)));
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7"));
- QTest::qWait(100);
+ QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethodNoArgs", "return 7",
+ &success));
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, rv)));
@@ -434,8 +381,10 @@ void tst_QQmlEngineDebugService::setMethodBody()
Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
QVERIFY(rv == QVariant(qreal(28)));
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7"));
- QTest::qWait(100);
+ QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethod", "return a + 7",
+ &success));
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
@@ -445,96 +394,78 @@ void tst_QQmlEngineDebugService::setMethodBody()
void tst_QQmlEngineDebugService::watch_property()
{
- QQmlDebugObjectReference obj = findRootObject();
- QQmlDebugPropertyReference prop = findProperty(obj.properties(), "width");
+ QmlDebugObjectReference obj = findRootObject();
+ QmlDebugPropertyReference prop = findProperty(obj.properties, "width");
- QQmlDebugPropertyWatch *watch;
+ bool success;
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- watch = unconnected->addWatch(prop, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
- delete watch;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->addWatch(prop, &success);
+ QVERIFY(!success);
delete unconnected;
- watch = m_dbg->addWatch(QQmlDebugPropertyReference(), this);
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
- delete watch;
+ m_dbg->addWatch(QmlDebugPropertyReference(), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), false);
- watch = m_dbg->addWatch(prop, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->name(), prop.name());
+ quint32 id = m_dbg->addWatch(prop, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+ QSignalSpy spy(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant)));
int origWidth = m_rootItem->property("width").toInt();
m_rootItem->setProperty("width", origWidth*2);
- // stateChanged() is received before valueChanged()
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
QCOMPARE(spy.count(), 1);
- m_dbg->removeWatch(watch);
- delete watch;
+ m_dbg->removeWatch(id, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
// restore original value and verify spy doesn't get additional signal since watch has been removed
m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
+ QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name.toUtf8());
QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
}
void tst_QQmlEngineDebugService::watch_object()
{
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QVERIFY(q_engines->engines().count() > 0);
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().contexts().count());
- QVERIFY(q_context->rootContext().contexts().last().objects().count() > 0);
- QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().contexts().last().objects()[0], this);
- waitForQuery(q_obj);
-
- QQmlDebugObjectReference obj = q_obj->object();
+ QmlDebugObjectReference obj = findRootObject();
- delete q_engines;
- delete q_context;
- delete q_obj;
+ bool success;
- QQmlDebugWatch *watch;
-
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- watch = unconnected->addWatch(obj, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
- delete watch;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->addWatch(obj, &success);
+ QVERIFY(!success);
delete unconnected;
- watch = m_dbg->addWatch(QQmlDebugObjectReference(), this);
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
- delete watch;
+ m_dbg->addWatch(QmlDebugObjectReference(), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), false);
- watch = m_dbg->addWatch(obj, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
+ quint32 id = m_dbg->addWatch(obj, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+ QSignalSpy spy(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant)));
int origWidth = m_rootItem->property("width").toInt();
int origHeight = m_rootItem->property("height").toInt();
m_rootItem->setProperty("width", origWidth*2);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
m_rootItem->setProperty("height", origHeight*2);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
- // stateChanged() is received before any valueChanged() signals
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(watch->state(), QQmlDebugWatch::Active);
QVERIFY(spy.count() > 0);
int newWidth = -1;
@@ -548,8 +479,10 @@ void tst_QQmlEngineDebugService::watch_object()
}
- m_dbg->removeWatch(watch);
- delete watch;
+ m_dbg->removeWatch(id, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
// since watch has been removed, restoring the original values should not trigger a valueChanged()
spy.clear();
@@ -570,58 +503,50 @@ void tst_QQmlEngineDebugService::watch_expression()
int origWidth = m_rootItem->property("width").toInt();
- QQmlDebugObjectReference obj = findRootObject();
+ QmlDebugObjectReference obj = findRootObject();
- QQmlDebugObjectExpressionWatch *watch;
+ bool success;
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- watch = unconnected->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
- delete watch;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->addWatch(obj, expr, &success);
+ QVERIFY(!success);
delete unconnected;
- watch = m_dbg->addWatch(QQmlDebugObjectReference(), expr, this);
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->expression(), expr);
+ m_dbg->addWatch(QmlDebugObjectReference(), expr, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), false);
- QSignalSpy spyState(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)));
+ quint32 id = m_dbg->addWatch(obj, expr, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
- int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
+ QSignalSpy spy(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant)));
int width = origWidth;
for (int i=0; i<incrementCount+1; i++) {
if (i > 0) {
width += increment;
m_rootItem->setProperty("width", width);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
}
- if (!QQmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
- QFAIL("Did not receive valueChanged() for expression");
}
- if (spyState.count() == 0)
- QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
- QCOMPARE(spyState.count(), 1);
- QCOMPARE(watch->state(), QQmlDebugWatch::Active);
-
- m_dbg->removeWatch(watch);
- delete watch;
+ m_dbg->removeWatch(id, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
// restore original value and verify spy doesn't get a signal since watch has been removed
m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
- QCOMPARE(spy.count(), expectedSpyCount);
+ QCOMPARE(spy.count(), incrementCount);
width = origWidth + increment;
for (int i=0; i<spy.count(); i++) {
- QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
width += increment;
+ QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
}
}
@@ -637,165 +562,126 @@ void tst_QQmlEngineDebugService::watch_expression_data()
void tst_QQmlEngineDebugService::watch_context()
{
- QQmlDebugContextReference c;
- QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(c, QString(), this));
+ QmlDebugContextReference c;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
+ bool success;
+ m_dbg->addWatch(c, QString(), &success);
+ QVERIFY(!success);
}
void tst_QQmlEngineDebugService::watch_file()
{
- QQmlDebugFileReference f;
- QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(f, this));
+ QmlDebugFileReference f;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
+ bool success;
+ m_dbg->addWatch(f, &success);
+ QVERIFY(!success);
}
void tst_QQmlEngineDebugService::queryAvailableEngines()
{
- QQmlDebugEnginesQuery *q_engines;
+ bool success;
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- q_engines = unconnected->queryAvailableEngines(0);
- QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
- delete q_engines;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryAvailableEngines(&success);
+ QVERIFY(!success);
delete unconnected;
- q_engines = m_dbg->queryAvailableEngines(this);
- delete q_engines;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- QVERIFY(q_engines->engines().isEmpty());
- waitForQuery(q_engines);
+ m_dbg->queryAvailableEngines(&success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
// TODO test multiple engines
- QList<QQmlDebugEngineReference> engines = q_engines->engines();
+ QList<QmlDebugEngineReference> engines = m_dbg->engines();
QCOMPARE(engines.count(), 1);
- foreach(const QQmlDebugEngineReference &e, engines) {
- QCOMPARE(e.debugId(), QQmlDebugService::idForObject(m_engine));
- QCOMPARE(e.name(), m_engine->objectName());
+ foreach (const QmlDebugEngineReference &e, engines) {
+ QCOMPARE(e.debugId, QQmlDebugService::idForObject(m_engine));
+ QCOMPARE(e.name, m_engine->objectName());
}
-
- // Make query invalid by deleting client
- q_engines = m_dbg->queryAvailableEngines(this);
- QCOMPARE(q_engines->state(), QQmlDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
- delete q_engines;
- m_dbg = new QQmlEngineDebug(m_conn, this);
}
void tst_QQmlEngineDebugService::queryRootContexts()
{
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- int engineId = q_engines->engines()[0].debugId();
- delete q_engines;
-
- QQmlDebugRootContextQuery *q_context;
+ bool success;
+ m_dbg->queryAvailableEngines(&success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QVERIFY(m_dbg->engines().count());
+ int engineId = m_dbg->engines()[0].debugId;
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- q_context = unconnected->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
- delete q_context;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryRootContexts(engineId, &success);
+ QVERIFY(!success);
delete unconnected;
- q_context = m_dbg->queryRootContexts(engineId, this);
- delete q_context;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- waitForQuery(q_context);
+ m_dbg->queryRootContexts(engineId, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QQmlContext *actualContext = m_engine->rootContext();
- QQmlDebugContextReference context = q_context->rootContext();
- QCOMPARE(context.debugId(), QQmlDebugService::idForObject(actualContext));
- QCOMPARE(context.name(), actualContext->objectName());
+ QmlDebugContextReference context = m_dbg->rootContext();
+ QCOMPARE(context.debugId, QQmlDebugService::idForObject(actualContext));
+ QCOMPARE(context.name, actualContext->objectName());
// root context query sends only root object data - it doesn't fill in
// the children or property info
- QCOMPARE(context.objects().count(), 0);
-
- QCOMPARE(context.contexts().count(), 5);
- QVERIFY(context.contexts()[0].debugId() >= 0);
- QCOMPARE(context.contexts()[0].name(), QString("tst_QQmlDebug_childContext"));
-
- // Make query invalid by deleting client
- q_context = m_dbg->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QQmlDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
- delete q_context;
- m_dbg = new QQmlEngineDebug(m_conn, this);
+ QCOMPARE(context.objects.count(), 0);
+ QCOMPARE(context.contexts.count(), 5);
+ QVERIFY(context.contexts[0].debugId >= 0);
+ QCOMPARE(context.contexts[0].name, QString("tst_QQmlDebug_childContext"));
}
void tst_QQmlEngineDebugService::queryObject()
{
QFETCH(bool, recursive);
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
+ bool success;
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- QQmlDebugObjectReference rootObject = q_context->rootContext().contexts().last().objects()[0];
+ QmlDebugObjectReference rootObject = findRootObject();
- QQmlDebugObjectQuery *q_obj = 0;
-
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
- delete q_obj;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ recursive ? unconnected->queryObjectRecursive(rootObject, &success) : unconnected->queryObject(rootObject, &success);
+ QVERIFY(!success);
delete unconnected;
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- delete q_obj;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- waitForQuery(q_obj);
-
- QQmlDebugObjectReference obj = q_obj->object();
+ recursive ? m_dbg->queryObjectRecursive(rootObject, &success) : m_dbg->queryObject(rootObject, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QQmlDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
- delete q_obj;
- m_dbg = new QQmlEngineDebug(m_conn, this);
+ QmlDebugObjectReference obj = m_dbg->object();
// check source as defined in main()
- QQmlDebugFileReference source = obj.source();
- QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 3);
- QCOMPARE(source.columnNumber(), 1);
+ QmlDebugFileReference source = obj.source;
+ QCOMPARE(source.url, QUrl::fromLocalFile(""));
+ QCOMPARE(source.lineNumber, 3);
+ QCOMPARE(source.columnNumber, 1);
// generically test all properties, children and childrens' properties
recursiveObjectTest(m_rootItem, obj, recursive);
if (recursive) {
- foreach(const QQmlDebugObjectReference &child, obj.children())
- QVERIFY(child.properties().count() > 0);
+ foreach (const QmlDebugObjectReference &child, obj.children)
+ QVERIFY(child.properties.count() > 0);
- QQmlDebugObjectReference rect;
- QQmlDebugObjectReference text;
- foreach (const QQmlDebugObjectReference &child, obj.children()) {
- if (child.className() == "Rectangle")
+ QmlDebugObjectReference rect;
+ QmlDebugObjectReference text;
+ foreach (const QmlDebugObjectReference &child, obj.children) {
+ if (child.className == "Rectangle")
rect = child;
- else if (child.className() == "Text")
+ else if (child.className == "Text")
text = child;
}
// test specific property values
- QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
- QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
- QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+ QCOMPARE(findProperty(rect.properties, "width").value, qVariantFromValue(500));
+ QCOMPARE(findProperty(rect.properties, "height").value, qVariantFromValue(600));
+ QCOMPARE(findProperty(rect.properties, "color").value, qVariantFromValue(QColor("blue")));
- QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+ QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue")));
} else {
- foreach(const QQmlDebugObjectReference &child, obj.children())
- QCOMPARE(child.properties().count(), 0);
+ foreach (const QmlDebugObjectReference &child, obj.children)
+ QCOMPARE(child.properties.count(), 0);
}
}
@@ -812,40 +698,20 @@ void tst_QQmlEngineDebugService::queryExpressionResult()
QFETCH(QString, expr);
QFETCH(QVariant, result);
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines); // check immediate deletion is ok
-
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- int objectId = q_context->rootContext().contexts().last().objects()[0].debugId();
+ int objectId = findRootObject().debugId;
- QQmlDebugExpressionQuery *q_expr;
+ bool success;
- QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
- q_expr = unconnected->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
- delete q_expr;
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryExpressionResult(objectId, expr, &success);
+ QVERIFY(!success);
delete unconnected;
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- delete q_expr;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->expression().toString(), expr);
- waitForQuery(q_expr);
+ m_dbg->queryExpressionResult(objectId, expr, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QCOMPARE(q_expr->result(), result);
-
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QQmlDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
- delete q_expr;
- m_dbg = new QQmlEngineDebug(m_conn, this);
+ QCOMPARE(m_dbg->resultExpr(), result);
}
void tst_QQmlEngineDebugService::queryExpressionResult_data()
@@ -863,204 +729,94 @@ void tst_QQmlEngineDebugService::queryExpressionResult_data()
QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
}
-void tst_QQmlEngineDebugService::tst_QQmlDebugFileReference()
-{
- QQmlDebugFileReference ref;
- QVERIFY(ref.url().isEmpty());
- QCOMPARE(ref.lineNumber(), -1);
- QCOMPARE(ref.columnNumber(), -1);
-
- ref.setUrl(QUrl("http://test"));
- QCOMPARE(ref.url(), QUrl("http://test"));
- ref.setLineNumber(1);
- QCOMPARE(ref.lineNumber(), 1);
- ref.setColumnNumber(1);
- QCOMPARE(ref.columnNumber(), 1);
-
- QQmlDebugFileReference copy(ref);
- QQmlDebugFileReference copyAssign;
- copyAssign = ref;
- foreach (const QQmlDebugFileReference &r, (QList<QQmlDebugFileReference>() << copy << copyAssign)) {
- QCOMPARE(r.url(), ref.url());
- QCOMPARE(r.lineNumber(), ref.lineNumber());
- QCOMPARE(r.columnNumber(), ref.columnNumber());
- }
-}
-
-void tst_QQmlEngineDebugService::tst_QQmlDebugEngineReference()
-{
- QQmlDebugEngineReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
-
- ref = QQmlDebugEngineReference(1);
- QCOMPARE(ref.debugId(), 1);
- QVERIFY(ref.name().isEmpty());
-
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- ref = q_engines->engines()[0];
- delete q_engines;
-
- QQmlDebugEngineReference copy(ref);
- QQmlDebugEngineReference copyAssign;
- copyAssign = ref;
- foreach (const QQmlDebugEngineReference &r, (QList<QQmlDebugEngineReference>() << copy << copyAssign)) {
- QCOMPARE(r.debugId(), ref.debugId());
- QCOMPARE(r.name(), ref.name());
- }
-}
-
-void tst_QQmlEngineDebugService::tst_QQmlDebugObjectReference()
-{
- QQmlDebugObjectReference ref;
- QCOMPARE(ref.debugId(), -1);
- QCOMPARE(ref.className(), QString());
- QCOMPARE(ref.name(), QString());
- QCOMPARE(ref.contextDebugId(), -1);
- QVERIFY(ref.properties().isEmpty());
- QVERIFY(ref.children().isEmpty());
-
- QQmlDebugFileReference source = ref.source();
- QVERIFY(source.url().isEmpty());
- QVERIFY(source.lineNumber() < 0);
- QVERIFY(source.columnNumber() < 0);
-
- ref = QQmlDebugObjectReference(1);
- QCOMPARE(ref.debugId(), 1);
-
- QQmlDebugObjectReference rootObject = findRootObject();
- QQmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(query);
- ref = query->object();
- delete query;
-
- QVERIFY(ref.debugId() >= 0);
-
- QQmlDebugObjectReference copy(ref);
- QQmlDebugObjectReference copyAssign;
- copyAssign = ref;
- foreach (const QQmlDebugObjectReference &r, (QList<QQmlDebugObjectReference>() << copy << copyAssign))
- recursiveCompareObjects(r, ref);
-}
-
-void tst_QQmlEngineDebugService::tst_QQmlDebugContextReference()
-{
- QQmlDebugContextReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
- QVERIFY(ref.objects().isEmpty());
- QVERIFY(ref.contexts().isEmpty());
-
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- ref = q_context->rootContext();
- delete q_engines;
- delete q_context;
- QVERIFY(ref.debugId() >= 0);
-
- QQmlDebugContextReference copy(ref);
- QQmlDebugContextReference copyAssign;
- copyAssign = ref;
- foreach (const QQmlDebugContextReference &r, (QList<QQmlDebugContextReference>() << copy << copyAssign))
- recursiveCompareContexts(r, ref);
-}
-
-void tst_QQmlEngineDebugService::tst_QQmlDebugPropertyReference()
-{
- QQmlDebugObjectReference rootObject = findRootObject();
- QQmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
- waitForQuery(query);
- QQmlDebugObjectReference obj = query->object();
- delete query;
-
- QQmlDebugPropertyReference ref = findProperty(obj.properties(), "scale");
- QVERIFY(ref.objectDebugId() > 0);
- QVERIFY(!ref.name().isEmpty());
- QVERIFY(!ref.value().isNull());
- QVERIFY(!ref.valueTypeName().isEmpty());
- QVERIFY(!ref.binding().isEmpty());
- QVERIFY(ref.hasNotifySignal());
-
- QQmlDebugPropertyReference copy(ref);
- QQmlDebugPropertyReference copyAssign;
- copyAssign = ref;
- foreach (const QQmlDebugPropertyReference &r, (QList<QQmlDebugPropertyReference>() << copy << copyAssign))
- compareProperties(r, ref);
-}
-
void tst_QQmlEngineDebugService::setBindingForObject()
{
- QQmlDebugObjectReference rootObject = findRootObject();
- QVERIFY(rootObject.debugId() != -1);
- QQmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width");
+ QmlDebugObjectReference rootObject = findRootObject();
+ QVERIFY(rootObject.debugId != -1);
+ QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
- QCOMPARE(widthPropertyRef.value(), QVariant(10));
- QCOMPARE(widthPropertyRef.binding(), QString());
+ QCOMPARE(widthPropertyRef.value, QVariant(10));
+ QCOMPARE(widthPropertyRef.binding, QString());
+ bool success;
//
// set literal
//
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true);
+ m_dbg->setBindingForObject(rootObject.debugId, "width", "15", true,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
+ widthPropertyRef = findProperty(rootObject.properties, "width");
- QCOMPARE(widthPropertyRef.value(), QVariant(15));
- QCOMPARE(widthPropertyRef.binding(), QString());
+ QCOMPARE(widthPropertyRef.value, QVariant(15));
+ QCOMPARE(widthPropertyRef.binding, QString());
//
// set expression
//
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false);
+ m_dbg->setBindingForObject(rootObject.debugId, "width", "height", false,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
+ widthPropertyRef = findProperty(rootObject.properties, "width");
- QCOMPARE(widthPropertyRef.value(), QVariant(20));
- QCOMPARE(widthPropertyRef.binding(), QString("height"));
+ QCOMPARE(widthPropertyRef.value, QVariant(20));
+ QCOMPARE(widthPropertyRef.binding, QString("height"));
//
// reset
//
- m_dbg->resetBindingForObject(rootObject.debugId(), "width");
+ m_dbg->resetBindingForObject(rootObject.debugId, "width", &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
+ widthPropertyRef = findProperty(rootObject.properties, "width");
// QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
- QCOMPARE(widthPropertyRef.binding(), QString());
+ QCOMPARE(widthPropertyRef.binding, QString());
//
// set handler
//
rootObject = findRootObject();
- QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
- QQmlDebugObjectReference mouseAreaObject = rootObject.children().at(2);
- QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
+ QCOMPARE(rootObject.children.size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
+ QmlDebugObjectReference mouseAreaObject = rootObject.children.at(2);
+ m_dbg->queryObjectRecursive(mouseAreaObject, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ mouseAreaObject = m_dbg->object();
- QCOMPARE(mouseAreaObject.className(), QString("MouseArea"));
+ QCOMPARE(mouseAreaObject.className, QString("MouseArea"));
- QQmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
+ QmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })"));
+ QCOMPARE(onEnteredRef.name, QString("onEntered"));
+ QCOMPARE(onEnteredRef.value, QVariant("(function onEntered() { { console.log('hello') } })"));
- m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ;
+ m_dbg->setBindingForObject(mouseAreaObject.debugId, "onEntered",
+ "{console.log('hello, world') }", false,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
rootObject = findRootObject();
- mouseAreaObject = rootObject.children().at(2);
- q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
- onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }"));
+ mouseAreaObject = rootObject.children.at(2);
+ m_dbg->queryObjectRecursive(mouseAreaObject, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ mouseAreaObject = m_dbg->object();
+ onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
+ QCOMPARE(onEnteredRef.name, QString("onEntered"));
+ QCOMPARE(onEnteredRef.value, QVariant("{console.log('hello, world') }"));
}
void tst_QQmlEngineDebugService::setBindingInStates()
@@ -1069,155 +825,151 @@ void tst_QQmlEngineDebugService::setBindingInStates()
const int sourceIndex = 3;
- QQmlDebugObjectReference obj = findRootObject(sourceIndex);
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
+ QmlDebugObjectReference obj = findRootObject(sourceIndex);
+ QVERIFY(obj.debugId != -1);
+ QVERIFY(obj.children.count() >= 2);
+ bool success;
// We are going to switch state a couple of times, we need to get rid of the transition before
- QQmlDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this);
- waitForQuery(q_deleteTransition);
- delete q_deleteTransition;
+ m_dbg->queryExpressionResult(obj.debugId,QString("transitions = []"), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
// check initial value of the property that is changing
- QQmlDebugExpressionQuery *q_setState;
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
+ m_dbg->queryExpressionResult(obj.debugId,QString("state=\"state1\""), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(),200);
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
+ m_dbg->queryExpressionResult(obj.debugId,QString("state=\"\""),
+ &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex, true);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(),100);
// change the binding
- QQmlDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
+ QmlDebugObjectReference state = obj.children[1];
+ QCOMPARE(state.className, QString("State"));
+ QVERIFY(state.children.count() > 0);
- QQmlDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
+ QmlDebugObjectReference propertyChange = state.children[0];
+ QVERIFY(propertyChange.debugId != -1);
- QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) );
+ m_dbg->setBindingForObject(propertyChange.debugId, "width",QVariant(300),true,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
// check properties changed in state
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(),100);
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
+ m_dbg->queryExpressionResult(obj.debugId,QString("state=\"state1\""), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(),300);
// check changing properties of base state from within a state
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false));
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true));
+ m_dbg->setBindingForObject(obj.debugId,"width","height*2",false,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ m_dbg->setBindingForObject(obj.debugId,"height","200",true,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(),300);
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
+ m_dbg->queryExpressionResult(obj.debugId,QString("state=\"\""), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(), 400);
// reset binding while in a state
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
+ m_dbg->queryExpressionResult(obj.debugId,QString("state=\"state1\""), &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(), 300);
- m_dbg->resetBindingForObject(propertyChange.debugId(), "width");
+ m_dbg->resetBindingForObject(propertyChange.debugId, "width", &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(), 400);
// re-add binding
- m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true);
+ m_dbg->setBindingForObject(propertyChange.debugId, "width", "300", true,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+ QCOMPARE(findProperty(obj.properties,"width").value.toInt(), 300);
}
void tst_QQmlEngineDebugService::queryObjectTree()
{
const int sourceIndex = 3;
- // Check if states/transitions are initialized when fetching root item
- QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().contexts().count() >= sourceIndex);
- int count = q_context->rootContext().contexts().count();
- QQmlDebugObjectReference rootObject = q_context->rootContext().contexts()[count - sourceIndex - 1].objects()[0];
-
- QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(q_obj);
-
- QQmlDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
-
+ QmlDebugObjectReference obj = findRootObject(sourceIndex, true);
+ QVERIFY(obj.debugId != -1);
+ QVERIFY(obj.children.count() >= 2);
// check state
- QQmlDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
+ QmlDebugObjectReference state = obj.children[1];
+ QCOMPARE(state.className, QString("State"));
+ QVERIFY(state.children.count() > 0);
- QQmlDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
+ QmlDebugObjectReference propertyChange = state.children[0];
+ QVERIFY(propertyChange.debugId != -1);
- QQmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target");
- QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId());
+ QmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties,"target");
+ QCOMPARE(propertyChangeTarget.objectDebugId, propertyChange.debugId);
- QQmlDebugObjectReference targetReference = qvariant_cast<QQmlDebugObjectReference>(propertyChangeTarget.value());
- QVERIFY(targetReference.debugId() != -1);
+ QmlDebugObjectReference targetReference = qvariant_cast<QmlDebugObjectReference>(propertyChangeTarget.value);
+ QVERIFY(targetReference.debugId != -1);
// check transition
- QQmlDebugObjectReference transition = obj.children()[0];
- QCOMPARE(transition.className(), QString("Transition"));
- QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*"));
- QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value());
- QVERIFY(transition.children().count() > 0);
+ QmlDebugObjectReference transition = obj.children[0];
+ QCOMPARE(transition.className, QString("Transition"));
+ QCOMPARE(findProperty(transition.properties,"from").value.toString(), QString("*"));
+ QCOMPARE(findProperty(transition.properties,"to").value, findProperty(state.properties,"name").value);
+ QVERIFY(transition.children.count() > 0);
- QQmlDebugObjectReference animation = transition.children()[0];
- QVERIFY(animation.debugId() != -1);
+ QmlDebugObjectReference animation = transition.children[0];
+ QVERIFY(animation.debugId != -1);
- QQmlDebugPropertyReference animationTarget = findProperty(animation.properties(),"target");
- QCOMPARE(animationTarget.objectDebugId(), animation.debugId());
+ QmlDebugPropertyReference animationTarget = findProperty(animation.properties,"target");
+ QCOMPARE(animationTarget.objectDebugId, animation.debugId);
- targetReference = qvariant_cast<QQmlDebugObjectReference>(animationTarget.value());
- QVERIFY(targetReference.debugId() != -1);
+ targetReference = qvariant_cast<QmlDebugObjectReference>(animationTarget.value);
+ QVERIFY(targetReference.debugId != -1);
- QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width"));
- QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100);
+ QCOMPARE(findProperty(animation.properties,"property").value.toString(), QString("width"));
+ QCOMPARE(findProperty(animation.properties,"duration").value.toInt(), 100);
}
int main(int argc, char *argv[])
diff --git a/tests/auto/qml/debugger/qqmlinspector/app/app.pro b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
index 9c7574a97e..ce8bfc645a 100644
--- a/tests/auto/qml/debugger/qqmlinspector/app/app.pro
+++ b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
@@ -1,4 +1,5 @@
TARGET = app
+DESTDIR = $$OUT_PWD
QT += qml quick
CONFIG += declarative_debug
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
index e30b847139..39e0f0d3e5 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -141,7 +141,11 @@ void tst_QQmlInspector::cleanupTestCase()
void tst_QQmlInspector::init()
{
+#if defined(Q_OS_WIN)
+ const QString executable = "app\\app.exe";
+#else
const QString executable = "app/app";
+#endif
const QString argument = "-qmljsdebugger=port:"STR_PORT",block";
m_process = new QQmlDebugProcess(executable);
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
index b4ca60b547..6d4758182e 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
@@ -9,4 +9,4 @@ include(../shared/debugutil.pri)
CONFIG += parallel_test declarative_debug
-QT += qml-private testlib
+QT += qml testlib
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
index 2bf43c92a2..a83590cf63 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -12,4 +12,4 @@ OTHER_FILES += data/test.qml
CONFIG += parallel_test declarative_debug
-QT += core-private v8-private qml-private testlib
+QT += core qml testlib
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 2b33ab3944..972c3ac6f4 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -42,7 +42,6 @@
#include <qtest.h>
#include <QLibraryInfo>
-#include "QtQml/private/qqmlprofilerservice_p.h"
#include "debugutil_p.h"
#include "qqmldebugclient.h"
#include "../../../shared/util.h"
@@ -50,11 +49,59 @@
#define PORT 13773
#define STR_PORT "13773"
+struct QQmlProfilerData
+{
+ qint64 time;
+ int messageType;
+ int detailType;
+
+ //###
+ QString detailData; //used by RangeData and RangeLocation
+ int line; //used by RangeLocation
+ int column; //used by RangeLocation
+ int framerate; //used by animation events
+ int animationcount; //used by animation events
+
+ QByteArray toByteArray() const;
+};
+
class QQmlProfilerClient : public QQmlDebugClient
{
Q_OBJECT
public:
+ enum Message {
+ Event,
+ RangeStart,
+ RangeData,
+ RangeLocation,
+ RangeEnd,
+ Complete, // end of transmission
+
+ MaximumMessage
+ };
+
+ enum EventType {
+ FramePaint,
+ Mouse,
+ Key,
+ AnimationFrame,
+ EndTrace,
+ StartTrace,
+
+ MaximumEventType
+ };
+
+ enum RangeType {
+ Painting,
+ Compiling,
+ Creating,
+ Binding, //running a binding
+ HandlingSignal, //running a signal handler
+
+ MaximumRangeType
+ };
+
QQmlProfilerClient(QQmlDebugConnection *connection)
: QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection)
{
@@ -123,21 +170,21 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message)
QVERIFY(data.time >= -1);
switch (data.messageType) {
- case (QQmlProfilerService::Event): {
+ case (QQmlProfilerClient::Event): {
stream >> data.detailType;
switch (data.detailType) {
- case QQmlProfilerService::AnimationFrame: {
+ case QQmlProfilerClient::AnimationFrame: {
stream >> data.framerate >> data.animationcount;
QVERIFY(data.framerate != -1);
QVERIFY(data.animationcount != -1);
break;
}
- case QQmlProfilerService::FramePaint:
- case QQmlProfilerService::Mouse:
- case QQmlProfilerService::Key:
- case QQmlProfilerService::StartTrace:
- case QQmlProfilerService::EndTrace:
+ case QQmlProfilerClient::FramePaint:
+ case QQmlProfilerClient::Mouse:
+ case QQmlProfilerClient::Key:
+ case QQmlProfilerClient::StartTrace:
+ case QQmlProfilerClient::EndTrace:
break;
default: {
QString failMsg = QString("Unknown event type:") + data.detailType;
@@ -147,28 +194,28 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message)
}
break;
}
- case QQmlProfilerService::Complete: {
+ case QQmlProfilerClient::Complete: {
emit complete();
return;
}
- case QQmlProfilerService::RangeStart: {
+ case QQmlProfilerClient::RangeStart: {
stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerClient::MaximumRangeType);
break;
}
- case QQmlProfilerService::RangeEnd: {
+ case QQmlProfilerClient::RangeEnd: {
stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerClient::MaximumRangeType);
break;
}
- case QQmlProfilerService::RangeData: {
+ case QQmlProfilerClient::RangeData: {
stream >> data.detailType >> data.detailData;
- QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerClient::MaximumRangeType);
break;
}
- case QQmlProfilerService::RangeLocation: {
+ case QQmlProfilerClient::RangeLocation: {
stream >> data.detailType >> data.detailData >> data.line >> data.column;
- QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerClient::MaximumRangeType);
QVERIFY(data.line >= -2);
break;
}
@@ -229,12 +276,12 @@ void tst_QQmlProfilerService::blockingConnectWithTraceEnabled()
QVERIFY(m_client->traceMessages.count());
// must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
// must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
void tst_QQmlProfilerService::blockingConnectWithTraceDisabled()
@@ -254,12 +301,12 @@ void tst_QQmlProfilerService::blockingConnectWithTraceDisabled()
QVERIFY(m_client->traceMessages.count());
// must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
// must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
void tst_QQmlProfilerService::nonBlockingConnect()
@@ -276,12 +323,12 @@ void tst_QQmlProfilerService::nonBlockingConnect()
}
// must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
// must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
void tst_QQmlProfilerService::profileOnExit()
@@ -298,12 +345,12 @@ void tst_QQmlProfilerService::profileOnExit()
}
// must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
// must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
QTEST_MAIN(tst_QQmlProfilerService)
diff --git a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
index a8dd634855..5088953c92 100644
--- a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
+++ b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
@@ -12,4 +12,4 @@ OTHER_FILES += data/test.qml
CONFIG += parallel_test declarative_debug
-QT += qml-private testlib
+QT += qml testlib
diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
index 7b9cda937c..497d544390 100644
--- a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
+++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
@@ -42,7 +42,6 @@
#include <qtest.h>
#include <QLibraryInfo>
-#include "QtQml/private/qv8profilerservice_p.h"
#include "debugutil_p.h"
#include "qqmldebugclient.h"
#include "../../../shared/util.h"
@@ -50,11 +49,34 @@
#define PORT 13774
#define STR_PORT "13774"
+struct QV8ProfilerData
+{
+ int messageType;
+ QString filename;
+ QString functionname;
+ int lineNumber;
+ double totalTime;
+ double selfTime;
+ int treeLevel;
+
+ QByteArray toByteArray() const;
+};
+
class QV8ProfilerClient : public QQmlDebugClient
{
Q_OBJECT
public:
+ enum MessageType {
+ V8Entry,
+ V8Complete,
+ V8SnapshotChunk,
+ V8SnapshotComplete,
+ V8Started,
+
+ V8MaximumMessage
+ };
+
QV8ProfilerClient(QQmlDebugConnection *connection)
: QQmlDebugClient(QLatin1String("V8Profiler"), connection)
{
@@ -139,28 +161,28 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message)
stream >> messageType;
QVERIFY(messageType >= 0);
- QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage);
+ QVERIFY(messageType < QV8ProfilerClient::V8MaximumMessage);
switch (messageType) {
- case QV8ProfilerService::V8Entry: {
+ case QV8ProfilerClient::V8Entry: {
QV8ProfilerData entry;
stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel;
traceMessages.append(entry);
break;
}
- case QV8ProfilerService::V8Complete:
+ case QV8ProfilerClient::V8Complete:
emit complete();
break;
- case QV8ProfilerService::V8SnapshotChunk: {
+ case QV8ProfilerClient::V8SnapshotChunk: {
QByteArray json;
stream >> json;
snapshotMessages.append(json);
break;
}
- case QV8ProfilerService::V8SnapshotComplete:
+ case QV8ProfilerClient::V8SnapshotComplete:
emit snapshot();
break;
- case QV8ProfilerService::V8Started:
+ case QV8ProfilerClient::V8Started:
emit started();
break;
default:
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index 3d2f460456..ac9fa5fae2 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -55,23 +55,6 @@ bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int tim
return timer.isActive();
}
-QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent)
- : QQmlDebugService(s, version, parent)
-{
- registerService();
-}
-
-void QQmlDebugTestService::messageReceived(const QByteArray &ba)
-{
- sendMessage(ba);
-}
-
-void QQmlDebugTestService::stateChanged(State)
-{
- emit stateHasChanged();
-}
-
-
QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c)
: QQmlDebugClient(s, c)
{
diff --git a/tests/auto/qml/debugger/shared/debugutil.pri b/tests/auto/qml/debugger/shared/debugutil.pri
index b74f6b08b0..cb9c761395 100644
--- a/tests/auto/qml/debugger/shared/debugutil.pri
+++ b/tests/auto/qml/debugger/shared/debugutil.pri
@@ -1,9 +1,8 @@
-QT += core-private
-
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/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index 177c712833..2ea295b822 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -52,7 +52,6 @@
#include <QtQml/qqmlengine.h>
#include "qqmldebugclient.h"
-#include <private/qqmldebugservice_p.h>
class QQmlDebugTest
{
@@ -60,20 +59,6 @@ public:
static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
};
-class QQmlDebugTestService : public QQmlDebugService
-{
- Q_OBJECT
-public:
- QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
-
-signals:
- void stateHasChanged();
-
-protected:
- virtual void messageReceived(const QByteArray &ba);
- virtual void stateChanged(State state);
-};
-
class QQmlDebugTestClient : public QQmlDebugClient
{
Q_OBJECT
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
index 0453f88350..50feb950fb 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
@@ -40,8 +40,7 @@
****************************************************************************/
#include "qqmldebugclient.h"
-
-#include <private/qpacketprotocol_p.h>
+#include "../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h"
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h
index 1b05e86a64..0f140a1db1 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.h
+++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h
@@ -44,8 +44,6 @@
#include <QtNetwork/qtcpsocket.h>
-#include <private/qtqmlglobal_p.h>
-
class QQmlDebugConnectionPrivate;
class QQmlDebugConnection : public QIODevice
{
@@ -84,7 +82,6 @@ class QQmlDebugClientPrivate;
class QQmlDebugClient : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QQmlDebugClient)
Q_DISABLE_COPY(QQmlDebugClient)
public:
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
new file mode 100644
index 0000000000..1c8afd836b
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite 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 "qqmldebugtestservice.h"
+
+QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent)
+ : QQmlDebugService(s, version, parent)
+{
+ registerService();
+}
+
+void QQmlDebugTestService::messageReceived(const QByteArray &ba)
+{
+ sendMessage(ba);
+}
+
+void QQmlDebugTestService::stateChanged(State)
+{
+ emit stateHasChanged();
+}
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
new file mode 100644
index 0000000000..14fda551de
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
@@ -0,0 +1,62 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite 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 QQMLDEBUGTESTSERVICE_H
+#define QQMLDEBUGTESTSERVICE_H
+
+#include <private/qqmldebugservice_p.h>
+
+class QQmlDebugTestService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
+
+signals:
+ void stateHasChanged();
+
+protected:
+ virtual void messageReceived(const QByteArray &ba);
+ virtual void stateChanged(State state);
+};
+
+#endif // QQMLDEBUGTESTSERVICE_H
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp
deleted file mode 100644
index 8a46c7617c..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebug.cpp
+++ /dev/null
@@ -1,1068 +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"
-
-#include <private/qqmlenginedebugservice_p.h>
-
-#include <QtCore/private/qobject_p.h>
-
-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 QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QQmlEngineDebug)
-public:
- QQmlEngineDebugPrivate(QQmlDebugConnection *);
- ~QQmlEngineDebugPrivate();
-
- void stateChanged(QQmlEngineDebug::State status);
- void message(const QByteArray &);
-
- 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<int, QQmlDebugEnginesQuery *> enginesQuery;
- QHash<int, QQmlDebugRootContextQuery *> rootContextQuery;
- QHash<int, QQmlDebugObjectQuery *> objectQuery;
- QHash<int, QQmlDebugExpressionQuery *> expressionQuery;
-
- QHash<int, QQmlDebugWatch *> watched;
-};
-
-QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *client,
- QQmlEngineDebugPrivate *p)
- : QQmlDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
-{
-}
-
-void QQmlEngineDebugClient::stateChanged(State status)
-{
- if (priv)
- priv->stateChanged(static_cast<QQmlEngineDebug::State>(status));
-}
-
-void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
-{
- if (priv)
- priv->message(data);
-}
-
-QQmlEngineDebugPrivate::QQmlEngineDebugPrivate(QQmlDebugConnection *c)
- : client(new QQmlEngineDebugClient(c, this)), nextId(0)
-{
-}
-
-QQmlEngineDebugPrivate::~QQmlEngineDebugPrivate()
-{
- if (client)
- client->priv = 0;
- delete client;
-
- QHash<int, QQmlDebugEnginesQuery*>::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<int, QQmlDebugRootContextQuery*>::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<int, QQmlDebugObjectQuery*>::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<int, QQmlDebugExpressionQuery*>::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<int, QQmlDebugWatch*>::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 = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->enginesQuery.remove(q->m_queryId);
- }
-}
-
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c,
- QQmlDebugRootContextQuery *q)
-{
- if (c && q) {
- QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->rootContextQuery.remove(q->m_queryId);
- }
-}
-
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugObjectQuery *q)
-{
- if (c && q) {
- QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->objectQuery.remove(q->m_queryId);
- }
-}
-
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugExpressionQuery *q)
-{
- if (c && q) {
- QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->expressionQuery.remove(q->m_queryId);
- }
-}
-
-void QQmlEngineDebugPrivate::remove(QQmlEngineDebug *c, QQmlDebugWatch *w)
-{
- if (c && w) {
- QQmlEngineDebugPrivate *p = (QQmlEngineDebugPrivate *)QObjectPrivate::get(c);
- p->watched.remove(w->m_queryId);
- }
-}
-
-void QQmlEngineDebugPrivate::decode(QDataStream &ds, QQmlDebugObjectReference &o,
- bool simple)
-{
- QQmlEngineDebugService::QQmlObjectData 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) {
- QQmlEngineDebugService::QQmlObjectProperty 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 QQmlEngineDebugService::QQmlObjectProperty::Basic:
- case QQmlEngineDebugService::QQmlObjectProperty::List:
- case QQmlEngineDebugService::QQmlObjectProperty::SignalProperty:
- {
- prop.m_value = data.value;
- break;
- }
- case QQmlEngineDebugService::QQmlObjectProperty::Object:
- {
- QQmlDebugObjectReference obj;
- obj.m_debugId = prop.m_value.toInt();
- prop.m_value = QVariant::fromValue(obj);
- break;
- }
- case QQmlEngineDebugService::QQmlObjectProperty::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_func()->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_func()->newObjects();
- }
-}
-
-QQmlEngineDebug::QQmlEngineDebug(QQmlDebugConnection *client, QObject *parent)
- : QObject(*(new QQmlEngineDebugPrivate(client)), parent)
-{
-}
-
-QQmlEngineDebug::~QQmlEngineDebug()
-{
-}
-
-QQmlEngineDebug::State QQmlEngineDebug::state() const
-{
- Q_D(const QQmlEngineDebug);
-
- return static_cast<QQmlEngineDebug::State>(d->client->state());
-}
-
-QQmlDebugPropertyWatch *QQmlEngineDebug::addWatch(const QQmlDebugPropertyReference &property, QObject *parent)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- 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)
-{
- Q_D(QQmlEngineDebug);
-
- if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line;
- d->client->sendMessage(message);
- return true;
- } else {
- return false;
- }
-}
-
-bool QQmlEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName)
-{
- Q_D(QQmlEngineDebug);
-
- if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
- d->client->sendMessage(message);
- return true;
- } else {
- return false;
- }
-}
-
-bool QQmlEngineDebug::setMethodBody(int objectDebugId, const QString &methodName,
- const QString &methodBody)
-{
- Q_D(QQmlEngineDebug);
-
- if (d->client->state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("SET_METHOD_BODY") << 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<QQmlDebugEngineReference> 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<QQmlDebugPropertyReference> QQmlDebugObjectReference::properties() const
-{
- return m_properties;
-}
-
-QList<QQmlDebugObjectReference> 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<QQmlDebugObjectReference> QQmlDebugContextReference::objects() const
-{
- return m_objects;
-}
-
-QList<QQmlDebugContextReference> 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 2ebdebca53..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebug_p.h
+++ /dev/null
@@ -1,388 +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
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-#include <private/qtqmlglobal_p.h>
-
-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);
-
-Q_SIGNALS:
- void newObjects();
- void stateChanged(State state);
-
-private:
- Q_DECLARE_PRIVATE(QQmlEngineDebug)
-};
-
-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<QQmlDebugPropertyReference> properties() const;
- QList<QQmlDebugObjectReference> 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<QQmlDebugPropertyReference> m_properties;
- QList<QQmlDebugObjectReference> m_children;
-};
-
-class QQmlDebugContextReference
-{
-public:
- QQmlDebugContextReference();
- QQmlDebugContextReference(const QQmlDebugContextReference &);
- QQmlDebugContextReference &operator=(const QQmlDebugContextReference &);
-
- int debugId() const;
- QString name() const;
-
- QList<QQmlDebugObjectReference> objects() const;
- QList<QQmlDebugContextReference> contexts() const;
-
-private:
- friend class QQmlEngineDebugPrivate;
- int m_debugId;
- QString m_name;
- QList<QQmlDebugObjectReference> m_objects;
- QList<QQmlDebugContextReference> 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<QQmlDebugEngineReference> engines() const;
-private:
- friend class QQmlEngineDebug;
- friend class QQmlEngineDebugPrivate;
- QQmlDebugEnginesQuery(QObject *);
- QQmlEngineDebug *m_client;
- int m_queryId;
- QList<QQmlDebugEngineReference> 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
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 6f9cc93757..e34304b258 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -2369,6 +2369,8 @@ void tst_QJSEngine::valueConversion_basic()
QCOMPARE(eng.fromScriptValue<QChar>(code), c);
QCOMPARE(eng.fromScriptValue<QChar>(eng.toScriptValue(c)), c);
}
+
+ QVERIFY(eng.toScriptValue(static_cast<void *>(0)).isNull());
}
#if 0 // FIXME: No API for custom types
@@ -2588,6 +2590,8 @@ void tst_QJSEngine::valueConversion_QVariant()
}
QCOMPARE(qjsvalue_cast<QVariant>(QJSValue(123)), QVariant(123));
+
+ QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, 0)).isNull());
}
#if 0 // FIXME: No support for custom types
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index ad655217ad..3522f22ca2 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -993,8 +993,8 @@ void tst_QJSValue::toVariant()
QCOMPARE(qjsvalue_cast<QVariant>(undefined), QVariant());
QJSValue null = eng.evaluate("null");
- QCOMPARE(null.toVariant(), QVariant());
- QCOMPARE(qjsvalue_cast<QVariant>(null), QVariant());
+ QCOMPARE(null.toVariant(), QVariant(QMetaType::VoidStar, 0));
+ QCOMPARE(qjsvalue_cast<QVariant>(null), QVariant(QMetaType::VoidStar, 0));
{
QJSValue number = eng.toScriptValue(123.0);
@@ -1064,6 +1064,14 @@ void tst_QJSValue::toVariant()
QJSValue str = QJSValue(QString("ciao"));
QCOMPARE(str.toVariant(), QVariant(QString("ciao")));
QCOMPARE(qjsvalue_cast<QVariant>(str), QVariant(QString("ciao")));
+
+ QJSValue undef = QJSValue(QJSValue::UndefinedValue);
+ QCOMPARE(undef.toVariant(), QVariant());
+ QCOMPARE(qjsvalue_cast<QVariant>(undef), QVariant());
+
+ QJSValue nil = QJSValue(QJSValue::NullValue);
+ QCOMPARE(nil.toVariant(), QVariant(QMetaType::VoidStar, 0));
+ QCOMPARE(qjsvalue_cast<QVariant>(nil), QVariant(QMetaType::VoidStar, 0));
}
#if 0 // FIXME: No automatic sequence conversion
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml
new file mode 100644
index 0000000000..578701844c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ dateProperty: if(1) new Date("1982-11-25")
+ dateTimeProperty: if(1) new Date("2009-05-12T13:22:01")
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml
new file mode 100644
index 0000000000..32b88d0183
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ dateProperty: if(1) "1982-11-25Z"
+ dateTimeProperty: if(1) "2009-05-12T13:22:01Z"
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml
new file mode 100644
index 0000000000..16213c691f
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ dateProperty: if(1) new Date("1982-11-25Z")
+ dateTimeProperty: if(1) new Date("2009-05-12T13:22:01Z")
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml
new file mode 100644
index 0000000000..ff1d85fbef
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ dateProperty: if(1) "1982-11-25Z"
+ dateTimeProperty: if(1) "2009-05-12T15:22:01+02:00"
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml
new file mode 100644
index 0000000000..859c02f79c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+MyTypeObject {
+ dateProperty: if(1) new Date("1982-11-25")
+ dateTimeProperty: if(1) new Date("2009-05-12T15:22:01+02:00")
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.qml
new file mode 100644
index 0000000000..07a638d50f
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignDate.qml
@@ -0,0 +1,9 @@
+import Qt.test 1.0
+import QtQuick 2.0
+
+MyTypeObject {
+ Component.onCompleted: {
+ dateProperty = new Date("1982-11-25")
+ dateTimeProperty = new Date("2009-05-12T13:22:01")
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/componentCreation.qml b/tests/auto/qml/qqmlecmascript/data/componentCreation.qml
new file mode 100644
index 0000000000..d21301ea13
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/componentCreation.qml
@@ -0,0 +1,52 @@
+import Qt.test 1.0
+import QtQuick 2.0
+
+MyTypeObject{
+ id: obj
+ objectName: "obj"
+
+ function url()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml');
+ }
+
+ function urlMode()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', Component.PreferSynchronous);
+ }
+
+ function urlParent()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', obj);
+ }
+
+ function urlNullParent()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', null);
+ }
+
+ function urlModeParent()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', Component.PreferSynchronous, obj);
+ }
+
+ function urlModeNullParent()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', Component.PreferSynchronous, null);
+ }
+
+ function invalidSecondArg()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', 'Bad argument');
+ }
+
+ function invalidThirdArg()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', Component.PreferSynchronous, 'Bad argument');
+ }
+
+ function invalidMode()
+ {
+ obj.componentProperty = Qt.createComponent('dynamicCreation.helper.qml', -666);
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/enums.3.qml b/tests/auto/qml/qqmlecmascript/data/enums.3.qml
new file mode 100644
index 0000000000..c77d635a1e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/enums.3.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+import Qt.test 1.0
+import Qt.test 1.0 as Namespace
+
+Item {
+ // Enums from type
+ property int a: Item.Center
+ property int b: Item.Right
+
+ // Enums from Qt
+ property int c: Qt.blue
+ property int d: Qt.darkRed
+
+ // Enums from other type
+ property int e: MyQmlObject.EnumValue3
+ property int f: MyQmlObject.EnumValue4
+
+ // Enums from namespaced other type
+ property int h: Namespace.MyQmlObject.EnumValue3
+ property int i: Namespace.MyQmlObject.EnumValue4
+
+ // Count the onChanged signals to see whether
+ // they're assigned as literals or via bindings
+ property int ac: 0
+ property int bc: 0
+ property int cc: 0
+ property int dc: 0
+ property int ec: 0
+ property int fc: 0
+ property int hc: 0
+ property int ic: 0
+
+ onAChanged: ac++
+ onBChanged: bc++
+ onCChanged: cc++
+ onDChanged: dc++
+ onEChanged: ec++
+ onFChanged: fc++
+ onHChanged: hc++
+ onIChanged: ic++
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml
new file mode 100644
index 0000000000..ae43e90210
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+import com.nokia.JsModule 1.0
+import com.nokia.JsModule 1.0 as RenamedModule
+import "testJsModuleImport.js" as TestJsModuleImport
+
+QtObject {
+ id: testQtObject
+
+ property string importedScriptStringValue: ScriptAPI.greeting();
+ property string renamedScriptStringValue: RenamedModule.ScriptAPI.greeting();
+ property string reimportedScriptStringValue: TestJsModuleImport.importedValue();
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js
new file mode 100644
index 0000000000..2d21953d2c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js
@@ -0,0 +1,5 @@
+.import com.nokia.JsModule 1.0 as JsModule
+
+function importedValue() {
+ return JsModule.ScriptAPI.greeting();
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js b/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js
new file mode 100644
index 0000000000..b90033eeb4
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js
@@ -0,0 +1,5 @@
+var major = 1
+var minor = 0
+
+function greeting() { return "Hello" }
+
diff --git a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir b/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir
new file mode 100644
index 0000000000..c33d1e7a0d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir
@@ -0,0 +1 @@
+ScriptAPI 1.0 ScriptAPI.js
diff --git a/tests/auto/qml/qqmlecmascript/data/ownershipConsistency.qml b/tests/auto/qml/qqmlecmascript/data/ownershipConsistency.qml
new file mode 100644
index 0000000000..7ae099e32e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/ownershipConsistency.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Item {
+ Loader {
+ source: "PropertyVarBaseItem.qml"
+ onLoaded: item.destroy()
+ }
+ Loader {
+ Component.onCompleted: setSource("PropertyVarBaseItem.qml", { random: "" })
+ onLoaded: item.destroy()
+ }
+
+ Repeater {
+ model: 1
+ Item { Component.onCompleted: destroy() }
+ }
+ Repeater {
+ model: 1
+ Item { id: me; Component.onCompleted: { setObject(me); getObject().destroy() } }
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/ownershipRootObject.qml b/tests/auto/qml/qqmlecmascript/data/ownershipRootObject.qml
new file mode 100644
index 0000000000..b1b0b72a87
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/ownershipRootObject.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+QtObject {
+ id: root
+ Component.onCompleted: { setObject(root); getObject() }
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index 64e91fbc95..a79207a1c8 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -196,7 +196,7 @@ void registerTypes()
qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
- qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<MyQmlObject::MyEnum2>("MyEnum2");
qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject");
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 861ff2e641..d932bc6d09 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -71,6 +71,8 @@ public:
private slots:
void initTestCase();
void assignBasicTypes();
+ void assignDate_data();
+ void assignDate();
void idShortcutInvalidates();
void boolPropertiesEvaluateAsBool();
void methods();
@@ -97,6 +99,8 @@ private slots:
void importScope();
void signalParameterTypes();
void objectsCompareAsEqual();
+ void componentCreation_data();
+ void componentCreation();
void dynamicCreation_data();
void dynamicCreation();
void dynamicDestruction();
@@ -129,6 +133,8 @@ private slots:
void ownership();
void cppOwnershipReturnValue();
void ownershipCustomReturnValue();
+ void ownershipRootObject();
+ void ownershipConsistency();
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
@@ -255,6 +261,9 @@ void tst_qqmlecmascript::initTestCase()
{
QQmlDataTest::initTestCase();
registerTypes();
+
+ QString dataDir(dataDirectory() + QLatin1Char('/') + QLatin1String("lib"));
+ engine.addImportPath(dataDir);
}
void tst_qqmlecmascript::assignBasicTypes()
@@ -274,7 +283,7 @@ void tst_qqmlecmascript::assignBasicTypes()
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1), Qt::UTC));
QCOMPARE(object->pointProperty(), QPoint(99,13));
QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
QCOMPARE(object->sizeProperty(), QSize(99, 13));
@@ -302,7 +311,7 @@ void tst_qqmlecmascript::assignBasicTypes()
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1), Qt::UTC));
QCOMPARE(object->pointProperty(), QPoint(99,13));
QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
QCOMPARE(object->sizeProperty(), QSize(99, 13));
@@ -317,6 +326,28 @@ void tst_qqmlecmascript::assignBasicTypes()
}
}
+void tst_qqmlecmascript::assignDate_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("Component.onComplete JS") << testFileUrl("assignDate.qml");
+ QTest::newRow("Binding JS") << testFileUrl("assignDate.2.qml");
+ QTest::newRow("Binding UTC") << testFileUrl("assignDate.3.qml");
+ QTest::newRow("Binding JS UTC") << testFileUrl("assignDate.4.qml");
+ QTest::newRow("Binding UTC+2") << testFileUrl("assignDate.5.qml");
+ QTest::newRow("Binding JS UTC+2 ") << testFileUrl("assignDate.6.qml");
+}
+
+void tst_qqmlecmascript::assignDate()
+{
+ QFETCH(QUrl, source);
+ QQmlComponent component(&engine, source);
+ QScopedPointer<QObject> obj(component.create());
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data());
+ QVERIFY(object != 0);
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1), Qt::UTC));
+}
+
void tst_qqmlecmascript::idShortcutInvalidates()
{
{
@@ -820,6 +851,34 @@ void tst_qqmlecmascript::enums()
delete object;
}
+ // Enums as literals
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // check the values are what we expect
+ QCOMPARE(object->property("a").toInt(), 4);
+ QCOMPARE(object->property("b").toInt(), 5);
+ QCOMPARE(object->property("c").toInt(), 9);
+ QCOMPARE(object->property("d").toInt(), 13);
+ QCOMPARE(object->property("e").toInt(), 2);
+ QCOMPARE(object->property("f").toInt(), 3);
+ QCOMPARE(object->property("h").toInt(), 2);
+ QCOMPARE(object->property("i").toInt(), 3);
+
+ // count of change signals
+ QCOMPARE(object->property("ac").toInt(), 0);
+ QCOMPARE(object->property("bc").toInt(), 0);
+ QCOMPARE(object->property("cc").toInt(), 0);
+ QCOMPARE(object->property("dc").toInt(), 0);
+ QCOMPARE(object->property("ec").toInt(), 0);
+ QCOMPARE(object->property("fc").toInt(), 0);
+ QCOMPARE(object->property("hc").toInt(), 1); // namespace -> binding
+ QCOMPARE(object->property("ic").toInt(), 1); // namespace -> binding
+
+ delete object;
+ }
}
void tst_qqmlecmascript::valueTypeFunctions()
@@ -1199,6 +1258,89 @@ void tst_qqmlecmascript::aliasPropertyReset()
delete object;
}
+void tst_qqmlecmascript::componentCreation_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QString>("creationError");
+ QTest::addColumn<QString>("createdParent");
+
+ QTest::newRow("url")
+ << "url"
+ << ""
+ << "";
+ QTest::newRow("urlMode")
+ << "urlMode"
+ << ""
+ << "";
+ QTest::newRow("urlParent")
+ << "urlParent"
+ << ""
+ << "obj";
+ QTest::newRow("urlNullParent")
+ << "urlNullParent"
+ << ""
+ << "null";
+ QTest::newRow("urlModeParent")
+ << "urlModeParent"
+ << ""
+ << "obj";
+ QTest::newRow("urlModeNullParent")
+ << "urlModeNullParent"
+ << ""
+ << "null";
+ QTest::newRow("invalidSecondArg")
+ << "invalidSecondArg"
+ << ":40: Error: Qt.createComponent(): Invalid arguments"
+ << "";
+ QTest::newRow("invalidThirdArg")
+ << "invalidThirdArg"
+ << ":45: Error: Qt.createComponent(): Invalid parent object"
+ << "";
+ QTest::newRow("invalidMode")
+ << "invalidMode"
+ << ":50: Error: Qt.createComponent(): Invalid arguments"
+ << "";
+}
+
+/*
+Test using createComponent to dynamically generate a component.
+*/
+void tst_qqmlecmascript::componentCreation()
+{
+ QFETCH(QString, method);
+ QFETCH(QString, creationError);
+ QFETCH(QString, createdParent);
+
+ QUrl testUrl(testFileUrl("componentCreation.qml"));
+
+ if (!creationError.isEmpty()) {
+ QString warning = testUrl.toString() + creationError;
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ }
+
+ QQmlComponent component(&engine, testUrl);
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, method.toUtf8());
+ QQmlComponent *created = object->componentProperty();
+
+ if (creationError.isEmpty()) {
+ QVERIFY(created);
+
+ QObject *expectedParent;
+ if (createdParent.isEmpty()) {
+ // For now, the parent should be the engine; this will change for QTBUG-24841
+ expectedParent = &engine;
+ } else if (createdParent == QLatin1String("obj")) {
+ expectedParent = object;
+ } else if (createdParent == QLatin1String("null")) {
+ expectedParent = 0;
+ }
+ QCOMPARE(created->parent(), expectedParent);
+ }
+}
+
void tst_qqmlecmascript::dynamicCreation_data()
{
QTest::addColumn<QString>("method");
@@ -2800,6 +2942,72 @@ void tst_qqmlecmascript::ownershipCustomReturnValue()
QVERIFY(source.value == 0);
}
+//the return value from getObject will be JS ownership,
+//unless strong Cpp ownership has been set
+class OwnershipChangingObject : public QObject
+{
+ Q_OBJECT
+public:
+ OwnershipChangingObject(): object(0) { }
+
+ QPointer<QObject> object;
+
+public slots:
+ QObject *getObject() { return object; }
+ void setObject(QObject *obj) { object = obj; }
+};
+
+void tst_qqmlecmascript::ownershipRootObject()
+{
+ OwnershipChangingObject own;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&own);
+
+ QQmlComponent component(&engine, testFileUrl("ownershipRootObject.qml"));
+ QQmlGuard<QObject> object = component.create(context);
+ QVERIFY(object);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object != 0);
+
+ delete context;
+ delete object;
+}
+
+void tst_qqmlecmascript::ownershipConsistency()
+{
+ OwnershipChangingObject own;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&own);
+
+ QString expectedWarning = testFileUrl("ownershipConsistency.qml").toString() + QLatin1String(":19: Error: Invalid attempt to destroy() an indestructible object");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ expectedWarning = testFileUrl("ownershipConsistency.qml").toString() + QLatin1String(":15: Error: Invalid attempt to destroy() an indestructible object");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ expectedWarning = testFileUrl("ownershipConsistency.qml").toString() + QLatin1String(":6: Error: Invalid attempt to destroy() an indestructible object");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ expectedWarning = testFileUrl("ownershipConsistency.qml").toString() + QLatin1String(":10: Error: Invalid attempt to destroy() an indestructible object");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+
+ QQmlComponent component(&engine, testFileUrl("ownershipConsistency.qml"));
+ QQmlGuard<QObject> object = component.create(context);
+ QVERIFY(object);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object != 0);
+
+ delete context;
+ delete object;
+}
+
class QListQObjectMethodsObject : public QObject
{
Q_OBJECT
@@ -3299,6 +3507,17 @@ void tst_qqmlecmascript::importScripts_data()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(20));
+
+ QTest::newRow("import module which exports a script")
+ << testFileUrl("jsimport/testJsImport.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("importedScriptStringValue")
+ << QLatin1String("renamedScriptStringValue")
+ << QLatin1String("reimportedScriptStringValue"))
+ << (QVariantList() << QVariant(QString("Hello"))
+ << QVariant(QString("Hello"))
+ << QVariant(QString("Hello")));
}
void tst_qqmlecmascript::importScripts()
diff --git a/tests/auto/qml/qqmlerror/.gitattributes b/tests/auto/qml/qqmlerror/.gitattributes
new file mode 100644
index 0000000000..f50af65222
--- /dev/null
+++ b/tests/auto/qml/qqmlerror/.gitattributes
@@ -0,0 +1 @@
+data/test.txt eol=lf
diff --git a/tests/auto/qml/qqmllanguage/data/globalEnums.qml b/tests/auto/qml/qqmllanguage/data/globalEnums.qml
new file mode 100644
index 0000000000..fa248d544d
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/globalEnums.qml
@@ -0,0 +1,55 @@
+import QtQuick 2.0
+import Test 1.0
+
+Item {
+ MyEnum1Class {
+ id: enum1Class
+ objectName: "enum1Class"
+ }
+
+ MyEnumDerivedClass {
+ id: enumDerivedClass
+ objectName: "enumDerivedClass"
+
+ onValueAChanged: {
+ aValue = newValue;
+ }
+
+ onValueBChanged: {
+ bValue = newValue;
+ }
+
+ onValueCChanged: {
+ cValue = newValue;
+ }
+
+ onValueDChanged: {
+ dValue = newValue;
+ }
+
+ onValueEChanged: {
+ eValue = newValue;
+ }
+
+ onValueE2Changed: {
+ e2Value = newValue;
+ }
+
+ property int aValue: 0
+ property int bValue: 0
+ property int cValue: 0
+ property int dValue: 0
+ property int eValue: 0
+ property int e2Value: 0
+ }
+
+ function setEnumValues() {
+ enum1Class.setValue(MyEnum1Class.A_13);
+ enumDerivedClass.setValueA(MyEnum1Class.A_11);
+ enumDerivedClass.setValueB(MyEnum2Class.B_37);
+ enumDerivedClass.setValueC(Qt.RichText);
+ enumDerivedClass.setValueD(Qt.ElideMiddle);
+ enumDerivedClass.setValueE(MyEnum2Class.E_14);
+ enumDerivedClass.setValueE2(MyEnum2Class.E_76);
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 3c7a7c2058..5e9423761c 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -77,6 +77,10 @@ void registerTypes()
qmlRegisterType<MyVersion2Class>("Test.VersionOrder", 2,0, "MyQmlObject");
qmlRegisterType<MyQmlObject>("Test.VersionOrder", 1,0, "MyQmlObject");
+
+ qmlRegisterType<MyEnum1Class>("Test",1,0,"MyEnum1Class");
+ qmlRegisterType<MyEnum2Class>("Test",1,0,"MyEnum2Class");
+ qmlRegisterType<MyEnumDerivedClass>("Test",1,0,"MyEnumDerivedClass");
}
QVariant myCustomVariantTypeConverter(const QString &data)
@@ -85,4 +89,3 @@ QVariant myCustomVariantTypeConverter(const QString &data)
rv.a = data.toInt();
return QVariant::fromValue(rv);
}
-
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index e7294f090c..7b3265efb4 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -811,14 +811,103 @@ class MyVersion2Class : public QObject
Q_OBJECT
};
+class MyEnum1Class : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(EnumA)
+
+public:
+ MyEnum1Class() : value(A_Invalid) {}
+
+ enum EnumA
+ {
+ A_Invalid = -1,
+
+ A_11 = 11,
+ A_13 = 13
+ };
+
+ Q_INVOKABLE void setValue(EnumA v) { value = v; }
+
+ EnumA getValue() { return value; }
+
+private:
+ EnumA value;
+};
+
+class MyEnum2Class : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(EnumB)
+ Q_ENUMS(EnumE)
+
+public:
+ MyEnum2Class() : valueA(MyEnum1Class::A_Invalid), valueB(B_Invalid), valueC(Qt::PlainText),
+ valueD(Qt::ElideLeft), valueE(E_Invalid), valueE2(E_Invalid) {}
+
+ enum EnumB
+ {
+ B_Invalid = -1,
+
+ B_29 = 29,
+ B_31 = 31,
+ B_37 = 37
+ };
+
+ enum EnumE
+ {
+ E_Invalid = -1,
+
+ E_14 = 14,
+ E_76 = 76
+ };
+
+ MyEnum1Class::EnumA getValueA() { return valueA; }
+ EnumB getValueB() { return valueB; }
+ Qt::TextFormat getValueC() { return valueC; }
+ Qt::TextElideMode getValueD() { return valueD; }
+ EnumE getValueE() { return valueE; }
+ EnumE getValueE2() { return valueE2; }
+
+ Q_INVOKABLE void setValueA(MyEnum1Class::EnumA v) { valueA = v; emit valueAChanged(v); }
+ Q_INVOKABLE void setValueB(EnumB v) { valueB = v; emit valueBChanged(v); }
+ Q_INVOKABLE void setValueC(Qt::TextFormat v) { valueC = v; emit valueCChanged(v); } //registered
+ Q_INVOKABLE void setValueD(Qt::TextElideMode v) { valueD = v; emit valueDChanged(v); } //unregistered
+ Q_INVOKABLE void setValueE(EnumE v) { valueE = v; emit valueEChanged(v); }
+ Q_INVOKABLE void setValueE2(MyEnum2Class::EnumE v) { valueE2 = v; emit valueE2Changed(v); }
+
+signals:
+ void valueAChanged(MyEnum1Class::EnumA newValue);
+ void valueBChanged(MyEnum2Class::EnumB newValue);
+ void valueCChanged(Qt::TextFormat newValue);
+ void valueDChanged(Qt::TextElideMode newValue);
+ void valueEChanged(EnumE newValue);
+ void valueE2Changed(MyEnum2Class::EnumE newValue);
+
+private:
+ MyEnum1Class::EnumA valueA;
+ EnumB valueB;
+ Qt::TextFormat valueC;
+ Qt::TextElideMode valueD;
+ EnumE valueE;
+ EnumE valueE2;
+};
+
+class MyEnumDerivedClass : public MyEnum2Class
+{
+ Q_OBJECT
+};
+
+Q_DECLARE_METATYPE(MyEnum2Class::EnumB)
+Q_DECLARE_METATYPE(MyEnum1Class::EnumA)
+Q_DECLARE_METATYPE(Qt::TextFormat)
+
QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
QML_DECLARE_TYPE(MyRevisionedClass)
QML_DECLARE_TYPE(MyRevisionedSubclass)
QML_DECLARE_TYPE(MySubclass)
-
-
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 266cd2a52d..837a9d2604 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
+#include <QSignalSpy>
#include <private/qqmlproperty_p.h>
#include <private/qqmlmetatype_p.h>
@@ -176,6 +177,8 @@ private slots:
void crash1();
void crash2();
+ void globalEnums();
+
private:
QQmlEngine engine;
void testType(const QString& qml, const QString& type, const QString& error);
@@ -2285,6 +2288,64 @@ void tst_qqmllanguage::remoteLoadCrash()
delete o;
}
+// QTBUG-20639
+void tst_qqmllanguage::globalEnums()
+{
+ qRegisterMetaType<MyEnum1Class::EnumA>();
+ qRegisterMetaType<MyEnum2Class::EnumB>();
+ qRegisterMetaType<Qt::TextFormat>();
+
+ QQmlComponent component(&engine, TEST_FILE("globalEnums.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ MyEnum1Class *enum1Class = o->findChild<MyEnum1Class *>(QString::fromLatin1("enum1Class"));
+ QVERIFY(enum1Class != 0);
+ QVERIFY(enum1Class->getValue() == -1);
+
+ MyEnumDerivedClass *enum2Class = o->findChild<MyEnumDerivedClass *>(QString::fromLatin1("enumDerivedClass"));
+ QVERIFY(enum2Class != 0);
+ QVERIFY(enum2Class->getValueA() == -1);
+ QVERIFY(enum2Class->getValueB() == -1);
+ QVERIFY(enum2Class->getValueC() == 0);
+ QVERIFY(enum2Class->getValueD() == 0);
+ QVERIFY(enum2Class->getValueE() == -1);
+ QVERIFY(enum2Class->getValueE2() == -1);
+
+ QVERIFY(enum2Class->property("aValue") == 0);
+ QVERIFY(enum2Class->property("bValue") == 0);
+ QVERIFY(enum2Class->property("cValue") == 0);
+ QVERIFY(enum2Class->property("dValue") == 0);
+ QVERIFY(enum2Class->property("eValue") == 0);
+ QVERIFY(enum2Class->property("e2Value") == 0);
+
+ QSignalSpy signalA(enum2Class, SIGNAL(valueAChanged(MyEnum1Class::EnumA)));
+ QSignalSpy signalB(enum2Class, SIGNAL(valueBChanged(MyEnum2Class::EnumB)));
+
+ QMetaObject::invokeMethod(o, "setEnumValues");
+
+ QVERIFY(enum1Class->getValue() == MyEnum1Class::A_13);
+ QVERIFY(enum2Class->getValueA() == MyEnum1Class::A_11);
+ QVERIFY(enum2Class->getValueB() == MyEnum2Class::B_37);
+ QVERIFY(enum2Class->getValueC() == Qt::RichText);
+ QVERIFY(enum2Class->getValueD() == Qt::ElideMiddle);
+ QVERIFY(enum2Class->getValueE() == MyEnum2Class::E_14);
+ QVERIFY(enum2Class->getValueE2() == MyEnum2Class::E_76);
+
+ QVERIFY(signalA.count() == 1);
+ QVERIFY(signalB.count() == 1);
+
+ QVERIFY(enum2Class->property("aValue") == MyEnum1Class::A_11);
+ QVERIFY(enum2Class->property("bValue") == 37);
+ QVERIFY(enum2Class->property("cValue") == 1);
+ QVERIFY(enum2Class->property("dValue") == 2);
+ QVERIFY(enum2Class->property("eValue") == 14);
+ QVERIFY(enum2Class->property("e2Value") == 76);
+
+ delete o;
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmlxmlhttprequest/.gitattributes b/tests/auto/qml/qqmlxmlhttprequest/.gitattributes
new file mode 100644
index 0000000000..7805eb6951
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/.gitattributes
@@ -0,0 +1,3 @@
+data/testdocument.html eol=lf
+data/redirecttarget.html eol=lf
+data/utf16.html eol=lf
diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
index 68c0d79f92..2726e20577 100644
--- a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
+++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
@@ -10,5 +10,3 @@ TESTDATA = data/*
CONFIG += parallel_test
QT += core-private gui-private qml-private testlib
-
-win32:CONFIG += insignificant_test # QTBUG-24777
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index 3761929362..804bd1a813 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <qtest.h>
+#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
diff --git a/tests/auto/qml/v4/data/objectToBool.qml b/tests/auto/qml/v4/data/objectToBool.qml
new file mode 100644
index 0000000000..8c8a67bee0
--- /dev/null
+++ b/tests/auto/qml/v4/data/objectToBool.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+QtObject {
+ property QtObject prop1: null
+ property QtObject prop2: QtObject {}
+
+ property bool test1: prop1 ? true : false
+ property bool test2: prop2 ? true : false
+
+ property bool test3: prop1 == false
+ property bool test4: prop1 === false
+
+ property bool test5: prop2 == false
+ property bool test6: prop2 === false
+}
+
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
index 1c89617157..8c811f230e 100644
--- a/tests/auto/qml/v4/tst_v4.cpp
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -133,6 +133,7 @@ void tst_v4::qtscript_data()
QTest::newRow("double bool jump") << "doubleBoolJump.qml";
QTest::newRow("unary minus") << "unaryMinus.qml";
QTest::newRow("null qobject") << "nullQObject.qml";
+ QTest::newRow("qobject -> bool") << "objectToBool.qml";
}
void tst_v4::unnecessaryReeval()