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>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDebug>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDebug>
+#include <QScopedPointer>
#include <QNetworkCookieJar>
#include "testhttpserver.h"
#include "../../shared/util.h"
#include <QNetworkCookieJar>
#include "testhttpserver.h"
#include "../../shared/util.h"
QFETCH(QString, url);
QFETCH(bool, remote);
QFETCH(QString, url);
QFETCH(bool, remote);
- TestHTTPServer *server = 0;
+ QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
- 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"),
QVERIFY(server->isValid());
QVERIFY(server->wait(TEST_FILE("open_network.expect"),
TEST_FILE("open_network.reply"),
QTRY_VERIFY(object->property("dataOK").toBool() == true);
QTRY_VERIFY(object->property("dataOK").toBool() == true);