diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-11-28 09:24:35 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-03 08:28:22 +0100 |
commit | cfdcc65cc54fc973a147044fc592779e87a669c4 (patch) | |
tree | 455063d17200ee52c32338c0f33914e641261673 /tests | |
parent | b970c579163c317e1d5aa881507c029a15800746 (diff) |
Fix expression evaluation in specific frames in the debugger
Expressions from the QML/JS console are intended to be executed in a specific
frame / context. However that wasn't implemented properly, we should pop the
current context frameNr times.
[ChangeLog][QtQml] Fix inspecting objects in QML/JS console in different frames.
Change-Id: If575d4005c52a9fe6805538a7b1a02b9e32049d6
Task-number: QTBUG-42831
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qv4debugger/tst_qv4debugger.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index 3fe14fa216..6457cb7898 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -182,6 +182,14 @@ public: m_stackTrace = debugger->stackTrace(); + while (!m_expressionRequests.isEmpty()) { + ExpressionRequest request = m_expressionRequests.takeFirst(); + QVariantMap result; + collector.setDestination(&result); + debugger->evaluateExpression(request.frameNr, request.expression, &collector); + m_expressionResults << result[QString::fromLatin1("body")]; + } + if (m_captureContextInfo) captureContextInfo(debugger); @@ -233,6 +241,13 @@ public: QList<QVariantMap> m_capturedLocals; QVariant m_thrownValue; + struct ExpressionRequest { + QString expression; + int frameNr; + }; + QVector<ExpressionRequest> m_expressionRequests; + QVector<QVariant> m_expressionResults; + // Utility methods: void dumpStackTrace() const { @@ -269,6 +284,8 @@ private slots: // exceptions: void pauseOnThrow(); + void evaluateExpression(); + private: void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1) { @@ -556,6 +573,33 @@ void tst_qv4debugger::pauseOnThrow() QCOMPARE(m_debuggerAgent->m_thrownValue.toString(), QString("hard")); } +void tst_qv4debugger::evaluateExpression() +{ + QString script = + "function testFunction() {\n" + " var x = 10\n" + " return x\n" // breakpoint + "}\n" + "var x = 20\n" + "testFunction()\n"; + + TestAgent::ExpressionRequest request; + request.expression = "x"; + request.frameNr = 0; + m_debuggerAgent->m_expressionRequests << request; + request.expression = "x"; + request.frameNr = 1; + m_debuggerAgent->m_expressionRequests << request; + + m_debuggerAgent->addBreakPoint("evaluateExpression", 3); + + evaluateJavaScript(script, "evaluateExpression"); + + QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 2); + QCOMPARE(m_debuggerAgent->m_expressionResults[0].toInt(), 10); + QCOMPARE(m_debuggerAgent->m_expressionResults[1].toInt(), 20); +} + QTEST_MAIN(tst_qv4debugger) #include "tst_qv4debugger.moc" |