diff options
Diffstat (limited to 'tests/auto/quick')
9 files changed, 62 insertions, 58 deletions
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index d10963b579..49bbb3a4c5 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -259,8 +259,8 @@ void tst_qquickanimatedimage::remote() QFETCH(QString, fileName); QFETCH(bool, paused); - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; @@ -324,8 +324,8 @@ void tst_qquickanimatedimage::invalidSource() void tst_qquickanimatedimage::sourceSizeChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; @@ -390,8 +390,8 @@ void tst_qquickanimatedimage::sourceSizeChanges() void tst_qquickanimatedimage::qtbug_16520() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; @@ -413,8 +413,8 @@ void tst_qquickanimatedimage::qtbug_16520() void tst_qquickanimatedimage::progressAndStatusChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 4e7b6522dd..c02a5c7a87 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -143,11 +143,10 @@ void tst_qquickborderimage::imageSource() QFETCH(bool, remote); QFETCH(QString, error); - TestHTTPServer *server = 0; + TestHTTPServer server; if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(dataDirectory()); + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); + server.serveDirectory(dataDirectory()); } if (!error.isEmpty()) @@ -177,7 +176,6 @@ void tst_qquickborderimage::imageSource() } delete obj; - delete server; } void tst_qquickborderimage::clearSource() @@ -292,11 +290,11 @@ void tst_qquickborderimage::sciSource() QFETCH(bool, valid); bool remote = source.startsWith("http"); - TestHTTPServer *server = 0; + + TestHTTPServer server; if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(dataDirectory()); + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); + server.serveDirectory(dataDirectory()); } QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; @@ -325,7 +323,6 @@ void tst_qquickborderimage::sciSource() } delete obj; - delete server; } void tst_qquickborderimage::sciSource_data() @@ -435,11 +432,10 @@ void tst_qquickborderimage::statusChanges() QFETCH(bool, remote); QFETCH(QQuickImageBase::Status, finalStatus); - TestHTTPServer *server = 0; + TestHTTPServer server; if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(dataDirectory(), TestHTTPServer::Delay); + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); + server.serveDirectory(dataDirectory()); } QString componentStr = "import QtQuick 2.0\nBorderImage { width: 300; height: 300 }"; @@ -452,18 +448,17 @@ void tst_qquickborderimage::statusChanges() QVERIFY(obj != 0); obj->setSource(source); if (remote) - server->sendDelayedItem(); + server.sendDelayedItem(); QTRY_VERIFY(obj->status() == finalStatus); QCOMPARE(spy.count(), emissions); delete obj; - delete server; } void tst_qquickborderimage::sourceSizeChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; @@ -528,8 +523,8 @@ void tst_qquickborderimage::sourceSizeChanges() void tst_qquickborderimage::progressAndStatusChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp index bcb496eab7..5c2bbf1650 100644 --- a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp +++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp @@ -75,8 +75,7 @@ private: TestHTTPServer server; }; -tst_qquickfontloader::tst_qquickfontloader() : - server(SERVER_PORT) +tst_qquickfontloader::tst_qquickfontloader() { } @@ -84,7 +83,7 @@ void tst_qquickfontloader::initTestCase() { QQmlDataTest::initTestCase(); server.serveDirectory(dataDirectory()); - QVERIFY(server.isValid()); + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); } void tst_qquickfontloader::noFont() diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index b23591b593..b73dcdfcde 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -176,9 +176,9 @@ void tst_qquickimage::imageSource() QFETCH(bool, cache); QFETCH(QString, error); - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; if (remote) { - QVERIFY(server.isValid()); + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); } @@ -524,8 +524,8 @@ void tst_qquickimage::noLoading() { qRegisterMetaType<QQuickImageBase::Status>(); - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); @@ -685,8 +685,8 @@ void tst_qquickimage::nullPixmapPaint() void tst_qquickimage::imageCrash_QTBUG_22125() { - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); { @@ -756,8 +756,8 @@ void tst_qquickimage::sourceSize() void tst_qquickimage::sourceSizeChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; @@ -822,8 +822,8 @@ void tst_qquickimage::sourceSizeChanges() void tst_qquickimage::progressAndStatusChanges() { - TestHTTPServer server(14449); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(14449), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlEngine engine; diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 877bb59613..9ac2663f24 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -446,8 +446,8 @@ void tst_QQuickLoader::noResize() void tst_QQuickLoader::networkRequestUrl() { - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QQmlComponent component(&engine); @@ -470,8 +470,8 @@ void tst_QQuickLoader::networkRequestUrl() /* XXX Component waits until all dependencies are loaded. Is this actually possible? */ void tst_QQuickLoader::networkComponent() { - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQmlComponent component(&engine); @@ -503,8 +503,8 @@ void tst_QQuickLoader::networkComponent() void tst_QQuickLoader::failNetworkRequest() { - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); QTest::ignoreMessage(QtWarningMsg, SERVER_ADDR "/IDontExist.qml: File not found"); @@ -718,8 +718,8 @@ void tst_QQuickLoader::initialPropertyValues() QFETCH(QStringList, propertyNames); QFETCH(QVariantList, propertyValues); - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory()); foreach (const QString &warning, expectedWarnings) diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp index 75bd468aef..f104154205 100644 --- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -59,7 +59,7 @@ class tst_qquickpixmapcache : public QQmlDataTest { Q_OBJECT public: - tst_qquickpixmapcache() : server(14452) {} + tst_qquickpixmapcache() {} private slots: void initTestCase(); @@ -116,6 +116,8 @@ void tst_qquickpixmapcache::initTestCase() { QQmlDataTest::initTestCase(); + QVERIFY2(server.listen(14452), qPrintable(server.errorString())); + // This avoids a race condition/deadlock bug in network config // manager when it is accessed by the HTTP server thread before // anything else. Bug report can be found at: @@ -379,7 +381,8 @@ void tst_qquickpixmapcache::shrinkcache() void createNetworkServer() { QEventLoop eventLoop; - TestHTTPServer server(14453); + TestHTTPServer server; + QVERIFY2(server.listen(14453), qPrintable(server.errorString())); server.serveDirectory(QQmlDataTest::instance()->testFile("http")); QTimer::singleShot(100, &eventLoop, SLOT(quit())); eventLoop.exec(); @@ -407,7 +410,8 @@ void tst_qquickpixmapcache::networkCrash() // QTBUG-22125 void tst_qquickpixmapcache::lockingCrash() { - TestHTTPServer server(14453); + TestHTTPServer server; + QVERIFY2(server.listen(14453), qPrintable(server.errorString())); server.serveDirectory(testFile("http"), TestHTTPServer::Delay); { diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 0b6998146e..3859fa8424 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -2022,7 +2022,8 @@ void tst_qquicktext::embeddedImages() QFETCH(QUrl, qmlfile); QFETCH(QString, error); - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(testFile("http")); if (!error.isEmpty()) @@ -2760,7 +2761,8 @@ void tst_qquicktext::imgTagsBaseUrl() QFETCH(QUrl, contextUrl); QFETCH(qreal, imgHeight); - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(testFile("")); QByteArray baseUrlFragment; diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 91a6886bf0..3bf872569f 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2603,7 +2603,8 @@ void tst_qquicktextedit::cursorDelegate() void tst_qquicktextedit::remoteCursorDelegate() { - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQuickView view; @@ -2740,7 +2741,8 @@ void tst_qquicktextedit::delegateLoading() QFETCH(QString, qmlfile); QFETCH(QString, error); - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect); server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay); server.serveDirectory(testFile("http")); @@ -5214,7 +5216,8 @@ void tst_qquicktextedit::embeddedImages() QFETCH(QUrl, qmlfile); QFETCH(QString, error); - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(testFile("http")); if (!error.isEmpty()) diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 273c0de660..05cf0b9a5b 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2853,7 +2853,8 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::remoteCursorDelegate() { - TestHTTPServer server(SERVER_PORT); + TestHTTPServer server; + QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString())); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQuickView view; |