Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativexmlhttprequest / tst_qdeclarativexmlhttprequest.cpp
index 51b23c7..f3c3b57 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the test suite of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 #include <QDeclarativeEngine>
 #include <QDeclarativeComponent>
 #include <QDebug>
+#include <QScopedPointer>
 #include <QNetworkCookieJar>
 #include "testhttpserver.h"
-#include "../../../shared/util.h"
+#include "../../shared/util.h"
 
 #define SERVER_PORT 14445
 
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
-class tst_qdeclarativexmlhttprequest : public QObject
+class tst_qdeclarativexmlhttprequest : public QDeclarativeDataTest
 {
     Q_OBJECT
 public:
@@ -125,15 +121,10 @@ private:
     QDeclarativeEngine engine;
 };
 
-inline QUrl TEST_FILE(const QString &filename)
-{
-    return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + 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);
 
@@ -175,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");
@@ -194,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);
 
@@ -210,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);
 
@@ -226,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);
 
@@ -239,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,13 +250,13 @@ void tst_qdeclarativexmlhttprequest::open()
     QFETCH(QString, url);
     QFETCH(bool, remote);
 
-    TestHTTPServer *server = 0;
+    QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
     if (remote) {
-        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"), 
-                             TEST_FILE("testdocument.html")));
+        QVERIFY(server->wait(testFileUrl("open_network.expect"),
+                             testFileUrl("open_network.reply"),
+                             testFileUrl("testdocument.html")));
     }
 
     QDeclarativeComponent component(&engine, qmlFile);
@@ -283,7 +274,6 @@ void tst_qdeclarativexmlhttprequest::open()
 
     QTRY_VERIFY(object->property("dataOK").toBool() == true);
 
-    delete server;
     delete object;
 }
 
@@ -293,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);
 
@@ -316,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);
 
@@ -329,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);
 
@@ -339,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);
 
@@ -354,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");
@@ -374,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");
@@ -391,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);
 
@@ -435,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");
@@ -463,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");
@@ -483,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);
 
@@ -495,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);
 
@@ -507,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);
 
@@ -523,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");
@@ -542,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");
@@ -561,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");
@@ -586,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");
@@ -618,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");
@@ -639,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");
@@ -662,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");
@@ -688,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");
@@ -724,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);
 
@@ -736,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);
 
@@ -748,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);
 
@@ -763,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");
@@ -792,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);
 
@@ -804,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);
 
@@ -816,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);
 
@@ -832,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");
@@ -861,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()
@@ -873,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");
@@ -902,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()
@@ -915,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");
@@ -945,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()
@@ -957,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);
 
@@ -996,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);
 
@@ -1023,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(SRCDIR "/data");
+        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");
@@ -1042,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(SRCDIR "/data");
+        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");
@@ -1061,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(SRCDIR "/data");
+        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");
@@ -1084,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);
 
@@ -1098,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);
 
@@ -1112,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);
 
@@ -1126,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);
 
@@ -1140,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);
 
@@ -1154,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);