/****************************************************************************
**
-** 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.
**
**
**
**
+**
** $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:
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);
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");
// ### 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);
// 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);
// 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);
// 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);
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);
QTRY_VERIFY(object->property("dataOK").toBool() == true);
- delete server;
delete object;
}
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);
// 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);
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);
}
{
- 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);
{
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");
{
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");
// 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);
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");
{
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");
// 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);
// 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);
// 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);
{
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");
{
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");
{
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");
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");
// 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");
// 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");
{
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");
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");
// 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);
// 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);
// 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);
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");
// 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);
// 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);
// 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);
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");
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()
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");
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()
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");
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()
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);
// 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);
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");
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");
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");
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);
// 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);
// 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);
// 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);
// 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);
// 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);