aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-28 10:57:34 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-28 14:29:59 +0200
commit94db5de2acefb6e96d4f6cfda2df14905a5e63c5 (patch)
treec361f5dd4989ee0743e2a9f94b64dbb2127e5dea /tests/auto/qml/qqmlxmlhttprequest
parent11f67b80c4eab4b1e3eb8e6b1e8b69e7a60e42a9 (diff)
parentdee67b41b031791c7b6313e935e622ef8d594686 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I075e742da8396a268d97d3ab34bcd9e0c0cf001f
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest')
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml3
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.expect2
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp121
19 files changed, 87 insertions, 71 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml
index c4ecbd8912..a631daf9e3 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml
@@ -17,7 +17,7 @@ Item {
var o = Qt.createQmlObject(seqComponent,root);
}
}
- doc.open("GET", "http://127.0.0.1:14445/TestComponent3.qml");
+ doc.open("GET", serverBaseUrl + "/TestComponent3.qml");
doc.send();
}
}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
index d6951a8255..7e1edeb2a3 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
@@ -5,6 +5,6 @@ Content-Length: 9
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
Test Data \ No newline at end of file
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
index cf5830ed0c..bc40e5ea0f 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
index cf5830ed0c..bc40e5ea0f 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect
index 79a61383e3..112ac4e207 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_binary_data.expect
@@ -4,4 +4,4 @@ Content-Type: image/png
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect
index 59a7806bc9..97b016f50a 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect
@@ -4,4 +4,4 @@ Content-Type: application/jsonrequest
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
index 9c07d4b633..144f0f6e98 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
@@ -5,6 +5,6 @@ Content-Length: 12
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
My Sent Data \ No newline at end of file
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect
index b099ed205e..8d83a00549 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.10.expect
@@ -5,6 +5,6 @@ Content-Length: 12
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
My Sent Data \ No newline at end of file
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
index c2aba77881..b53764fd97 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
@@ -5,6 +5,6 @@ Content-Length: 12
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
My Sent Data \ No newline at end of file
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
index b09b1bcec5..5f365b42af 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
@@ -5,6 +5,6 @@ Content-Length: 12
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
My Sent Data \ No newline at end of file
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect
index 8462c40ba1..e93c019dd5 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.8.expect
@@ -4,4 +4,4 @@ Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect
index 02af8c99b8..da38968e9a 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.9.expect
@@ -4,4 +4,4 @@ Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
index dd86b837f4..672dc60021 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
index cf5830ed0c..bc40e5ea0f 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
index 7b7b282660..2a642e4292 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
index e7f8e10780..94b3016490 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
@@ -5,5 +5,5 @@ Test-header2: value,value2
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml b/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
index b35c31d513..97feeb9324 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml
@@ -5,6 +5,7 @@ Item {
property int whichCount: 0
property bool success: false
+ property string serverBaseUrl;
SequentialAnimation {
id: anim
@@ -23,7 +24,7 @@ Item {
function updateList() {
var xhr = new XMLHttpRequest();
- xhr.open("GET","http://127.0.0.1:14445/testlist"); // list of components
+ xhr.open("GET",serverBaseUrl + "/testlist"); // list of components
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
var components = xhr.responseText.split('\n');
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.expect b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
index cf5830ed0c..bc40e5ea0f 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
@@ -3,5 +3,5 @@ Accept-Language: en-US
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
-Host: 127.0.0.1:14445
+Host: {{ServerHostUrl}}
diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
index d901c4dd14..ad78fafc67 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
+++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
@@ -38,11 +38,11 @@
#include <QScopedPointer>
#include <QNetworkCookieJar>
#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
#include "testhttpserver.h"
#include "../../shared/util.h"
-#define SERVER_PORT 14445
-
class tst_qqmlxmlhttprequest : public QQmlDataTest
{
Q_OBJECT
@@ -239,10 +239,11 @@ void tst_qqmlxmlhttprequest::open()
TestHTTPServer server;
if (remote) {
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("open_network.expect"),
testFileUrl("open_network.reply"),
testFileUrl("testdocument.html")));
+ url = server.urlString(url);
}
QQmlComponent component(&engine, qmlFile);
@@ -269,10 +270,10 @@ void tst_qqmlxmlhttprequest::open_data()
QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
- QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "/testdocument.html" << true;
// ### Check that the username/password were sent to the server
- QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "/testdocument.html" << true;
}
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
@@ -291,9 +292,11 @@ class TestThreadedHTTPServer : public QObject
public:
TestThreadedHTTPServer(const QUrl &expectUrl, const QUrl &replyUrl, const QUrl &bodyUrl)
: m_server(Q_NULLPTR) {
+ QMutexLocker locker(&m_lock);
moveToThread(&m_thread);
m_thread.start();
QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection, Q_ARG(QUrl, expectUrl), Q_ARG(QUrl, replyUrl), Q_ARG(QUrl, bodyUrl));
+ m_startupCondition.wait(&m_lock);
}
~TestThreadedHTTPServer() {
m_server->deleteLater();
@@ -301,16 +304,23 @@ public:
m_thread.wait();
}
+ QUrl serverBaseUrl;
+
private slots:
void start(const QUrl &expectUrl, const QUrl &replyUrl, const QUrl &bodyUrl) {
+ QMutexLocker locker(&m_lock);
m_server = new TestHTTPServer;
- QVERIFY2(m_server->listen(SERVER_PORT), qPrintable(m_server->errorString()));
+ QVERIFY2(m_server->listen(), qPrintable(m_server->errorString()));
+ serverBaseUrl = m_server->baseUrl();
QVERIFY(m_server->wait(expectUrl, replyUrl, bodyUrl));
+ m_startupCondition.wakeAll();
}
private:
TestHTTPServer *m_server;
QThread m_thread;
+ QMutex m_lock;
+ QWaitCondition m_startupCondition;
};
// Test that calling XMLHttpRequest.open() with sync
@@ -321,7 +331,7 @@ void tst_qqmlxmlhttprequest::open_sync()
QQmlComponent component(&engine, testFileUrl("open_sync.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.serverBaseUrl.resolved(QStringLiteral("/testdocument.html")).toString());
component.completeCreate();
QCOMPARE(object->property("responseText").toString(), QStringLiteral("QML Rocks!\n"));
@@ -351,7 +361,7 @@ void tst_qqmlxmlhttprequest::open_arg_count()
void tst_qqmlxmlhttprequest::setRequestHeader()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
testFileUrl("setRequestHeader.reply"),
testFileUrl("testdocument.html")));
@@ -359,7 +369,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader()
QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -369,7 +379,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader()
void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
testFileUrl("setRequestHeader.reply"),
testFileUrl("testdocument.html")));
@@ -377,7 +387,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -426,7 +436,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
QFETCH(QString, name);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("open_network.expect"),
testFileUrl("open_network.reply"),
testFileUrl("testdocument.html")));
@@ -434,7 +444,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
object->setProperty("header", name);
component.completeCreate();
@@ -452,7 +462,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
void tst_qqmlxmlhttprequest::setRequestHeader_sent()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("open_network.expect"),
testFileUrl("open_network.reply"),
testFileUrl("testdocument.html")));
@@ -460,7 +470,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_sent()
QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QCOMPARE(object->property("test").toBool(), true);
@@ -504,7 +514,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
{
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
testFileUrl("send_ignoreData.reply"),
testFileUrl("testdocument.html")));
@@ -513,7 +523,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
object->setProperty("reqType", "GET");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -521,7 +531,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
testFileUrl("send_ignoreData.reply"),
QUrl()));
@@ -530,7 +540,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
object->setProperty("reqType", "HEAD");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -538,7 +548,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
testFileUrl("send_ignoreData.reply"),
QUrl()));
@@ -547,7 +557,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData()
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
object->setProperty("reqType", "DELETE");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -561,7 +571,7 @@ void tst_qqmlxmlhttprequest::send_withdata()
QFETCH(QString, file_qml);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl(file_expected),
testFileUrl("send_data.reply"),
testFileUrl("testdocument.html")));
@@ -569,7 +579,7 @@ void tst_qqmlxmlhttprequest::send_withdata()
QQmlComponent component(&engine, testFileUrl(file_qml));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QTRY_VERIFY(object->property("dataOK").toBool() == true);
@@ -597,7 +607,7 @@ void tst_qqmlxmlhttprequest::send_options()
QFETCH(QString, file_reply);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl(file_expected),
testFileUrl(file_reply),
testFileUrl("testdocument.html")));
@@ -605,7 +615,7 @@ void tst_qqmlxmlhttprequest::send_options()
QQmlComponent component(&engine, testFileUrl(file_qml));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- QString url = "http://127.0.0.1:14445";
+ QString url = server.baseUrl().toString();
if (url_suffix != "/")
url.append("/");
if (!url_suffix.isEmpty())
@@ -672,7 +682,7 @@ void tst_qqmlxmlhttprequest::abort_opened()
void tst_qqmlxmlhttprequest::abort()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("abort.expect"),
testFileUrl("abort.reply"),
testFileUrl("testdocument.html")));
@@ -680,8 +690,11 @@ void tst_qqmlxmlhttprequest::abort()
QQmlComponent component(&engine, testFileUrl("abort.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ const QUrl url = server.url("/testdocument.html");
+ QUrl dummyUrl = url;
+ dummyUrl.setPort(dummyUrl.port() - 1);
+ object->setProperty("urlDummy", dummyUrl.toString());
+ object->setProperty("url", url.toString());
component.completeCreate();
QCOMPARE(object->property("seenDone").toBool(), true);
@@ -696,7 +709,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader()
QQmlEngine engine; // Avoid cookie contamination
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
testFileUrl("getResponseHeader.reply"),
testFileUrl("testdocument.html")));
@@ -705,7 +718,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader()
QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QCOMPARE(object->property("unsentException").toBool(), true);
@@ -763,7 +776,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders()
QQmlEngine engine; // Avoid cookie contamination
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
testFileUrl("getResponseHeader.reply"),
testFileUrl("testdocument.html")));
@@ -771,7 +784,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders()
QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
component.completeCreate();
QCOMPARE(object->property("unsentException").toBool(), true);
@@ -821,7 +834,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders_args()
void tst_qqmlxmlhttprequest::getBinaryData()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("receive_binary_data.expect"),
testFileUrl("receive_binary_data.reply"),
testFileUrl("qml_logo.png")));
@@ -829,7 +842,7 @@ void tst_qqmlxmlhttprequest::getBinaryData()
QQmlComponent component(&engine, testFileUrl("receiveBinaryData.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/gml_logo.png");
+ object->setProperty("url", server.urlString("/gml_logo.png"));
component.completeCreate();
QFileInfo fileInfo("data/qml_logo.png");
@@ -839,7 +852,7 @@ void tst_qqmlxmlhttprequest::getBinaryData()
void tst_qqmlxmlhttprequest::getJsonData()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("receive_json_data.expect"),
testFileUrl("receive_binary_data.reply"),
testFileUrl("json.data")));
@@ -847,7 +860,7 @@ void tst_qqmlxmlhttprequest::getJsonData()
QQmlComponent component(&engine, testFileUrl("receiveJsonData.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/json.data");
+ object->setProperty("url", server.urlString("/json.data"));
component.completeCreate();
QTRY_VERIFY(object->property("result").toBool());
@@ -859,7 +872,7 @@ void tst_qqmlxmlhttprequest::status()
QFETCH(int, status);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
testFileUrl("testdocument.html")));
@@ -867,7 +880,7 @@ void tst_qqmlxmlhttprequest::status()
QQmlComponent component(&engine, testFileUrl("status.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
object->setProperty("expectedStatus", status);
component.completeCreate();
@@ -898,7 +911,7 @@ void tst_qqmlxmlhttprequest::statusText()
QFETCH(QString, statusText);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
testFileUrl("testdocument.html")));
@@ -906,7 +919,7 @@ void tst_qqmlxmlhttprequest::statusText()
QQmlComponent component(&engine, testFileUrl("statusText.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
object->setProperty("expectedStatus", statusText);
component.completeCreate();
@@ -938,7 +951,7 @@ void tst_qqmlxmlhttprequest::responseText()
QFETCH(QString, responseText);
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
bodyUrl));
@@ -946,7 +959,7 @@ void tst_qqmlxmlhttprequest::responseText()
QQmlComponent component(&engine, testFileUrl("responseText.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("url", server.urlString("/testdocument.html"));
object->setProperty("expectedText", responseText);
component.completeCreate();
@@ -1039,14 +1052,14 @@ void tst_qqmlxmlhttprequest::redirects()
{
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ server.addRedirect("redirect.html", server.urlString("/redirecttarget.html"));
server.serveDirectory(dataDirectory());
QQmlComponent component(&engine, testFileUrl("redirects.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("url", server.urlString("/redirect.html"));
object->setProperty("expectedText", "");
component.completeCreate();
@@ -1056,14 +1069,14 @@ void tst_qqmlxmlhttprequest::redirects()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ server.addRedirect("redirect.html", server.urlString("/redirectmissing.html"));
server.serveDirectory(dataDirectory());
QQmlComponent component(&engine, testFileUrl("redirectError.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("url", server.urlString("/redirect.html"));
object->setProperty("expectedText", "");
component.completeCreate();
@@ -1073,14 +1086,14 @@ void tst_qqmlxmlhttprequest::redirects()
{
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ server.addRedirect("redirect.html", server.urlString("/redirect.html"));
server.serveDirectory(dataDirectory());
QQmlComponent component(&engine, testFileUrl("redirectRecur.qml"));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("url", server.urlString("/redirect.html"));
object->setProperty("expectedText", "");
component.completeCreate();
@@ -1175,12 +1188,14 @@ void tst_qqmlxmlhttprequest::stateChangeCallingContext()
// without a valid calling context.
TestHTTPServer server;
- QVERIFY2(server.listen(SERVER_PORT), qPrintable(server.errorString()));
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
QQmlComponent component(&engine, testFileUrl("stateChangeCallingContext.qml"));
- QScopedPointer<QObject> object(component.create());
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
QVERIFY(!object.isNull());
+ object->setProperty("serverBaseUrl", server.baseUrl().toString());
+ component.completeCreate();
server.sendDelayedItem();
QTRY_VERIFY(object->property("success").toBool() == true);
}