Use unique port numbers for http servers in auto tests.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Tue, 3 Jul 2012 04:00:25 +0000 (14:00 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 5 Jul 2012 05:14:07 +0000 (07:14 +0200)
Prevents conflicts when tests are run in parallel.

Change-Id: Ic1652d963da291c7c41b31e2621874824fa575cb
Reviewed-by: Damian Jansen <damian.jansen@nokia.com>
tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml
tests/auto/quick/qquickloader/tst_qquickloader.cpp
tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml
tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml
tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml
tests/auto/quick/qquicktext/tst_qquicktext.cpp

index 81aed01..b649075 100644 (file)
@@ -47,8 +47,8 @@
 #include "../../shared/testhttpserver.h"
 #include "../../shared/util.h"
 
-#define SERVER_ADDR "http://127.0.0.1:14450"
-#define SERVER_PORT 14450
+#define SERVER_ADDR "http://127.0.0.1:14456"
+#define SERVER_PORT 14456
 
 
 class tst_qqmlmoduleplugin : public QQmlDataTest
@@ -230,7 +230,7 @@ void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
 
     QQmlEngine engine;
     QQmlComponent component(&engine);
-    component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
+    component.setData("import \"" SERVER_ADDR "/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
 
     QTRY_COMPARE(component.status(), QQmlComponent::Ready);
     QObject *object = component.create();
index 10f81ac..cab8a22 100644 (file)
@@ -49,7 +49,8 @@
 #include <QtQuick/QQuickView>
 #include <QtQuick/QQuickItem>
 
-#define SERVER_PORT 14448
+#define SERVER_PORT 14457
+#define SERVER_ADDR "http://localhost:14457"
 
 class tst_qquickfontloader : public QQmlDataTest
 {
@@ -152,7 +153,7 @@ void tst_qquickfontloader::webFont()
 #if defined(Q_OS_WIN)
     QSKIP("Windows doesn't support font loading.");
 #endif
-    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
+    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/tarzeau_ocr_a.ttf\" }";
     QQmlComponent component(&engine);
 
     component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
@@ -171,7 +172,7 @@ void tst_qquickfontloader::redirWebFont()
 #endif
     server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
 
-    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
+    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/olddir/oldname.ttf\" }";
     QQmlComponent component(&engine);
 
     component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
@@ -188,8 +189,8 @@ void tst_qquickfontloader::failWebFont()
 #if defined(Q_OS_WIN)
     QSKIP("Windows doesn't support font loading.");
 #endif
-    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
-    QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
+    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SERVER_ADDR "/nonexist.ttf\" }";
+    QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"" SERVER_ADDR "/nonexist.ttf\"");
     QQmlComponent component(&engine);
     component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
     QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
@@ -222,7 +223,7 @@ void tst_qquickfontloader::changeFont()
     QCOMPARE(statusSpy.count(), 0);
     QTRY_COMPARE(fontObject->name(), QString("OCRA"));
 
-    ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+    ctxt->setContextProperty("font", SERVER_ADDR "/daniel.ttf");
     QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Loading);
     QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
     QCOMPARE(nameSpy.count(), 1);
@@ -235,7 +236,7 @@ void tst_qquickfontloader::changeFont()
     QCOMPARE(statusSpy.count(), 2);
     QTRY_COMPARE(fontObject->name(), QString("OCRA"));
 
-    ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+    ctxt->setContextProperty("font", SERVER_ADDR "/daniel.ttf");
     QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
     QCOMPARE(nameSpy.count(), 3);
     QCOMPARE(statusSpy.count(), 2);
index 79e9264..fff67f3 100644 (file)
@@ -14,7 +14,7 @@ Item {
     }
 
     Component.onCompleted: {
-        loader.setSource("http://127.0.0.1:14450/InitialPropertyValuesComponent.qml", {"canary": 6});
+        loader.setSource("http://127.0.0.1:14458/InitialPropertyValuesComponent.qml", {"canary": 6});
         loader.active = true;
     }
 }
index dc21af8..fa09779 100644 (file)
@@ -49,7 +49,8 @@
 #include "testhttpserver.h"
 #include "../../shared/util.h"
 
-#define SERVER_PORT 14450
+#define SERVER_PORT 14458
+#define SERVER_ADDR "http://localhost:14458"
 
 class PeriodicIncubationController : public QObject,
     public QQmlIncubationController
@@ -431,7 +432,7 @@ void tst_QQuickLoader::networkRequestUrl()
     server.serveDirectory(dataDirectory());
 
     QQmlComponent component(&engine);
-    component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
+    component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"" SERVER_ADDR "/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
     if (component.isError())
         qDebug() << component.errors();
     QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
@@ -457,7 +458,7 @@ void tst_QQuickLoader::networkComponent()
     QQmlComponent component(&engine);
     component.setData(QByteArray(
                 "import QtQuick 2.0\n"
-                "import \"http://127.0.0.1:14450/\" as NW\n"
+                "import \"" SERVER_ADDR "/\" as NW\n"
                 "Item {\n"
                 " Component { id: comp; NW.Rect120x60 {} }\n"
                 " Loader { sourceComponent: comp } }")
@@ -484,10 +485,10 @@ void tst_QQuickLoader::failNetworkRequest()
     QVERIFY(server.isValid());
     server.serveDirectory(dataDirectory());
 
-    QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
+    QTest::ignoreMessage(QtWarningMsg, SERVER_ADDR "/IDontExist.qml: File not found");
 
     QQmlComponent component(&engine);
-    component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
+    component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"" SERVER_ADDR "/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl(QString(SERVER_ADDR "/dummy.qml")));
     QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
     QVERIFY(loader != 0);
 
index 702633c..5d241f9 100644 (file)
@@ -2,5 +2,5 @@ import QtQuick 2.0
 
 Text {
     textFormat: Text.RichText
-    text: "<img src='http://127.0.0.1:14453/exists.png'>"
+    text: "<img src='http://127.0.0.1:14459/exists.png'>"
 }
index 5762f3e..adeed88 100644 (file)
@@ -2,5 +2,5 @@ import QtQuick 2.0
 
 Text {
     textFormat: Text.RichText
-    text: "<img src='http://127.0.0.1:14453/notexists.png'>"
+    text: "<img src='http://127.0.0.1:14459/notexists.png'>"
 }
index cee1974..2835d81 100644 (file)
@@ -3,5 +3,5 @@ import QtQuick 2.0
 Text {
     textFormat: Text.RichText
     text: "<img src='exists.png'>"
-    baseUrl: "http://127.0.0.1:14453/text.html"
+    baseUrl: "http://127.0.0.1:14459/text.html"
 }
index 2bdf4a9..0adddb9 100644 (file)
@@ -57,6 +57,9 @@
 
 DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
 
+#define SERVER_PORT 14459
+#define SERVER_ADDR "http://127.0.0.1:14459"
+
 Q_DECLARE_METATYPE(QQuickText::TextFormat)
 
 class tst_qquicktext : public QQmlDataTest
@@ -1829,7 +1832,7 @@ void tst_qquicktext::embeddedImages_data()
     QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
     QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
     QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
-        << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
+                                  << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading " SERVER_ADDR "/notexists.png - server replied: Not found";
     QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
 }
 
@@ -1840,7 +1843,7 @@ void tst_qquicktext::embeddedImages()
     QFETCH(QUrl, qmlfile);
     QFETCH(QString, error);
 
-    TestHTTPServer server(14453);
+    TestHTTPServer server(SERVER_PORT);
     server.serveDirectory(testFile("http"));
 
     if (!error.isEmpty())
@@ -2280,18 +2283,18 @@ void tst_qquicktext::imgTagsBaseUrl_data()
             << 181.;
 
     QTest::newRow("absolute remote")
-            << QUrl("http://127.0.0.1:14453/images/heart200.png")
+            << QUrl(SERVER_ADDR "/images/heart200.png")
             << QUrl()
             << QUrl()
             << 181.;
     QTest::newRow("relative remote base 1")
             << QUrl("images/heart200.png")
-            << QUrl("http://127.0.0.1:14453/")
+            << QUrl(SERVER_ADDR "/")
             << testFileUrl("nonexistant/app.qml")
             << 181.;
     QTest::newRow("relative remote base 2")
             << QUrl("heart200.png")
-            << QUrl("http://127.0.0.1:14453/images/")
+            << QUrl(SERVER_ADDR "/images/")
             << testFileUrl("nonexistant/app.qml")
             << 181.;
 }
@@ -2303,7 +2306,7 @@ void tst_qquicktext::imgTagsBaseUrl()
     QFETCH(QUrl, contextUrl);
     QFETCH(qreal, imgHeight);
 
-    TestHTTPServer server(14453);
+    TestHTTPServer server(SERVER_PORT);
     server.serveDirectory(testFile(""));
 
     QByteArray baseUrlFragment;