qdeclarativexmlhttprequest: Stabilize, ensure deletion of server.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 20 Dec 2011 14:46:17 +0000 (15:46 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 20 Dec 2011 14:48:52 +0000 (15:48 +0100)
Introduce QScopedPointer to make sure the server is also deleted in
case the test fails thus suppressing follow-up errors caused by
the port still being in use by a leaked server.

Change-Id: I9fd8a96ea5aba42487df8f22bc9a79917b9d8c16
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp

index da5431c..abefa30 100644 (file)
@@ -43,6 +43,7 @@
 #include <QDeclarativeEngine>
 #include <QDeclarativeComponent>
 #include <QDebug>
+#include <QScopedPointer>
 #include <QNetworkCookieJar>
 #include "testhttpserver.h"
 #include "../../shared/util.h"
@@ -254,9 +255,9 @@ void tst_qdeclarativexmlhttprequest::open()
     QFETCH(QString, url);
     QFETCH(bool, remote);
 
-    TestHTTPServer *server = 0;
+    QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
     if (remote) {
-        server = new TestHTTPServer(SERVER_PORT);
+        server.reset(new TestHTTPServer(SERVER_PORT));
         QVERIFY(server->isValid());
         QVERIFY(server->wait(TEST_FILE("open_network.expect"), 
                              TEST_FILE("open_network.reply"), 
@@ -278,7 +279,6 @@ void tst_qdeclarativexmlhttprequest::open()
 
     QTRY_VERIFY(object->property("dataOK").toBool() == true);
 
-    delete server;
     delete object;
 }