summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2011-06-14 13:57:49 (GMT)
committerAurindam Jana <aurindam.jana@nokia.com>2011-06-14 15:17:36 (GMT)
commit26a265924055bf8ccc74728620711b9f44626cb1 (patch)
tree524adb2b1425829b4adfffd7d6662f768053e97e /tests
parent85b6b4006609914733461e777b0e051b6946344f (diff)
downloadQt-26a265924055bf8ccc74728620711b9f44626cb1.zip
Qt-26a265924055bf8ccc74728620711b9f44626cb1.tar.gz
Qt-26a265924055bf8ccc74728620711b9f44626cb1.tar.bz2
Rewrite autotests for js debugging
Change-Id: I5cb0e53ceab136bfe7c53a3d6c51c8865b76761b Reviewed-by: kkoehne
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/app/app.pro12
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/app/main.cpp31
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.js25
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.qml42
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/qdeclarativedebugjs.pro22
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp1323
-rw-r--r--tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro26
7 files changed, 1370 insertions, 111 deletions
diff --git a/tests/auto/declarative/qdeclarativedebugjs/app/app.pro b/tests/auto/declarative/qdeclarativedebugjs/app/app.pro
new file mode 100644
index 0000000..800c033
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugjs/app/app.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+QT += declarative
+
+CONFIG += console
+CONFIG -= app_bundle
+
+DESTDIR = ./
+
+INSTALLS =
+
+SOURCES += main.cpp
diff --git a/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp b/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp
new file mode 100644
index 0000000..22f22e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugjs/app/main.cpp
@@ -0,0 +1,31 @@
+#include <QApplication>
+#include <QDebug>
+#include <QDeclarativeComponent>
+#include <QDeclarativeEngine>
+#include <QStringList>
+#include <QtDeclarative/private/qdeclarativedebughelper_p.h>
+#include <QtDeclarative/private/qdeclarativedebugservice_p.h>
+
+int main(int argc, char *argv[])
+{
+ QDeclarativeDebugHelper::enableDebugging();
+
+ QApplication app(argc, argv);
+
+ const QUrl path = QUrl::fromLocalFile(app.arguments().last());
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, path);
+
+ if (!component.isReady()) {
+ qWarning() << component.errorString();
+ return -1;
+ }
+
+ QObject *obj = component.create();
+
+// printf("%u\n", QDeclarativeDebugService::idForObject(obj));
+// fflush(stdout);
+
+ return app.exec();
+}
diff --git a/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.js b/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.js
index 8decbf0..f96f8e9 100644
--- a/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.js
+++ b/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.js
@@ -1,11 +1,28 @@
-
function function2InScript(a)
{
- mainRectangle.foo = a;
+ logger("return function2InScript");
+ root.result = a;
}
-
-function functionInScript(a , b)
+function functionInScript(a, b)
{
+ logger("enter functionInScript");
+ var names = ["Clark Kent", "Peter Parker", "Bruce Wayne"];
+ var aliases = ["Superman", "Spiderman", "Batman"];
+ var details = {
+ category: "Superheroes",
+ names: names,
+ aliases: aliases
+ };
function2InScript(a + b);
+ logger("return functionInScript");
+ return details;
+}
+
+function logger(msg)
+{
+ //console.log(msg);
+ return true;
}
+
+//DO NOT CHANGE CODE ABOVE THIS LINE
diff --git a/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.qml b/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.qml
index 9096c32..f062bb9 100644
--- a/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.qml
+++ b/tests/auto/declarative/qdeclarativedebugjs/data/backtrace1.qml
@@ -1,27 +1,41 @@
import QtQuick 1.0
-import Qt.test 1.0
import "backtrace1.js" as Script
-Rectangle {
- id: mainRectangle
+Item {
+ id: root
- property string foo: "Default";
- width: 200
- height: 200
+ property int result:0
+ Component.onCompleted:
+ {
+ root.result = 10;
+ Script.functionInScript(4,5);
+ root.name = "nemo";
+ Script.logger(root.simpleBinding);
+ }
- MyTestObject {
+ //DO NOT CHANGE CODE ABOVE
+ //ADD CODE FROM HERE
- function append(a, b) {
- return a + " " + b;
- }
+ property string name
+ property int simpleBinding: result
+ VisualItemModel {
+ id: itemModel
+ Rectangle { height: 30; width: 80; color: "red" }
+ Rectangle { height: 30; width: 80; color: "green" }
+ Rectangle { height: 30; width: 80; color: "blue" }
+ }
- id: testObject;
- someProperty: append("Hello", mainRectangle.foo)
+ ListView {
+ anchors.fill: parent
+ model: itemModel
- onSignaled: {
- Script.functionInScript(value , "b");
+ Component.onCompleted:
+ {
+ Script.logger("List Loaded");
}
}
+
}
+
diff --git a/tests/auto/declarative/qdeclarativedebugjs/qdeclarativedebugjs.pro b/tests/auto/declarative/qdeclarativedebugjs/qdeclarativedebugjs.pro
index 0a33c27..720de19 100644
--- a/tests/auto/declarative/qdeclarativedebugjs/qdeclarativedebugjs.pro
+++ b/tests/auto/declarative/qdeclarativedebugjs/qdeclarativedebugjs.pro
@@ -1,20 +1,4 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativedebugjs.cpp
-INCLUDEPATH += ../shared
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-symbian: {
- importFiles.files = data
- importFiles.path = .
- DEPLOYMENT += importFiles
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
-
-CONFIG += parallel_test
+TEMPLATE = subdirs
+SUBDIRS = tst_qdeclarativedebugjs.pro \
+ app
diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
index 92f9c6e..ca735b7 100644
--- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
+++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
@@ -38,117 +38,1292 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <qtest.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeitem.h>
-#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
+#include <QtDeclarative/private/qdeclarativedebugservice_p.h>
+#include <QtDeclarative/private/qdeclarativedebug_p.h>
+#include <QtDeclarative/private/qjsdebuggeragent_p.h>
+#include <QtCore/QFileInfo>
#include <QtCore/QDir>
-#include <QtScript/QScriptEngineAgent>
-#include <private/qdeclarativeengine_p.h>
+#include <QtCore/QProcess>
+#include "../../../shared/util.h"
+#include "../shared/debugutil_p.h"
-class MyTestObject : public QObject {
+class QJSDebugClient : public QDeclarativeDebugClient
+{
Q_OBJECT
- Q_PROPERTY(QString someProperty READ someProperty WRITE setSomeProperty NOTIFY somePropertyChanged)
-
public:
- QString someProperty() { return _someProperty; }
- void setSomeProperty(const QString &p) { _someProperty = p; }
- QString _someProperty;
+ QJSDebugClient(QDeclarativeDebugConnection *connection) : QDeclarativeDebugClient(QLatin1String("JSDebugger"), connection) {}
+
+ void ping();
+ void exec(const QByteArray &debuggerId, const QString &expr);
+ void setBreakpoints(const QSet<JSAgentBreakpointData> &breakpoints);
+ void setWatchExpressions(const QStringList &watchExpressions);
+ void stepOver();
+ void stepInto();
+ void interrupt();
+ void stepOut();
+ void continueExecution();
+ void expandObjectById(const QByteArray& objectName, quint64 objectId);
+ void setProperty(const QByteArray& id, qint64 objectId, const QString &property, const QString &value);
+ void activateFrame(int frameId);
+
+ // info from last exec
+ JSAgentWatchData exec_data;
+ QByteArray exec_iname;
+
+ QByteArray object_name;
+ QList<JSAgentWatchData> object_children;
- void emitSignal(const QString &value) { emit signaled(value); }
+ int frame_id;
+
+ // info from last stop
+ QList<JSAgentStackData> break_stackFrames;
+ QList<JSAgentWatchData> break_watches;
+ QList<JSAgentWatchData> break_locals;
+ bool break_becauseOfException;
+ QString break_error;
signals:
- void signaled(const QString &value);
- void somePropertyChanged();
-};
+ void statusHasChanged();
+
+ void pong();
+ void result();
+ void stopped();
+ void expanded();
+ void watchTriggered();
+protected:
+ virtual void statusChanged(Status status);
+ virtual void messageReceived(const QByteArray &data);
-class BtAgent : public QScriptEngineAgent {
+private:
+ int m_ping;
+};
+
+class QJSDebugProcess : public QObject
+{
+ Q_OBJECT
public:
- BtAgent(QScriptEngine *engine) : QScriptEngineAgent(engine)
- { count = 0; engine->setAgent(this); }
+ QJSDebugProcess();
+ ~QJSDebugProcess();
- QStringList bt;
- int count;
- int breakpoint;
- void positionChange(qint64 , int lineNumber, int )
- {
- if(lineNumber == breakpoint) {
- count++;
- bt = engine()->currentContext()->backtrace();
+ void start(const QStringList &arguments);
+ bool waitForStarted();
+
+private slots:
+ void processAppOutput();
+
+private:
+ QProcess m_process;
+ QTimer m_timer;
+ QEventLoop m_eventLoop;
+ bool m_started;
+};
+
+class tst_QDeclarativeDebugJS : public QObject
+{
+ Q_OBJECT
+private:
+ QDeclarativeDebugConnection *m_conn;
+ QDeclarativeEngine *m_engine;
+ QJSDebugClient *m_client;
+
+private slots:
+ void pingPong();
+ void exec();
+ void setBreakpoint();
+ void stepOver();
+ void stepInto();
+ void interrupt();
+ void stepOut();
+ void continueExecution();
+ void expandObject();
+ void setProperty();
+ void setProperty2();
+ void watchExpression();
+ void activateFrame();
+ void setBreakpoint2();
+ void stepOver2();
+ void stepInto2();
+ void interrupt2();
+ void stepOut2();
+ void continueExecution2();
+ void expandObject2();
+ void setProperty3();
+ void setProperty4();
+ void activateFrame2();
+ void verifyQMLOptimizerDisabled();
+};
+
+
+void QJSDebugClient::ping()
+{
+ m_ping++;
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "PING";
+ rs << cmd;
+ rs << m_ping;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::exec(const QByteArray &debuggerId, const QString &expr)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "EXEC";
+ rs << cmd;
+ rs << debuggerId;
+ rs << expr;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::setBreakpoints(const QSet<JSAgentBreakpointData> &breakpoints)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "BREAKPOINTS";
+ rs << cmd
+ << breakpoints;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::setWatchExpressions(const QStringList &watchExpressions)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "WATCH_EXPRESSIONS";
+ rs << cmd
+ << watchExpressions;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::stepOver()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "STEPOVER";
+ rs << cmd;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::stepInto()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "STEPINTO";
+ rs << cmd;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::interrupt()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "INTERRUPT";
+ rs << cmd;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::stepOut()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "STEPOUT";
+ rs << cmd;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::continueExecution()
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "CONTINUE";
+ rs << cmd;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::expandObjectById(const QByteArray& objectName, quint64 objectId)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "EXPAND";
+ rs << cmd
+ << objectName
+ << objectId;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::setProperty(const QByteArray& id, qint64 objectId, const QString &property, const QString &value)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "SET_PROPERTY";
+ rs << cmd
+ << id
+ << objectId
+ << property
+ << value;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::activateFrame(int frameId)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "ACTIVATE_FRAME";
+ rs << cmd
+ << frameId;
+ sendMessage(reply);
+}
+
+void QJSDebugClient::statusChanged(Status /*status*/)
+{
+ emit statusHasChanged();
+}
+
+void QJSDebugClient::messageReceived(const QByteArray &data)
+{
+ QByteArray rwData = data;
+ QDataStream stream(&rwData, QIODevice::ReadOnly);
+
+ QByteArray command;
+ stream >> command;
+
+ if (command == "STOPPED") {
+ stream >> break_stackFrames >> break_watches >> break_locals >> break_becauseOfException >> break_error;
+ if (!break_becauseOfException) {
+ break_error.clear();
}
+ emit stopped();
+ } else if (command == "RESULT") {
+ stream >> exec_iname;
+ stream >> exec_data;
+ emit result();
+ } else if (command == "EXPANDED") {
+ stream >> object_name >> object_children;
+ emit expanded();
+ } else if (command == "LOCALS") {
+ stream >> frame_id >> break_locals;
+ if (!stream.atEnd()) { // compatibility with jsdebuggeragent from 2.1, 2.2
+ stream >> break_watches;
+ }
+ emit watchTriggered();
+ } else if (command == "PONG") {
+ int ping;
+ stream >> ping;
+ QCOMPARE(ping, m_ping);
+ emit pong();
+ } else {
+ QFAIL("Unknown message :" + command);
}
-};
+ QVERIFY(stream.atEnd());
+}
+QJSDebugProcess::QJSDebugProcess()
+ : m_started(false)
+{
+ m_process.setProcessChannelMode(QProcess::MergedChannels);
+ connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
+ connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
+ m_timer.setSingleShot(true);
+ m_timer.setInterval(5000);
+ QStringList environment = QProcess::systemEnvironment();
+ environment.append("QML_DISABLE_OPTIMIZER=1");
+ m_process.setEnvironment(environment);
+}
+QJSDebugProcess::~QJSDebugProcess()
+{
+ m_process.terminate();
+ m_process.waitForFinished();
+}
-/*
-This test covers evaluation of ECMAScript expressions and bindings from within
-QML. This does not include static QML language issues.
+void QJSDebugProcess::start(const QStringList &arguments)
+{
+ m_process.start("app/app", arguments);
+ m_timer.start();
+}
-Static QML language issues are covered in qmllanguage
-*/
-inline QUrl TEST_FILE(const QString &filename)
+bool QJSDebugProcess::waitForStarted()
+{
+ m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
+
+ return m_started;
+}
+
+void QJSDebugProcess::processAppOutput()
+{
+ const QString appOutput = m_process.readAll();
+ if (appOutput.startsWith("Qml debugging is enabled")) // ignore
+ return;
+ if (appOutput.startsWith("QDeclarativeDebugServer:")) { // ignore
+ if (appOutput.contains("Waiting for connection ")) {
+ m_started = true;
+ m_eventLoop.quit();
+ }
+ return;
+ }
+ qDebug() << appOutput;
+}
+
+inline QString TEST_FILE(const QString &filename)
{
QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+ return fileInfo.absoluteDir().filePath("data/" + filename);
}
-inline QUrl TEST_FILE(const char *filename)
+void tst_QDeclarativeDebugJS::pingPong()
{
- return TEST_FILE(QLatin1String(filename));
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QJSDebugClient client(&connection);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ client.ping();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(pong())));
}
-class tst_QDeclarativeDebugJS : public QObject
+void tst_QDeclarativeDebugJS::exec()
{
- Q_OBJECT
-public:
- tst_QDeclarativeDebugJS() {}
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
-private slots:
- void initTestCase();
- void backtrace1();
-};
+ QDeclarativeDebugConnection connection;
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QJSDebugClient client(&connection);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ // Evaluate script without context
+ client.exec("queryid", "1+1");
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(result())));
+ QCOMPARE(client.exec_iname, QByteArray("queryid"));
+ QCOMPARE(client.exec_data.exp, QByteArray("1+1"));
+ QCOMPARE(client.exec_data.name, QByteArray("1+1"));
+ QCOMPARE(client.exec_data.hasChildren, false);
+ QCOMPARE(client.exec_data.type, QByteArray("Number"));
+ QCOMPARE(client.exec_data.value, QByteArray("2"));
+
+ // TODO: Test access to context after breakpoint is hit
+}
+
+
+void tst_QDeclarativeDebugJS::setBreakpoint()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ //TEST LINE
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.fileUrl, bp1.fileUrl);
+ QCOMPARE(data.lineNumber, bp1.lineNumber);
+
+}
+
+void tst_QDeclarativeDebugJS::stepOver()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
-void tst_QDeclarativeDebugJS::initTestCase()
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepOver();
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.fileUrl, bp1.fileUrl);
+ QCOMPARE(data.lineNumber, bp1.lineNumber +1);
+}
+
+void tst_QDeclarativeDebugJS::stepInto()
{
- qmlRegisterType<MyTestObject>("Qt.test", 1,0, "MyTestObject");
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 12;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepInto();
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ QByteArray functionName("functionInScript");
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.functionName, functionName);
+ QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded()));
}
-void tst_QDeclarativeDebugJS::backtrace1()
+void tst_QDeclarativeDebugJS::interrupt()
{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 12;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.interrupt();
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ QByteArray functionName("functionInScript");
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.functionName, functionName);
+ QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded()));
+}
+
+void tst_QDeclarativeDebugJS::stepOut()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1,bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 12;
+
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp2.lineNumber = 13;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepOut();
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+ JSAgentStackData data = client.break_stackFrames.at(0);
+
+ QCOMPARE(data.fileUrl, bp2.fileUrl);
+ QCOMPARE(data.lineNumber, bp2.lineNumber);
+
+}
+
+void tst_QDeclarativeDebugJS::continueExecution()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp2.lineNumber = 13;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.continueExecution();
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.fileUrl, bp2.fileUrl);
+ QCOMPARE(data.lineNumber, bp2.lineNumber);
+}
+
+void tst_QDeclarativeDebugJS::expandObject()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ foreach ( JSAgentWatchData data, client.break_locals)
{
- QDeclarativeEngine engine;
- QUrl file = TEST_FILE("backtrace1.qml");
- QDeclarativeComponent component(&engine, file);
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
- QVERIFY(item);
- MyTestObject *obj = item->findChild<MyTestObject *>();
- QVERIFY(obj);
- QCOMPARE(obj->someProperty(), QString("Hello Default"));
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&engine);
- BtAgent agent(&ep->scriptEngine);
- agent.breakpoint = 16;
-
- obj->emitSignal("blah");
- QCOMPARE(obj->someProperty(), QString("Hello blahb"));
- QCOMPARE(agent.count, 1);
-
- QStringList expected;
- expected << "append(a = 'Hello', b = 'blahb') at @PREFIX@/backtrace1.qml:16"
- << "$someProperty() at @PREFIX@/backtrace1.qml:21"
- << "function2InScript(a = 'blahb') at @PREFIX@/backtrace1.js:4"
- << "functionInScript(a = 'blah', b = 'b') at @PREFIX@/backtrace1.js:10"
- << "onSignaled() at @PREFIX@/backtrace1.qml:24"
- << "<global>() at -1";
- expected.replaceInStrings("@PREFIX@", file.toString().section('/', 0, -2));
- QCOMPARE(agent.bt, expected);
+ if( data.name == "details")
+ {
+ //TEST LINE
+ client.expandObjectById(data.name,data.objectId);
+ }
}
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+ QCOMPARE(client.object_name,QByteArray("details"));
+ QCOMPARE(client.object_children.at(0).name,QByteArray("category"));
+ QCOMPARE(client.object_children.at(0).type,QByteArray("String"));
+ QCOMPARE(client.object_children.at(1).name,QByteArray("names"));
+ QCOMPARE(client.object_children.at(1).type,QByteArray("Array"));
+ QCOMPARE(client.object_children.at(2).name,QByteArray("aliases"));
+ QCOMPARE(client.object_children.at(2).type,QByteArray("Array"));
+
}
+void tst_QDeclarativeDebugJS::setProperty()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp2.lineNumber = 18;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ quint64 objectId;
+ QByteArray objectName;
+
+ foreach ( JSAgentWatchData data, client.break_locals)
+ {
+ if( data.name == "details")
+ {
+ objectId = data.objectId;
+ objectName = data.name;
+ //TEST LINE
+ client.setProperty(data.name, data.objectId, "total", "names.length");
+ }
+ }
+
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+ client.expandObjectById(objectName,objectId);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+
+ QCOMPARE(client.object_name,QByteArray("details"));
+ QCOMPARE(client.object_children.at(0).name,QByteArray("category"));
+ QCOMPARE(client.object_children.at(0).type,QByteArray("String"));
+ QCOMPARE(client.object_children.at(0).value,QByteArray("Superheroes"));
+ QCOMPARE(client.object_children.at(1).name,QByteArray("names"));
+ QCOMPARE(client.object_children.at(1).type,QByteArray("Array"));
+ QCOMPARE(client.object_children.at(2).name,QByteArray("aliases"));
+ QCOMPARE(client.object_children.at(2).type,QByteArray("Array"));
+ QCOMPARE(client.object_children.at(3).name,QByteArray("total"));
+ QCOMPARE(client.object_children.at(3).type,QByteArray("Number"));
+ // foreach ( JSAgentWatchData data, client.object_children)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+}
+
+void tst_QDeclarativeDebugJS::setProperty2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp2.lineNumber = 18;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ quint64 objectId;
+ QByteArray objectName;
+
+ foreach ( JSAgentWatchData data, client.break_locals)
+ {
+ if( data.name == "details")
+ {
+ objectId = data.objectId;
+ objectName = data.name;
+ //TEST LINE
+ client.setProperty(data.name, data.objectId, "category", data.name + ".category = 'comic characters'");
+ }
+ }
+
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+ client.expandObjectById(objectName,objectId);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+
+ QCOMPARE(client.object_name,QByteArray("details"));
+ QCOMPARE(client.object_children.at(0).name,QByteArray("category"));
+ QCOMPARE(client.object_children.at(0).type,QByteArray("String"));
+ QCOMPARE(client.object_children.at(0).value,QByteArray("comic characters"));
+ QCOMPARE(client.object_children.at(1).name,QByteArray("names"));
+ QCOMPARE(client.object_children.at(1).type,QByteArray("Array"));
+ QCOMPARE(client.object_children.at(2).name,QByteArray("aliases"));
+ QCOMPARE(client.object_children.at(2).type,QByteArray("Array"));
+
+ // foreach ( JSAgentWatchData data, client.object_children)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+}
+
+void tst_QDeclarativeDebugJS::watchExpression()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ QByteArray watchExpression("root.result = 20");
+ QStringList watchList;
+ watchList.append(QString(watchExpression));
+
+ //TEST LINE
+ client.setWatchExpressions(watchList);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentWatchData data = client.break_watches.at(0);
+ QCOMPARE(data.exp, watchExpression);
+ QCOMPARE(data.value.toInt(), 20);
+ QCOMPARE(data.type, QByteArray("Number"));
+}
+
+void tst_QDeclarativeDebugJS::activateFrame()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 3;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.activateFrame(2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(watchTriggered())));
+
+ QCOMPARE(client.break_locals.at(1).name,QByteArray("names"));
+ QCOMPARE(client.break_locals.at(1).type,QByteArray("Array"));
+ QCOMPARE(client.break_locals.at(2).name,QByteArray("a"));
+ QCOMPARE(client.break_locals.at(2).type,QByteArray("Number"));
+ QCOMPARE(client.break_locals.at(2).value,QByteArray("4"));
+ QCOMPARE(client.break_locals.at(3).name,QByteArray("b"));
+ QCOMPARE(client.break_locals.at(3).type,QByteArray("Number"));
+ QCOMPARE(client.break_locals.at(3).value,QByteArray("5"));
+
+ // foreach ( JSAgentWatchData data, client.break_locals)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+
+}
+
+void tst_QDeclarativeDebugJS::setBreakpoint2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 40;
+
+ //TEST LINE
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(!QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+}
+
+void tst_QDeclarativeDebugJS::stepOver2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepOver();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepOver();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.fileUrl, bp1.fileUrl);
+ QCOMPARE(data.lineNumber, bp1.lineNumber +2);
+}
+
+void tst_QDeclarativeDebugJS::stepInto2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ QByteArray functionName("logger");
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.functionName, functionName);
+ QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded()));
+}
+
+void tst_QDeclarativeDebugJS::interrupt2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.interrupt();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.interrupt();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ QByteArray functionName("logger");
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.functionName, functionName);
+ QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded()));
+}
+
+void tst_QDeclarativeDebugJS::stepOut2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1,bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 12;
+
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp2.lineNumber = 13;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.stepOut();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepOut();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+
+ QCOMPARE(data.fileUrl, bp2.fileUrl);
+ QCOMPARE(data.lineNumber, bp2.lineNumber);
+
+}
+
+void tst_QDeclarativeDebugJS::continueExecution2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2, bp3;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 11;
+
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp2.lineNumber = 12;
+
+ bp3.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp3.lineNumber = 13;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2 << bp3);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ JSAgentStackData data = client.break_stackFrames.at(0);
+ QCOMPARE(data.fileUrl, bp3.fileUrl);
+ QCOMPARE(data.lineNumber, bp3.lineNumber);
+}
+
+void tst_QDeclarativeDebugJS::expandObject2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.expandObjectById(QByteArray("details"),123);
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+ QCOMPARE(client.object_name,QByteArray("details"));
+
+ QEXPECT_FAIL("", "", Continue);
+ QCOMPARE(client.object_children.length(),0);
+
+}
+
+void tst_QDeclarativeDebugJS::setProperty3()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp2.lineNumber = 18;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ quint64 objectId;
+ QByteArray objectName;
+
+ foreach ( JSAgentWatchData data, client.break_locals)
+ {
+ if( data.name == "details")
+ {
+ objectId = data.objectId;
+ objectName = data.name;
+ //TEST LINE
+ client.setProperty(data.name, 123, "total", "names.length");
+ }
+ }
+
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+ client.expandObjectById(objectName,objectId);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+
+ QCOMPARE(client.object_name,QByteArray("details"));
+ QCOMPARE(client.object_children.length(),3);
+
+ // foreach ( JSAgentWatchData data, client.object_children)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+}
+
+void tst_QDeclarativeDebugJS::setProperty4()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 17;
+ bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp2.lineNumber = 18;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1 << bp2);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ quint64 objectId;
+ QByteArray objectName;
+
+ foreach ( JSAgentWatchData data, client.break_locals)
+ {
+ if( data.name == "details")
+ {
+ objectId = data.objectId;
+ objectName = data.name;
+ //TEST LINE
+ client.setProperty(data.name, 123, "category", data.name + ".category = 'comic characters'");
+ }
+ }
+
+ client.continueExecution();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+ client.expandObjectById(objectName,objectId);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(expanded())));
+
+ QCOMPARE(client.object_name,QByteArray("details"));
+ QCOMPARE(client.object_children.at(0).name,QByteArray("category"));
+ QCOMPARE(client.object_children.at(0).type,QByteArray("String"));
+ QCOMPARE(client.object_children.at(0).value,QByteArray("Superheroes"));
+ QCOMPARE(client.object_children.at(1).name,QByteArray("names"));
+ QCOMPARE(client.object_children.at(1).type,QByteArray("Array"));
+ QCOMPARE(client.object_children.at(2).name,QByteArray("aliases"));
+ QCOMPARE(client.object_children.at(2).type,QByteArray("Array"));
+
+ // foreach ( JSAgentWatchData data, client.object_children)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+}
+
+void tst_QDeclarativeDebugJS::activateFrame2()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1, bp2;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded();
+ bp1.lineNumber = 4;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ client.stepInto();
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+ //TEST LINE
+ client.activateFrame(5);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(watchTriggered())));
+
+ QCOMPARE(client.break_locals.length(),0);
+
+ // foreach ( JSAgentWatchData data, client.break_locals)
+ // {
+ // qDebug() << data.name << data.type << data.value;
+ // }
+
+}
+
+void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled()
+{
+ QJSDebugProcess process;
+ process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml"));
+ QVERIFY(process.waitForStarted());
+
+ QDeclarativeDebugConnection connection;
+ QJSDebugClient client(&connection);
+
+ connection.connectToHost("127.0.0.1", 3771);
+ QVERIFY(connection.waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ if (client.status() == QJSDebugClient::Unavailable)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())));
+ QCOMPARE(client.status(), QJSDebugClient::Enabled);
+
+ JSAgentBreakpointData bp1;
+ bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded();
+ bp1.lineNumber = 21;
+
+ client.setBreakpoints(QSet<JSAgentBreakpointData>() << bp1);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped())));
+
+}
QTEST_MAIN(tst_QDeclarativeDebugJS)
#include "tst_qdeclarativedebugjs.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro
new file mode 100644
index 0000000..dc6d2ff
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro
@@ -0,0 +1,26 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative script
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qdeclarativedebugjs.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+symbian: {
+ importFiles.files = data
+ importFiles.path = .
+ DEPLOYMENT += importFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
+
+OTHER_FILES = data/backtrace1.js data/backtrace1.qml
+
+CONFIG += parallel_test
+