Debugger: Make QDeclarativeDebugJS autotest more robust & faster
authorKai Koehne <kai.koehne@nokia.com>
Mon, 17 Oct 2011 12:13:01 +0000 (14:13 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 17 Oct 2011 12:56:09 +0000 (14:56 +0200)
Also compile it by default (again).

Change-Id: I04537e29d48cd1918160fe57220eecf1a72a8e66
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
tests/auto/declarative/debugger/debugger.pro
tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml
tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro
tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp

index 3ea5c41..a9c5bde 100644 (file)
@@ -4,7 +4,7 @@ PRIVATETESTS += \
     qdeclarativeenginedebug \
     qdeclarativedebugclient \
     qdeclarativedebugservice \
-#    qdeclarativedebugjs \
+    qdeclarativedebugjs \
     qpacketprotocol
 
 contains(QT_CONFIG, private_tests) {
index 386b366..3bfeb10 100644 (file)
@@ -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();
     }
-
 }
 
index ee40056..2386d0b 100644 (file)
@@ -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();