From 2946c6849159be12959151142171fa3b8c87f282 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 17 Oct 2011 14:13:01 +0200 Subject: [PATCH] Debugger: Make QDeclarativeDebugJS autotest more robust & faster Also compile it by default (again). Change-Id: I04537e29d48cd1918160fe57220eecf1a72a8e66 Reviewed-by: Aurindam Jana Reviewed-by: Christiaan Janssen --- tests/auto/declarative/debugger/debugger.pro | 2 +- .../debugger/qdeclarativedebugjs/data/test.qml | 12 ++--- .../qdeclarativedebugjs/qdeclarativedebugjs.pro | 2 + .../tst_qdeclarativedebugjs.cpp | 40 ++++++++++++++----- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro index 3ea5c41..a9c5bde 100644 --- a/tests/auto/declarative/debugger/debugger.pro +++ b/tests/auto/declarative/debugger/debugger.pro @@ -4,7 +4,7 @@ PRIVATETESTS += \ qdeclarativeenginedebug \ qdeclarativedebugclient \ qdeclarativedebugservice \ -# qdeclarativedebugjs \ + qdeclarativedebugjs \ qpacketprotocol contains(QT_CONFIG, private_tests) { diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml index 386b366..3bfeb10 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml @@ -47,11 +47,11 @@ import "test.js" as Script Rectangle { id: root width: 10; height: 10; - Component.onCompleted: print("onCompleted") - - property int result:0 + Component.onCompleted: { Script.printMessage("onCompleted"); doSomething(); } + property int result: 0 property int someValue: 10 + property bool raiseException: false function doSomething() { var a = root.result; @@ -63,7 +63,7 @@ Rectangle { } Timer { - interval: 4000; running: true; repeat: true + id: timer; interval: 1 onTriggered: { doSomething(); Script.printMessage("onTriggered"); @@ -77,10 +77,8 @@ Rectangle { function doSomethingElse() { result = Script.add(result,8); - eval("print(root.result)"); - if (root.result > 15) + if (raiseException) dummy(); } - } diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro index a6f005e..236692a 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro @@ -18,3 +18,5 @@ DEPLOYMENT += testDataFiles CONFIG += parallel_test #temporary CONFIG += insignificant_test + +OTHER_FILES += data/test.qml data/test.js diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index ee40056..2386d0b 100644 --- a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -291,6 +291,10 @@ void QJSDebugProcess::processAppOutput() continue; } } + if (line.startsWith("QDeclarativeDebugServer: Unable to listen on port")) { + QFAIL("Application cannot open port 3771: Port is blocked?"); + break; + } // qWarning() << line; } m_mutex.unlock(); @@ -960,7 +964,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data) if (type == "response") { if (!value.value("success").toBool()) { - qDebug() << "Error: The test case will fail since no signal is emitted"; +// qDebug() << "Error: The test case will fail since no signal is emitted"; return; } @@ -1169,12 +1173,19 @@ void tst_QDeclarativeDebugJS::setBreakpointInScriptOnCompleted() void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback() { + int sourceLine = 49; + client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(QMLFILE), sourceLine, -1, true); + client->startDebugging(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->evaluate("timer.running = true"); + client->continueDebugging(QJSDebugClient::Continue); + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - int sourceLine = 67; + sourceLine = 67; client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(QMLFILE), sourceLine, -1, true); - client->startDebugging(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); QString jsonString(client->response); @@ -1325,6 +1336,10 @@ void tst_QDeclarativeDebugJS::changeBreakpoint() 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 @@ -1367,6 +1382,8 @@ void tst_QDeclarativeDebugJS::changeBreakpointOnCondition() 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 @@ -1431,6 +1448,8 @@ void tst_QDeclarativeDebugJS::clearBreakpoint() 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 @@ -1448,13 +1467,12 @@ void tst_QDeclarativeDebugJS::setExceptionBreak() { //void setExceptionBreak(QString type, bool enabled = false); - client->interrupt(); + int sourceLine = 49; + client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(QMLFILE), sourceLine, -1, true); + client->setExceptionBreak(QJSDebugClient::All,true); client->startDebugging(); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()))); - - client->setExceptionBreak(QJSDebugClient::All,true); - QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result()))); - + client->evaluate("root.raiseException = true"); client->continueDebugging(QJSDebugClient::Continue); QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 10000)); } @@ -1507,8 +1525,8 @@ void tst_QDeclarativeDebugJS::stepIn() { //void continueDebugging(StepAction stepAction, int stepCount = 1); - int sourceLine = 67; - int actualLine = 56; + int sourceLine = 61; + int actualLine = 78; client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(QMLFILE), sourceLine, -1, true); client->startDebugging(); @@ -1531,7 +1549,7 @@ void tst_QDeclarativeDebugJS::stepOut() //void continueDebugging(StepAction stepAction, int stepCount = 1); int sourceLine = 56; - int actualLine = 68; + int actualLine = 49; client->setBreakpoint(QLatin1String(SCRIPT), QLatin1String(QMLFILE), sourceLine, -1, true); client->startDebugging(); -- 1.7.2.5