diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-07-04 17:01:02 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-08-08 10:45:12 +0200 |
commit | 6333e0913fc0078c0221a8909ced8df03a568992 (patch) | |
tree | 40661d956eb9a87ba3f695811de0e3c591ab7583 /tests | |
parent | 94669499fd943fc72095afd739a21cd8e675f14f (diff) |
Add support for conditional breakpoints and evaluate.
Also centralized the context state saver and added line number saving, so that the
JS jobs for evaluation of breakpoint conditions don't change the state of the current
engine context.
Task-number: QTBUG-37119
Task-number: QTCREATORBUG-11516
Change-Id: Ia21b3d64e239e5b67f3c07e1c006d8e6748f29b6
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 36 | ||||
-rw-r--r-- | tests/auto/qml/qv4debugger/tst_qv4debugger.cpp | 24 |
2 files changed, 41 insertions, 19 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index fef020704f..8763c4fa55 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -187,7 +187,7 @@ private slots: void setBreakpointInScriptOnComment(); void setBreakpointInScriptOnEmptyLine(); void setBreakpointInScriptOnOptimizedBinding(); -// void setBreakpointInScriptWithCondition(); // Not supported yet. + void setBreakpointInScriptWithCondition(); void setBreakpointInScriptThatQuits(); //void setBreakpointInFunction(); //NOT SUPPORTED // void setBreakpointOnEvent(); @@ -1082,13 +1082,8 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); } -#if 0 void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() { - QFAIL("conditional breakpoints are not yet supported"); - - //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 = 50; QVERIFY(init(CONDITION_QMLFILE)); @@ -1102,23 +1097,26 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() QString jsonString = client->response; QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - QVariantMap body = value.value("body").toMap(); - - int frameIndex = body.value("index").toInt(); - - //Verify the value of 'result' - client->evaluate(QLatin1String("a"),frameIndex); + { + QVariantMap body = value.value("body").toMap(); + int frameIndex = body.value("index").toInt(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + //Verify the value of 'result' + client->evaluate(QLatin1String("a"),frameIndex); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + } jsonString = client->response; - value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - body = value.value("body").toMap(); - - QVERIFY(body.value("value").toInt() > out); + QJSValue val = client->parser.call(QJSValueList() << QJSValue(jsonString)); + QVERIFY(val.isObject()); + QJSValue body = val.property(QStringLiteral("body")); + QVERIFY(body.isObject()); + val = body.property("value"); + QVERIFY(val.isNumber()); + + const int a = val.toInt(); + QVERIFY(a > out); } -#endif void tst_QQmlDebugJS::setBreakpointInScriptThatQuits() { diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index d7b1f2dbc3..45652d7191 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -266,6 +266,7 @@ private slots: void removePendingBreakPoint(); void addBreakPointWhilePaused(); void removeBreakPointForNextInstruction(); + void conditionalBreakPoint(); // context access: void readArguments(); @@ -412,6 +413,29 @@ void tst_qv4debugger::removeBreakPointForNextInstruction() QVERIFY(!m_debuggerAgent->m_wasPaused); } +void tst_qv4debugger::conditionalBreakPoint() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "function test() {\n" + " for (var i = 0; i < 15; ++i) {\n" + " var x = i;\n" + " }\n" + "}\n" + "test()\n"; + + m_debuggerAgent->addBreakPoint("conditionalBreakPoint", 3, /*enabled*/true, QStringLiteral("i > 10")); + evaluateJavaScript(script, "conditionalBreakPoint"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 4); + QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + QCOMPARE(state.fileName, QString("conditionalBreakPoint")); + QCOMPARE(state.lineNumber, 3); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 2); + QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains(QStringLiteral("i"))); + QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["i"].toInt(), 11); +} + void tst_qv4debugger::readArguments() { m_debuggerAgent->m_captureContextInfo = true; |