aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-03-09 18:53:23 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-03-14 09:02:51 +0000
commitffe538a565e2f14ad276078891f18ec90d09be82 (patch)
treedd69cbe8e6d635159203d0f066ea5ea670bb1ea4 /tests/auto/qml/debugger
parent9180241819a9ea5e517977efc5bb031521a56cc6 (diff)
QV4DebugService: Reduce unnecessary recursion and redundancy
Large parts of the protocol are unnecessary. There is no reason to send a separate chunk of "handles" with almost every reply. The refs are given as part of the regular data and if the client wants to find out more, it can do further lookups. Also, it makes no sense to encode the function and script names as objects, as they are in fact not JavaScript objects. Unfortunately these cleanups require some cooperation from the client. Older clients will misbehave if we just drop the redundancy. Therefore, we introduce parameters which the client can explicitly set with the "connect" message. redundantRefs tells the service if redundant references are required, namesAsObjects tells it if script and function names have to be sent as objects/ Once we can require clients that support these options, we can drop the code that generates redundant data. Also, fix tst_qv4debugger::evaluateExpression() to actually check all the expressions evaluated, not only the first and second one. Task-number: QTBUG-42435 Change-Id: If93d2a2b9d0b8035f85dbef871bc1b03f199171d Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/debugger')
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp118
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp82
2 files changed, 140 insertions, 60 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
index 31b8d63ec2..d248cf9708 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -257,7 +257,7 @@ public:
stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
}
- void connect();
+ void connect(bool redundantRefs = false, bool namesAsObjects = false);
void interrupt();
void continueDebugging(StepAction stepAction);
@@ -304,9 +304,13 @@ public:
};
-void QJSDebugClient::connect()
+void QJSDebugClient::connect(bool redundantRefs, bool namesAsObjects)
{
- sendMessage(packMessage(CONNECT));
+ QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}"));
+ jsonVal.setProperty("redundantRefs", QJSValue(redundantRefs));
+ jsonVal.setProperty("namesAsObjects", QJSValue(namesAsObjects));
+ sendMessage(packMessage(CONNECT,
+ stringify.call(QJSValueList() << jsonVal).toString().toUtf8()));
}
void QJSDebugClient::interrupt()
@@ -870,8 +874,10 @@ void tst_QQmlDebugJS::interrupt()
//void connect()
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
client->interrupt();
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(interruptRequested())));
@@ -882,8 +888,10 @@ void tst_QQmlDebugJS::getVersion()
//void version()
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
client->version();
@@ -894,9 +902,11 @@ void tst_QQmlDebugJS::getVersionWhenAttaching()
{
//void version()
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene, QLatin1String(TIMER_QMLFILE), false);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
client->version();
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
@@ -907,8 +917,10 @@ void tst_QQmlDebugJS::disconnect()
//void disconnect()
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
client->disconnect();
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
@@ -918,12 +930,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, ONCOMPLETED_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
QString jsonString(client->response);
@@ -939,12 +953,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, CREATECOMPONENT_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
QString jsonString(client->response);
@@ -959,10 +975,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
{
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 35;
init(qmlscene, TIMER_QMLFILE);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
//We can set the breakpoint after connect() here because the timer is repeating and if we miss
//its first iteration we can still catch the second one.
client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
@@ -981,12 +999,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 31;
init(qmlscene, LOADJSFILE_QMLFILE);
client->setBreakpoint(QLatin1String(TEST_JSFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
QString jsonString(client->response);
@@ -1002,13 +1022,15 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
int actualLine = 36;
init(qmlscene, BREAKPOINTRELOCATION_QMLFILE);
client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
@@ -1025,13 +1047,15 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 35;
int actualLine = 36;
init(qmlscene, BREAKPOINTRELOCATION_QMLFILE);
client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
@@ -1048,12 +1072,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 39;
init(qmlscene, BREAKPOINTRELOCATION_QMLFILE);
client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
QString jsonString(client->response);
@@ -1068,11 +1094,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
{
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int out = 10;
int sourceLine = 37;
init(qmlscene, CONDITION_QMLFILE);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
//The breakpoint is in a timer loop so we can set it after connect().
client->setBreakpoint(QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
@@ -1105,12 +1133,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
{
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene, QUIT_QMLFILE);
int sourceLine = 36;
client->setBreakpoint(QLatin1String(QUIT_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
QString jsonString(client->response);
@@ -1147,12 +1177,14 @@ void tst_QQmlDebugJS::clearBreakpoint()
{
//void clearBreakpoint(int breakpoint);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine1 = 37;
int sourceLine2 = 38;
init(qmlscene, CHANGEBREAKPOINT_QMLFILE);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
//The breakpoints are in a timer loop so we can set them after connect().
//Furthermore the breakpoints should be hit in the right order because setting of breakpoints
//can only occur in the QML event loop. (see QCOMPARE for sourceLine2 below)
@@ -1195,10 +1227,12 @@ void tst_QQmlDebugJS::setExceptionBreak()
{
//void setExceptionBreak(QString type, bool enabled = false);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene, EXCEPTION_QMLFILE);
client->setExceptionBreak(QJSDebugClient::All,true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
}
@@ -1206,12 +1240,14 @@ void tst_QQmlDebugJS::stepNext()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 37;
init(qmlscene, STEPACTION_QMLFILE);
client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->continueDebugging(QJSDebugClient::Next);
@@ -1230,13 +1266,15 @@ void tst_QQmlDebugJS::stepIn()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 41;
int actualLine = 37;
init(qmlscene, STEPACTION_QMLFILE);
client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->continueDebugging(QJSDebugClient::In);
@@ -1255,13 +1293,15 @@ void tst_QQmlDebugJS::stepOut()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 37;
int actualLine = 41;
init(qmlscene, STEPACTION_QMLFILE);
client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->continueDebugging(QJSDebugClient::Out);
@@ -1280,6 +1320,8 @@ void tst_QQmlDebugJS::continueDebugging()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine1 = 41;
int sourceLine2 = 38;
@@ -1287,7 +1329,7 @@ void tst_QQmlDebugJS::continueDebugging()
client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->continueDebugging(QJSDebugClient::Continue);
@@ -1306,12 +1348,14 @@ void tst_QQmlDebugJS::backtrace()
{
//void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, ONCOMPLETED_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->backtrace();
@@ -1322,12 +1366,14 @@ void tst_QQmlDebugJS::getFrameDetails()
{
//void frame(int number = -1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, ONCOMPLETED_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->frame();
@@ -1338,12 +1384,14 @@ void tst_QQmlDebugJS::getScopeDetails()
{
//void scope(int number = -1, int frameNumber = -1);
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, ONCOMPLETED_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->scope();
@@ -1374,11 +1422,13 @@ void tst_QQmlDebugJS::evaluateInLocalScope()
//void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
int sourceLine = 34;
init(qmlscene, ONCOMPLETED_QMLFILE);
client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->frame();
@@ -1461,10 +1511,12 @@ void tst_QQmlDebugJS::getScripts()
//void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
QFETCH(bool, qmlscene);
+ QFETCH(bool, redundantRefs);
+ QFETCH(bool, namesAsObjects);
init(qmlscene);
client->setBreakpoint(QString(TEST_QMLFILE), 35, -1, true);
- client->connect();
+ client->connect(redundantRefs, namesAsObjects);
QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
client->scripts();
@@ -1482,8 +1534,16 @@ void tst_QQmlDebugJS::getScripts()
void tst_QQmlDebugJS::targetData()
{
QTest::addColumn<bool>("qmlscene");
- QTest::newRow("custom") << false;
- QTest::newRow("qmlscene") << true;
+ QTest::addColumn<bool>("redundantRefs");
+ QTest::addColumn<bool>("namesAsObjects");
+ QTest::newRow("custom / redundant / objects") << false << true << true;
+ QTest::newRow("qmlscene / redundant / objects") << true << true << true;
+ QTest::newRow("custom / redundant / strings") << false << true << false;
+ QTest::newRow("qmlscene / redundant / strings") << true << true << false;
+ QTest::newRow("custom / sparse / objects") << false << false << true;
+ QTest::newRow("qmlscene / sparse / objects") << true << false << true;
+ QTest::newRow("custom / sparse / strings") << false << false << false;
+ QTest::newRow("qmlscene / sparse / strings") << true << false << false;
}
QTEST_MAIN(tst_QQmlDebugJS)
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index 56320b8365..6d0d884ed7 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -120,7 +120,6 @@ public:
typedef QV4DataCollector::Refs Refs;
typedef QV4DataCollector::Ref Ref;
struct NamedRefs {
- QJsonArray refs;
QJsonObject scope;
int size() const {
@@ -131,15 +130,6 @@ public:
return scope.contains(name);
}
- QJsonObject resolveRef(int ref) const {
- foreach (const QJsonValue &val, refs) {
- QJsonObject obj = val.toObject();
- if (obj.value(QLatin1String("handle")).toInt() == ref)
- return obj;
- }
- return QJsonObject();
- }
-
#define DUMP_JSON(x) {\
QJsonDocument doc(x);\
qDebug() << #x << "=" << doc.toJson(QJsonDocument::Indented);\
@@ -209,7 +199,6 @@ public slots:
request.expression, &collector);
debugger->runInEngine(&job);
m_expressionResults << job.returnValue();
- m_expressionRefs << job.refs();
}
if (m_captureContextInfo)
@@ -235,24 +224,17 @@ public:
ScopeJob job(&collector, i, 0);
debugger->runInEngine(&job);
NamedRefs &refs = m_capturedScope.last();
- refs.refs = job.refs();
QJsonObject object = job.returnValue();
object = object.value(QLatin1String("object")).toObject();
- int ref = object.value(QLatin1String("ref")).toInt();
- object = refs.resolveRef(ref);
+ if (object.contains("ref") && !object.contains("properties")) {
+ QVERIFY(collector.redundantRefs());
+ object = collector.lookupRef(object.value("ref").toInt(), true);
+ QVERIFY(object.contains("properties"));
+ }
foreach (const QJsonValue &value, object.value(QLatin1String("properties")).toArray()) {
QJsonObject property = value.toObject();
QString name = property.value(QLatin1String("name")).toString();
property.remove(QLatin1String("name"));
- if (property.contains(QLatin1String("ref"))) {
- int childRef = property.value(QLatin1String("ref")).toInt();
- if (childRef >= 0 && refs.refs.size() > childRef) {
- property.remove(QLatin1String("ref"));
- property.insert(QLatin1String("properties"),
- refs.resolveRef(childRef).value(
- QLatin1String("properties")).toArray());
- }
- }
refs.scope.insert(name, property);
}
}
@@ -283,7 +265,6 @@ public:
QVector<ExpressionRequest> m_expressionRequests;
QV4Debugger::Speed m_resumeSpeed;
QList<QJsonObject> m_expressionResults;
- QList<QJsonArray> m_expressionRefs;
QV4Debugger *m_debugger;
// Utility methods:
@@ -315,9 +296,13 @@ private slots:
void conditionalBreakPointInQml();
// context access:
+ void readArguments_data() { redundancy_data(); }
void readArguments();
+ void readLocals_data() { redundancy_data(); }
void readLocals();
+ void readObject_data() { redundancy_data(); }
void readObject();
+ void readContextInAllFrames_data() { redundancy_data(); }
void readContextInAllFrames();
// exceptions:
@@ -325,7 +310,9 @@ private slots:
void breakInCatch();
void breakInWith();
+ void evaluateExpression_data() { redundancy_data(); }
void evaluateExpression();
+ void stepToEndOfScript_data() { redundancy_data(); }
void stepToEndOfScript();
void lastLineOfLoop_data();
@@ -343,6 +330,8 @@ private:
waitForSignal(m_engine, SIGNAL(evaluateFinished()), /*timeout*/0);
}
+ void redundancy_data();
+
TestEngine *m_engine;
QV4::ExecutionEngine *m_v4;
TestAgent *m_debuggerAgent;
@@ -537,6 +526,9 @@ void tst_qv4debugger::conditionalBreakPointInQml()
void tst_qv4debugger::readArguments()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"function f(a, b, c, d) {\n"
@@ -560,6 +552,9 @@ void tst_qv4debugger::readArguments()
void tst_qv4debugger::readLocals()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"function f(a, b) {\n"
@@ -583,6 +578,9 @@ void tst_qv4debugger::readLocals()
void tst_qv4debugger::readObject()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"function f(a) {\n"
@@ -599,6 +597,12 @@ void tst_qv4debugger::readObject()
QVERIFY(frame0.contains("b"));
QCOMPARE(frame0.type("b"), QStringLiteral("object"));
QJsonObject b = frame0.rawValue("b");
+ QVERIFY(b.contains(QStringLiteral("ref")));
+ QVERIFY(b.contains(QStringLiteral("value")));
+ QVERIFY(!b.contains(QStringLiteral("properties")));
+ QVERIFY(b.value("value").isDouble());
+ QCOMPARE(b.value("value").toInt(), 2);
+ b = m_debuggerAgent->collector.lookupRef(b.value("ref").toInt(), true);
QVERIFY(b.contains(QStringLiteral("properties")));
QVERIFY(b.value("properties").isArray());
QJsonArray b_props = b.value("properties").toArray();
@@ -614,7 +618,8 @@ void tst_qv4debugger::readObject()
QCOMPARE(b_tail.value("name").toString(), QStringLiteral("tail"));
QVERIFY(b_tail.contains("ref"));
- QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt());
+ QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt(),
+ true);
QCOMPARE(b_tail_value.value("type").toString(), QStringLiteral("object"));
QVERIFY(b_tail_value.contains("properties"));
QJsonArray b_tail_props = b_tail_value.value("properties").toArray();
@@ -631,6 +636,9 @@ void tst_qv4debugger::readObject()
void tst_qv4debugger::readContextInAllFrames()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"function fact(n) {\n"
@@ -678,7 +686,8 @@ void tst_qv4debugger::pauseOnThrow()
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::Throwing);
QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 2);
QVERIFY(m_debuggerAgent->m_thrownValue >= qint64(0));
- QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue);
+ QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue,
+ true);
// DUMP_JSON(exception);
QCOMPARE(exception.value("type").toString(), QStringLiteral("string"));
QCOMPARE(exception.value("value").toString(), QStringLiteral("hard"));
@@ -722,6 +731,9 @@ void tst_qv4debugger::breakInWith()
void tst_qv4debugger::evaluateExpression()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
QString script =
"function testFunction() {\n"
" var x = 10\n"
@@ -750,14 +762,12 @@ void tst_qv4debugger::evaluateExpression()
evaluateJavaScript(script, "evaluateExpression");
- QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 4);
- QCOMPARE(m_debuggerAgent->m_expressionRefs[0].size(), 1);
- QJsonObject result0 = m_debuggerAgent->m_expressionRefs[0].first().toObject();
+ QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 4);
+ QJsonObject result0 = m_debuggerAgent->m_expressionResults[0];
QCOMPARE(result0.value("type").toString(), QStringLiteral("number"));
QCOMPARE(result0.value("value").toInt(), 10);
for (int i = 1; i < 4; ++i) {
- QCOMPARE(m_debuggerAgent->m_expressionRefs[i].size(), 1);
- QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject();
+ QJsonObject result1 = m_debuggerAgent->m_expressionResults[i];
QCOMPARE(result1.value("type").toString(), QStringLiteral("number"));
QCOMPARE(result1.value("value").toInt(), 20);
}
@@ -765,6 +775,9 @@ void tst_qv4debugger::evaluateExpression()
void tst_qv4debugger::stepToEndOfScript()
{
+ QFETCH(bool, redundantRefs);
+ m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
+
QString script =
"var ret = 0;\n"
"ret += 4;\n"
@@ -827,6 +840,13 @@ void tst_qv4debugger::lastLineOfLoop()
QCOMPARE(secondState.lineNumber, 7);
}
+void tst_qv4debugger::redundancy_data()
+{
+ QTest::addColumn<bool>("redundantRefs");
+ QTest::addRow("redundant") << true;
+ QTest::addRow("sparse") << false;
+}
+
QTEST_MAIN(tst_qv4debugger)
#include "tst_qv4debugger.moc"