diff options
author | Aurindam Jana <aurindam.jana@nokia.com> | 2011-12-02 14:52:21 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-14 18:48:21 +0100 |
commit | 4e2924fbc30905a136cc54f229f1906b11602c3e (patch) | |
tree | 85025c8f0c450ddf8f8e38fc19fc19cdf01638bc /tests/auto/declarative/debugger | |
parent | d8e13b08c67439e4e6695ef72d1a9bb0317e97ff (diff) |
QV8DebugService: Simplify the service code
Removed all parsing functionality. The service only acts as a delegate
to v8 debugger. Apart from that, it calls the v8 debug static APIs
when requested by client.
Change-Id: I2917c2d080e5b409a4b5f39d386279c33634cade
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/declarative/debugger')
12 files changed, 777 insertions, 336 deletions
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml new file mode 100644 index 0000000000..d63e5f1495 --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + Component.onCompleted: { + //Comment + + var b = 6; + } +} + diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml new file mode 100644 index 0000000000..682cf42511 --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int d: 0 + + function doSomething() { + var a = 5; + var b = 6; + } + + Timer { + id: timer; interval: 1; running: true; repeat: true + onTriggered: doSomething(); + } + +} diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml new file mode 100644 index 0000000000..5b7fb4907b --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int a: 0 + Timer { + id: timer; interval: 1; repeat: true; running: true + onTriggered: a++ + } +} + diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml new file mode 100644 index 0000000000..f4ac8437c9 --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE +Item { + Component.onCompleted: { + var component = Qt.createComponent("oncompleted.qml") + if (component.status === Component.Ready) { + component.createObject(); + } + } +} + + diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml new file mode 100644 index 0000000000..ac5bcfbcfb --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: root + + Component.onCompleted: dummy() +} + diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml new file mode 100644 index 0000000000..59001c8b0b --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "test.js" as Script + +//DO NOT CHANGE +Item { + Component.onCompleted: Script.printMessage("onCompleted"); +} diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml new file mode 100644 index 0000000000..98d8b9121a --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + Component.onCompleted: { + console.log("Hello world") + } + id: root + property int a: 10 +} + diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml new file mode 100644 index 0000000000..edb12f4259 --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int d: 0 + + function doSomething() { + var a = 5; + var b = 6; + } + + Component.onCompleted: doSomething() + +} diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml index 3bfeb1011a..ee1751e7b5 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml @@ -40,45 +40,15 @@ ****************************************************************************/ import QtQuick 2.0 -import "test.js" as Script //DO NOT CHANGE -Rectangle { - id: root - width: 10; height: 10; - Component.onCompleted: { Script.printMessage("onCompleted"); doSomething(); } - - property int result: 0 - property int someValue: 10 - property bool raiseException: false - - function doSomething() { - var a = root.result; - var b = commonFunction(); - var c = [1,2,3]; - var d = Script.add(a,c[2]); - result += d; - doSomethingElse(); - } - - Timer { - id: timer; interval: 1 - onTriggered: { - doSomething(); - Script.printMessage("onTriggered"); - } - } - - function commonFunction() { - console.log("commonFunction"); - return 5; - } - - function doSomethingElse() { - result = Script.add(result,8); - if (raiseException) - dummy(); +Item { + Component.onCompleted: { + var a = [1, 2] + var b = {a: "hello", d: 1 } + var c + var d = 12 } } diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml index d48153a56d..386885d23b 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml @@ -44,7 +44,7 @@ import QtQuick 2.0 //DO NOT CHANGE Item { Timer { - id: timer; interval: 1000; running: true; repeat: true; triggeredOnStart: true + id: timer; interval: 1; running: true; repeat: true; triggeredOnStart: true onTriggered: { console.log("timer"); } diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro index 445973882a..8f61aae8c6 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro @@ -18,4 +18,12 @@ DEPLOYMENT += testDataFiles CONFIG += parallel_test OTHER_FILES += data/test.qml data/test.js \ - data/timer.qml + data/timer.qml \ + data/exception.qml \ + data/oncompleted.qml \ + data/loadjsfile.qml \ + data/condition.qml \ + data/changeBreakpoint.qml \ + data/stepAction.qml \ + data/breakpointRelocation.qml \ + data/createComponent.qml diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index aa50d64c9e..8b40b64bdb 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -53,6 +53,8 @@ #include "../shared/debugutil_p.h" #include "../../../shared/util.h" +const char *V8REQUEST = "v8request"; +const char *V8MESSAGE = "v8message"; const char *SEQ = "seq"; const char *TYPE = "type"; const char *COMMAND = "command"; @@ -113,6 +115,8 @@ const char *OUT = "out"; const char *FUNCTION = "function"; const char *SCRIPT = "script"; +const char *SCRIPTREGEXP = "scriptRegExp"; +const char *EVENT = "event"; const char *ALL = "all"; const char *UNCAUGHT = "uncaught"; @@ -125,6 +129,14 @@ const char *NORMALMODE = "-qmljsdebugger=port:3771"; const char *TEST_QMLFILE = "test.qml"; const char *TEST_JSFILE = "test.js"; const char *TIMER_QMLFILE = "timer.qml"; +const char *LOADJSFILE_QMLFILE = "loadjsfile.qml"; +const char *EXCEPTION_QMLFILE = "exception.qml"; +const char *ONCOMPLETED_QMLFILE = "oncompleted.qml"; +const char *CREATECOMPONENT_QMLFILE = "createComponent.qml"; +const char *CONDITION_QMLFILE = "condition.qml"; +const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml"; +const char *STEPACTION_QMLFILE = "stepAction.qml"; +const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml"; #define VARIANTMAPINIT \ QString obj("{}"); \ @@ -158,6 +170,8 @@ private slots: void cleanup(); + void connect(); + void interrupt(); void getVersion(); void getVersionWhenAttaching(); @@ -170,12 +184,14 @@ private slots: void listBreakpoints(); void setBreakpointInScriptOnCompleted(); + void setBreakpointInScriptOnComponentCreated(); void setBreakpointInScriptOnTimerCallback(); void setBreakpointInScriptInDifferentFile(); void setBreakpointInScriptOnComment(); void setBreakpointInScriptOnEmptyLine(); void setBreakpointInScriptWithCondition(); //void setBreakpointInFunction(); //NOT SUPPORTED + void setBreakpointOnEvent(); void setBreakpointWhenAttaching(); void changeBreakpoint(); @@ -214,6 +230,7 @@ private: QDeclarativeDebugProcess *process; QJSDebugClient *client; QDeclarativeDebugConnection *connection; + QTime t; }; class QJSDebugClient : public QDeclarativeDebugClient @@ -248,7 +265,7 @@ public: stringify = jsEngine.evaluate(QLatin1String("JSON.stringify")); } - void startDebugging(); + void connect(); void interrupt(); void continueDebugging(StepAction stepAction, int stepCount = 1); @@ -278,21 +295,21 @@ protected: signals: void enabled(); - void breakpointSet(); + void connected(); + void interruptRequested(); void result(); void stopped(); private: void sendMessage(const QByteArray &); void flushSendBuffer(); - QByteArray packMessage(QByteArray message); + QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray()); private: QJSEngine jsEngine; int seq; QList<QByteArray> sendBuffer; - public: QJSValue parser; QJSValue stringify; @@ -300,30 +317,14 @@ public: }; -void QJSDebugClient::startDebugging() +void QJSDebugClient::connect() { - // { "seq" : <number>, - // "type" : "request", - // "command" : "connect", - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONNECT))); - - QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(CONNECT)); } void QJSDebugClient::interrupt() { - // { "seq" : <number>, - // "type" : "request", - // "command" : "interrupt", - // } - VARIANTMAPINIT; - jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(INTERRUPT))); - - QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(INTERRUPT)); } void QJSDebugClient::continueDebugging(StepAction action, int count) @@ -356,7 +357,7 @@ void QJSDebugClient::continueDebugging(StepAction action, int count) } } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/) @@ -395,7 +396,7 @@ void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::lookup(QList<int> handles, bool includeSource) @@ -428,7 +429,7 @@ void QJSDebugClient::lookup(QList<int> handles, bool includeSource) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom) @@ -460,7 +461,7 @@ void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::frame(int number) @@ -484,7 +485,7 @@ void QJSDebugClient::frame(int number) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::scope(int number, int frameNumber) @@ -512,7 +513,7 @@ void QJSDebugClient::scope(int number, int frameNumber) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::scopes(int frameNumber) @@ -536,7 +537,7 @@ void QJSDebugClient::scopes(int frameNumber) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/) @@ -580,7 +581,7 @@ void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVar } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::source(int frame, int fromLine, int toLine) @@ -613,7 +614,7 @@ void QJSDebugClient::source(int frame, int fromLine, int toLine) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount) @@ -630,34 +631,43 @@ void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int c // "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(QJSValue(), QJSValueList() << obj); + if (type == QLatin1String(EVENT)) { + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << target.toUtf8() << enabled; + sendMessage(packMessage(QByteArray("breakonsignal"), reply)); - args.setProperty(QLatin1String(TYPE),QJSValue(type)); - args.setProperty(QLatin1String(TARGET),QJSValue(target)); + } else { + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT))); - if (line != -1) - args.setProperty(QLatin1String(LINE),QJSValue(line)); + QJSValue args = parser.call(QJSValue(), QJSValueList() << obj); - if (column != -1) - args.setProperty(QLatin1String(COLUMN),QJSValue(column)); + args.setProperty(QLatin1String(TYPE),QJSValue(type)); + args.setProperty(QLatin1String(TARGET),QJSValue(target)); - args.setProperty(QLatin1String(ENABLED),QJSValue(enabled)); + if (line != -1) + args.setProperty(QLatin1String(LINE),QJSValue(line)); - if (!condition.isEmpty()) - args.setProperty(QLatin1String(CONDITION),QJSValue(condition)); + if (column != -1) + args.setProperty(QLatin1String(COLUMN),QJSValue(column)); - if (ignoreCount != -1) - args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount)); + args.setProperty(QLatin1String(ENABLED),QJSValue(enabled)); - if (args.isValid()) { - jsonVal.setProperty(QLatin1String(ARGUMENTS),args); - } + if (!condition.isEmpty()) + args.setProperty(QLatin1String(CONDITION),QJSValue(condition)); - QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + if (ignoreCount != -1) + args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount)); + + if (args.isValid()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); + } } void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount) @@ -690,7 +700,7 @@ void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString cond } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::clearBreakpoint(int breakpoint) @@ -713,7 +723,7 @@ void QJSDebugClient::clearBreakpoint(int breakpoint) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::setExceptionBreak(Exception type, bool enabled) @@ -743,7 +753,7 @@ void QJSDebugClient::setExceptionBreak(Exception type, bool enabled) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::v8flags(QString flags) @@ -766,7 +776,7 @@ void QJSDebugClient::v8flags(QString flags) } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::version() @@ -779,7 +789,7 @@ void QJSDebugClient::version() jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION))); QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } //void QJSDebugClient::profile(ProfileCommand command) @@ -805,7 +815,7 @@ void QJSDebugClient::version() // } // QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); -// sendMessage(packMessage(json.toString().toUtf8())); +// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); //} void QJSDebugClient::disconnect() @@ -818,7 +828,7 @@ void QJSDebugClient::disconnect() jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT))); QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(DISCONNECT, json.toString().toUtf8())); } void QJSDebugClient::gc() @@ -841,7 +851,7 @@ void QJSDebugClient::gc() } QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::listBreakpoints() @@ -854,7 +864,7 @@ void QJSDebugClient::listBreakpoints() jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS))); QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal); - sendMessage(packMessage(json.toString().toUtf8())); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } void QJSDebugClient::statusChanged(Status status) @@ -872,50 +882,59 @@ void QJSDebugClient::messageReceived(const QByteArray &data) ds >> command; if (command == "V8DEBUG") { - ds >> response; - QString jsonString(response); - QVariantMap value = parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - QString type = value.value("type").toString(); - - if (type == "response") { - - if (!value.value("success").toBool()) { -// qDebug() << "Error: The test case will fail since no signal is emitted"; - return; - } - - QString debugCommand(value.value("command").toString()); - if (debugCommand == "backtrace" || - debugCommand == "lookup" || - debugCommand == "setbreakpoint" || - debugCommand == "evaluate" || - debugCommand == "listbreakpoints" || - debugCommand == "version" || - debugCommand == "v8flags" || - 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 == "event") { - QString event(value.value("event").toString()); - - if (event == "break" || - event == "exception") { - emit stopped(); - } + 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(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString type = value.value("type").toString(); + + if (type == "response") { + + if (!value.value("success").toBool()) { +// qDebug() << "Error: The test case will fail since no signal is emitted"; + return; + } + + QString debugCommand(value.value("command").toString()); + if (debugCommand == "backtrace" || + debugCommand == "lookup" || + debugCommand == "setbreakpoint" || + debugCommand == "evaluate" || + debugCommand == "listbreakpoints" || + debugCommand == "version" || + debugCommand == "v8flags" || + 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(); + } } } } @@ -936,17 +955,18 @@ void QJSDebugClient::flushSendBuffer() sendBuffer.clear(); } -QByteArray QJSDebugClient::packMessage(QByteArray message) +QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message) { QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); QByteArray cmd = "V8DEBUG"; - rs << cmd << message; + rs << cmd << type << message; return reply; } void tst_QDeclarativeDebugJS::initTestCase() { + t.start(); process = 0; client = 0; connection = 0; @@ -964,6 +984,8 @@ void tst_QDeclarativeDebugJS::cleanupTestCase() if (connection) delete connection; + +// qDebug() << "Time Elapsed:" << t.elapsed(); } bool tst_QDeclarativeDebugJS::init(const QString &qmlFile, bool blockMode) @@ -1009,14 +1031,33 @@ void tst_QDeclarativeDebugJS::cleanup() connection = 0; } +void tst_QDeclarativeDebugJS::connect() +{ + //void connect() + + QVERIFY(init()); + client->connect(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected()))); +} + +void tst_QDeclarativeDebugJS::interrupt() +{ + //void connect() + + QVERIFY(init()); + client->connect(); + + client->interrupt(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(interruptRequested()))); +} + void tst_QDeclarativeDebugJS::getVersion() { //void version() QVERIFY(init()); - client->interrupt(); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected()))); client->version(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1027,9 +1068,7 @@ void tst_QDeclarativeDebugJS::getVersionWhenAttaching() //void version() QVERIFY(init(QLatin1String(TIMER_QMLFILE), false)); - client->interrupt(); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); client->version(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1040,9 +1079,7 @@ void tst_QDeclarativeDebugJS::applyV8Flags() //void v8flags(QString flags) QVERIFY(init()); - client->interrupt(); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); client->v8flags(QString()); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1053,9 +1090,7 @@ void tst_QDeclarativeDebugJS::disconnect() //void disconnect() QVERIFY(init()); - client->interrupt(); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); client->disconnect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1066,9 +1101,7 @@ void tst_QDeclarativeDebugJS::gc() //void gc() QVERIFY(init()); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), 43, -1, true); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); client->gc(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1078,17 +1111,19 @@ void tst_QDeclarativeDebugJS::listBreakpoints() { //void listBreakpoints() - int sourceLine1 = 57; - int sourceLine2 = 60; - int sourceLine3 = 67; + int sourceLine1 = 47; + int sourceLine2 = 48; + int sourceLine3 = 49; QVERIFY(init()); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), sourceLine3, -1, true); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); client->listBreakpoints(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1104,11 +1139,11 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnCompleted() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine = 49; - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); @@ -1117,24 +1152,37 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnCompleted() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE)); } -void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback() +void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComponentCreated() { - int sourceLine = 49; - QVERIFY(init()); - - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - sourceLine = 67; - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + + int sourceLine = 47; + QVERIFY(init(CREATECOMPONENT_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - client->evaluate("timer.running = true"); - client->continueDebugging(QJSDebugClient::Continue); + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE)); +} +void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback() +{ + int sourceLine = 48; + QVERIFY(init(TIMER_QMLFILE)); + + client->connect(); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); @@ -1143,7 +1191,7 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE)); } void tst_QDeclarativeDebugJS::setBreakpointInScriptInDifferentFile() @@ -1151,10 +1199,10 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptInDifferentFile() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int sourceLine = 43; - QVERIFY(init()); + QVERIFY(init(LOADJSFILE_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); @@ -1170,14 +1218,14 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComment() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine = 48; - int actualLine = 50; - QVERIFY(init()); + int sourceLine = 47; + int actualLine = 49; + QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1185,21 +1233,21 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComment() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), actualLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); } void tst_QDeclarativeDebugJS::setBreakpointInScriptOnEmptyLine() { //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine = 49; - int actualLine = 50; - QVERIFY(init()); + int sourceLine = 48; + int actualLine = 49; + QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1207,7 +1255,7 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnEmptyLine() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), actualLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); } void tst_QDeclarativeDebugJS::setBreakpointInScriptWithCondition() @@ -1215,11 +1263,11 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptWithCondition() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int out = 10; - int sourceLine = 51; - QVERIFY(init()); + int sourceLine = 50; + QVERIFY(init(CONDITION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_JSFILE), sourceLine, -1, true, QLatin1String("out > 10")); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10")); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); //Get the frame index @@ -1231,7 +1279,7 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptWithCondition() int frameIndex = body.value("index").toInt(); //Verify the value of 'result' - client->evaluate(QLatin1String("out"),frameIndex); + client->evaluate(QLatin1String("a"),frameIndex); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1248,8 +1296,8 @@ void tst_QDeclarativeDebugJS::setBreakpointWhenAttaching() int sourceLine = 49; QVERIFY(init(QLatin1String(TIMER_QMLFILE), false)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TIMER_QMLFILE), sourceLine); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); } @@ -1259,7 +1307,7 @@ void tst_QDeclarativeDebugJS::setBreakpointWhenAttaching() // int actualLine = 31; -// client->startDebugging(); +// client->connect(); // client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true); // QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); @@ -1273,17 +1321,38 @@ void tst_QDeclarativeDebugJS::setBreakpointWhenAttaching() // QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE)); //} +void tst_QDeclarativeDebugJS::setBreakpointOnEvent() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + QVERIFY(init(TIMER_QMLFILE)); + + client->connect(); + + client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE)); +} + + void tst_QDeclarativeDebugJS::changeBreakpoint() { //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine1 = 78; - int sourceLine2 = 79; - QVERIFY(init()); + int sourceLine1 = 50; + int sourceLine2 = 51; + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - client->startDebugging(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); //Will hit 1st brakpoint, change this breakpoint enable = false @@ -1303,9 +1372,6 @@ void tst_QDeclarativeDebugJS::changeBreakpoint() //Hit 2nd breakpoint QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - // start timer - client->evaluate("timer.running = true"); - //Continue with debugging client->continueDebugging(QJSDebugClient::Continue); //Should stop at 2nd breakpoint @@ -1323,14 +1389,15 @@ void tst_QDeclarativeDebugJS::changeBreakpointOnCondition() { //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine1 = 56; - int sourceLine2 = 60; - int result = 0; - QVERIFY(init()); + int sourceLine1 = 50; + int sourceLine2 = 51; + + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - client->startDebugging(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); //Will hit 1st brakpoint, change this breakpoint enable = false @@ -1341,7 +1408,7 @@ void tst_QDeclarativeDebugJS::changeBreakpointOnCondition() QList<QVariant> breakpointsHit = body.value("breakpoints").toList(); int breakpoint = breakpointsHit.at(0).toInt(); - client->changeBreakpoint(breakpoint,false,QLatin1String("a = 0")); + client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0")); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1349,8 +1416,7 @@ void tst_QDeclarativeDebugJS::changeBreakpointOnCondition() client->continueDebugging(QJSDebugClient::Continue); //Hit 2nd breakpoint QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - // start timer - client->evaluate("timer.running = true"); + //Continue with debugging client->continueDebugging(QJSDebugClient::Continue); //Should stop at 2nd breakpoint @@ -1363,41 +1429,20 @@ void tst_QDeclarativeDebugJS::changeBreakpointOnCondition() QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); - client->frame(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); - - //Get the frame index - jsonString = client->response; - value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - body = value.value("body").toMap(); - - int frameIndex = body.value("index").toInt(); - - //Verify the value of 'result' - client->evaluate(QLatin1String("root.result"),frameIndex); - - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); - - jsonString = client->response; - value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - body = value.value("body").toMap(); - - QVERIFY(body.value("value").toInt() > result); } void tst_QDeclarativeDebugJS::clearBreakpoint() { //void clearBreakpoint(int breakpoint); - int sourceLine1 = 78; - int sourceLine2 = 79; - QVERIFY(init()); + int sourceLine1 = 50; + int sourceLine2 = 51; + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - client->startDebugging(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); //Will hit 1st brakpoint, change this breakpoint enable = false @@ -1408,7 +1453,7 @@ void tst_QDeclarativeDebugJS::clearBreakpoint() QList<QVariant> breakpointsHit = body.value("breakpoints").toList(); int breakpoint = breakpointsHit.at(0).toInt(); - client->changeBreakpoint(breakpoint,false,QLatin1String("result > 5")); + client->clearBreakpoint(breakpoint); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1416,8 +1461,7 @@ void tst_QDeclarativeDebugJS::clearBreakpoint() client->continueDebugging(QJSDebugClient::Continue); //Hit 2nd breakpoint QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - // start timer - client->evaluate("timer.running = true"); + //Continue with debugging client->continueDebugging(QJSDebugClient::Continue); //Should stop at 2nd breakpoint @@ -1435,32 +1479,25 @@ void tst_QDeclarativeDebugJS::setExceptionBreak() { //void setExceptionBreak(QString type, bool enabled = false); - int sourceLine = 49; - QVERIFY(init()); - - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); + QVERIFY(init(EXCEPTION_QMLFILE)); client->setExceptionBreak(QJSDebugClient::All,true); - client->startDebugging(); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - client->evaluate("root.raiseException = true"); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); - client->continueDebugging(QJSDebugClient::Continue); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); } void tst_QDeclarativeDebugJS::stepNext() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine = 57; - QVERIFY(init()); + int sourceLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->continueDebugging(QJSDebugClient::Next); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1468,22 +1505,22 @@ void tst_QDeclarativeDebugJS::stepNext() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } void tst_QDeclarativeDebugJS::stepNextWithCount() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine = 59; - QVERIFY(init()); + int sourceLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - client->continueDebugging(QJSDebugClient::Next,2); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); + client->continueDebugging(QJSDebugClient::Next, 2); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1491,23 +1528,23 @@ void tst_QDeclarativeDebugJS::stepNextWithCount() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } void tst_QDeclarativeDebugJS::stepIn() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine = 61; - int actualLine = 78; - QVERIFY(init()); + int sourceLine = 54; + int actualLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->continueDebugging(QJSDebugClient::In); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1515,23 +1552,23 @@ void tst_QDeclarativeDebugJS::stepIn() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), actualLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } void tst_QDeclarativeDebugJS::stepOut() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine = 56; - int actualLine = 49; - QVERIFY(init()); + int sourceLine = 50; + int actualLine = 54; + QVERIFY(init(STEPACTION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->continueDebugging(QJSDebugClient::Out); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1539,24 +1576,24 @@ void tst_QDeclarativeDebugJS::stepOut() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), actualLine); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } void tst_QDeclarativeDebugJS::continueDebugging() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine1 = 56; - int sourceLine2 = 60; - QVERIFY(init()); + int sourceLine1 = 54; + int sourceLine2 = 51; + QVERIFY(init(STEPACTION_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); - client->startDebugging(); + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->continueDebugging(QJSDebugClient::Continue); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); QVariantMap value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1564,18 +1601,18 @@ void tst_QDeclarativeDebugJS::continueDebugging() QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); - QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_QMLFILE)); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } void tst_QDeclarativeDebugJS::backtrace() { //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); - int sourceLine = 60; - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->backtrace(); @@ -1586,11 +1623,11 @@ void tst_QDeclarativeDebugJS::getFrameDetails() { //void frame(int number = -1); - int sourceLine = 60; - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->frame(); @@ -1601,11 +1638,11 @@ void tst_QDeclarativeDebugJS::getScopeDetails() { //void scope(int number = -1, int frameNumber = -1); - int sourceLine = 60; - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->scope(); @@ -1616,14 +1653,10 @@ void tst_QDeclarativeDebugJS::evaluateInGlobalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); - int sourceLine = 49; QVERIFY(init()); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - client->evaluate(QLatin1String("print('Hello World')"),true); + client->connect(); + client->evaluate(QLatin1String("print('Hello World')"), true); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); //Verify the value of 'print' @@ -1639,11 +1672,11 @@ void tst_QDeclarativeDebugJS::evaluateInLocalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); - int sourceLine = 60; - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(TEST_QMLFILE), sourceLine, -1, true); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->frame(); @@ -1657,10 +1690,10 @@ void tst_QDeclarativeDebugJS::evaluateInLocalScope() int frameIndex = body.value("index").toInt(); - client->evaluate(QLatin1String("root.someValue"),frameIndex); + client->evaluate(QLatin1String("root.a"), frameIndex); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); - //Verify the value of 'root.someValue' + //Verify the value of 'timer.interval' jsonString = client->response; value = client->parser.call(QJSValue(), QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); @@ -1673,10 +1706,11 @@ void tst_QDeclarativeDebugJS::getScopes() { //void scopes(int frameNumber = -1); - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->interrupt(); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->scopes(); @@ -1687,11 +1721,9 @@ void tst_QDeclarativeDebugJS::getScripts() { //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant()); - QVERIFY(init(QLatin1String(TIMER_QMLFILE), true)); + QVERIFY(init()); - client->interrupt(); - client->startDebugging(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + client->connect(); client->scripts(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); @@ -1709,10 +1741,11 @@ void tst_QDeclarativeDebugJS::getSource() { //void source(int frame = -1, int fromLine = -1, int toLine = -1); - QVERIFY(init()); + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); - client->interrupt(); - client->startDebugging(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); client->source(); |