#include "qdeclarativedebugservice_p_p.h"
#include <private/qv8debug_p.h>
#include <private/qjsconverter_impl_p.h>
+#include <private/qv8engine_p.h>
#include <QtCore/QHash>
#include <QtCore/QFileInfo>
#include <QtCore/QMutex>
-#define DEBUGGER_SCRIPT "(function(){"\
- "var DebuggerScript = {};"\
- "DebuggerScript.getScriptName = function(eventData){"\
- "return eventData.script_.script_.nameOrSourceURL();"\
- "};"\
- "DebuggerScript.getScripts = function(){"\
- "var result = [];"\
- "var scripts = Debug.scripts();"\
- "for (var i = 0; i < scripts.length; ++i) {"\
- "var script = scripts[i];"\
- "if (script.type == Debug.ScriptType.Native) continue;"\
- "result.push(script.nameOrSourceURL());"\
- "}"\
- "return result;"\
- "};"\
- "return DebuggerScript;"\
- "})();"
-
-#define DEBUGGER_UTILITY "(function(){"\
- "var DebuggerUtility = {};"\
- "DebuggerUtility.parseRequest = function(request){"\
- "return JSON.parse(request);"\
- "};"\
- "DebuggerUtility.stringifyRequest = function(request){"\
- "return JSON.stringify(request);"\
- "};"\
- "return DebuggerUtility;"\
- "})();"
-
const char *V8_DEBUGGER_KEY_CONNECT = "connect";
const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt";
const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect";
-const char *V8_DEBUGGER_KEY_CLEARBREAKPOINT = "clearbreakpoint";
-const char *V8_DEBUGGER_KEY_CHANGEBREAKPOINT = "changebreakpoint";
-const char *V8_DEBUGGER_KEY_SETBREAKPOINT = "setbreakpoint";
-const char *V8_DEBUGGER_KEY_TARGET = "target";
-const char *V8_DEBUGGER_KEY_SCRIPT = "script";
-const char *V8_DEBUGGER_KEY_COMMAND = "command";
-const char *V8_DEBUGGER_KEY_SEQ = "seq";
-const char *V8_DEBUGGER_KEY_REQUEST_SEQ = "request_seq";
-const char *V8_DEBUGGER_KEY_SUCCESS = "success";
-const char *V8_DEBUGGER_KEY_BREAKPOINT = "breakpoint";
-const char *V8_DEBUGGER_KEY_ARGUMENTS = "arguments";
-const char *V8_DEBUGGER_KEY_ENABLED = "enabled";
-const char *V8_DEBUGGER_KEY_TYPE = "type";
-const char *V8_DEBUGGER_KEY_EVENT = "event";
-const char *V8_DEBUGGER_KEY_BODY = "body";
-const char *V8_DEBUGGER_KEY_RUNNING = "running";
+const char *V8_DEBUGGER_KEY_REQUEST = "v8request";
+const char *V8_DEBUGGER_KEY_V8MESSAGE = "v8message";
+const char *V8_DEBUGGER_KEY_BREAK_ON_SIGNAL = "breakonsignal";
QT_BEGIN_NAMESPACE
// running, we therefore need a plain pointer.
static QV8DebugService *v8ServiceInstancePtr = 0;
+void DebugMessageDispatchHandler()
+{
+ QMetaObject::invokeMethod(v8ServiceInstancePtr, "processDebugMessages", Qt::QueuedConnection);
+}
+
void DebugMessageHandler(const v8::Debug::Message& message)
{
v8::DebugEvent event = message.GetEvent();
if (event != v8::Break && event != v8::Exception &&
- event != v8::AfterCompile && event != v8::BeforeCompile) {
- return;
- }
-
- const QString response(QJSConverter::toString(message.GetJSON()));
-
- v8ServiceInstancePtr->debugMessageHandler(response, message.WillStartRunning());
-
- if (event == v8::AfterCompile) {
- v8ServiceInstancePtr->appendSourcePath(message.GetEventData());
- } //TODO::v8::Exception
+ event != v8::AfterCompile && event != v8::BeforeCompile)
+ return;
+ v8ServiceInstancePtr->debugMessageHandler(QJSConverter::toString(message.GetJSON()));
}
class QV8DebugServicePrivate : public QDeclarativeDebugServicePrivate
public:
QV8DebugServicePrivate()
: connectReceived(false)
- , scheduleBreak(false)
- , debuggerThreadIsolate(0)
- , isRunning(true)
+ , engine(0)
{
}
- ~QV8DebugServicePrivate()
- {
- debuggerScript.Dispose();
- debuggerUtility.Dispose();
- debuggerUtilityContext.Dispose();
- if (debuggerThreadIsolate)
- debuggerThreadIsolate->Dispose();
- }
-
void initializeDebuggerThread();
- void sendDebugMessage(const QString &message);
- void updateSourcePath(const QString &sourcePath);
- static QByteArray packMessage(const QString &message);
- QString createResponse(const QVariantMap &response) const;
- v8::Handle<v8::Object> createV8Object(const QVariantMap &map) const;
+ static QByteArray packMessage(const QString &type, const QString &message = QString());
bool connectReceived;
- bool scheduleBreak;
- v8::Isolate *debuggerThreadIsolate;
- v8::Persistent<v8::Object> debuggerScript;
- v8::Persistent<v8::Object> debuggerUtility;
- v8::Persistent<v8::Context> debuggerUtilityContext;
- // keep messageReceived() from running until initialize() has finished
QMutex initializeMutex;
-
- bool isRunning;
- QHash<QString, QString> sourcePath;
- QHash<QString, QString> requestCache;
- QHash<int, SignalHandlerData> handlersList;
+ QStringList breakOnSignals;
+ const QV8Engine *engine;
};
QV8DebugService::QV8DebugService(QObject *parent)
// wait for statusChanged() -> initialize()
d->initializeMutex.lock();
if (registerService() == Enabled) {
- initialize(false);
+ init();
// ,block mode, client attached
while (!d->connectReceived) {
waitForMessage();
return v8ServiceInstance();
}
-void QV8DebugService::initialize()
+void QV8DebugService::initialize(const QV8Engine *engine)
{
// just make sure that the service is properly registered
- v8ServiceInstance();
+ v8ServiceInstance()->setEngine(engine);
}
-void QV8DebugService::debugMessageHandler(const QString &message, bool willStartRunning)
+void QV8DebugService::setEngine(const QV8Engine *engine)
{
Q_D(QV8DebugService);
- d->isRunning = willStartRunning;
- if (d->scheduleBreak)
- scheduledDebugBreak();
-
- sendMessage(QV8DebugServicePrivate::packMessage(message));
+ d->engine = engine;
}
-
-void QV8DebugService::appendSourcePath(const v8::Handle<v8::Object> &eventData)
+//V8 DEBUG SERVICE PROTOCOL
+// <HEADER><TYPE><DATA>
+// <HEADER> : "V8DEBUG"
+// <TYPE> : ("connect", "disconnect", "interrupt", "v8request", "v8message", "breakonsignal")
+// <DATA> : For _v8request_ and _v8message_ it is the JSON request string.
+// For _breakonsignal_ it is <signalname_string><enabled_bool>
+// Empty string for the other types
+void QV8DebugService::debugMessageHandler(const QString &message)
{
- Q_D(QV8DebugService);
-
- Q_ASSERT(!d->debuggerScript.IsEmpty());
- v8::HandleScope handleScope;
- v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
- v8::Context::Scope contextScope(debuggerContext);
- v8::Handle<v8::Function> getScriptNameFn =
- v8::Local<v8::Function>::Cast(d->debuggerScript->Get(v8::String::New("getScriptName")));
- v8::Handle<v8::Value> argv[] = { eventData };
- v8::Handle<v8::Value> scriptName = getScriptNameFn->Call(d->debuggerScript, 1, argv);
- Q_ASSERT(scriptName->IsString());
-
- d->updateSourcePath(QJSConverter::toString(scriptName->ToString()));
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_V8MESSAGE), message));
}
+
void QV8DebugService::signalEmitted(const QString &signal)
{
//This function is only called by QDeclarativeBoundSignal
//Parse just the name and remove the class info
//Normalize to Lower case.
QString signalName = signal.left(signal.indexOf(QLatin1String("("))).toLower();
- foreach (const SignalHandlerData &data, d->handlersList) {
- if (data.functionName == signalName
- && data.enabled) {
- d->scheduleBreak = true;
+
+ foreach (const QString &signal, d->breakOnSignals) {
+ if (signal == signalName) {
+ scheduledDebugBreak(true);
+ break;
}
}
- if (d->scheduleBreak)
- scheduledDebugBreak();
}
-void QV8DebugService::initialize(bool getCompiledScripts)
+// executed in the gui thread
+void QV8DebugService::init()
{
Q_D(QV8DebugService);
- if (d->debuggerScript.IsEmpty()) {
- v8::HandleScope handleScope;
- v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
- v8::Context::Scope contextScope(debuggerContext);
- v8::Handle<v8::Script> script = v8::Script::New(v8::String::New(DEBUGGER_SCRIPT), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
- d->debuggerScript = v8::Persistent<v8::Object>::New(v8::Local<v8::Object>::Cast(script->Run()));
- }
v8::Debug::SetMessageHandler2(DebugMessageHandler);
-
- if (getCompiledScripts) {
- v8::HandleScope handleScope;
- v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
- v8::Context::Scope contextScope(debuggerContext);
- v8::Handle<v8::Function> getScriptsFn =
- v8::Local<v8::Function>::Cast(d->debuggerScript->Get(v8::String::New("getScripts")));
- v8::Handle<v8::Value> result = getScriptsFn->Call(d->debuggerScript, 0, 0);
- if (result.IsEmpty())
- return;
-
- Q_ASSERT(!result->IsUndefined() && result->IsArray());
- v8::Handle<v8::Array> scripts = v8::Handle<v8::Array>::Cast(result);
- uint len = scripts->Length();
- for (uint i = 0; i < len; ++i) {
- d->updateSourcePath(QJSConverter::toString(scripts->Get(i)->ToString()));
- }
- }
-
+ v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler);
d->initializeMutex.unlock();
}
-void QV8DebugService::scheduledDebugBreak()
+// executed in the gui thread
+void QV8DebugService::scheduledDebugBreak(bool schedule)
{
- Q_D(QV8DebugService);
- if (d->scheduleBreak) {
+ if (schedule)
v8::Debug::DebugBreak();
- d->scheduleBreak = false;
- }
-}
-
-void QV8DebugService::cancelDebugBreak()
-{
- v8::Debug::CancelDebugBreak();
+ else
+ v8::Debug::CancelDebugBreak();
}
// executed in the debugger thread
{
Q_D(QV8DebugService);
if (newStatus == Enabled) {
- if (!d->debuggerThreadIsolate)
- d->initializeDebuggerThread();
-
// execute in GUI thread
d->initializeMutex.lock();
- QMetaObject::invokeMethod(this, "initialize", Qt::QueuedConnection, Q_ARG(bool, true));
+ QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
}
}
+
+//V8 DEBUG SERVICE PROTOCOL
+// <HEADER><TYPE><DATA>
+// <HEADER> : "V8DEBUG"
+// <TYPE> : ("connect", "disconnect", "interrupt", "v8request", "v8message", "breakonsignal")
+// <DATA> : For _v8request_ and _v8message_ it is the JSON request string.
+// For _breakonsignal_ it is <signalname_string><enabled_bool>
+// Empty string for the other types
// executed in the debugger thread
void QV8DebugService::messageReceived(const QByteArray &message)
{
QByteArray command;
ds >> command;
- QMutexLocker locker(&d->initializeMutex);
-
if (command == "V8DEBUG") {
- if (!d->debuggerThreadIsolate)
- d->initializeDebuggerThread();
-
-
- QString request;
- {
- QByteArray requestArray;
- ds >> requestArray;
- request = QString::fromUtf8(requestArray);
+ QByteArray type;
+ QByteArray data;
+ ds >> type >> data;
+
+ if (type == V8_DEBUGGER_KEY_CONNECT) {
+ QMutexLocker locker(&d->initializeMutex);
+ d->connectReceived = true;
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT)));
+
+ } else if (type == V8_DEBUGGER_KEY_INTERRUPT) {
+ // break has to be executed in gui thread
+ QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true));
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT)));
+
+ } else if (type == V8_DEBUGGER_KEY_DISCONNECT) {
+ // cancel break has to be executed in gui thread
+ QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false));
+ sendDebugMessage(QString::fromUtf8(data));
+
+ } else if (type == V8_DEBUGGER_KEY_REQUEST) {
+ sendDebugMessage(QString::fromUtf8(data));
+
+ } else if (type == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) {
+ QDataStream rs(data);
+ QByteArray signal;
+ bool enabled;
+ rs >> signal >> enabled;
+ //Normalize to lower case.
+ QString signalName(QString::fromUtf8(signal).toLower());
+ if (enabled)
+ d->breakOnSignals.append(signalName);
+ else
+ d->breakOnSignals.removeOne(signalName);
+ sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL)));
}
-
- bool forwardRequestToV8 = false;
- Q_ASSERT(!d->debuggerUtility.IsEmpty());
- {
- v8::Isolate::Scope i_scope(d->debuggerThreadIsolate);
-
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(d->debuggerUtilityContext);
-
- v8::Handle<v8::Function> parseFn =
- v8::Local<v8::Function>::Cast(d->debuggerUtility->Get(v8::String::New("parseRequest")));
- v8::Handle<v8::Value> argv[] = { QJSConverter::toString(request) };
- v8::Handle<v8::Value> result = parseFn->Call(d->debuggerUtility, 1, argv);
- Q_ASSERT(result->IsObject());
-
- v8::Handle<v8::Object> requestObj = v8::Handle<v8::Object>::Cast(result);
- const QString debugCommand = QJSConverter::toString(requestObj->Get(v8::String::New(V8_DEBUGGER_KEY_COMMAND))->ToString());
- const int sequence = requestObj->Get(v8::String::New(V8_DEBUGGER_KEY_SEQ))->Int32Value();
-
- if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_CONNECT)) {
- d->connectReceived = true;
- QVariantMap response;
- response.insert(QLatin1String(V8_DEBUGGER_KEY_COMMAND), QVariant(debugCommand));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_REQUEST_SEQ), QVariant(sequence));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_SUCCESS), QVariant(true));
- sendMessage(QV8DebugServicePrivate::packMessage(d->createResponse(response)));
-
- } else if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_INTERRUPT)) {
- // break has to be executed in gui thread
- d->scheduleBreak = true;
- QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection);
- QVariantMap response;
- response.insert(QLatin1String(V8_DEBUGGER_KEY_COMMAND), QVariant(debugCommand));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_REQUEST_SEQ), QVariant(sequence));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_SUCCESS), QVariant(true));
- sendMessage(QV8DebugServicePrivate::packMessage(d->createResponse(response)));
-
- } else if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_DISCONNECT)) {
- // cancel break has to be executed in gui thread
- QMetaObject::invokeMethod(this, "cancelDebugBreak", Qt::QueuedConnection);
- forwardRequestToV8 = true;
-
- } else if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_CLEARBREAKPOINT)) {
- //check if the breakpoint is a negative integer (event breakpoint)
- v8::Handle<v8::Object> argsObj = requestObj->Get(v8::String::New(V8_DEBUGGER_KEY_ARGUMENTS))->ToObject();
- const int bp = argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_BREAKPOINT))->Int32Value();
-
- if (bp < 0) {
- d->handlersList.remove(bp);
- } else {
- forwardRequestToV8 = true;
- }
-
- } else if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_CHANGEBREAKPOINT)) {
- //check if the breakpoint is a negative integer (event breakpoint)
- v8::Handle<v8::Object> argsObj = requestObj->Get(v8::String::New(V8_DEBUGGER_KEY_ARGUMENTS))->ToObject();
- const int bp = argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_BREAKPOINT))->Int32Value();
-
- if (bp < 0) {
- SignalHandlerData data = d->handlersList.value(bp);
- data.enabled = argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_ENABLED))->BooleanValue();
- d->handlersList.insert(bp, data);
-
- } else {
- forwardRequestToV8 = true;
- }
-
- } else if (debugCommand == QLatin1String(V8_DEBUGGER_KEY_SETBREAKPOINT)) {
- v8::Handle<v8::Object> argsObj = requestObj->Get(v8::String::New(V8_DEBUGGER_KEY_ARGUMENTS))->ToObject();
- const QString type = QJSConverter::toString(argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_TYPE))->ToString());
- QString target = QJSConverter::toString(argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_TARGET))->ToString());
-
- if (type == QLatin1String(V8_DEBUGGER_KEY_SCRIPT)) {
- //check if the script associated with the breakpoint is cached
- if (d->sourcePath.contains(target)) {
- //replace fileName with correct filePath
- request.replace(target, d->sourcePath.value(target));
- forwardRequestToV8 = true;
-
- } else {
- //store the message till file is compiled
- d->requestCache.insertMulti(target, request);
- }
-
- } else if (type == QLatin1String(V8_DEBUGGER_KEY_EVENT)) {
- //Handle this internally
- bool success = true;
- if (target.startsWith(QLatin1String("on"))) {
- SignalHandlerData data;
- //Only store the probable signal name.
- //Normalize to lower case.
- data.functionName = target.remove(0,2).toLower();
- data.enabled = argsObj->Get(v8::String::New(V8_DEBUGGER_KEY_ENABLED))->BooleanValue();
- d->handlersList.insert(-sequence, data);
- } else {
- success = false;
- }
- //TODO::have to send back response
- QVariantMap body;
- body.insert(QLatin1String(V8_DEBUGGER_KEY_TYPE), QVariant(QLatin1String(V8_DEBUGGER_KEY_EVENT)));
- body.insert(QLatin1String(V8_DEBUGGER_KEY_BREAKPOINT), QVariant(-sequence));
- QVariantMap response;
- response.insert(QLatin1String(V8_DEBUGGER_KEY_COMMAND), QVariant(debugCommand));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_REQUEST_SEQ), QVariant(sequence));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_SUCCESS), QVariant(success));
- response.insert(QLatin1String(V8_DEBUGGER_KEY_BODY), body);
-
- sendMessage(QV8DebugServicePrivate::packMessage(d->createResponse(response)));
- }
- } else {
- //Forward all other requests
- forwardRequestToV8 = true;
- }
- }
-
- if (forwardRequestToV8)
- d->sendDebugMessage(request);
}
}
-void QV8DebugServicePrivate::initializeDebuggerThread()
-{
- Q_ASSERT(!debuggerThreadIsolate);
-
- //Create an isolate & engine in debugger thread
- debuggerThreadIsolate = v8::Isolate::New();
- v8::Isolate::Scope i_scope(debuggerThreadIsolate);
- if (debuggerUtility.IsEmpty()) {
- v8::HandleScope handleScope;
- debuggerUtilityContext = v8::Context::New();
- v8::Context::Scope contextScope(debuggerUtilityContext);
- v8::Handle<v8::Script> script = v8::Script::New(v8::String::New(DEBUGGER_UTILITY), 0, 0, v8::Handle<v8::String>(), v8::Script::NativeMode);
- debuggerUtility = v8::Persistent<v8::Object>::New(v8::Local<v8::Object>::Cast(script->Run()));
- }
-}
-
-void QV8DebugServicePrivate::sendDebugMessage(const QString &message)
+void QV8DebugService::sendDebugMessage(const QString &message)
{
v8::Debug::SendCommand(message.utf16(), message.size());
}
-void QV8DebugServicePrivate::updateSourcePath(const QString &source)
+void QV8DebugService::processDebugMessages()
{
- const QString fileName(QFileInfo(source).fileName());
- sourcePath.insert(fileName, source);
-
- //Check if there are any pending breakpoint requests for this file
- if (requestCache.contains(fileName)) {
- QList<QString> list = requestCache.values(fileName);
- requestCache.remove(fileName);
- foreach (QString request, list) {
- request.replace(fileName, source);
- sendDebugMessage(request);
- }
- }
+ Q_D(QV8DebugService);
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(d->engine->context());
+ v8::Debug::ProcessDebugMessages();
}
-QByteArray QV8DebugServicePrivate::packMessage(const QString &message)
+QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message)
{
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
QByteArray cmd("V8DEBUG");
- rs << cmd << message.toUtf8();
+ rs << cmd << type.toUtf8() << message.toUtf8();
return reply;
}
-QString QV8DebugServicePrivate::createResponse(const QVariantMap &response) const
-{
- v8::HandleScope handleScope;
- v8::Context::Scope contextScope(debuggerUtilityContext);
-
- v8::Handle<v8::Object> respObj = createV8Object(response);
- respObj->Set(v8::String::New(V8_DEBUGGER_KEY_TYPE), v8::String::New("response"));
- respObj->Set(v8::String::New(V8_DEBUGGER_KEY_RUNNING), v8::Boolean::New(isRunning));
- v8::Handle<v8::Function> stringifyFn =
- v8::Local<v8::Function>::Cast(debuggerUtility->Get(v8::String::New("stringifyRequest")));
- v8::Handle<v8::Value> argv[] = { respObj };
- v8::Handle<v8::Value> result = stringifyFn->Call(debuggerScript, 1, argv);
- Q_ASSERT(result->IsString());
-
- return QJSConverter::toString(result->ToString());
-
-}
-
-v8::Handle<v8::Object> QV8DebugServicePrivate::createV8Object(const QVariantMap &map) const
-{
- v8::Handle<v8::Object> obj = v8::Object::New();
- foreach (const QVariant &var, map) {
- v8::Handle<v8::String> key = QJSConverter::toString(map.key(var));
- v8::Handle<v8::Value> val;
- switch (var.type()) {
- case QVariant::Bool:
- val = v8::Boolean::New(var.toBool());
- break;
- case QVariant::Int:
- val = v8::Int32::New(var.toInt());
- break;
- case QVariant::String:
- val = QJSConverter::toString(var.toString());
- break;
- case QVariant::Map:
- createV8Object(var.toMap());
- break;
- default:
- //Add other types when required.
- //Not handled currently
- break;
- }
- if (!val.IsEmpty())
- obj->Set(key, val);
- }
- return obj;
-}
-
QT_END_NAMESPACE
#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";
const char *FUNCTION = "function";
const char *SCRIPT = "script";
+const char *SCRIPTREGEXP = "scriptRegExp";
+const char *EVENT = "event";
const char *ALL = "all";
const char *UNCAUGHT = "uncaught";
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("{}"); \
void cleanup();
+ void connect();
+ void interrupt();
void getVersion();
void getVersionWhenAttaching();
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();
QDeclarativeDebugProcess *process;
QJSDebugClient *client;
QDeclarativeDebugConnection *connection;
+ QTime t;
};
class QJSDebugClient : public QDeclarativeDebugClient
stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
}
- void startDebugging();
+ void connect();
void interrupt();
void continueDebugging(StepAction stepAction, int stepCount = 1);
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;
};
-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)
}
}
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*/)
}
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)
}
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)
}
QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
- sendMessage(packMessage(json.toString().toUtf8()));
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
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)
}
QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
- sendMessage(packMessage(json.toString().toUtf8()));
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
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*/)
}
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)
}
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)
// "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)
}
QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
- sendMessage(packMessage(json.toString().toUtf8()));
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
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)
}
QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
- sendMessage(packMessage(json.toString().toUtf8()));
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
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()
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)
// }
// QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
-// sendMessage(packMessage(json.toString().toUtf8()));
+// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
//}
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()
}
QJSValue json = stringify.call(QJSValue(), QJSValueList() << jsonVal);
- sendMessage(packMessage(json.toString().toUtf8()));
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
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)
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();
+ }
}
}
}
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;
if (connection)
delete connection;
+
+// qDebug() << "Time Elapsed:" << t.elapsed();
}
bool tst_QDeclarativeDebugJS::init(const QString &qmlFile, bool blockMode)
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())));
//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())));
//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())));
//void disconnect()
QVERIFY(init());
- client->interrupt();
- client->startDebugging();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
+ client->connect();
client->disconnect();
QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
//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())));
{
//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())));
{
//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);
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);
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()
//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);
{
//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();
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();
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()
//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
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())));
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())));
}
// int actualLine = 31;
-// client->startDebugging();
+// client->connect();
// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true);
// QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
// 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
//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
{
//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
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())));
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
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
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())));
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
{
//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();
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();
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();
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();
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();
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();
{
//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();
{
//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();
{
//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'
{
//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();
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();
{
//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();
{
//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())));
{
//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();