aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro3
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp902
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro2
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp30
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro1
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp157
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro1
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp19
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp508
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.h233
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri3
-rw-r--r--tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp124
-rw-r--r--tests/auto/qml/debugger/shared/qqmlinspectorclient.pri3
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp2
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp2
-rw-r--r--tests/auto/qml/qml.pro4
-rw-r--r--tests/auto/qml/qmlcachegen/Retain.qml2
-rw-r--r--tests/auto/qml/qmlcachegen/qmlcachegen.pro3
-rw-r--r--tests/auto/qml/qmlcachegen/retain.qrc5
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp8
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml2
-rw-r--r--tests/auto/qml/qqmlconsole/data/logging.qml2
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp15
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp7
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp2
-rw-r--r--tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml6
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp26
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml67
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp17
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp43
-rw-r--r--tests/auto/qml/qv4assembler/data/crash.qml (renamed from tests/auto/qml/debugger/shared/qqmlinspectorclient.h)56
-rw-r--r--tests/auto/qml/qv4assembler/qv4assembler.pro5
-rw-r--r--tests/auto/qml/qv4assembler/tst_qv4assembler.cpp54
-rw-r--r--tests/auto/qml/v4traced/tst_v4traced.cpp325
-rw-r--r--tests/auto/qml/v4traced/v4traced.pro5
42 files changed, 865 insertions, 1804 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
index 8fef435d98..acd5546a02 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -1,13 +1,12 @@
CONFIG += testcase
TARGET = tst_qqmldebugjs
-QT += qml testlib gui-private core-private
+QT += testlib gui-private core-private
macos:CONFIG -= app_bundle
SOURCES += tst_qqmldebugjs.cpp
INCLUDEPATH += ../shared
include(../shared/debugutil.pri)
-include(../shared/qqmlenginedebugclient.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 1202cddc05..1ac28c473b 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -28,10 +28,10 @@
#include "debugutil_p.h"
#include "qqmldebugprocess_p.h"
-#include "../shared/qqmlenginedebugclient.h"
#include "../../../shared/util.h"
-#include <private/qqmldebugclient_p.h>
+#include <private/qqmlenginedebugclient_p.h>
+#include <private/qv4debugclient_p.h>
#include <private/qqmldebugconnection_p.h>
#include <private/qpacket_p.h>
@@ -43,72 +43,8 @@
#include <QtCore/qdir.h>
#include <QtCore/qmutex.h>
#include <QtCore/qlibraryinfo.h>
-#include <QtQml/qjsengine.h>
-
-const char *V8REQUEST = "v8request";
-const char *V8MESSAGE = "v8message";
-const char *SEQ = "seq";
-const char *TYPE = "type";
-const char *COMMAND = "command";
-const char *ARGUMENTS = "arguments";
-const char *STEPACTION = "stepaction";
-const char *STEPCOUNT = "stepcount";
-const char *EXPRESSION = "expression";
-const char *FRAME = "frame";
-const char *CONTEXT = "context";
-const char *GLOBAL = "global";
-const char *DISABLEBREAK = "disable_break";
-const char *HANDLES = "handles";
-const char *INCLUDESOURCE = "includeSource";
-const char *FROMFRAME = "fromFrame";
-const char *TOFRAME = "toFrame";
-const char *BOTTOM = "bottom";
-const char *NUMBER = "number";
-const char *FRAMENUMBER = "frameNumber";
-const char *TYPES = "types";
-const char *IDS = "ids";
-const char *FILTER = "filter";
-const char *FROMLINE = "fromLine";
-const char *TOLINE = "toLine";
-const char *TARGET = "target";
-const char *LINE = "line";
-const char *COLUMN = "column";
-const char *ENABLED = "enabled";
-const char *CONDITION = "condition";
-const char *IGNORECOUNT = "ignoreCount";
-const char *BREAKPOINT = "breakpoint";
-const char *FLAGS = "flags";
-
-const char *CONTINEDEBUGGING = "continue";
-const char *EVALUATE = "evaluate";
-const char *LOOKUP = "lookup";
-const char *BACKTRACE = "backtrace";
-const char *SCOPE = "scope";
-const char *SCOPES = "scopes";
-const char *SCRIPTS = "scripts";
-const char *SOURCE = "source";
-const char *SETBREAKPOINT = "setbreakpoint";
-const char *CLEARBREAKPOINT = "clearbreakpoint";
-const char *CHANGEBREAKPOINT = "changebreakpoint";
-const char *SETEXCEPTIONBREAK = "setexceptionbreak";
-const char *VERSION = "version";
-const char *DISCONNECT = "disconnect";
-const char *GARBAGECOLLECTOR = "gc";
-
-const char *CONNECT = "connect";
-const char *INTERRUPT = "interrupt";
-
-const char *REQUEST = "request";
-const char *IN = "in";
-const char *NEXT = "next";
-const char *OUT = "out";
-
-const char *SCRIPT = "script";
-const char *SCRIPTREGEXP = "scriptRegExp";
-const char *EVENT = "event";
-
-const char *ALL = "all";
-const char *UNCAUGHT = "uncaught";
+#include <QtCore/qjsonobject.h>
+#include <QtCore/qjsonarray.h>
const char *BLOCKMODE = "-qmljsdebugger=port:3771,3800,block";
const char *NORMALMODE = "-qmljsdebugger=port:3771,3800";
@@ -129,13 +65,6 @@ const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
const char *ENCODEQMLSCOPE_QMLFILE = "encodeQmlScope.qml";
const char *BREAKONANCHOR_QMLFILE = "breakOnAnchor.qml";
-#define VARIANTMAPINIT \
- QString obj("{}"); \
- QJSValue jsonVal = parser.call(QJSValueList() << obj); \
- jsonVal.setProperty(SEQ,QJSValue(seq++)); \
- jsonVal.setProperty(TYPE,REQUEST);
-
-
#undef QVERIFY
#define QVERIFY(statement) \
do {\
@@ -146,9 +75,6 @@ do {\
}\
} while (0)
-
-class QJSDebugClient;
-
class tst_QQmlDebugJS : public QQmlDebugTest
{
Q_OBJECT
@@ -231,7 +157,7 @@ private:
ConnectResult init(bool qmlscene, const QString &qmlFile = QString(TEST_QMLFILE),
bool blockMode = true, bool restrictServices = false);
QList<QQmlDebugClient *> createClients() override;
- QPointer<QJSDebugClient> m_client;
+ QPointer<QV4DebugClient> m_client;
void targetData();
bool waitForClientSignal(const char *signal, int timeout = 30000);
@@ -240,555 +166,7 @@ private:
QTime t;
};
-class QJSDebugClient : public QQmlDebugClient
-{
- Q_OBJECT
-public:
- enum StepAction
- {
- Continue,
- In,
- Out,
- Next
- };
-
- enum Exception
- {
- All,
- Uncaught
- };
-
- QJSDebugClient(QQmlDebugConnection *connection)
- : QQmlDebugClient(QLatin1String("V8Debugger"), connection),
- seq(0)
- {
- parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
- stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
- QObject::connect(this, &QQmlDebugClient::stateChanged,
- this, &QJSDebugClient::onStateChanged);
- }
-
- void connect();
- void interrupt();
-
- void continueDebugging(StepAction stepAction);
- void evaluate(QString expr, int frame = -1, int context = -1);
- void lookup(QList<int> handles, bool includeSource = false);
- void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
- void frame(int number = -1);
- void scope(int number = -1, int frameNumber = -1);
- void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
- void setBreakpoint(QString target, int line = -1, int column = -1, bool enabled = true,
- QString condition = QString(), int ignoreCount = -1);
- void clearBreakpoint(int breakpoint);
- void changeBreakpoint(int breakpoint, bool enabled);
- void setExceptionBreak(Exception type, bool enabled = false);
- void version();
- void disconnect();
-
-protected:
- //inherited from QQmlDebugClient
- void onStateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void connected();
- void interruptRequested();
- void result();
- void failure();
- void stopped();
-
-private:
- void sendMessage(const QByteArray &);
- void flushSendBuffer();
- QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
-
-private:
- QJSEngine jsEngine;
- int seq;
-
- QList<QByteArray> sendBuffer;
-public:
- QJSValue parser;
- QJSValue stringify;
- QByteArray response;
-
-};
-
-void QJSDebugClient::connect()
-{
- const QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}"));
- sendMessage(packMessage(CONNECT,
- stringify.call(QJSValueList() << jsonVal).toString().toUtf8()));
-}
-
-void QJSDebugClient::interrupt()
-{
- sendMessage(packMessage(INTERRUPT));
-}
-
-void QJSDebugClient::continueDebugging(StepAction action)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "continue",
- // "arguments" : { "stepaction" : <"in", "next" or "out">,
- // "stepcount" : <number of steps (default 1)>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
-
- if (action != Continue) {
- QJSValue args = parser.call(QJSValueList() << obj);
- switch (action) {
- case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
- break;
- case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
- break;
- case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
- break;
- default:break;
- }
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::evaluate(QString expr, int frame, int context)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "evaluate",
- // "arguments" : { "expression" : <expression to evaluate>,
- // "frame" : <number>,
- // "context" : <object ID>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
-
- if (frame != -1)
- args.setProperty(QLatin1String(FRAME),QJSValue(frame));
-
- if (context != -1)
- args.setProperty(QLatin1String(CONTEXT), QJSValue(context));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "lookup",
- // "arguments" : { "handles" : <array of handles>,
- // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int handle, handles) {
- array.setProperty(index++,QJSValue(handle));
- }
- args.setProperty(QLatin1String(HANDLES),array);
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "backtrace",
- // "arguments" : { "fromFrame" : <number>
- // "toFrame" : <number>
- // "bottom" : <boolean, set to true if the bottom of the stack is requested>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (fromFrame != -1)
- args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
-
- if (toFrame != -1)
- args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
-
- if (bottom)
- args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::frame(int number)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "frame",
- // "arguments" : { "number" : <frame number>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scope(int number, int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scope",
- // "arguments" : { "number" : <scope number>
- // "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (frameNumber != -1)
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scripts",
- // "arguments" : { "types" : <types of scripts to retrieve
- // set bit 0 for native scripts
- // set bit 1 for extension scripts
- // set bit 2 for normal scripts
- // (default is 4 for normal scripts)>
- // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
- // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
- // "filter" : <string or number: filter string or script id.
- // If a number is specified, then only the script with the same number as its script id will be retrieved.
- // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPES),QJSValue(types));
-
- if (ids.count()) {
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int id, ids) {
- array.setProperty(index++,QJSValue(id));
- }
- args.setProperty(QLatin1String(IDS),array);
- }
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setBreakpoint(QString target, int line, int column, bool enabled,
- QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setbreakpoint",
- // "arguments" : { "type" : "scriptRegExp"
- // "target" : <function expression or script identification>
- // "line" : <line in script or function>
- // "column" : <character position within the line>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
- // }
- // }
-
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(SCRIPTREGEXP)));
- args.setProperty(QLatin1String(TARGET),QJSValue(target));
-
- if (line != -1)
- args.setProperty(QLatin1String(LINE),QJSValue(line));
-
- if (column != -1)
- args.setProperty(QLatin1String(COLUMN),QJSValue(column));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::clearBreakpoint(int breakpoint)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "clearbreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "changebreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to change>
- // "enabled" : <bool: enables the break type if true, disables if false>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND), QLatin1String(CHANGEBREAKPOINT));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT), breakpoint);
- args.setProperty(QLatin1String(ENABLED), enabled);
- jsonVal.setProperty(QLatin1String(ARGUMENTS), args);
-
- const QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setexceptionbreak",
- // "arguments" : { "type" : <string: "all", or "uncaught">,
- // "enabled" : <optional bool: enables the break type if true>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (type == All)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
- else if (type == Uncaught)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
-
- if (enabled)
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::version()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "version",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::disconnect()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "disconnect",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::onStateChanged(State state)
-{
- if (state == Enabled)
- flushSendBuffer();
-}
-
-void QJSDebugClient::messageReceived(const QByteArray &data)
-{
- QPacket ds(connection()->currentDataStreamVersion(), data);
- QByteArray command;
- ds >> command;
-
- if (command == "V8DEBUG") {
- QByteArray type;
- ds >> type >> response;
-
- if (type == CONNECT) {
- emit connected();
-
- } else if (type == INTERRUPT) {
- emit interruptRequested();
-
- } else if (type == V8MESSAGE) {
- QString jsonString(response);
- QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
- QString type = value.value("type").toString();
-
- if (type == "response") {
-
- if (!value.value("success").toBool()) {
- emit failure();
- qDebug() << "Received success == false response from application:"
- << value.value("message").toString();
- return;
- }
-
- QString debugCommand(value.value("command").toString());
- if (debugCommand == "backtrace" ||
- debugCommand == "lookup" ||
- debugCommand == "setbreakpoint" ||
- debugCommand == "evaluate" ||
- debugCommand == "version" ||
- debugCommand == "disconnect" ||
- debugCommand == "gc" ||
- debugCommand == "changebreakpoint" ||
- debugCommand == "clearbreakpoint" ||
- debugCommand == "frame" ||
- debugCommand == "scope" ||
- debugCommand == "scopes" ||
- debugCommand == "scripts" ||
- debugCommand == "source" ||
- debugCommand == "setexceptionbreak" /*||
- debugCommand == "profile"*/) {
- emit result();
- } else {
- // DO NOTHING
- }
-
- } else if (type == QLatin1String(EVENT)) {
- QString event(value.value(QLatin1String(EVENT)).toString());
-
- if (event == "break" ||
- event == "exception")
- emit stopped();
- }
-
- }
- }
-}
-
-void QJSDebugClient::sendMessage(const QByteArray &msg)
-{
- if (state() == Enabled) {
- QQmlDebugClient::sendMessage(msg);
- } else {
- sendBuffer.append(msg);
- }
-}
-
-void QJSDebugClient::flushSendBuffer()
-{
- foreach (const QByteArray &msg, sendBuffer)
- QQmlDebugClient::sendMessage(msg);
- sendBuffer.clear();
-}
-
-QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
-{
- QPacket rs(connection()->currentDataStreamVersion());
- QByteArray cmd = "V8DEBUG";
- rs << cmd << type << message;
- return rs.data();
-}
void tst_QQmlDebugJS::initTestCase()
{
@@ -842,7 +220,7 @@ void tst_QQmlDebugJS::interrupt()
m_client->connect();
m_client->interrupt();
- QVERIFY(waitForClientSignal(SIGNAL(interruptRequested())));
+ QVERIFY(waitForClientSignal(SIGNAL(interrupted())));
}
void tst_QQmlDebugJS::getVersion()
@@ -896,13 +274,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(ONCOMPLETED_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
@@ -917,13 +293,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(ONCOMPLETED_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
@@ -939,13 +313,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(TIMER_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
@@ -960,13 +332,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(TEST_JSFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
@@ -983,13 +353,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
@@ -1006,13 +374,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
@@ -1027,13 +393,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
@@ -1050,11 +414,8 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
//Get the frame index
- QString jsonString = m_client->response;
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
{
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
int frameIndex = body.value("index").toInt();
//Verify the value of 'result'
@@ -1062,13 +423,10 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
QVERIFY(waitForClientSignal(SIGNAL(result())));
}
- jsonString = m_client->response;
- QJSValue val = m_client->parser.call(QJSValueList() << QJSValue(jsonString));
- QVERIFY(val.isObject());
- QJSValue body = val.property(QStringLiteral("body"));
- QVERIFY(body.isObject());
- val = body.property("value");
- QVERIFY(val.isNumber());
+ const QJsonObject body = m_client->response().body.toObject();
+ QVERIFY(!body.isEmpty());
+ QJsonValue val = body.value("value");
+ QVERIFY(val.isDouble());
const int a = val.toInt();
QVERIFY(a > out);
@@ -1086,15 +444,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE));
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
QVERIFY(m_process->waitForFinished());
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
}
@@ -1134,34 +489,32 @@ void tst_QQmlDebugJS::clearBreakpoint()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+ {
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ const QJsonObject body = m_client->response().body.toObject();
+ const QJsonArray breakpointsHit = body.value("breakpoints").toArray();
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+ int breakpoint = breakpointsHit.at(0).toInt();
+ m_client->clearBreakpoint(breakpoint);
- int breakpoint = breakpointsHit.at(0).toInt();
- m_client->clearBreakpoint(breakpoint);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
- QVERIFY(waitForClientSignal(SIGNAL(result())));
+ //Continue with debugging
+ m_client->continueDebugging(QV4DebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- //Continue with debugging
- m_client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(waitForClientSignal(SIGNAL(stopped())));
+ //Continue with debugging
+ m_client->continueDebugging(QV4DebugClient::Continue);
+ }
- //Continue with debugging
- m_client->continueDebugging(QJSDebugClient::Continue);
//Should stop at 2nd breakpoint
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- jsonString = m_client->response;
- value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ {
+ const QJsonObject body = m_client->response().body.toObject();
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ }
}
void tst_QQmlDebugJS::changeBreakpoint()
@@ -1174,23 +527,21 @@ void tst_QQmlDebugJS::changeBreakpoint()
QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess);
bool isStopped = false;
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() { isStopped = true; });
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() { isStopped = true; });
auto continueDebugging = [&]() {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
isStopped = false;
};
m_client->connect();
auto extractBody = [&]() {
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
- return value.value("body").toMap();
+ return m_client->response().body.toObject();
};
- auto extractBreakPointId = [&](const QVariantMap &body) {
- const QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+ auto extractBreakPointId = [&](const QJsonObject &body) {
+ const QJsonArray breakpointsHit = body.value("breakpoints").toArray();
if (breakpointsHit.size() != 1)
return -1;
return breakpointsHit[0].toInt();
@@ -1198,7 +549,7 @@ void tst_QQmlDebugJS::changeBreakpoint()
auto setBreakPoint = [&](int sourceLine, bool enabled) {
int id = -1;
- auto connection = QObject::connect(m_client.data(), &QJSDebugClient::result, [&]() {
+ auto connection = QObject::connect(m_client.data(), &QV4DebugClient::result, [&]() {
id = extractBody().value("breakpoint").toInt();
});
@@ -1221,7 +572,7 @@ void tst_QQmlDebugJS::changeBreakpoint()
auto verifyBreakpoint = [&](int sourceLine, int breakpointId) {
QTRY_VERIFY_WITH_TIMEOUT(isStopped, 30000);
- const QVariantMap body = extractBody();
+ const QJsonObject body = extractBody();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
QCOMPARE(extractBreakPointId(body), breakpointId);
};
@@ -1261,7 +612,7 @@ void tst_QQmlDebugJS::setExceptionBreak()
QFETCH(bool, qmlscene);
QCOMPARE(init(qmlscene, EXCEPTION_QMLFILE), ConnectSuccess);
- m_client->setExceptionBreak(QJSDebugClient::All,true);
+ m_client->setExceptionBreak(QV4DebugClient::All,true);
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
}
@@ -1278,24 +629,19 @@ void tst_QQmlDebugJS::stepNext()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- m_client->continueDebugging(QJSDebugClient::Next);
+ m_client->continueDebugging(QV4DebugClient::Next);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(STEPACTION_QMLFILE));
}
-static QVariantMap responseBody(QJSDebugClient *client)
+static QJsonObject responseBody(QV4DebugClient *client)
{
- const QString jsonString(client->response);
- const QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString))
- .toVariant().toMap();
- return value.value("body").toMap();
+ return client->response().body.toObject();
}
void tst_QQmlDebugJS::stepIn()
@@ -1312,12 +658,12 @@ void tst_QQmlDebugJS::stepIn()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
- m_client->continueDebugging(QJSDebugClient::In);
+ m_client->continueDebugging(QV4DebugClient::In);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- const QVariantMap body = responseBody(m_client);
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::stepOut()
@@ -1334,12 +680,12 @@ void tst_QQmlDebugJS::stepOut()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
- m_client->continueDebugging(QJSDebugClient::Out);
+ m_client->continueDebugging(QV4DebugClient::Out);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- const QVariantMap body = responseBody(m_client);
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::continueDebugging()
@@ -1356,16 +702,14 @@ void tst_QQmlDebugJS::continueDebugging()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::backtrace()
@@ -1449,32 +793,27 @@ void tst_QQmlDebugJS::evaluateInLocalScope()
m_client->frame();
QVERIFY(waitForClientSignal(SIGNAL(result())));
- //Get the frame index
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- m_client->evaluate(QLatin1String("root.a"), frameIndex);
- QVERIFY(waitForClientSignal(SIGNAL(result())));
-
- //Verify the value of 'timer.interval'
- jsonString = m_client->response;
- value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
+ {
+ //Get the frame index
+ const QJsonObject body = responseBody(m_client);
+ int frameIndex = body.value("index").toInt();
+ m_client->evaluate(QLatin1String("root.a"), frameIndex);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+ }
- QCOMPARE(body.value("value").toInt(),10);
+ {
+ //Verify the value of 'timer.interval'
+ const QJsonObject body = responseBody(m_client);
+ QCOMPARE(body.value("value").toInt(),10);
+ }
}
void tst_QQmlDebugJS::evaluateInContext()
{
m_connection = new QQmlDebugConnection();
- m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath)
- + "/qmlscene", this);
- m_client = new QJSDebugClient(m_connection);
+ m_process = new QQmlDebugProcess(
+ QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this);
+ m_client = new QV4DebugClient(m_connection);
QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(m_connection));
m_process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE));
@@ -1497,7 +836,7 @@ void tst_QQmlDebugJS::evaluateInContext()
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
QVERIFY(engineClient->engines().count());
- engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success);
+ engineClient->queryRootContexts(engineClient->engines()[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
@@ -1530,14 +869,12 @@ void tst_QQmlDebugJS::getScripts()
m_client->scripts();
QVERIFY(waitForClientSignal(SIGNAL(result())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList()
- << QJSValue(jsonString)).toVariant().toMap();
- QList<QVariant> scripts = value.value("body").toList();
+ const QJsonArray scripts = m_client->response().body.toArray();
QCOMPARE(scripts.count(), 1);
- QVERIFY(scripts.first().toMap()[QStringLiteral("name")].toString().endsWith(QStringLiteral("data/test.qml")));
+ QVERIFY(scripts.first().toObject()[QStringLiteral("name")].toString()
+ .endsWith(QStringLiteral("data/test.qml")));
}
void tst_QQmlDebugJS::encodeQmlScope()
@@ -1551,42 +888,38 @@ void tst_QQmlDebugJS::encodeQmlScope()
bool isStopped = false;
bool scopesFailed = false;
- QObject::connect(m_client.data(), &QJSDebugClient::failure, this, [&]() {
- qWarning() << "received failure" << m_client->response;
+ QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() {
+ qWarning() << "received failure" << m_client->response().body;
scopesFailed = true;
m_process->stop();
numFrames = 2;
isStopped = false;
});
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() {
m_client->frame();
isStopped = true;
});
- QObject::connect(m_client.data(), &QJSDebugClient::result, this, [&]() {
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
-
- const QMap<QString, QVariant> body = value.value("body").toMap();
- const QString command = value.value("command").toString();
+ QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() {
+ const QV4DebugClient::Response value = m_client->response();
- if (command == QString("scope")) {
+ if (value.command == QString("scope")) {
// If the scope commands fail we get a failure() signal above.
if (++numReceivedScopes == numExpectedScopes) {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
isStopped = false;
}
- } else if (command == QString("frame")) {
+ } else if (value.command == QString("frame")) {
// We want at least a global scope and some kind of local scope here.
- const QList<QVariant> scopes = body.value("scopes").toList();
- if (scopes.length() < 2)
+ const QJsonArray scopes = value.body.toObject().value("scopes").toArray();
+ if (scopes.count() < 2)
scopesFailed = true;
- for (const QVariant &scope : scopes) {
+ for (const QJsonValue &scope : scopes) {
++numExpectedScopes;
- m_client->scope(scope.toMap().value("index").toInt());
+ m_client->scope(scope.toObject().value("index").toInt());
}
++numFrames;
@@ -1611,21 +944,21 @@ void tst_QQmlDebugJS::breakOnAnchor()
int breaks = 0;
bool stopped = false;
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() {
stopped = true;
++breaks;
m_client->evaluate("this", 0, -1);
});
- QObject::connect(m_client.data(), &QJSDebugClient::result, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() {
if (stopped) {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
stopped = false;
}
});
- QObject::connect(m_client.data(), &QJSDebugClient::failure, this, [&]() {
- qWarning() << "received failure" << m_client->response;
+ QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() {
+ qWarning() << "received failure" << m_client->response().body;
});
m_client->setBreakpoint(file, 34);
@@ -1643,7 +976,7 @@ void tst_QQmlDebugJS::breakOnAnchor()
QList<QQmlDebugClient *> tst_QQmlDebugJS::createClients()
{
- m_client = new QJSDebugClient(m_connection);
+ m_client = new QV4DebugClient(m_connection);
return QList<QQmlDebugClient *>({m_client});
}
@@ -1661,10 +994,9 @@ bool tst_QQmlDebugJS::waitForClientSignal(const char *signal, int timeout)
void tst_QQmlDebugJS::checkVersionParameters()
{
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
- QCOMPARE(value.value("command").toString(), QString("version"));
- const QVariantMap body = value.value("body").toMap();
+ const QV4DebugClient::Response value = m_client->response();
+ QCOMPARE(value.command, QString("version"));
+ const QJsonObject body = value.body.toObject();
QCOMPARE(body.value("UnpausedEvaluate").toBool(), true);
QCOMPARE(body.value("ContextEvaluate").toBool(), true);
QCOMPARE(body.value("ChangeBreakpoint").toBool(), true);
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
index 54244c6d16..454a1e3ab0 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
@@ -6,8 +6,6 @@ osx:CONFIG -= app_bundle
SOURCES += tst_qqmlenginedebuginspectorintegration.cpp
-include(../shared/qqmlinspectorclient.pri)
-include(../shared/qqmlenginedebugclient.pri)
include(../shared/debugutil.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
index 249416a3b9..980e2be1f1 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
@@ -26,12 +26,12 @@
**
****************************************************************************/
-#include "qqmlinspectorclient.h"
-#include "qqmlenginedebugclient.h"
#include "../shared/debugutil_p.h"
#include "../../../shared/util.h"
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlenginedebugclient_p.h>
+#include <private/qqmlinspectorclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
@@ -49,7 +49,7 @@ private:
ConnectResult init(bool restrictServices);
QList<QQmlDebugClient *> createClients() override;
- QmlDebugObjectReference findRootObject();
+ QQmlEngineDebugObjectReference findRootObject();
QPointer<QQmlInspectorClient> m_inspectorClient;
QPointer<QQmlEngineDebugClient> m_engineDebugClient;
@@ -65,23 +65,23 @@ private slots:
void destroyObject();
};
-QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject()
+QQmlEngineDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject()
{
bool success = false;
m_engineDebugClient->queryAvailableEngines(&success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
- m_engineDebugClient->queryRootContexts(m_engineDebugClient->engines()[0].debugId, &success);
+ m_engineDebugClient->queryRootContexts(m_engineDebugClient->engines()[0], &success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
int count = m_engineDebugClient->rootContext().contexts.count();
m_engineDebugClient->queryObject(
m_engineDebugClient->rootContext().contexts[count - 1].objects[0], &success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
return m_engineDebugClient->object();
}
@@ -121,7 +121,7 @@ void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup()
QCOMPARE(init(true), ConnectSuccess);
bool success = false;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
const QString fileName = QFileInfo(rootObject.source.url.toString()).fileName();
int lineNumber = rootObject.source.lineNumber;
@@ -131,7 +131,7 @@ void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
success = false;
lineNumber = child.source.lineNumber;
columnNumber = child.source.columnNumber;
@@ -146,10 +146,10 @@ void tst_QQmlEngineDebugInspectorIntegration::select()
{
QCOMPARE(init(true), ConnectSuccess);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QList<int> childIds;
int requestId = 0;
- foreach (const QmlDebugObjectReference &child, rootObject.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, rootObject.children) {
requestId = m_inspectorClient->select(QList<int>() << child.debugId);
QTRY_COMPARE(m_recipient->lastResponseId, requestId);
QVERIFY(m_recipient->lastResult);
@@ -171,7 +171,7 @@ void tst_QQmlEngineDebugInspectorIntegration::createObject()
" color: \"blue\"\n"
"}");
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
@@ -192,7 +192,7 @@ void tst_QQmlEngineDebugInspectorIntegration::moveObject()
QCOMPARE(init(true), ConnectSuccess);
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
@@ -217,7 +217,7 @@ void tst_QQmlEngineDebugInspectorIntegration::destroyObject()
QCOMPARE(init(true), ConnectSuccess);
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
index ed4224446e..5ff65ba276 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
@@ -5,7 +5,6 @@ osx:CONFIG -= app_bundle
SOURCES += \
tst_qqmlenginedebugservice.cpp
-include(../shared/qqmlenginedebugclient.pri)
include(../shared/debugutil.pri)
DEFINES += QT_QML_DEBUG_NO_WARNING
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index c613d88b2b..99c90c142f 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -26,7 +26,6 @@
**
****************************************************************************/
-#include "qqmlenginedebugclient.h"
#include "debugutil_p.h"
#include "../../../shared/util.h"
@@ -36,6 +35,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlproperty_p.h>
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlenginedebugclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
@@ -60,7 +60,7 @@
#define QVERIFYOBJECT(statement) \
do {\
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
- return QmlDebugObjectReference();\
+ return QQmlEngineDebugObjectReference();\
}\
} while (0)
@@ -126,14 +126,14 @@ public:
tst_QQmlEngineDebugService() : m_conn(nullptr), m_dbg(nullptr), m_engine(nullptr), m_rootItem(nullptr) {}
private:
- QmlDebugObjectReference findRootObject(int context = 0,
+ QQmlEngineDebugObjectReference findRootObject(int context = 0,
bool recursive = false);
- QmlDebugPropertyReference findProperty(
- const QList<QmlDebugPropertyReference> &props,
+ QQmlEngineDebugPropertyReference findProperty(
+ const QList<QQmlEngineDebugPropertyReference> &props,
const QString &name) const;
void recursiveObjectTest(QObject *o,
- const QmlDebugObjectReference &oref,
+ const QQmlEngineDebugObjectReference &oref,
bool recursive) const;
void getContexts();
@@ -182,7 +182,7 @@ private slots:
void createObjectOnDestruction();
};
-QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
+QQmlEngineDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
int context, bool recursive)
{
bool success = false;
@@ -191,7 +191,7 @@ QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFYOBJECT(m_dbg->engines().count());
- m_dbg->queryRootContexts(m_dbg->engines()[0].debugId, &success);
+ m_dbg->queryRootContexts(m_dbg->engines()[0], &success);
QVERIFYOBJECT(success);
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
@@ -207,18 +207,18 @@ QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
return m_dbg->object();
}
-QmlDebugPropertyReference tst_QQmlEngineDebugService::findProperty(
- const QList<QmlDebugPropertyReference> &props, const QString &name) const
+QQmlEngineDebugPropertyReference tst_QQmlEngineDebugService::findProperty(
+ const QList<QQmlEngineDebugPropertyReference> &props, const QString &name) const
{
- foreach (const QmlDebugPropertyReference &p, props) {
+ foreach (const QQmlEngineDebugPropertyReference &p, props) {
if (p.name == name)
return p;
}
- return QmlDebugPropertyReference();
+ return QQmlEngineDebugPropertyReference();
}
void tst_QQmlEngineDebugService::recursiveObjectTest(
- QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
+ QObject *o, const QQmlEngineDebugObjectReference &oref, bool recursive) const
{
const QMetaObject *meta = o->metaObject();
@@ -236,8 +236,8 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
int debugId = QQmlDebugService::idForObject(child);
QVERIFY(debugId >= 0);
- QmlDebugObjectReference cref;
- foreach (const QmlDebugObjectReference &ref, oref.children) {
+ QQmlEngineDebugObjectReference cref;
+ foreach (const QQmlEngineDebugObjectReference &ref, oref.children) {
QVERIFY(!ref.className.isEmpty());
if (ref.debugId == debugId) {
cref = ref;
@@ -250,7 +250,7 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
recursiveObjectTest(child, cref, true);
}
- foreach (const QmlDebugPropertyReference &p, oref.properties) {
+ foreach (const QQmlEngineDebugPropertyReference &p, oref.properties) {
QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
// signal properties are fake - they are generated from QQmlAbstractBoundSignal children
@@ -269,7 +269,8 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
QCOMPARE(p.name, QString::fromUtf8(pmeta.name()));
if (pmeta.userType() == QMetaType::QObjectStar) {
- const QmlDebugObjectReference ref = qvariant_cast<QmlDebugObjectReference>(p.value);
+ const QQmlEngineDebugObjectReference ref
+ = qvariant_cast<QQmlEngineDebugObjectReference>(p.value);
QObject *pobj = qvariant_cast<QObject *>(pmeta.read(o));
if (pobj) {
if (pobj->objectName().isEmpty())
@@ -312,9 +313,9 @@ void tst_QQmlEngineDebugService::getContexts()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QList<QmlDebugEngineReference> engines = m_dbg->engines();
+ QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
QCOMPARE(engines.count(), 1);
- m_dbg->queryRootContexts(engines.first().debugId, &success);
+ m_dbg->queryRootContexts(engines.first(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
@@ -441,7 +442,7 @@ void tst_QQmlEngineDebugService::cleanupTestCase()
void tst_QQmlEngineDebugService::setMethodBody()
{
bool success;
- QmlDebugObjectReference obj = findRootObject(2);
+ QQmlEngineDebugObjectReference obj = findRootObject(2);
QVERIFY(!obj.className.isEmpty());
QObject *root = m_components.at(2);
@@ -483,9 +484,9 @@ void tst_QQmlEngineDebugService::setMethodBody()
void tst_QQmlEngineDebugService::watch_property()
{
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
- QmlDebugPropertyReference prop = findProperty(obj.properties, "width");
+ QQmlEngineDebugPropertyReference prop = findProperty(obj.properties, "width");
bool success;
@@ -494,7 +495,7 @@ void tst_QQmlEngineDebugService::watch_property()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugPropertyReference(), &success);
+ m_dbg->addWatch(QQmlEngineDebugPropertyReference(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -528,7 +529,7 @@ void tst_QQmlEngineDebugService::watch_property()
void tst_QQmlEngineDebugService::watch_object()
{
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
bool success;
@@ -538,7 +539,7 @@ void tst_QQmlEngineDebugService::watch_object()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugObjectReference(), &success);
+ m_dbg->addWatch(QQmlEngineDebugObjectReference(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -594,7 +595,7 @@ void tst_QQmlEngineDebugService::watch_expression()
int origWidth = m_rootItem->property("width").toInt();
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
bool success;
@@ -604,7 +605,7 @@ void tst_QQmlEngineDebugService::watch_expression()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugObjectReference(), expr, &success);
+ m_dbg->addWatch(QQmlEngineDebugObjectReference(), expr, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -654,7 +655,7 @@ void tst_QQmlEngineDebugService::watch_expression_data()
void tst_QQmlEngineDebugService::watch_context()
{
- QmlDebugContextReference c;
+ QQmlEngineDebugContextReference c;
QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
bool success;
m_dbg->addWatch(c, QString(), &success);
@@ -663,7 +664,7 @@ void tst_QQmlEngineDebugService::watch_context()
void tst_QQmlEngineDebugService::watch_file()
{
- QmlDebugFileReference f;
+ QQmlEngineDebugFileReference f;
QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
bool success;
m_dbg->addWatch(f, &success);
@@ -684,10 +685,10 @@ void tst_QQmlEngineDebugService::queryAvailableEngines()
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
// TODO test multiple engines
- QList<QmlDebugEngineReference> engines = m_dbg->engines();
+ QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
QCOMPARE(engines.count(), 1);
- foreach (const QmlDebugEngineReference &e, engines) {
+ foreach (const QQmlEngineDebugEngineReference &e, engines) {
QCOMPARE(e.debugId, QQmlDebugService::idForObject(m_engine));
QCOMPARE(e.name, m_engine->objectName());
}
@@ -700,19 +701,19 @@ void tst_QQmlEngineDebugService::queryRootContexts()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFY(m_dbg->engines().count());
- int engineId = m_dbg->engines()[0].debugId;
+ const QQmlEngineDebugEngineReference engine = m_dbg->engines()[0];
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
- unconnected->queryRootContexts(engineId, &success);
+ unconnected->queryRootContexts(engine, &success);
QVERIFY(!success);
delete unconnected;
- m_dbg->queryRootContexts(engineId, &success);
+ m_dbg->queryRootContexts(engine, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QQmlContext *actualContext = m_engine->rootContext();
- QmlDebugContextReference context = m_dbg->rootContext();
+ QQmlEngineDebugContextReference context = m_dbg->rootContext();
QCOMPARE(context.debugId, QQmlDebugService::idForObject(actualContext));
QCOMPARE(context.name, actualContext->objectName());
@@ -730,7 +731,7 @@ void tst_QQmlEngineDebugService::queryObject()
bool success;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
@@ -742,11 +743,11 @@ void tst_QQmlEngineDebugService::queryObject()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
// check source as defined in main()
- QmlDebugFileReference source = obj.source;
+ QQmlEngineDebugFileReference source = obj.source;
QCOMPARE(source.url, QUrl::fromLocalFile(""));
QCOMPARE(source.lineNumber, 3);
QCOMPARE(source.columnNumber, 1);
@@ -755,14 +756,14 @@ void tst_QQmlEngineDebugService::queryObject()
recursiveObjectTest(m_rootItem, obj, recursive);
if (recursive) {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QVERIFY(child.properties.count() > 0);
}
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ QQmlEngineDebugObjectReference rect;
+ QQmlEngineDebugObjectReference text;
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
if (child.className == "Rectangle")
rect = child;
@@ -777,7 +778,7 @@ void tst_QQmlEngineDebugService::queryObject()
QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue")));
} else {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QCOMPARE(child.properties.count(), 0);
}
@@ -798,7 +799,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
bool success;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
const QString fileName = QFileInfo(rootObject.source.url.toString()).fileName();
@@ -821,11 +822,11 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->objects().count(), 1);
- QmlDebugObjectReference obj = m_dbg->objects().first();
+ QQmlEngineDebugObjectReference obj = m_dbg->objects().first();
QVERIFY(!obj.className.isEmpty());
// check source as defined in main()
- QmlDebugFileReference source = obj.source;
+ QQmlEngineDebugFileReference source = obj.source;
QCOMPARE(source.url, QUrl(fileName));
QCOMPARE(source.lineNumber, lineNumber);
QCOMPARE(source.columnNumber, columnNumber);
@@ -834,14 +835,14 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
recursiveObjectTest(m_rootItem, obj, recursive);
if (recursive) {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QVERIFY(child.properties.count() > 0);
}
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ QQmlEngineDebugObjectReference rect;
+ QQmlEngineDebugObjectReference text;
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
if (child.className == "Rectangle")
rect = child;
@@ -856,7 +857,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue")));
} else {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QCOMPARE(child.properties.count(), 0);
}
@@ -873,7 +874,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation_data()
void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
int contextId = rootObject.contextDebugId;
QQmlContext *context = qobject_cast<QQmlContext *>(QQmlDebugService::objectForId(contextId));
@@ -900,7 +901,7 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
QVERIFY(!child.className.isEmpty());
success = false;
lineNumber = child.source.lineNumber;
@@ -923,7 +924,7 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
QVERIFY(!child.className.isEmpty());
success = false;
lineNumber = child.source.lineNumber;
@@ -939,7 +940,7 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
{
bool success;
- QmlDebugObjectReference rootObject = findRootObject(4, true);
+ QQmlEngineDebugObjectReference rootObject = findRootObject(4, true);
QVERIFY(!rootObject.className.isEmpty());
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
@@ -951,7 +952,7 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
QCOMPARE(findProperty(obj.properties, "modelIndex").value,
@@ -962,14 +963,14 @@ void tst_QQmlEngineDebugService::jsonData()
{
bool success;
- QmlDebugObjectReference rootObject = findRootObject(5, true);
+ QQmlEngineDebugObjectReference rootObject = findRootObject(5, true);
QVERIFY(!rootObject.className.isEmpty());
m_dbg->queryObject(rootObject, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
QCOMPARE(findProperty(obj.properties, "data").value,
@@ -1064,10 +1065,10 @@ void tst_QQmlEngineDebugService::queryExpressionResultBC_data()
void tst_QQmlEngineDebugService::setBindingForObject()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QVERIFY(rootObject.debugId != -1);
- QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
+ QQmlEngineDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
QCOMPARE(widthPropertyRef.value, QVariant(10));
QCOMPARE(widthPropertyRef.binding, QString());
@@ -1112,7 +1113,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QCOMPARE(rootObject.children.size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
- QmlDebugObjectReference mouseAreaObject = rootObject.children.at(2);
+ QQmlEngineDebugObjectReference mouseAreaObject = rootObject.children.at(2);
QVERIFY(!mouseAreaObject.className.isEmpty());
m_dbg->queryObjectRecursive(mouseAreaObject, &success);
QVERIFY(success);
@@ -1120,7 +1121,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
mouseAreaObject = m_dbg->object();
QCOMPARE(mouseAreaObject.className, QString("MouseArea"));
- QmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
+ QQmlEngineDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
QCOMPARE(onEnteredRef.name, QString("onEntered"));
// Sorry, can't do that anymore: QCOMPARE(onEnteredRef.value, QVariant("{ console.log('hello') }"));
@@ -1149,10 +1150,10 @@ void tst_QQmlEngineDebugService::setBindingForObject()
void tst_QQmlEngineDebugService::resetBindingForObject()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QVERIFY(rootObject.debugId != -1);
- QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
+ QQmlEngineDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
bool success = false;
@@ -1188,7 +1189,7 @@ void tst_QQmlEngineDebugService::resetBindingForObject()
rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
- QmlDebugPropertyReference boldPropertyRef = findProperty(rootObject.properties, "font.bold");
+ QQmlEngineDebugPropertyReference boldPropertyRef = findProperty(rootObject.properties, "font.bold");
QCOMPARE(boldPropertyRef.value.toBool(), false);
QCOMPARE(boldPropertyRef.binding, QString());
@@ -1200,7 +1201,7 @@ void tst_QQmlEngineDebugService::setBindingInStates()
const int sourceIndex = 3;
- QmlDebugObjectReference obj = findRootObject(sourceIndex);
+ QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
QVERIFY(obj.children.count() >= 2);
@@ -1233,11 +1234,11 @@ void tst_QQmlEngineDebugService::setBindingInStates()
// change the binding
- QmlDebugObjectReference state = obj.children[1];
+ QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
QVERIFY(state.children.count() > 0);
- QmlDebugObjectReference propertyChange = state.children[0];
+ QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
QVERIFY(propertyChange.debugId != -1);
@@ -1316,43 +1317,43 @@ void tst_QQmlEngineDebugService::queryObjectTree()
{
const int sourceIndex = 3;
- QmlDebugObjectReference obj = findRootObject(sourceIndex, true);
+ QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex, true);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
QVERIFY(obj.children.count() >= 2);
// check state
- QmlDebugObjectReference state = obj.children[1];
+ QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
QVERIFY(state.children.count() > 0);
- QmlDebugObjectReference propertyChange = state.children[0];
+ QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
QVERIFY(propertyChange.debugId != -1);
- QmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties,"target");
+ QQmlEngineDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties,"target");
QCOMPARE(propertyChangeTarget.objectDebugId, propertyChange.debugId);
- QmlDebugObjectReference targetReference = qvariant_cast<QmlDebugObjectReference>(propertyChangeTarget.value);
+ QQmlEngineDebugObjectReference targetReference = qvariant_cast<QQmlEngineDebugObjectReference>(propertyChangeTarget.value);
QVERIFY(!targetReference.className.isEmpty());
QCOMPARE(targetReference.debugId, -1);
QCOMPARE(targetReference.name, QString("<unnamed object>"));
// check transition
- QmlDebugObjectReference transition = obj.children[0];
+ QQmlEngineDebugObjectReference 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 animation = transition.children[0];
+ QQmlEngineDebugObjectReference animation = transition.children[0];
QVERIFY(!animation.className.isEmpty());
QVERIFY(animation.debugId != -1);
- QmlDebugPropertyReference animationTarget = findProperty(animation.properties,"target");
+ QQmlEngineDebugPropertyReference animationTarget = findProperty(animation.properties,"target");
QCOMPARE(animationTarget.objectDebugId, animation.debugId);
- targetReference = qvariant_cast<QmlDebugObjectReference>(animationTarget.value);
+ targetReference = qvariant_cast<QQmlEngineDebugObjectReference>(animationTarget.value);
QVERIFY(!targetReference.className.isEmpty());
QCOMPARE(targetReference.debugId, -1);
QCOMPARE(targetReference.name, QString("<unnamed object>"));
@@ -1362,7 +1363,7 @@ void tst_QQmlEngineDebugService::queryObjectTree()
}
void tst_QQmlEngineDebugService::asynchronousCreate() {
- QmlDebugObjectReference object;
+ QQmlEngineDebugObjectReference object;
auto connection = connect(m_dbg, &QQmlEngineDebugClient::newObject, this, [&](int objectId) {
object.debugId = objectId;
});
diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
index 3d4473c693..0d42030b52 100644
--- a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
+++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
@@ -6,7 +6,6 @@ osx:CONFIG -= app_bundle
SOURCES += tst_qqmlinspector.cpp
-include(../shared/qqmlinspectorclient.pri)
include(../shared/debugutil.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
index 5c9506eb21..6685558bb5 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -26,12 +26,12 @@
**
****************************************************************************/
-#include "qqmlinspectorclient.h"
#include "../shared/debugutil_p.h"
#include "../shared/qqmldebugprocess_p.h"
#include "../../../shared/util.h"
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlinspectorclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index e0bd5413fe..085eb7b87a 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -201,7 +201,7 @@ private:
CheckType = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckFileEndsWith
};
- ConnectResult connect(bool block, const QString &testFile, bool recordFromStart = true,
+ ConnectResult connect(bool block, const QString &file, bool recordFromStart = true,
uint flushInterval = 0, bool restrictServices = true,
const QString &executable
= QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
@@ -209,8 +209,8 @@ private:
void checkTraceReceived();
void checkJsHeap();
bool verify(MessageListType type, int expectedPosition,
- const QQmlProfilerEventType &expectedType, quint32 checks,
- const QVector<qint64> &numbers);
+ const QQmlProfilerEventType &expected, quint32 checks,
+ const QVector<qint64> &expectedNumbers);
QList<QQmlDebugClient *> createClients() override;
QScopedPointer<QQmlProfilerTestClient> m_client;
@@ -235,7 +235,7 @@ private slots:
private:
bool m_recordFromStart = true;
- bool m_flushInterval = 0;
+ bool m_flushInterval = false;
bool m_isComplete = false;
// Don't use ({...}) here as MSVC will interpret that as the "QVector(int size)" ctor.
@@ -305,7 +305,7 @@ void tst_QQmlProfilerService::checkJsHeap()
qint64 used = 0;
qint64 lastTimestamp = -1;
foreach (const QQmlProfilerEvent &message, m_client->jsHeapMessages) {
- const qint64 amount = message.number<qint64>(0);
+ const auto amount = message.number<qint64>(0);
const QQmlProfilerEventType &type = m_client->types.at(message.typeIndex());
switch (type.detailType()) {
case HeapPage:
@@ -328,10 +328,11 @@ void tst_QQmlProfilerService::checkJsHeap()
if (lastTimestamp == -1) {
lastTimestamp = message.timestamp();
continue;
- } else if (message.timestamp() == lastTimestamp) {
- continue;
}
+ if (message.timestamp() == lastTimestamp)
+ continue;
+
lastTimestamp = message.timestamp();
QVERIFY2(used >= 0, QString::fromLatin1("Negative memory usage seen: %1")
@@ -759,7 +760,7 @@ void tst_QQmlProfilerService::memory()
QVERIFY(m_client);
int smallItems = 0;
- for (auto message : m_client->jsHeapMessages) {
+ for (const auto& message : m_client->jsHeapMessages) {
const QQmlProfilerEventType &type = m_client->types[message.typeIndex()];
if (type.detailType() == SmallItem)
++smallItems;
@@ -793,7 +794,7 @@ void tst_QQmlProfilerService::compile()
checkJsHeap();
Message rangeStage = MaximumMessage;
- for (auto message : m_client->qmlMessages) {
+ for (const auto& message : m_client->qmlMessages) {
const QQmlProfilerEventType &type = m_client->types[message.typeIndex()];
if (type.rangeType() == Compiling) {
switch (rangeStage) {
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
deleted file mode 100644
index 7e736ec400..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qqmlenginedebugclient.h"
-#include <private/qqmldebugconnection_p.h>
-
-struct QmlObjectData {
- QUrl url;
- int lineNumber;
- int columnNumber;
- QString idString;
- QString objectName;
- QString objectType;
- int objectId;
- int contextId;
- int parentId;
-};
-
-QPacket &operator>>(QPacket &ds, QmlObjectData &data)
-{
- ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
- >> data.objectName >> data.objectType >> data.objectId >> data.contextId
- >> data.parentId;
- return ds;
-}
-
-struct QmlObjectProperty {
- enum Type { Unknown, Basic, Object, List, SignalProperty };
- Type type;
- QString name;
- QVariant value;
- QString valueTypeName;
- QString binding;
- bool hasNotifySignal;
-};
-
-QPacket &operator>>(QPacket &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 = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("WATCH_PROPERTY") << id << property.objectDebugId
- << property.name.toUtf8();
- sendMessage(ds.data());
- *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 = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.debugId << expr;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugObjectReference &object, bool *success)
-{
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("WATCH_OBJECT") << id << object.debugId;
- sendMessage(ds.data());
- *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) {
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("NO_WATCH") << id;
- sendMessage(ds.data());
- *success = true;
- }
-}
-
-quint32 QQmlEngineDebugClient::queryAvailableEngines(bool *success)
-{
- m_engines.clear();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("LIST_ENGINES") << id;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryRootContexts(
- const QmlDebugEngineReference &engine, bool *success)
-{
- m_rootContext = QmlDebugContextReference();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && engine.debugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("LIST_OBJECTS") << id << engine.debugId;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryObject(
- const QmlDebugObjectReference &object, bool *success)
-{
- m_object = QmlDebugObjectReference();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("FETCH_OBJECT") << id << object.debugId << false << true;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryObjectsForLocation(
- const QString &file, int lineNumber, int columnNumber, bool *success)
-{
- m_objects.clear();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
- << columnNumber << false << true;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryObjectRecursive(
- const QmlDebugObjectReference &object, bool *success)
-{
- m_object = QmlDebugObjectReference();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("FETCH_OBJECT") << id << object.debugId << true << true;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryObjectsForLocationRecursive(const QString &file,
- int lineNumber, int columnNumber, bool *success)
-{
- m_objects.clear();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id << file << lineNumber
- << columnNumber << true << true;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryExpressionResult(
- int objectDebugId, const QString &expr, bool *success)
-{
- m_exprResult = QVariant();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr
- << engines()[0].debugId;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::queryExpressionResultBC(
- int objectDebugId, const QString &expr, bool *success)
-{
- m_exprResult = QVariant();
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr;
- sendMessage(ds.data());
- *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 = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
- << bindingExpression << isLiteralValue << source << line;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::resetBindingForObject(
- int objectDebugId,
- const QString &propertyName,
- bool *success)
-{
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-quint32 QQmlEngineDebugClient::setMethodBody(
- int objectDebugId, const QString &methodName,
- const QString &methodBody, bool *success)
-{
- quint32 id = -1;
- *success = false;
- if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
- id = getId();
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
- << methodName << methodBody;
- sendMessage(ds.data());
- *success = true;
- }
- return id;
-}
-
-void QQmlEngineDebugClient::decode(QPacket &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.name = data.value.toString();
- obj.className = prop.valueTypeName;
- prop.value = qVariantFromValue(obj);
- break;
- }
- case QmlObjectProperty::Unknown:
- break;
- }
- o.properties << prop;
- }
-}
-
-void QQmlEngineDebugClient::decode(QPacket &ds,
- QList<QmlDebugObjectReference> &o,
- bool simple)
-{
- int count;
- ds >> count;
- for (int i = 0; i < count; i++) {
- QmlDebugObjectReference obj;
- decode(ds, obj, simple);
- o << obj;
- }
-}
-
-void QQmlEngineDebugClient::decode(QPacket &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;
- QPacket ds(connection()->currentDataStreamVersion(), 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 == "FETCH_OBJECTS_FOR_LOCATION_R") {
- if (!ds.atEnd())
- decode(ds, m_objects, 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") {
- int engineId, objectId, parentId;
- ds >> engineId >> objectId >> parentId;
- emit newObject(objectId);
- 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/shared/qqmlenginedebugclient.h b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
deleted file mode 100644
index 5d74f2d43c..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQMLENGINEDEBUGCLIENT_H
-#define QQMLENGINEDEBUGCLIENT_H
-
-#include <private/qqmldebugclient_p.h>
-#include <private/qpacket_p.h>
-
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-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 queryObjectsForLocation(const QString &file,
- int lineNumber, int columnNumber, bool *success);
- quint32 queryObjectRecursive(const QmlDebugObjectReference &,
- bool *success);
- quint32 queryObjectsForLocationRecursive(const QString &file,
- int lineNumber, int columnNumber, bool *success);
- quint32 queryExpressionResult(int objectDebugId,
- const QString &expr,
- bool *success);
- quint32 queryExpressionResultBC(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(QPacket &ds, QmlDebugContextReference &);
- void decode(QPacket &ds, QmlDebugObjectReference &, bool simple);
- void decode(QPacket &ds, QList<QmlDebugObjectReference> &o, bool simple);
-
- QList<QmlDebugEngineReference> engines() { return m_engines; }
- QmlDebugContextReference rootContext() { return m_rootContext; }
- QmlDebugObjectReference object() { return m_object; }
- QList<QmlDebugObjectReference> objects() { return m_objects; }
- QVariant resultExpr() { return m_exprResult; }
- bool valid() { return m_valid; }
-
-signals:
- void newObject(int objectId);
- 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;
- QList<QmlDebugObjectReference> m_objects;
- QVariant m_exprResult;
-};
-
-#endif // QQMLENGINEDEBUGCLIENT_H
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri
deleted file mode 100644
index a969b4f153..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-HEADERS += $$PWD/qqmlenginedebugclient.h
-
-SOURCES += $$PWD/qqmlenginedebugclient.cpp
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
deleted file mode 100644
index 20faef177e..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qqmlinspectorclient.h"
-
-#include <private/qpacket_p.h>
-#include <private/qqmldebugconnection_p.h>
-#include <QtCore/qdebug.h>
-
-QQmlInspectorClient::QQmlInspectorClient(QQmlDebugConnection *connection) :
- QQmlDebugClient(QLatin1String("QmlInspector"), connection),
- m_lastRequestId(-1)
-{
-}
-
-int QQmlInspectorClient::setInspectToolEnabled(bool enabled)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray(enabled ? "enable" : "disable");
-
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("showAppOnTop") << showOnTop;
-
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::setAnimationSpeed(qreal speed)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("setAnimationSpeed") << speed;
-
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::select(const QList<int> &objectIds)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("select") << objectIds;
-
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::createObject(const QString &qml, int parentId, const QStringList &imports,
- const QString &filename)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("createObject") << qml << parentId << imports << filename;
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::moveObject(int childId, int newParentId)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("moveObject") << childId << newParentId;
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-int QQmlInspectorClient::destroyObject(int objectId)
-{
- QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
- << QByteArray("destroyObject") << objectId;
- sendMessage(ds.data());
- return m_lastRequestId;
-}
-
-void QQmlInspectorClient::messageReceived(const QByteArray &message)
-{
- QPacket ds(connection()->currentDataStreamVersion(), message);
- QByteArray type;
- ds >> type;
-
- if (type != QByteArray("response")) {
- qDebug() << "Unhandled message of type" << type;
- return;
- }
-
- int responseId;
- bool result;
- ds >> responseId >> result;
- emit responseReceived(responseId, result);
-}
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri b/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri
deleted file mode 100644
index c136e1313a..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-HEADERS += $$PWD/qqmlinspectorclient.h
-
-SOURCES += $$PWD/qqmlinspectorclient.cpp
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 42d8f37ca8..76328bb405 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -502,7 +502,7 @@ void tst_QJSEngine::newVariant_valueOfToString()
QJSValue value = object.property("valueOf").callWithInstance(object);
QVERIFY(value.isObject());
QVERIFY(value.strictlyEquals(object));
- QCOMPARE(object.toString(), QString::fromLatin1("QVariant(QPoint)"));
+ QCOMPARE(object.toString(), QString::fromLatin1("QVariant(QPoint, QPoint(10,20))"));
}
}
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index f9718e3699..b58cd98d1e 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -405,7 +405,7 @@ void tst_QJSValue::toString()
// then fall back to "QVariant(typename)"
QJSValue variant = eng.toScriptValue(QPoint(10, 20));
QVERIFY(variant.isVariant());
- QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)"));
+ QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint, QPoint(10,20))"));
variant = eng.toScriptValue(QUrl());
QVERIFY(variant.isVariant());
QVERIFY(variant.toString().isEmpty());
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 7cfddf0eaf..5448088ee5 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -104,3 +104,7 @@ qtConfig(private_tests): \
qtNomakeTools( \
qmlplugindump \
)
+
+QtConfig(qml_tracing) {
+ PRIVATETESTS += v4traced
+}
diff --git a/tests/auto/qml/qmlcachegen/Retain.qml b/tests/auto/qml/qmlcachegen/Retain.qml
new file mode 100644
index 0000000000..0e69012662
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/Retain.qml
@@ -0,0 +1,2 @@
+import QtQml 2.0
+QtObject {}
diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
index 7f7b3128cf..c7820ac1cd 100644
--- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro
+++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
@@ -21,4 +21,7 @@ RESOURCES += Enums.qml
RESOURCES += jsmoduleimport.qml script.mjs
+RESOURCES += retain.qrc
+QTQUICK_COMPILER_RETAINED_RESOURCES += retain.qrc
+
QT += core-private qml-private testlib
diff --git a/tests/auto/qml/qmlcachegen/retain.qrc b/tests/auto/qml/qmlcachegen/retain.qrc
new file mode 100644
index 0000000000..af042b25d8
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/retain.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>Retain.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 97ac466e94..8cfa4cb6af 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -52,6 +52,7 @@ private slots:
void aheadOfTimeCompilation();
void functionExpressions();
void versionChecksForAheadOfTimeUnits();
+ void retainedResources();
void workerScripts();
@@ -392,6 +393,13 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
QQmlMetaType::removeCachedUnitLookupFunction(testHandler);
}
+void tst_qmlcachegen::retainedResources()
+{
+ QFile file(":/Retain.qml");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.readAll().startsWith("import QtQml 2.0"));
+}
+
void tst_qmlcachegen::workerScripts()
{
QVERIFY(QFile::exists(":/workerscripts/worker.js"));
diff --git a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
index 989b295cb5..c5ebed612c 100644
--- a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
@@ -18,7 +18,7 @@ Item{
id: b
Item{
property bool testBool: false
- property int testInt: null
+ property int testInt: { return null; }
property QtObject testObject: null
}
}
diff --git a/tests/auto/qml/qqmlconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml
index 0764ad7545..1f929d311b 100644
--- a/tests/auto/qml/qqmlconsole/data/logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/logging.qml
@@ -68,6 +68,8 @@ QtObject {
console.log(1, ["ping","pong"], new Object, 2);
console.log(contextStringListProperty);
+ console.log(customObject);
+ console.log([[1,2,3,[2,2,2,2],4],[5,6,7,8]]);
try {
console.log(exception);
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
index 817ca0a257..b157314071 100644
--- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -51,6 +51,15 @@ private:
QQmlEngine engine;
};
+struct CustomObject {};
+
+QDebug operator<<(QDebug dbg, const CustomObject &)
+{
+ return dbg << "MY OBJECT";
+}
+
+Q_DECLARE_METATYPE(CustomObject)
+
void tst_qqmlconsole::logging()
{
QUrl testUrl = testFileUrl("logging.qml");
@@ -83,11 +92,17 @@ void tst_qqmlconsole::logging()
QTest::ignoreMessage(QtDebugMsg, "1 pong! [object Object]");
QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] [object Object] 2");
QTest::ignoreMessage(QtDebugMsg, "[Hello,World]");
+ QTest::ignoreMessage(QtDebugMsg, "QVariant(CustomObject, MY OBJECT)");
+ QTest::ignoreMessage(QtDebugMsg, "[[1,2,3,[2,2,2,2],4],[5,6,7,8]]");
QScopedPointer<QQmlContext> loggingContext(new QQmlContext(engine.rootContext()));
QStringList stringList; stringList << QStringLiteral("Hello") << QStringLiteral("World");
loggingContext->setContextProperty("contextStringListProperty", stringList);
+ CustomObject customObject;
+ QVERIFY(QMetaType::registerDebugStreamOperator<CustomObject>());
+ loggingContext->setContextProperty("customObject", QVariant::fromValue(customObject));
+
QQmlComponent component(&engine, testUrl);
QScopedPointer<QObject> object(component.create(loggingContext.data()));
QVERIFY(object != nullptr);
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml b/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml
new file mode 100644
index 0000000000..6666b85ffd
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml
@@ -0,0 +1,7 @@
+import QtQml 2.2
+
+QtObject {
+ property var foo: null
+ property bool signalSeen: false
+ onFooChanged: signalSeen = true
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 788ecce1c5..958bf847ce 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -5991,6 +5991,13 @@ void tst_qqmlecmascript::nullObjectInitializer()
QVERIFY(value.userType() == qMetaTypeId<QObject*>());
QVERIFY(!value.value<QObject*>());
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("qmlVarNullBinding.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QVERIFY(!obj->property("signalSeen").toBool());
+ }
}
// Test that bindings don't evaluate once the engine has been destroyed
diff --git a/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt
new file mode 100644
index 0000000000..af103cf8bf
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt
@@ -0,0 +1 @@
+4:27:Cannot assign object of type "Component" to property of type "QQmlTimer*" as the former is neither the same as the latter nor a sub-class of it.
diff --git a/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml
new file mode 100644
index 0000000000..2159bf8116
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml
@@ -0,0 +1,9 @@
+import QtQml 2.9
+
+QtObject {
+ property Timer stuff: Component {
+ QtObject {
+ objectName: "wrong"
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml
index acd5463a3c..ac5622f9fb 100644
--- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml
@@ -10,7 +10,7 @@ Item {
}
}
- property bool expectNull: null
+ property bool expectNull: { return null; }
function setExpectNull(b) {
success = false;
diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml
index ed0e0d10f0..3c18739c32 100644
--- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml
@@ -10,7 +10,7 @@ Item {
}
}
- property bool expectNull: null
+ property bool expectNull: { return null; }
function setExpectNull(b) {
success = false;
diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml
index f5e94ba715..e2e560199f 100644
--- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml
@@ -10,7 +10,7 @@ Item {
}
}
- property bool expectNull: null
+ property bool expectNull: { return null; }
function setExpectNull(b) {
success = false;
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 89856d6603..764a67a295 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -611,6 +611,8 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("badCompositeRegistration.1") << "badCompositeRegistration.1.qml" << "badCompositeRegistration.1.errors.txt" << false;
QTest::newRow("badCompositeRegistration.2") << "badCompositeRegistration.2.qml" << "badCompositeRegistration.2.errors.txt" << false;
+
+ QTest::newRow("assignComponentToWrongType") << "assignComponentToWrongType.qml" << "assignComponentToWrongType.errors.txt" << false;
}
diff --git a/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
index 7ceb231c8d..b7492e507e 100644
--- a/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
+++ b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
@@ -7,5 +7,11 @@ QtObject {
mydata.opt1 = opt1;
mydata.setOpt1(opt1);
mydata.setOption1(opt1);
+
+ var opt2 = mydata.opt2;
+ opt2 = (opt2 === MyEnum.Short8 ? MyEnum.Short16 : MyEnum.Short0);
+ mydata.opt2 = opt2;
+ mydata.setOpt2(opt2);
+ mydata.setOption2(opt2);
}
}
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 1c8e3c50ab..5abda7b854 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -290,17 +290,27 @@ class MyEnum : public QObject
};
Q_DECLARE_FLAGS(Option1, Option1Flag)
Q_FLAG(Option1)
+
+ enum ShortEnum: quint16 {
+ Short0 = 0,
+ Short8 = 0xff,
+ Short16 = 0xffff
+ };
+ Q_ENUM(ShortEnum);
};
class MyData : public QObject
{
Q_OBJECT
Q_PROPERTY(MyEnum::Option1 opt1 READ opt1 WRITE setOpt1 NOTIFY opt1Changed)
+ Q_PROPERTY(MyEnum::ShortEnum opt2 READ opt2 WRITE setOpt2 NOTIFY opt2Changed)
public:
MyEnum::Option1 opt1() const { return m_opt1; }
+ MyEnum::ShortEnum opt2() const { return m_opt2; }
signals:
void opt1Changed(MyEnum::Option1 opt1);
+ void opt2Changed(MyEnum::ShortEnum opt2);
public slots:
void setOpt1(MyEnum::Option1 opt1)
@@ -312,10 +322,21 @@ public slots:
}
}
+ void setOpt2(MyEnum::ShortEnum opt2)
+ {
+ QCOMPARE(opt2, MyEnum::Short16);
+ if (opt2 != m_opt2) {
+ m_opt2 = opt2;
+ emit opt2Changed(opt2);
+ }
+ }
+
void setOption1(MyEnum::Option1 opt1) { setOpt1(opt1); }
+ void setOption2(MyEnum::ShortEnum opt2) { setOpt2(opt2); }
private:
MyEnum::Option1 m_opt1 = MyEnum::Option10;
+ MyEnum::ShortEnum m_opt2 = MyEnum::Short8;
};
void tst_qqmlpropertycache::passForeignEnums()
@@ -332,11 +353,14 @@ void tst_qqmlpropertycache::passForeignEnums()
QQmlComponent component(&engine, testFile("foreignEnums.qml"));
QVERIFY(component.isReady());
- QObject *obj = component.create(engine.rootContext());
+ QScopedPointer<QObject> obj(component.create(engine.rootContext()));
+ QVERIFY(!obj.isNull());
QCOMPARE(data.opt1(), MyEnum::Option1AD);
+ QCOMPARE(data.opt2(), MyEnum::Short16);
}
Q_DECLARE_METATYPE(MyEnum::Option1)
+Q_DECLARE_METATYPE(MyEnum::ShortEnum)
class TestClass : public QObject
{
diff --git a/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml b/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml
new file mode 100644
index 0000000000..7d2683d869
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml 2.2
+import QtQuick.LocalStorage 2.0
+
+QtObject {
+ property var db;
+ property string version;
+
+ function create() {
+ db = LocalStorage.openDatabaseSync("testdb", "2", "stuff for testing", 100000);
+ version = db.version;
+ }
+
+ function upgrade() {
+ db = db.changeVersion(db.version, "22", function(y) {});
+ version = db.version;
+ }
+}
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
index f1dcefdab6..28f9c9a0c2 100644
--- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -63,6 +63,7 @@ private slots:
void testQml_cleanopen_data();
void testQml_cleanopen();
void totalDatabases();
+ void upgradeDatabase();
void cleanupTestCase();
@@ -200,6 +201,22 @@ void tst_qqmlsqldatabase::totalDatabases()
QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
}
+void tst_qqmlsqldatabase::upgradeDatabase()
+{
+ QQmlComponent component(engine, testFile("changeVersion.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+ QVERIFY(object);
+ QVERIFY(object->property("version").toString().isEmpty());
+
+ QVERIFY(QMetaObject::invokeMethod(object, "create"));
+ QCOMPARE(object->property("version").toString(), QLatin1String("2"));
+
+ QVERIFY(QMetaObject::invokeMethod(object, "upgrade"));
+ QCOMPARE(object->property("version").toString(), QLatin1String("22"));
+}
+
QTEST_MAIN(tst_qqmlsqldatabase)
#include "tst_qqmlsqldatabase.moc"
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 1ee4510e30..6ccfc77c25 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -90,6 +90,7 @@ private slots:
void customValueTypeInQml();
void gadgetInheritance();
void gadgetTemplateInheritance();
+ void sequences();
void toStringConversion();
void enumerableProperties();
void enumProperties();
@@ -1590,6 +1591,7 @@ struct BaseGadget
Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
public:
BaseGadget() : m_baseProperty(0) {}
+ BaseGadget(int initValue) : m_baseProperty(initValue) {}
int baseProperty() const { return m_baseProperty; }
void setBaseProperty(int value) { m_baseProperty = value; }
@@ -1686,6 +1688,47 @@ void tst_qqmlvaluetypes::gadgetTemplateInheritance()
QCOMPARE(value.property("baseProperty").toInt(), 42);
}
+void tst_qqmlvaluetypes::sequences()
+{
+ QJSEngine engine;
+ {
+ QList<BaseGadget> gadgetList{1, 4, 7, 8, 15};
+ QJSValue value = engine.toScriptValue(gadgetList);
+ QCOMPARE(value.property("length").toInt(), gadgetList.length());
+ for (int i = 0; i < gadgetList.length(); ++i)
+ QCOMPARE(value.property(i).property("baseProperty").toInt(), gadgetList.at(i).baseProperty());
+ }
+ {
+ std::vector<BaseGadget> container{1, 4, 7, 8, 15};
+ QJSValue value = engine.toScriptValue(container);
+ QCOMPARE(value.property("length").toInt(), int(container.size()));
+ for (size_t i = 0; i < container.size(); ++i)
+ QCOMPARE(value.property(i).property("baseProperty").toInt(), container.at(i).baseProperty());
+ }
+ {
+ QVector<QChar> qcharVector{1, 4, 42, 8, 15};
+ QJSValue value = engine.toScriptValue(qcharVector);
+ QCOMPARE(value.property("length").toInt(), qcharVector.length());
+ for (int i = 0; i < qcharVector.length(); ++i)
+ QCOMPARE(value.property(i).toInt(), qcharVector.at(i));
+ }
+ {
+ MyTypeObject a, b, c;
+ QSet<QObject*> objSet{&a, &b, &c};
+ QJSValue value = engine.toScriptValue(objSet);
+ QCOMPARE(value.property("length").toInt(), objSet.size());
+ for (int i = 0; i < objSet.size(); ++i)
+ QCOMPARE(value.property(i).property("point").property("x").toInt(), a.point().x());
+ }
+ {
+ MyTypeObject a, b, c;
+ QSet<MyTypeObject*> container{&a, &b, &c};
+ QJSValue value = engine.toScriptValue(container);
+ QCOMPARE(value.property("length").toInt(), container.size());
+ for (int i = 0; i < container.size(); ++i)
+ QCOMPARE(value.property(i).property("point").property("x").toInt(), a.point().x());
+ }
+}
struct StringLessGadget {
Q_GADGET
};
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h b/tests/auto/qml/qv4assembler/data/crash.qml
index bfb489c8f7..dfdb9ceba5 100644
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h
+++ b/tests/auto/qml/qv4assembler/data/crash.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -25,35 +25,29 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QQMLINSPECTORCLIENT_H
-#define QQMLINSPECTORCLIENT_H
-#include <private/qqmldebugclient_p.h>
+import QtQml 2.2
+import Crash 1.0
+
+QtObject {
+ property Crash crash: Crash {
+ id: crash
+ }
+
+ // Recursion makes the crash more reliable
+ // With a single frame the unwinder might guess
+ // the next frame by chance.
+ function recurse(x) {
+ if (x > 32)
+ crash.crash();
+ else
+ recurse(x + 1);
+ }
+
+ property Timer timer: Timer {
+ interval: 10
+ running: true
+ onTriggered: recurse(0)
+ }
+}
-class QQmlInspectorClient : public QQmlDebugClient
-{
- Q_OBJECT
-
-public:
- QQmlInspectorClient(QQmlDebugConnection *connection);
-
- int setInspectToolEnabled(bool enabled);
- int setShowAppOnTop(bool showOnTop);
- int setAnimationSpeed(qreal speed);
- int select(const QList<int> &objectIds);
- int createObject(const QString &qml, int parentId, const QStringList &imports,
- const QString &filename);
- int moveObject(int childId, int newParentId);
- int destroyObject(int objectId);
-
-signals:
- void responseReceived(int requestId, bool result);
-
-protected:
- void messageReceived(const QByteArray &message);
-
-private:
- int m_lastRequestId;
-};
-
-#endif // QQMLINSPECTORCLIENT_H
diff --git a/tests/auto/qml/qv4assembler/qv4assembler.pro b/tests/auto/qml/qv4assembler/qv4assembler.pro
index afd7586ac7..895e241cc9 100644
--- a/tests/auto/qml/qv4assembler/qv4assembler.pro
+++ b/tests/auto/qml/qv4assembler/qv4assembler.pro
@@ -1,7 +1,12 @@
CONFIG += testcase
TARGET = tst_qv4assembler
+
+include (../../shared/util.pri)
+
macos:CONFIG -= app_bundle
+TESTDATA = data/*
+
SOURCES += tst_qv4assembler.cpp
QT += qml-private testlib
diff --git a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
index 9bd1afa256..a04024f2e3 100644
--- a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
+++ b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
@@ -26,18 +26,34 @@
**
****************************************************************************/
+#include <util.h>
+
#include <QtTest/QtTest>
#include <QtCore/qprocess.h>
#include <QtCore/qtemporaryfile.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlapplicationengine.h>
+
+#ifdef Q_OS_WIN
+#include <Windows.h>
+#endif
-class tst_QV4Assembler : public QObject
+class tst_QV4Assembler : public QQmlDataTest
{
Q_OBJECT
private slots:
+ void initTestCase() override;
void perfMapFile();
+ void functionTable();
};
+void tst_QV4Assembler::initTestCase()
+{
+ qputenv("QV4_JIT_CALL_THRESHOLD", "0");
+ QQmlDataTest::initTestCase();
+}
+
void tst_QV4Assembler::perfMapFile()
{
#if !defined(Q_OS_LINUX)
@@ -85,6 +101,42 @@ void tst_QV4Assembler::perfMapFile()
#endif
}
+#ifdef Q_OS_WIN
+class Crash : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Crash(QObject *parent = nullptr) : QObject(parent) { }
+ Q_INVOKABLE static void crash();
+};
+
+static bool crashHandlerHit = false;
+
+static LONG WINAPI crashHandler(EXCEPTION_POINTERS*)
+{
+ crashHandlerHit = true;
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+
+void Crash::crash()
+{
+ SetUnhandledExceptionFilter(crashHandler);
+ RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, nullptr);
+}
+#endif
+
+void tst_QV4Assembler::functionTable()
+{
+#ifndef Q_OS_WIN
+ QSKIP("Function tables only exist on windows.");
+#else
+ QQmlApplicationEngine engine;
+ qmlRegisterType<Crash>("Crash", 1, 0, "Crash");
+ engine.load(testFileUrl("crash.qml"));
+ QTRY_VERIFY(crashHandlerHit);
+#endif
+}
+
QTEST_MAIN(tst_QV4Assembler)
#include "tst_qv4assembler.moc"
diff --git a/tests/auto/qml/v4traced/tst_v4traced.cpp b/tests/auto/qml/v4traced/tst_v4traced.cpp
new file mode 100644
index 0000000000..f82cc0ed5e
--- /dev/null
+++ b/tests/auto/qml/v4traced/tst_v4traced.cpp
@@ -0,0 +1,325 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QJSEngine>
+#include <private/qjsvalue_p.h>
+#include <private/qv4scopedvalue_p.h>
+#include <private/qv4script_p.h>
+
+class EnvVarSaver
+{
+public:
+ EnvVarSaver(const char *name, const QByteArray &newValue)
+ : _name(name)
+ {
+ _wasSet = qEnvironmentVariableIsSet(name);
+ if (_wasSet)
+ _oldValue = qgetenv(name);
+ qputenv(name, newValue);
+ }
+
+ ~EnvVarSaver()
+ {
+ if (_wasSet)
+ qputenv(_name, _oldValue);
+ else
+ qunsetenv(_name);
+ }
+
+private:
+ const char *_name;
+ bool _wasSet;
+ QByteArray _oldValue;
+};
+
+class tst_v4traced : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void collectTraces_data();
+ void collectTraces();
+
+ void binopI32deopt_data();
+ void binopI32deopt();
+
+ void calls_data();
+ void calls();
+
+ void setLookup();
+ void construct();
+};
+
+void tst_v4traced::collectTraces_data()
+{
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<int>("tracePointCount");
+ QTest::addColumn<int>("interestingTracePoint");
+ QTest::addColumn<quint8>("expectedBits");
+
+ QTest::newRow("int+") << "var a = 4; a + 2" << 2 << 1 << quint8(QV4::ObservedTraceValues::Integer);
+ QTest::newRow("double+") << "var a = 4.1; a + 1.9" << 2 << 1 << quint8(QV4::ObservedTraceValues::Double);
+ QTest::newRow("object+") << "var a = '4'; a + '2'" << 2 << 1 << quint8(QV4::ObservedTraceValues::Other);
+}
+
+void tst_v4traced::collectTraces()
+{
+ QFETCH(QString, code);
+ QFETCH(int, tracePointCount);
+ QFETCH(int, interestingTracePoint);
+ QFETCH(quint8, expectedBits);
+
+ EnvVarSaver forceInterpreter("QV4_FORCE_INTERPRETER", "1");
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedValue result(scope);
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "collectTraces"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(script->function()->tracingEnabled());
+ result = script->run();
+ QVERIFY(!scope.engine->hasException);
+
+ QCOMPARE(int(script->function()->compiledFunction->nTraceInfos), tracePointCount);
+ QCOMPARE(*script->function()->traceInfo(interestingTracePoint), expectedBits);
+}
+
+void tst_v4traced::binopI32deopt_data()
+{
+ QTest::addColumn<QString>("operand");
+ QTest::addColumn<int>("int_arg1");
+ QTest::addColumn<int>("int_arg2");
+ QTest::addColumn<int>("int_result");
+ QTest::addColumn<QString>("other_arg1");
+ QTest::addColumn<QString>("other_arg2");
+ QTest::addColumn<double>("other_result");
+
+ QTest::newRow("+") << "+" << 1 << 2 << 3 << "1.1" << "1.9" << 3.0;
+ QTest::newRow("-") << "-" << 3 << 2 << 1 << "3.1" << "2.1" << 1.0;
+ QTest::newRow("*") << "*" << 2 << 3 << 6 << "2.1" << "1.9" << 3.99;
+ QTest::newRow("/") << "/" << 6 << 3 << 2 << "6.6" << "3.3" << 2.0;
+
+ QTest::newRow("&") << "&" << 6 << 3 << 2 << "'6'" << "'3'" << 2.0;
+ QTest::newRow("|") << "|" << 6 << 3 << 7 << "'6'" << "'3'" << 7.0;
+ QTest::newRow("^") << "^" << 6 << 3 << 5 << "'6'" << "'3'" << 5.0;
+
+ QTest::newRow("<<") << "<<" << 5 << 1 << 10 << "'5'" << "'1'" << 10.0;
+ QTest::newRow(">>") << ">>" << -1 << 1 << -1 << "'-1'" << "'1'" << -1.0;
+ QTest::newRow(">>>") << ">>>" << -1 << 1 << 0x7FFFFFFF << "'-1'" << "'1'" << 2147483647.0;
+
+ QTest::newRow("==") << "==" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow("!=") << "!=" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+ QTest::newRow("<" ) << "<" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow("<=") << "<=" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow(">" ) << ">" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+ QTest::newRow(">=") << ">=" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+}
+
+void tst_v4traced::binopI32deopt()
+{
+ QFETCH(QString, operand);
+ QFETCH(int, int_arg1);
+ QFETCH(int, int_arg2);
+ QFETCH(int, int_result);
+ QFETCH(QString, other_arg1);
+ QFETCH(QString, other_arg2);
+ QFETCH(double, other_result);
+
+ QString func = QStringLiteral("function binopI32(a, b) { return a %1 b }").arg(operand);
+ QString intCall = QStringLiteral("binopI32(%1, %2)").arg(int_arg1).arg(int_arg2);
+ QString otherCall = QStringLiteral("binopI32(%1, %2)").arg(other_arg1).arg(other_arg2);
+
+ QJSEngine engine;
+ engine.evaluate(func);
+
+ QCOMPARE(engine.evaluate(intCall).toInt(), int_result); // interpret + trace
+ QCOMPARE(engine.evaluate(intCall).toInt(), int_result); // jit
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // deopt
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // retrace
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // rejit
+}
+
+void tst_v4traced::calls_data()
+{
+ QTest::addColumn<QString>("call");
+
+ QTest::newRow("callGlobalLookup") << "globalLookup";
+ QTest::newRow("callPropertyLookup") << "obj.propertyLookup";
+}
+
+class Calls
+{
+public:
+ static int callCount;
+
+ static QV4::ReturnedValue doSomething(const QV4::FunctionObject */*o*/,
+ const QV4::Value */*thiz*/,
+ const QV4::Value *argv, int argc)
+ {
+ ++callCount;
+
+ if (argc == 0)
+ return QV4::Encode(42);
+
+ int prod = 1;
+ for (int i = 0; i < argc; ++i) {
+ Q_ASSERT(argv[i].isInteger());
+ prod *= argv[i].int_32();
+ }
+ return QV4::Encode(prod);
+ }
+};
+
+int Calls::callCount = 0;
+
+void tst_v4traced::calls()
+{
+ QFETCH(QString, call);
+
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ vm.globalObject->defineDefaultProperty(QLatin1String("globalLookup"),
+ Calls::doSomething);
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("obj"), obj);
+ obj->defineDefaultProperty("propertyLookup", Calls::doSomething);
+
+ QString code = QStringLiteral(
+ "function doCalls() {\n"
+ " if (%1() != 42) return false\n"
+ " if (%1(21, 2) != 42) return false\n"
+ " if (%1(2, 3, 7) != 42) return false\n"
+ " return true\n"
+ "}\n"
+ "var result = true\n"
+ "for (var i = 0; i < 10; ++i) {\n"
+ " if (!doCalls()) { result = false; break }"
+ "}\n"
+ "result\n").arg(call);
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "call"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ Calls::callCount = 0;
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->isBoolean());
+ QVERIFY(result->booleanValue());
+ QCOMPARE(Calls::callCount, 30);
+}
+
+void tst_v4traced::setLookup()
+{
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("oracle"), obj);
+ obj->defineDefaultProperty("answer", QV4::Primitive::fromInt32(32));
+
+ QString code = QStringLiteral(
+ "function doit() {\n"
+ " ++oracle.answer\n"
+ "}\n"
+ "for (var i = 0; i < 10; ++i) doit()\n"
+ "oracle.answer\n");
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "setLookup"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->isInteger());
+ QCOMPARE(result->int_32(), 42);
+}
+
+void tst_v4traced::construct()
+{
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("oracle"), obj);
+ obj->defineDefaultProperty("answer", QV4::Primitive::fromInt32(32));
+
+ QString code = QStringLiteral(
+ "function doit() {\n"
+ " this.arr = new Array()\n"
+ " this.arr[0] = 0\n"
+ " this.arr[1] = 1\n"
+ " this.arr[2] = 2\n"
+ "}\n"
+ "var o\n"
+ "for (var i = 0; i < 10; ++i) o = new doit()\n"
+ "o.arr\n");
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "setLookup"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->as<QV4::ArrayObject>());
+}
+
+QTEST_MAIN(tst_v4traced)
+
+#include "tst_v4traced.moc"
diff --git a/tests/auto/qml/v4traced/v4traced.pro b/tests/auto/qml/v4traced/v4traced.pro
new file mode 100644
index 0000000000..cbc8f38046
--- /dev/null
+++ b/tests/auto/qml/v4traced/v4traced.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_v4traced
+macos:CONFIG -= app_bundle
+QT += core-private qml-private testlib
+SOURCES += tst_v4traced.cpp