aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-21 09:06:26 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-21 15:35:22 +0100
commit8249c72213bc7d212c05aa086b3145a5742706a3 (patch)
tree4a34b97b0d57a05707c65b7328d5ab1bf4254920 /tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
parent3c211558f6b571555558bd1fc59774e36a6da710 (diff)
QDeclarative tests: Introduce base class for data tests.
In tests/auto/shared/util.* replace macros/find functions by a base class QDeclarativeDataTest with accessors for the data directory helper functions to create URLs from it. The class relies on QFINDTESTDATA, which is the standard way of locating test data. Using the class should reduce the number of calls to QFileInfo.exists(), etc significantly. In addition, provide utility functions for messages. Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Change-Id: Id2beacb157922ee9412f9e45cf9695cec1f8379a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp215
1 files changed, 105 insertions, 110 deletions
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
index abefa30108..d93285eef7 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -50,7 +50,7 @@
#define SERVER_PORT 14445
-class tst_qdeclarativexmlhttprequest : public QObject
+class tst_qdeclarativexmlhttprequest : public QDeclarativeDataTest
{
Q_OBJECT
public:
@@ -121,15 +121,10 @@ private:
QDeclarativeEngine engine;
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
// Test that the dom exception codes are correct
void tst_qdeclarativexmlhttprequest::domExceptionCodes()
{
- QDeclarativeComponent component(&engine, TEST_FILE("domExceptionCodes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -171,10 +166,10 @@ void tst_qdeclarativexmlhttprequest::callbackException()
QFETCH(QString, which);
QFETCH(int, line);
- QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QDeclarativeComponent component(&engine, TEST_FILE("callbackException.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("callbackException.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
@@ -190,7 +185,7 @@ void tst_qdeclarativexmlhttprequest::callbackException()
// ### WebKit does not do this, but it seems to fit the standard and QML better
void tst_qdeclarativexmlhttprequest::staticStateValues()
{
- QDeclarativeComponent component(&engine, TEST_FILE("staticStateValues.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("staticStateValues.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -206,7 +201,7 @@ void tst_qdeclarativexmlhttprequest::staticStateValues()
// Test that the state value properties on instances have the correct values.
void tst_qdeclarativexmlhttprequest::instanceStateValues()
{
- QDeclarativeComponent component(&engine, TEST_FILE("instanceStateValues.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("instanceStateValues.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -222,7 +217,7 @@ void tst_qdeclarativexmlhttprequest::instanceStateValues()
// Test calling constructor
void tst_qdeclarativexmlhttprequest::constructor()
{
- QDeclarativeComponent component(&engine, TEST_FILE("constructor.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constructor.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -235,7 +230,7 @@ void tst_qdeclarativexmlhttprequest::constructor()
// Test that all the properties are set correctly before any request is sent
void tst_qdeclarativexmlhttprequest::defaultState()
{
- QDeclarativeComponent component(&engine, TEST_FILE("defaultState.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("defaultState.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -259,9 +254,9 @@ void tst_qdeclarativexmlhttprequest::open()
if (remote) {
server.reset(new TestHTTPServer(SERVER_PORT));
QVERIFY(server->isValid());
- QVERIFY(server->wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server->wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
}
QDeclarativeComponent component(&engine, qmlFile);
@@ -288,18 +283,18 @@ void tst_qdeclarativexmlhttprequest::open_data()
QTest::addColumn<QString>("url");
QTest::addColumn<bool>("remote");
- QTest::newRow("Relative url)") << TEST_FILE("open.qml") << "testdocument.html" << false;
- QTest::newRow("Absolute url)") << TEST_FILE("open.qml") << TEST_FILE("testdocument.html").toString() << false;
- QTest::newRow("Absolute network url)") << TEST_FILE("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ 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;
// ### Check that the username/password were sent to the server
- QTest::newRow("User/pass") << TEST_FILE("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
}
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
void tst_qdeclarativexmlhttprequest::open_invalid_method()
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_invalid_method.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_invalid_method.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -311,7 +306,7 @@ void tst_qdeclarativexmlhttprequest::open_invalid_method()
// Test that calling XMLHttpRequest.open() with sync raises an exception
void tst_qdeclarativexmlhttprequest::open_sync()
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_sync.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_sync.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -324,7 +319,7 @@ void tst_qdeclarativexmlhttprequest::open_sync()
void tst_qdeclarativexmlhttprequest::open_arg_count()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -334,7 +329,7 @@ void tst_qdeclarativexmlhttprequest::open_arg_count()
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -349,11 +344,11 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -369,11 +364,11 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_caseInsensitive()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_caseInsensitive.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -386,7 +381,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_caseInsensitive()
// Test setting headers before open() throws exception
void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -430,11 +425,11 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_illegalName.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -458,11 +453,11 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -478,7 +473,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -490,7 +485,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
// Test that calling send() in UNSENT state throws an exception
void tst_qdeclarativexmlhttprequest::send_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("send_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -502,7 +497,7 @@ void tst_qdeclarativexmlhttprequest::send_unsent()
// Test attempting to resend a sent request throws an exception
void tst_qdeclarativexmlhttprequest::send_alreadySent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_alreadySent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -518,11 +513,11 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "GET");
@@ -537,11 +532,11 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_HEAD.expect"),
- TEST_FILE("send_ignoreData.reply"),
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
+ testFileUrl("send_ignoreData.reply"),
QUrl()));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "HEAD");
@@ -556,11 +551,11 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_DELETE.expect"),
- TEST_FILE("send_ignoreData.reply"),
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
+ testFileUrl("send_ignoreData.reply"),
QUrl()));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "DELETE");
@@ -581,11 +576,11 @@ void tst_qdeclarativexmlhttprequest::send_withdata()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE(file_expected),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl(file_expected),
+ testFileUrl("send_data.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE(file_qml));
+ QDeclarativeComponent component(&engine, testFileUrl(file_qml));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -613,7 +608,7 @@ void tst_qdeclarativexmlhttprequest::send_withdata_data()
// Test abort() has no effect in unsent state
void tst_qdeclarativexmlhttprequest::abort_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("abort_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort_unsent.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
@@ -634,7 +629,7 @@ void tst_qdeclarativexmlhttprequest::abort_unsent()
// Test abort() cancels an open (but unsent) request
void tst_qdeclarativexmlhttprequest::abort_opened()
{
- QDeclarativeComponent component(&engine, TEST_FILE("abort_opened.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort_opened.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
@@ -657,11 +652,11 @@ void tst_qdeclarativexmlhttprequest::abort()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("abort.expect"),
- TEST_FILE("abort.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("abort.expect"),
+ testFileUrl("abort.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("abort.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
@@ -683,12 +678,12 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -719,7 +714,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader()
// Test getResponseHeader throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -731,7 +726,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
// Test getResponseHeader throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -743,7 +738,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -758,11 +753,11 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -787,7 +782,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
// Test getAllResponseHeaders throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -799,7 +794,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
// Test getAllResponseHeaders throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -811,7 +806,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -827,11 +822,11 @@ void tst_qdeclarativexmlhttprequest::status()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
- TEST_FILE("testdocument.html")));
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("status.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -856,9 +851,9 @@ void tst_qdeclarativexmlhttprequest::status_data()
QTest::addColumn<QUrl>("replyUrl");
QTest::addColumn<int>("status");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << 200;
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << 404;
- QTest::newRow("Bad Request") << TEST_FILE("status.400.reply") << 400;
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
}
void tst_qdeclarativexmlhttprequest::statusText()
@@ -868,11 +863,11 @@ void tst_qdeclarativexmlhttprequest::statusText()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
- TEST_FILE("testdocument.html")));
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("statusText.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -897,9 +892,9 @@ void tst_qdeclarativexmlhttprequest::statusText_data()
QTest::addColumn<QUrl>("replyUrl");
QTest::addColumn<QString>("statusText");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << "OK";
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << "Document not found";
- QTest::newRow("Bad Request") << TEST_FILE("status.400.reply") << "Bad request";
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
}
void tst_qdeclarativexmlhttprequest::responseText()
@@ -910,11 +905,11 @@ void tst_qdeclarativexmlhttprequest::responseText()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
bodyUrl));
- QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("responseText.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
@@ -940,10 +935,10 @@ void tst_qdeclarativexmlhttprequest::responseText_data()
QTest::addColumn<QUrl>("bodyUrl");
QTest::addColumn<QString>("responseText");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << TEST_FILE("testdocument.html") << "QML Rocks!\n";
- QTest::newRow("empty body") << TEST_FILE("status.200.reply") << QUrl() << "";
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << "";
- QTest::newRow("Bad Request") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << "";
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
+ QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+ QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
}
void tst_qdeclarativexmlhttprequest::nonUtf8()
@@ -952,7 +947,7 @@ void tst_qdeclarativexmlhttprequest::nonUtf8()
QFETCH(QString, responseText);
QFETCH(QString, xmlRootNodeValue);
- QDeclarativeComponent component(&engine, TEST_FILE("utf16.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("utf16.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -991,7 +986,7 @@ void tst_qdeclarativexmlhttprequest::nonUtf8_data()
// throws an exception
void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
{
- QDeclarativeComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1018,9 +1013,9 @@ void tst_qdeclarativexmlhttprequest::redirects()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirects.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirects.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
@@ -1037,9 +1032,9 @@ void tst_qdeclarativexmlhttprequest::redirects()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirectError.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirectError.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
@@ -1056,9 +1051,9 @@ void tst_qdeclarativexmlhttprequest::redirects()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirectRecur.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirectRecur.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
@@ -1079,7 +1074,7 @@ void tst_qdeclarativexmlhttprequest::redirects()
void tst_qdeclarativexmlhttprequest::responseXML_invalid()
{
- QDeclarativeComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1093,7 +1088,7 @@ void tst_qdeclarativexmlhttprequest::responseXML_invalid()
// Test the Document DOM element
void tst_qdeclarativexmlhttprequest::document()
{
- QDeclarativeComponent component(&engine, TEST_FILE("document.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("document.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1107,7 +1102,7 @@ void tst_qdeclarativexmlhttprequest::document()
// Test the Element DOM element
void tst_qdeclarativexmlhttprequest::element()
{
- QDeclarativeComponent component(&engine, TEST_FILE("element.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("element.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1121,7 +1116,7 @@ void tst_qdeclarativexmlhttprequest::element()
// Test the Attr DOM element
void tst_qdeclarativexmlhttprequest::attr()
{
- QDeclarativeComponent component(&engine, TEST_FILE("attr.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attr.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1135,7 +1130,7 @@ void tst_qdeclarativexmlhttprequest::attr()
// Test the Text DOM element
void tst_qdeclarativexmlhttprequest::text()
{
- QDeclarativeComponent component(&engine, TEST_FILE("text.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("text.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -1149,7 +1144,7 @@ void tst_qdeclarativexmlhttprequest::text()
// Test the CDataSection DOM element
void tst_qdeclarativexmlhttprequest::cdata()
{
- QDeclarativeComponent component(&engine, TEST_FILE("cdata.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("cdata.qml"));
QObject *object = component.create();
QVERIFY(object != 0);