From b05039d5efcaec69d01d3737ccb5f0199765632b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 Feb 2012 12:42:12 +0100 Subject: Add QDeclarativeDataTest base class to locate test data. - Remove TEST_FILE and TEST_DATA macros in favour of base class that uses QFINDTESTDATA to locate the data. This avoids repeated searching and handles Windows correctly (executables in release/debug subfolders). - Modeled after an existing class in the QtQuick2 tests (see qtdeclarative\tests\auto\shared\util.*). Change-Id: I9e595953328fb552648cef4c7f712d9000f53832 Reviewed-by: Matthew Vogt --- .../qdeclarativeanchors/qdeclarativeanchors.pro | 8 +- .../tst_qdeclarativeanchors.cpp | 36 ++- .../qdeclarativeanimatedimage.pro | 8 +- .../tst_qdeclarativeanimatedimage.cpp | 35 +-- .../tst_qdeclarativedebugjs.cpp | 178 ++++++++----- .../tst_qdeclarativedebugjs.pro | 10 +- .../qdeclarativeecmascript.pro | 8 +- .../tst_qdeclarativeecmascript.cpp | 292 ++++++++++----------- .../qdeclarativeinfo/qdeclarativeinfo.pro | 8 +- .../qdeclarativeinfo/tst_qdeclarativeinfo.cpp | 14 +- .../qdeclarativelanguage/qdeclarativelanguage.pro | 9 +- .../tst_qdeclarativelanguage.cpp | 183 ++++++------- .../qdeclarativelistreference.pro | 2 + .../tst_qdeclarativelistreference.cpp | 19 +- .../qdeclarativeloader/qdeclarativeloader.pro | 9 +- .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 90 +++---- .../tst_qdeclarativemoduleplugin.cpp | 56 ++-- .../tst_qdeclarativemoduleplugin.pro | 8 +- .../qdeclarativeproperty/qdeclarativeproperty.pro | 8 +- .../tst_qdeclarativeproperty.cpp | 25 +- .../declarative/qdeclarativeqt/qdeclarativeqt.pro | 8 +- .../qdeclarativeqt/tst_qdeclarativeqt.cpp | 71 +++-- .../qdeclarativerepeater/qdeclarativerepeater.pro | 8 +- .../tst_qdeclarativerepeater.cpp | 33 +-- .../qdeclarativevaluetypes.pro | 8 +- .../tst_qdeclarativevaluetypes.cpp | 138 +++++----- .../qdeclarativeworkerscript.pro | 8 +- .../tst_qdeclarativeworkerscript.cpp | 37 +-- .../qdeclarativexmlhttprequest.pro | 9 +- .../tst_qdeclarativexmlhttprequest.cpp | 201 +++++++------- .../declarative/qmlshadersplugin/data/main.qml | 80 ++++++ tests/auto/declarative/qmlshadersplugin/main.qml | 80 ------ .../qmlshadersplugin/qmlshadersplugin.pro | 2 + .../qmlshadersplugin/tst_qmlshadersplugin.cpp | 13 +- .../declarative/shared/qdeclarativedatatest.cpp | 109 ++++++++ .../auto/declarative/shared/qdeclarativedatatest.h | 90 +++++++ .../declarative/shared/qdeclarativedatatest.pri | 6 + 37 files changed, 984 insertions(+), 923 deletions(-) create mode 100644 tests/auto/declarative/qmlshadersplugin/data/main.qml delete mode 100644 tests/auto/declarative/qmlshadersplugin/main.qml create mode 100644 tests/auto/declarative/shared/qdeclarativedatatest.cpp create mode 100644 tests/auto/declarative/shared/qdeclarativedatatest.h create mode 100644 tests/auto/declarative/shared/qdeclarativedatatest.pri (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index e5299217..07bbb94d 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -6,13 +6,7 @@ contains(QT_CONFIG,quick1): QT += quick1 quick1-private widgets widgets-private SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 99b973d5..1267563f 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -50,15 +51,10 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor) Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine) -class tst_qdeclarativeanchors : public QObject +class tst_qdeclarativeanchors : public QDeclarativeDataTest { Q_OBJECT public: @@ -132,7 +128,7 @@ QGraphicsObject *findObject(QGraphicsObject *parent, const QString &objectName) void tst_qdeclarativeanchors::basicAnchors() { QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); + view->setSource(testFile("anchors.qml")); qApp->processEvents(); @@ -199,7 +195,7 @@ void tst_qdeclarativeanchors::basicAnchors() void tst_qdeclarativeanchors::basicAnchorsQGraphicsWidget() { QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchorsqgraphicswidget.qml")); + view->setSource(testFileUrl("anchorsqgraphicswidget.qml")); qApp->processEvents(); @@ -284,7 +280,7 @@ void mirrorAnchors(QDeclarativeItem *item) { void tst_qdeclarativeanchors::basicAnchorsRTL() { QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); + view->setSource(testFileUrl("anchors.qml")); qApp->processEvents(); @@ -366,7 +362,7 @@ void tst_qdeclarativeanchors::basicAnchorsRTL() void tst_qdeclarativeanchors::loops() { { - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); + QUrl source(testFileUrl("loop1.qml")); QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -381,7 +377,7 @@ void tst_qdeclarativeanchors::loops() } { - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); + QUrl source(testFileUrl("loop2.qml")); QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -568,7 +564,7 @@ void tst_qdeclarativeanchors::nullItem_data() void tst_qdeclarativeanchors::crash1() { - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); + QUrl source(testFileUrl("crash1.qml")); QString expect = source.toString() + ":4:5: QML Text: Possible anchor loop detected on fill."; @@ -591,7 +587,7 @@ void tst_qdeclarativeanchors::crash1() void tst_qdeclarativeanchors::fill() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("fill.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); @@ -615,7 +611,7 @@ void tst_qdeclarativeanchors::fill() void tst_qdeclarativeanchors::fillRTL() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("fill.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); @@ -640,7 +636,7 @@ void tst_qdeclarativeanchors::fillRTL() } void tst_qdeclarativeanchors::centerIn() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("centerin.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); @@ -660,7 +656,7 @@ void tst_qdeclarativeanchors::centerIn() void tst_qdeclarativeanchors::centerInRTL() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("centerin.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); @@ -680,7 +676,7 @@ void tst_qdeclarativeanchors::centerInRTL() void tst_qdeclarativeanchors::hvCenter() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("hvCenter.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); @@ -700,7 +696,7 @@ void tst_qdeclarativeanchors::hvCenter() void tst_qdeclarativeanchors::hvCenterRTL() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("hvCenter.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); @@ -720,7 +716,7 @@ void tst_qdeclarativeanchors::hvCenterRTL() } void tst_qdeclarativeanchors::margins() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("margins.qml")); qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); @@ -743,7 +739,7 @@ void tst_qdeclarativeanchors::margins() void tst_qdeclarativeanchors::marginsRTL() { - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + QDeclarativeView *view = new QDeclarativeView(testFileUrl("margins.qml")); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 4f4d4975..dac21171 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -7,13 +7,7 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp macx:CONFIG -= app_bundle -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index e0291562..75f5f6ce 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -55,7 +56,7 @@ #define SRCDIR "." #endif -class tst_qdeclarativeanimatedimage : public QObject +class tst_qdeclarativeanimatedimage : public QDeclarativeDataTest { Q_OBJECT public: @@ -94,7 +95,7 @@ QPixmap tst_qdeclarativeanimatedimage::grabScene(QGraphicsScene *scene, int widt void tst_qdeclarativeanimatedimage::play() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickman.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -105,7 +106,7 @@ void tst_qdeclarativeanimatedimage::play() void tst_qdeclarativeanimatedimage::pause() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -117,7 +118,7 @@ void tst_qdeclarativeanimatedimage::pause() void tst_qdeclarativeanimatedimage::stopped() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(!anim->isPlaying()); @@ -129,7 +130,7 @@ void tst_qdeclarativeanimatedimage::stopped() void tst_qdeclarativeanimatedimage::setFrame() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -141,7 +142,7 @@ void tst_qdeclarativeanimatedimage::setFrame() void tst_qdeclarativeanimatedimage::frameCount() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("colors.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -155,7 +156,7 @@ void tst_qdeclarativeanimatedimage::mirror_running() // test where mirror is set to true after animation has started QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/hearts.qml")); + QDeclarativeComponent component(&engine, testFileUrl("hearts.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); @@ -234,8 +235,8 @@ void tst_qdeclarativeanimatedimage::mirror_notRunning_data() { QTest::addColumn("fileUrl"); - QTest::newRow("paused") << QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"); - QTest::newRow("stopped") << QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"); + QTest::newRow("paused") << testFileUrl("stickmanpause.qml"); + QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml"); } void tst_qdeclarativeanimatedimage::remote() @@ -245,7 +246,7 @@ void tst_qdeclarativeanimatedimage::remote() TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); @@ -267,7 +268,7 @@ void tst_qdeclarativeanimatedimage::remote() void tst_qdeclarativeanimatedimage::sourceSize() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml")); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QCOMPARE(anim->width(),240.0); @@ -280,7 +281,7 @@ void tst_qdeclarativeanimatedimage::sourceSize() void tst_qdeclarativeanimatedimage::sourceSizeReadOnly() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("stickmanerror1.qml")); QVERIFY(component.isError()); QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); } @@ -317,10 +318,10 @@ void tst_qdeclarativeanimatedimage::qtbug_16520() { TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug-16520.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml")); QTRY_VERIFY(component.isReady()); QDeclarativeRectangle *root = qobject_cast(component.create()); @@ -339,12 +340,12 @@ void tst_qdeclarativeanimatedimage::progressAndStatusChanges() { TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif")); + ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast(component.create()); @@ -357,7 +358,7 @@ void tst_qdeclarativeanimatedimage::progressAndStatusChanges() QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarativeImageBase::Status))); // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif")); + ctxt->setContextProperty("srcImage", testFileUrl("colors.gif")); QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 1); diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index 4982ca3f..3929b9e5 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -55,6 +56,7 @@ class QJSDebugClient : public QDeclarativeDebugClient public: QJSDebugClient(QDeclarativeDebugConnection *connection) : QDeclarativeDebugClient(QLatin1String("JSDebugger"), connection) {} + void initTestCase(); void ping(); void exec(const QByteArray &debuggerId, const QString &expr); void setBreakpoints(const QSet &breakpoints); @@ -115,7 +117,7 @@ public: QJSDebugProcess(); ~QJSDebugProcess(); - void start(const QStringList &arguments); + void start(const QString &binary, const QStringList &arguments); bool waitForStarted(); private slots: @@ -128,7 +130,7 @@ private: bool m_started; }; -class tst_QDeclarativeDebugJS : public QObject +class tst_QDeclarativeDebugJS : public QDeclarativeDataTest { Q_OBJECT private: @@ -137,6 +139,7 @@ private: QJSDebugClient *m_client; private slots: + void initTestCase(); void pingPong(); void exec(); void setBreakpoint(); @@ -164,9 +167,10 @@ private slots: void testCoverageCompleted(); void testCoverageRun(); +private: + QString m_binary; }; - void QJSDebugClient::ping() { m_ping++; @@ -398,10 +402,11 @@ QJSDebugProcess::~QJSDebugProcess() } } -void QJSDebugProcess::start(const QStringList &arguments) +void QJSDebugProcess::start(const QString &binary, const QStringList &arguments) { - QString currentDir = QFileInfo(__FILE__).absoluteDir().absolutePath(); - m_process.start(currentDir + "/app/app", arguments); + m_process.start(binary, arguments); + QVERIFY2(m_process.waitForStarted(), + qPrintable(QString::fromLatin1("Unable to launch %1: %2").arg(binary, m_process.errorString()))); m_timer.start(); } @@ -436,16 +441,24 @@ void QJSDebugProcess::processAppOutput() } } -inline QString TEST_FILE(const QString &filename) +void tst_QDeclarativeDebugJS::initTestCase() { - QFileInfo fileInfo(__FILE__); - return fileInfo.absoluteDir().filePath("data/" + filename); + QDeclarativeDataTest::initTestCase(); + const QString appFolder = QFINDTESTDATA("app"); + QVERIFY2(!appFolder.isEmpty(), qPrintable(QString::fromLatin1("Unable to locate app folder from %1").arg(QDir::currentPath()))); + m_binary = appFolder + QStringLiteral("/app"); +#ifdef Q_OS_WIN + m_binary += QStringLiteral(".exe"); +#endif // Q_OS_WIN + const QFileInfo fi(m_binary); + QVERIFY2(fi.isExecutable(), qPrintable(QString::fromLatin1("%1 is not executable.").arg(m_binary))); } void tst_QDeclarativeDebugJS::pingPong() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771" + << QDeclarativeDataTest::instance()->testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -463,7 +476,8 @@ void tst_QDeclarativeDebugJS::pingPong() void tst_QDeclarativeDebugJS::exec() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771" + << QDeclarativeDataTest::instance()->testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -491,7 +505,8 @@ void tst_QDeclarativeDebugJS::exec() void tst_QDeclarativeDebugJS::setBreakpoint() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << QDeclarativeDataTest::instance()->testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -506,7 +521,7 @@ void tst_QDeclarativeDebugJS::setBreakpoint() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; //TEST LINE @@ -522,7 +537,8 @@ void tst_QDeclarativeDebugJS::setBreakpoint() void tst_QDeclarativeDebugJS::stepOver() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << QDeclarativeDataTest::instance()->testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -537,7 +553,7 @@ void tst_QDeclarativeDebugJS::stepOver() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = QDeclarativeDataTest::instance()->testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; client.setBreakpoints(QSet() << bp1); @@ -556,7 +572,8 @@ void tst_QDeclarativeDebugJS::stepOver() void tst_QDeclarativeDebugJS::stepInto() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << QDeclarativeDataTest::instance()->testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -571,7 +588,7 @@ void tst_QDeclarativeDebugJS::stepInto() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 12; client.setBreakpoints(QSet() << bp1); @@ -585,13 +602,14 @@ void tst_QDeclarativeDebugJS::stepInto() QByteArray functionName("functionInScript"); JSAgentStackData data = client.break_stackFrames.at(0); QCOMPARE(data.functionName, functionName); - QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded())); + QCOMPARE(data.fileUrl, QByteArray(testFileUrl("backtrace1.js").toEncoded())); } void tst_QDeclarativeDebugJS::interrupt() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -606,7 +624,7 @@ void tst_QDeclarativeDebugJS::interrupt() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 12; client.setBreakpoints(QSet() << bp1); @@ -620,13 +638,14 @@ void tst_QDeclarativeDebugJS::interrupt() QByteArray functionName("functionInScript"); JSAgentStackData data = client.break_stackFrames.at(0); QCOMPARE(data.functionName, functionName); - QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded())); + QCOMPARE(data.fileUrl, QByteArray(testFileUrl("backtrace1.js").toEncoded())); } void tst_QDeclarativeDebugJS::stepOut() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -641,10 +660,10 @@ void tst_QDeclarativeDebugJS::stepOut() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1,bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 12; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp2.lineNumber = 13; client.setBreakpoints(QSet() << bp1 << bp2); @@ -667,7 +686,8 @@ void tst_QDeclarativeDebugJS::stepOut() void tst_QDeclarativeDebugJS::continueExecution() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -682,10 +702,10 @@ void tst_QDeclarativeDebugJS::continueExecution() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp2.lineNumber = 13; client.setBreakpoints(QSet() << bp1 << bp2); @@ -704,7 +724,8 @@ void tst_QDeclarativeDebugJS::continueExecution() void tst_QDeclarativeDebugJS::expandObject() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -719,7 +740,7 @@ void tst_QDeclarativeDebugJS::expandObject() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; client.setBreakpoints(QSet() << bp1); @@ -748,7 +769,8 @@ void tst_QDeclarativeDebugJS::expandObject() void tst_QDeclarativeDebugJS::setProperty() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -763,9 +785,9 @@ void tst_QDeclarativeDebugJS::setProperty() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp2.lineNumber = 18; client.setBreakpoints(QSet() << bp1 << bp2); @@ -809,7 +831,8 @@ void tst_QDeclarativeDebugJS::setProperty() void tst_QDeclarativeDebugJS::setProperty2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -824,9 +847,9 @@ void tst_QDeclarativeDebugJS::setProperty2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp2.lineNumber = 18; client.setBreakpoints(QSet() << bp1 << bp2); @@ -869,7 +892,8 @@ void tst_QDeclarativeDebugJS::setProperty2() void tst_QDeclarativeDebugJS::watchExpression() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -891,7 +915,7 @@ void tst_QDeclarativeDebugJS::watchExpression() client.setWatchExpressions(watchList); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; client.setBreakpoints(QSet() << bp1); @@ -907,7 +931,8 @@ void tst_QDeclarativeDebugJS::watchExpression() void tst_QDeclarativeDebugJS::activateFrame() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -922,7 +947,7 @@ void tst_QDeclarativeDebugJS::activateFrame() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 3; client.setBreakpoints(QSet() << bp1); @@ -954,7 +979,8 @@ void tst_QDeclarativeDebugJS::activateFrame() void tst_QDeclarativeDebugJS::setBreakpoint2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -969,7 +995,7 @@ void tst_QDeclarativeDebugJS::setBreakpoint2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 40; //TEST LINE @@ -980,7 +1006,8 @@ void tst_QDeclarativeDebugJS::setBreakpoint2() void tst_QDeclarativeDebugJS::stepOver2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -995,7 +1022,7 @@ void tst_QDeclarativeDebugJS::stepOver2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; client.setBreakpoints(QSet() << bp1); @@ -1016,7 +1043,8 @@ void tst_QDeclarativeDebugJS::stepOver2() void tst_QDeclarativeDebugJS::stepInto2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1031,7 +1059,7 @@ void tst_QDeclarativeDebugJS::stepInto2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; client.setBreakpoints(QSet() << bp1); @@ -1047,13 +1075,14 @@ void tst_QDeclarativeDebugJS::stepInto2() QByteArray functionName("logger"); JSAgentStackData data = client.break_stackFrames.at(0); QCOMPARE(data.functionName, functionName); - QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded())); + QCOMPARE(data.fileUrl, QByteArray(testFileUrl("backtrace1.js").toEncoded())); } void tst_QDeclarativeDebugJS::interrupt2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1068,7 +1097,7 @@ void tst_QDeclarativeDebugJS::interrupt2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; client.setBreakpoints(QSet() << bp1); @@ -1084,13 +1113,14 @@ void tst_QDeclarativeDebugJS::interrupt2() QByteArray functionName("logger"); JSAgentStackData data = client.break_stackFrames.at(0); QCOMPARE(data.functionName, functionName); - QCOMPARE(data.fileUrl, QByteArray(QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded())); + QCOMPARE(data.fileUrl, QByteArray(testFileUrl("backtrace1.js").toEncoded())); } void tst_QDeclarativeDebugJS::stepOut2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1105,10 +1135,10 @@ void tst_QDeclarativeDebugJS::stepOut2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1,bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 12; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp2.lineNumber = 13; client.setBreakpoints(QSet() << bp1 << bp2); @@ -1137,7 +1167,8 @@ void tst_QDeclarativeDebugJS::stepOut2() void tst_QDeclarativeDebugJS::continueExecution2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1152,13 +1183,13 @@ void tst_QDeclarativeDebugJS::continueExecution2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2, bp3; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 11; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp2.lineNumber = 12; - bp3.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp3.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp3.lineNumber = 13; client.setBreakpoints(QSet() << bp1 << bp2 << bp3); @@ -1179,7 +1210,8 @@ void tst_QDeclarativeDebugJS::continueExecution2() void tst_QDeclarativeDebugJS::expandObject2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1194,7 +1226,7 @@ void tst_QDeclarativeDebugJS::expandObject2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; client.setBreakpoints(QSet() << bp1); @@ -1214,7 +1246,8 @@ void tst_QDeclarativeDebugJS::expandObject2() void tst_QDeclarativeDebugJS::setProperty3() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1229,9 +1262,9 @@ void tst_QDeclarativeDebugJS::setProperty3() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp2.lineNumber = 18; client.setBreakpoints(QSet() << bp1 << bp2); @@ -1268,7 +1301,8 @@ void tst_QDeclarativeDebugJS::setProperty3() void tst_QDeclarativeDebugJS::setProperty4() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1283,9 +1317,9 @@ void tst_QDeclarativeDebugJS::setProperty4() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 17; - bp2.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp2.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp2.lineNumber = 18; client.setBreakpoints(QSet() << bp1 << bp2); @@ -1328,7 +1362,8 @@ void tst_QDeclarativeDebugJS::setProperty4() void tst_QDeclarativeDebugJS::activateFrame2() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1343,7 +1378,7 @@ void tst_QDeclarativeDebugJS::activateFrame2() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1, bp2; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.js")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.js").toEncoded(); bp1.lineNumber = 4; client.setBreakpoints(QSet() << bp1); @@ -1368,7 +1403,8 @@ void tst_QDeclarativeDebugJS::activateFrame2() void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1383,7 +1419,7 @@ void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled() QCOMPARE(client.status(), QJSDebugClient::Enabled); JSAgentBreakpointData bp1; - bp1.fileUrl = QUrl::fromLocalFile(TEST_FILE("backtrace1.qml")).toEncoded(); + bp1.fileUrl = testFileUrl("backtrace1.qml").toEncoded(); bp1.lineNumber = 21; client.setBreakpoints(QSet() << bp1); @@ -1394,7 +1430,8 @@ void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled() void tst_QDeclarativeDebugJS::testCoverageCompleted() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; @@ -1414,7 +1451,8 @@ void tst_QDeclarativeDebugJS::testCoverageCompleted() void tst_QDeclarativeDebugJS::testCoverageRun() { QJSDebugProcess process; - process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + process.start(m_binary, QStringList() << "-qmljsdebugger=port:3771,block" + << testFile("backtrace1.qml")); QVERIFY(process.waitForStarted()); QDeclarativeDebugConnection connection; diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro index 98f96f82..c6423036 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.pro @@ -10,19 +10,11 @@ HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebugjs.cpp \ ../shared/debugutil.cpp -INCLUDEPATH += ../shared +include(../shared/qdeclarativedatatest.pri) # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - OTHER_FILES = data/backtrace1.js data/backtrace1.qml CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro index a65b723e..39435719 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro +++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro @@ -15,13 +15,7 @@ INCLUDEPATH += ../shared # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 5beba052..d561fbb3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -54,29 +55,14 @@ #include "testtypes.h" #include "testhttpserver.h" -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - /* This test covers evaluation of ECMAScript expressions and bindings from within QML. This does not include static QML language issues. Static QML language issues are covered in qmllanguage */ -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename)); -} -inline QUrl TEST_FILE(const char *filename) -{ - return TEST_FILE(QLatin1String(filename)); -} - -class tst_qdeclarativeecmascript : public QObject +class tst_qdeclarativeecmascript : public QDeclarativeDataTest { Q_OBJECT public: @@ -190,12 +176,16 @@ private: QDeclarativeEngine engine; }; -void tst_qdeclarativeecmascript::initTestCase() { registerTypes(); } +void tst_qdeclarativeecmascript::initTestCase() +{ + QDeclarativeDataTest::initTestCase(); + registerTypes(); +} void tst_qdeclarativeecmascript::assignBasicTypes() { { - QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); @@ -223,7 +213,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.2.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); @@ -255,7 +245,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() void tst_qdeclarativeecmascript::idShortcutInvalidates() { { - QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml")); + QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); @@ -264,7 +254,7 @@ void tst_qdeclarativeecmascript::idShortcutInvalidates() } { - QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); @@ -276,13 +266,13 @@ void tst_qdeclarativeecmascript::idShortcutInvalidates() void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool() { { - QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->stringProperty(), QLatin1String("pass")); } { - QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->stringProperty(), QLatin1String("pass")); @@ -292,7 +282,7 @@ void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool() void tst_qdeclarativeecmascript::signalAssignment() { { - QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->string(), QString()); @@ -301,7 +291,7 @@ void tst_qdeclarativeecmascript::signalAssignment() } { - QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->string(), QString()); @@ -313,7 +303,7 @@ void tst_qdeclarativeecmascript::signalAssignment() void tst_qdeclarativeecmascript::methods() { { - QDeclarativeComponent component(&engine, TEST_FILE("methods.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("methods.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); @@ -324,7 +314,7 @@ void tst_qdeclarativeecmascript::methods() } { - QDeclarativeComponent component(&engine, TEST_FILE("methods.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("methods.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); @@ -335,14 +325,14 @@ void tst_qdeclarativeecmascript::methods() } { - QDeclarativeComponent component(&engine, TEST_FILE("methods.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("methods.3.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 19); } { - QDeclarativeComponent component(&engine, TEST_FILE("methods.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("methods.4.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 19); @@ -351,7 +341,7 @@ void tst_qdeclarativeecmascript::methods() } { - QDeclarativeComponent component(&engine, TEST_FILE("methods.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("methods.5.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 9); @@ -360,7 +350,7 @@ void tst_qdeclarativeecmascript::methods() void tst_qdeclarativeecmascript::bindingLoop() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingLoop.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingLoop.qml")); QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); @@ -567,7 +557,7 @@ void tst_qdeclarativeecmascript::objectPropertiesTriggerReeval() void tst_qdeclarativeecmascript::deferredProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("deferredProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("deferredProperties.qml")); MyDeferredObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -588,7 +578,7 @@ void tst_qdeclarativeecmascript::deferredProperties() // Check errors on deferred properties are correctly emitted void tst_qdeclarativeecmascript::deferredPropertiesErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml")); MyDeferredObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -606,7 +596,7 @@ void tst_qdeclarativeecmascript::deferredPropertiesErrors() void tst_qdeclarativeecmascript::extensionObjects() { - QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml")); + QDeclarativeComponent component(&engine, testFileUrl("extensionObjects.qml")); MyExtendedObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -630,7 +620,7 @@ void tst_qdeclarativeecmascript::extensionObjects() void tst_qdeclarativeecmascript::overrideExtensionProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("extensionObjectsPropertyOverride.qml")); + QDeclarativeComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml")); OverrideDefaultPropertyObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -641,7 +631,7 @@ void tst_qdeclarativeecmascript::overrideExtensionProperties() void tst_qdeclarativeecmascript::attachedProperties() { { - QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("a").toInt(), 19); @@ -651,7 +641,7 @@ void tst_qdeclarativeecmascript::attachedProperties() } { - QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("a").toInt(), 26); @@ -661,7 +651,7 @@ void tst_qdeclarativeecmascript::attachedProperties() } { - QDeclarativeComponent component(&engine, TEST_FILE("writeAttachedProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("writeAttachedProperty.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -679,7 +669,7 @@ void tst_qdeclarativeecmascript::enums() { // Existent enums { - QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -696,7 +686,7 @@ void tst_qdeclarativeecmascript::enums() } // Non-existent enums { - QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml")); QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int a"; QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int b"; @@ -712,7 +702,7 @@ void tst_qdeclarativeecmascript::enums() void tst_qdeclarativeecmascript::valueTypeFunctions() { - QDeclarativeComponent component(&engine, TEST_FILE("valueTypeFunctions.qml")); + QDeclarativeComponent component(&engine, testFileUrl("valueTypeFunctions.qml")); MyTypeObject *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->rectProperty(), QRect(0,0,100,100)); @@ -727,7 +717,7 @@ void tst_qdeclarativeecmascript::constantsOverrideBindings() { // From ECMAScript { - QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -744,7 +734,7 @@ void tst_qdeclarativeecmascript::constantsOverrideBindings() // During construction { - QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -758,7 +748,7 @@ void tst_qdeclarativeecmascript::constantsOverrideBindings() #if 0 // From C++ { - QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -776,7 +766,7 @@ void tst_qdeclarativeecmascript::constantsOverrideBindings() // Using an alias { - QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -795,7 +785,7 @@ the original binding to be disabled. void tst_qdeclarativeecmascript::outerBindingOverridesInnerBinding() { QDeclarativeComponent component(&engine, - TEST_FILE("outerBindingOverridesInnerBinding.qml")); + testFileUrl("outerBindingOverridesInnerBinding.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -821,7 +811,7 @@ Tests for a regression where this used to crash. */ void tst_qdeclarativeecmascript::nonExistentAttachedObject() { - QDeclarativeComponent component(&engine, TEST_FILE("nonExistentAttachedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml")); QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString stringProperty"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -833,7 +823,7 @@ void tst_qdeclarativeecmascript::nonExistentAttachedObject() void tst_qdeclarativeecmascript::scope() { { - QDeclarativeComponent component(&engine, TEST_FILE("scope.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scope.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -850,7 +840,7 @@ void tst_qdeclarativeecmascript::scope() } { - QDeclarativeComponent component(&engine, TEST_FILE("scope.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scope.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -863,7 +853,7 @@ void tst_qdeclarativeecmascript::scope() } { - QDeclarativeComponent component(&engine, TEST_FILE("scope.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scope.3.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -874,7 +864,7 @@ void tst_qdeclarativeecmascript::scope() // Signal argument scope { - QDeclarativeComponent component(&engine, TEST_FILE("scope.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scope.4.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -896,7 +886,7 @@ is essentially a test of QDeclarativeMetaType::copy() */ void tst_qdeclarativeecmascript::signalParameterTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("signalParameterTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("signalParameterTypes.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -915,7 +905,7 @@ Test that two JS objects for the same QObject compare as equal. */ void tst_qdeclarativeecmascript::objectsCompareAsEqual() { - QDeclarativeComponent component(&engine, TEST_FILE("objectsCompareAsEqual.qml")); + QDeclarativeComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -933,7 +923,7 @@ Tests for a regression where the binding would not reevaluate. */ void tst_qdeclarativeecmascript::aliasPropertyAndBinding() { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyAndBinding.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -965,7 +955,7 @@ void tst_qdeclarativeecmascript::dynamicCreation() QFETCH(QString, method); QFETCH(QString, createdName); - QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -980,7 +970,7 @@ void tst_qdeclarativeecmascript::dynamicCreation() */ void tst_qdeclarativeecmascript::dynamicDestruction() { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.qml")); QDeclarativeGuard object = qobject_cast(component.create()); QVERIFY(object != 0); QDeclarativeGuard createdQmlObject = 0; @@ -1015,7 +1005,7 @@ void tst_qdeclarativeecmascript::dynamicDestruction() */ void tst_qdeclarativeecmascript::objectToString() { - QDeclarativeComponent component(&engine, TEST_FILE("declarativeToString.qml")); + QDeclarativeComponent component(&engine, testFileUrl("declarativeToString.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QMetaObject::invokeMethod(object, "testToString"); @@ -1031,14 +1021,14 @@ This test is best run under valgrind to ensure no invalid memory access occur. void tst_qdeclarativeecmascript::selfDeletingBinding() { { - QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.qml")); + QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.qml")); QObject *object = component.create(); QVERIFY(object != 0); object->setProperty("triggerDelete", true); } { - QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); object->setProperty("triggerDelete", true); @@ -1054,7 +1044,7 @@ and no synthesiszed properties). */ void tst_qdeclarativeecmascript::extendedObjectPropertyLookup() { - QDeclarativeComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml")); + QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml")); QObject *object = component.create(); QVERIFY(object != 0); } @@ -1064,7 +1054,7 @@ Test file/lineNumbers for binding/Script errors. */ void tst_qdeclarativeecmascript::scriptErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptErrors.qml")); QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; @@ -1099,7 +1089,7 @@ Test file/lineNumbers for inline functions. */ void tst_qdeclarativeecmascript::functionErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("functionErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("functionErrors.qml")); QString url = component.url().toString(); QString warning = url + ":5: Error: Invalid write to global property \"a\""; @@ -1116,7 +1106,7 @@ Test various errors that can occur when assigning a property from script */ void tst_qdeclarativeecmascript::propertyAssignmentErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("propertyAssignmentErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml")); QString url = component.url().toString(); @@ -1138,7 +1128,7 @@ a signal script. */ void tst_qdeclarativeecmascript::signalTriggeredBindings() { - QDeclarativeComponent component(&engine, TEST_FILE("signalTriggeredBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("signalTriggeredBindings.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1164,7 +1154,7 @@ Test that list properties can be iterated from ECMAScript */ void tst_qdeclarativeecmascript::listProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("listProperties.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1176,7 +1166,7 @@ void tst_qdeclarativeecmascript::listProperties() void tst_qdeclarativeecmascript::exceptionClearsOnReeval() { - QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml")); + QDeclarativeComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml")); QString url = component.url().toString(); QString warning = url + ":4: TypeError: Result of expression 'objectProperty' [null] is not an object."; @@ -1197,7 +1187,7 @@ void tst_qdeclarativeecmascript::exceptionClearsOnReeval() void tst_qdeclarativeecmascript::exceptionSlotProducesWarning() { - QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning.qml")); + QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning.qml")); QString url = component.url().toString(); QString warning = component.url().toString() + ":6: Error: JS exception"; @@ -1209,7 +1199,7 @@ void tst_qdeclarativeecmascript::exceptionSlotProducesWarning() void tst_qdeclarativeecmascript::exceptionBindingProducesWarning() { - QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml")); QString url = component.url().toString(); QString warning = component.url().toString() + ":5: Error: JS exception"; @@ -1229,7 +1219,7 @@ static void transientErrorsMsgHandler(QtMsgType, const char *) void tst_qdeclarativeecmascript::transientErrors() { { - QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("transientErrors.qml")); transientErrorsMsgCount = 0; QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); @@ -1244,7 +1234,7 @@ void tst_qdeclarativeecmascript::transientErrors() // One binding erroring multiple times, but then resolving { - QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("transientErrors.2.qml")); transientErrorsMsgCount = 0; QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); @@ -1261,7 +1251,7 @@ void tst_qdeclarativeecmascript::transientErrors() // Check that errors during shutdown are minimized void tst_qdeclarativeecmascript::shutdownErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("shutdownErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("shutdownErrors.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1276,7 +1266,7 @@ void tst_qdeclarativeecmascript::shutdownErrors() void tst_qdeclarativeecmascript::compositePropertyType() { - QDeclarativeComponent component(&engine, TEST_FILE("compositePropertyType.qml")); + QDeclarativeComponent component(&engine, testFileUrl("compositePropertyType.qml")); QTest::ignoreMessage(QtDebugMsg, "hello world"); QObject *object = qobject_cast(component.create()); delete object; @@ -1285,7 +1275,7 @@ void tst_qdeclarativeecmascript::compositePropertyType() // QTBUG-5759 void tst_qdeclarativeecmascript::jsObject() { - QDeclarativeComponent component(&engine, TEST_FILE("jsObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("jsObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1297,7 +1287,7 @@ void tst_qdeclarativeecmascript::jsObject() void tst_qdeclarativeecmascript::undefinedResetsProperty() { { - QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1314,7 +1304,7 @@ void tst_qdeclarativeecmascript::undefinedResetsProperty() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1331,7 +1321,7 @@ void tst_qdeclarativeecmascript::undefinedResetsProperty() // QTBUG-6781 void tst_qdeclarativeecmascript::bug1() { - QDeclarativeComponent component(&engine, TEST_FILE("bug.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bug.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1362,7 +1352,7 @@ void tst_qdeclarativeecmascript::bug2() // Don't crash in createObject when the component has errors. void tst_qdeclarativeecmascript::dynamicCreationCrash() { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1375,7 +1365,7 @@ void tst_qdeclarativeecmascript::dynamicCreationCrash() //QTBUG-9367 void tst_qdeclarativeecmascript::regExpBug() { - QDeclarativeComponent component(&engine, TEST_FILE("regExp.qml")); + QDeclarativeComponent component(&engine, testFileUrl("regExp.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]")); @@ -1843,7 +1833,7 @@ void tst_qdeclarativeecmascript::callQtInvokables() // QTBUG-13047 (check that you can pass registered object types as args) void tst_qdeclarativeecmascript::invokableObjectArg() { - QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectArg.qml")); + QDeclarativeComponent component(&engine, testFileUrl("invokableObjectArg.qml")); QObject *o = component.create(); QVERIFY(o); @@ -1857,7 +1847,7 @@ void tst_qdeclarativeecmascript::invokableObjectArg() // QTBUG-13047 (check that you can return registered object types from methods) void tst_qdeclarativeecmascript::invokableObjectRet() { - QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectRet.qml")); + QDeclarativeComponent component(&engine, testFileUrl("invokableObjectRet.qml")); QObject *o = component.create(); QVERIFY(o); @@ -1868,7 +1858,7 @@ void tst_qdeclarativeecmascript::invokableObjectRet() // QTBUG-5675 void tst_qdeclarativeecmascript::listToVariant() { - QDeclarativeComponent component(&engine, TEST_FILE("listToVariant.qml")); + QDeclarativeComponent component(&engine, testFileUrl("listToVariant.qml")); MyQmlContainer container; @@ -1893,11 +1883,11 @@ void tst_qdeclarativeecmascript::multiEngineObject() QDeclarativeEngine e1; e1.rootContext()->setContextProperty("thing", &obj); - QDeclarativeComponent c1(&e1, TEST_FILE("multiEngineObject.qml")); + QDeclarativeComponent c1(&e1, testFileUrl("multiEngineObject.qml")); QDeclarativeEngine e2; e2.rootContext()->setContextProperty("thing", &obj); - QDeclarativeComponent c2(&e2, TEST_FILE("multiEngineObject.qml")); + QDeclarativeComponent c2(&e2, testFileUrl("multiEngineObject.qml")); QObject *o1 = c1.create(); QObject *o2 = c2.create(); @@ -1912,7 +1902,7 @@ void tst_qdeclarativeecmascript::multiEngineObject() // Test that references to QObjects are cleanup when the object is destroyed void tst_qdeclarativeecmascript::deletedObject() { - QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml")); QObject *object = component.create(); @@ -1926,7 +1916,7 @@ void tst_qdeclarativeecmascript::deletedObject() void tst_qdeclarativeecmascript::attachedPropertyScope() { - QDeclarativeComponent component(&engine, TEST_FILE("attachedPropertyScope.qml")); + QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyScope.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1947,7 +1937,7 @@ void tst_qdeclarativeecmascript::attachedPropertyScope() void tst_qdeclarativeecmascript::scriptConnect() { { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1960,7 +1950,7 @@ void tst_qdeclarativeecmascript::scriptConnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1973,7 +1963,7 @@ void tst_qdeclarativeecmascript::scriptConnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.3.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1986,7 +1976,7 @@ void tst_qdeclarativeecmascript::scriptConnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.4.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1999,7 +1989,7 @@ void tst_qdeclarativeecmascript::scriptConnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.5.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2012,7 +2002,7 @@ void tst_qdeclarativeecmascript::scriptConnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.6.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.6.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2028,7 +2018,7 @@ void tst_qdeclarativeecmascript::scriptConnect() void tst_qdeclarativeecmascript::scriptDisconnect() { { - QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.1.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2047,7 +2037,7 @@ void tst_qdeclarativeecmascript::scriptDisconnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.2.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2066,7 +2056,7 @@ void tst_qdeclarativeecmascript::scriptDisconnect() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.3.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2084,7 +2074,7 @@ void tst_qdeclarativeecmascript::scriptDisconnect() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.4.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2122,7 +2112,7 @@ void tst_qdeclarativeecmascript::ownership() context->setContextObject(&own); { - QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml")); + QDeclarativeComponent component(&engine, testFileUrl("ownership.qml")); QVERIFY(own.object != 0); @@ -2139,7 +2129,7 @@ void tst_qdeclarativeecmascript::ownership() own.object = new QObject(&own); { - QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml")); + QDeclarativeComponent component(&engine, testFileUrl("ownership.qml")); QVERIFY(own.object != 0); @@ -2258,7 +2248,7 @@ void tst_qdeclarativeecmascript::qlistqobjectMethods() QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); context->setContextObject(&obj); - QDeclarativeComponent component(&engine, TEST_FILE("qlistqobjectMethods.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qlistqobjectMethods.qml")); QObject *object = component.create(context); @@ -2271,7 +2261,7 @@ void tst_qdeclarativeecmascript::qlistqobjectMethods() // QTBUG-9205 void tst_qdeclarativeecmascript::strictlyEquals() { - QDeclarativeComponent component(&engine, TEST_FILE("strictlyEquals.qml")); + QDeclarativeComponent component(&engine, testFileUrl("strictlyEquals.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2290,7 +2280,7 @@ void tst_qdeclarativeecmascript::strictlyEquals() void tst_qdeclarativeecmascript::compiled() { - QDeclarativeComponent component(&engine, TEST_FILE("compiled.qml")); + QDeclarativeComponent component(&engine, testFileUrl("compiled.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2330,7 +2320,7 @@ void tst_qdeclarativeecmascript::compiled() // Test that numbers assigned in bindings as strings work consistently void tst_qdeclarativeecmascript::numberAssignment() { - QDeclarativeComponent component(&engine, TEST_FILE("numberAssignment.qml")); + QDeclarativeComponent component(&engine, testFileUrl("numberAssignment.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2356,7 +2346,7 @@ void tst_qdeclarativeecmascript::numberAssignment() void tst_qdeclarativeecmascript::propertySplicing() { - QDeclarativeComponent component(&engine, TEST_FILE("propertySplicing.qml")); + QDeclarativeComponent component(&engine, testFileUrl("propertySplicing.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2369,7 +2359,7 @@ void tst_qdeclarativeecmascript::propertySplicing() // QTBUG-16683 void tst_qdeclarativeecmascript::signalWithUnknownTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("signalWithUnknownTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -2390,7 +2380,7 @@ void tst_qdeclarativeecmascript::signalWithUnknownTypes() // Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4 void tst_qdeclarativeecmascript::nullObjectBinding() { - QDeclarativeComponent component(&engine, TEST_FILE("nullObjectBinding.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nullObjectBinding.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2404,7 +2394,7 @@ void tst_qdeclarativeecmascript::nullObjectBinding() void tst_qdeclarativeecmascript::deletedEngine() { QDeclarativeEngine *engine = new QDeclarativeEngine; - QDeclarativeComponent component(engine, TEST_FILE("deletedEngine.qml")); + QDeclarativeComponent component(engine, testFileUrl("deletedEngine.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2425,7 +2415,7 @@ void tst_qdeclarativeecmascript::deletedEngine() // Test the crashing part of QTBUG-9705 void tst_qdeclarativeecmascript::libraryScriptAssert() { - QDeclarativeComponent component(&engine, TEST_FILE("libraryScriptAssert.qml")); + QDeclarativeComponent component(&engine, testFileUrl("libraryScriptAssert.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2435,7 +2425,7 @@ void tst_qdeclarativeecmascript::libraryScriptAssert() void tst_qdeclarativeecmascript::variantsAssignedUndefined() { - QDeclarativeComponent component(&engine, TEST_FILE("variantsAssignedUndefined.qml")); + QDeclarativeComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -2454,7 +2444,7 @@ void tst_qdeclarativeecmascript::variantsAssignedUndefined() void tst_qdeclarativeecmascript::qtbug_9792() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_9792.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_9792.qml")); QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); @@ -2481,7 +2471,7 @@ void tst_qdeclarativeecmascript::qtbug_9792() // Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly void tst_qdeclarativeecmascript::qtcreatorbug_1289() { - QDeclarativeComponent component(&engine, TEST_FILE("qtcreatorbug_1289.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2503,7 +2493,7 @@ void tst_qdeclarativeecmascript::qtcreatorbug_1289() void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() { { - QDeclarativeComponent component(&engine, TEST_FILE("noSpuriousWarningsAtShutdown.qml")); + QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml")); QObject *o = component.create(); @@ -2519,7 +2509,7 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() { - QDeclarativeComponent component(&engine, TEST_FILE("noSpuriousWarningsAtShutdown.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml")); QObject *o = component.create(); @@ -2537,7 +2527,7 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() void tst_qdeclarativeecmascript::canAssignNullToQObject() { { - QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml")); MyQmlObject *o = qobject_cast(component.create()); QVERIFY(o != 0); @@ -2552,7 +2542,7 @@ void tst_qdeclarativeecmascript::canAssignNullToQObject() } { - QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml")); MyQmlObject *o = qobject_cast(component.create()); QVERIFY(o != 0); @@ -2565,7 +2555,7 @@ void tst_qdeclarativeecmascript::canAssignNullToQObject() void tst_qdeclarativeecmascript::functionAssignment_fromBinding() { - QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.1.qml")); QString url = component.url().toString(); QString warning = url + ":4: Unable to assign a function to a property."; @@ -2583,7 +2573,7 @@ void tst_qdeclarativeecmascript::functionAssignment_fromJS() { QFETCH(QString, triggerProperty); - QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml")); QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); MyQmlObject *o = qobject_cast(component.create()); @@ -2615,7 +2605,7 @@ void tst_qdeclarativeecmascript::functionAssignment_fromJS_data() void tst_qdeclarativeecmascript::functionAssignmentfromJS_invalid() { - QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml")); QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); MyQmlObject *o = qobject_cast(component.create()); @@ -2639,7 +2629,7 @@ void tst_qdeclarativeecmascript::functionAssignmentfromJS_invalid() void tst_qdeclarativeecmascript::eval() { - QDeclarativeComponent component(&engine, TEST_FILE("eval.qml")); + QDeclarativeComponent component(&engine, testFileUrl("eval.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2655,7 +2645,7 @@ void tst_qdeclarativeecmascript::eval() void tst_qdeclarativeecmascript::function() { - QDeclarativeComponent component(&engine, TEST_FILE("function.qml")); + QDeclarativeComponent component(&engine, testFileUrl("function.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2672,7 +2662,7 @@ void tst_qdeclarativeecmascript::include() { // Non-library relative include { - QDeclarativeComponent component(&engine, TEST_FILE("include.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2688,7 +2678,7 @@ void tst_qdeclarativeecmascript::include() // Library relative include { - QDeclarativeComponent component(&engine, TEST_FILE("include_shared.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include_shared.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2704,7 +2694,7 @@ void tst_qdeclarativeecmascript::include() // Callback { - QDeclarativeComponent component(&engine, TEST_FILE("include_callback.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include_callback.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2720,7 +2710,7 @@ void tst_qdeclarativeecmascript::include() // Including file with ".pragma library" { - QDeclarativeComponent component(&engine, TEST_FILE("include_pragma.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include_pragma.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test1").toInt(), 100); @@ -2732,9 +2722,9 @@ void tst_qdeclarativeecmascript::include() { TestHTTPServer server(8111); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); - QDeclarativeComponent component(&engine, TEST_FILE("include_remote.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include_remote.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2760,9 +2750,9 @@ void tst_qdeclarativeecmascript::include() { TestHTTPServer server(8111); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); - QDeclarativeComponent component(&engine, TEST_FILE("include_remote_missing.qml")); + QDeclarativeComponent component(&engine, testFileUrl("include_remote_missing.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2778,7 +2768,7 @@ void tst_qdeclarativeecmascript::include() void tst_qdeclarativeecmascript::qtbug_10696() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_10696.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_10696.qml")); QObject *o = component.create(); QVERIFY(o != 0); delete o; @@ -2786,7 +2776,7 @@ void tst_qdeclarativeecmascript::qtbug_10696() void tst_qdeclarativeecmascript::qtbug_11606() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11606.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_11606.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test").toBool(), true); @@ -2795,7 +2785,7 @@ void tst_qdeclarativeecmascript::qtbug_11606() void tst_qdeclarativeecmascript::qtbug_11600() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11600.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_11600.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test").toBool(), true); @@ -2805,7 +2795,7 @@ void tst_qdeclarativeecmascript::qtbug_11600() // Reading and writing non-scriptable properties should fail void tst_qdeclarativeecmascript::nonscriptable() { - QDeclarativeComponent component(&engine, TEST_FILE("nonscriptable.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nonscriptable.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("readOk").toBool(), true); @@ -2816,7 +2806,7 @@ void tst_qdeclarativeecmascript::nonscriptable() // deleteLater() should not be callable from QML void tst_qdeclarativeecmascript::deleteLater() { - QDeclarativeComponent component(&engine, TEST_FILE("deleteLater.qml")); + QDeclarativeComponent component(&engine, testFileUrl("deleteLater.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test").toBool(), true); @@ -2825,7 +2815,7 @@ void tst_qdeclarativeecmascript::deleteLater() void tst_qdeclarativeecmascript::in() { - QDeclarativeComponent component(&engine, TEST_FILE("in.qml")); + QDeclarativeComponent component(&engine, testFileUrl("in.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test1").toBool(), true); @@ -2835,7 +2825,7 @@ void tst_qdeclarativeecmascript::in() void tst_qdeclarativeecmascript::sharedAttachedObject() { - QDeclarativeComponent component(&engine, TEST_FILE("sharedAttachedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sharedAttachedObject.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test1").toBool(), true); @@ -2846,7 +2836,7 @@ void tst_qdeclarativeecmascript::sharedAttachedObject() // QTBUG-13999 void tst_qdeclarativeecmascript::objectName() { - QDeclarativeComponent component(&engine, TEST_FILE("objectName.qml")); + QDeclarativeComponent component(&engine, testFileUrl("objectName.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2863,7 +2853,7 @@ void tst_qdeclarativeecmascript::objectName() void tst_qdeclarativeecmascript::writeRemovesBinding() { - QDeclarativeComponent component(&engine, TEST_FILE("writeRemovesBinding.qml")); + QDeclarativeComponent component(&engine, testFileUrl("writeRemovesBinding.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2875,7 +2865,7 @@ void tst_qdeclarativeecmascript::writeRemovesBinding() // Test bindings assigned to alias properties actually assign to the alias' target void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly() { - QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsAssignCorrectly.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2888,7 +2878,7 @@ void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly() void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget() { { - QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2898,7 +2888,7 @@ void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget() } { - QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2908,7 +2898,7 @@ void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget() } { - QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2922,7 +2912,7 @@ void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget() void tst_qdeclarativeecmascript::aliasWritesOverrideBindings() { { - QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2932,7 +2922,7 @@ void tst_qdeclarativeecmascript::aliasWritesOverrideBindings() } { - QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2942,7 +2932,7 @@ void tst_qdeclarativeecmascript::aliasWritesOverrideBindings() } { - QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -2955,7 +2945,7 @@ void tst_qdeclarativeecmascript::aliasWritesOverrideBindings() void tst_qdeclarativeecmascript::revisionErrors() { { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml")); QString url = component.url().toString(); QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2"; @@ -2969,7 +2959,7 @@ void tst_qdeclarativeecmascript::revisionErrors() QVERIFY(object != 0); } { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml")); QString url = component.url().toString(); // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0 @@ -2990,7 +2980,7 @@ void tst_qdeclarativeecmascript::revisionErrors() QVERIFY(object != 0); } { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml")); QString url = component.url().toString(); // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 @@ -3009,21 +2999,21 @@ void tst_qdeclarativeecmascript::revisionErrors() void tst_qdeclarativeecmascript::revision() { { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision.qml")); QString url = component.url().toString(); MyRevisionedClass *object = qobject_cast(component.create()); QVERIFY(object != 0); } { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision2.qml")); QString url = component.url().toString(); MyRevisionedClass *object = qobject_cast(component.create()); QVERIFY(object != 0); } { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision3.qml")); QString url = component.url().toString(); MyRevisionedClass *object = qobject_cast(component.create()); @@ -3031,7 +3021,7 @@ void tst_qdeclarativeecmascript::revision() } // Test that non-root classes can resolve revisioned methods { - QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision4.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -3080,7 +3070,7 @@ void tst_qdeclarativeecmascript::pushCleanContext() void tst_qdeclarativeecmascript::realToInt() { - QDeclarativeComponent component(&engine, TEST_FILE("realToInt.qml")); + QDeclarativeComponent component(&engine, testFileUrl("realToInt.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -3092,7 +3082,7 @@ void tst_qdeclarativeecmascript::realToInt() void tst_qdeclarativeecmascript::qtbug_20648() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_20648.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_20648.qml")); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("test").toInt(), 100); diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro index e464fa8c..0f5b64ad 100644 --- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro +++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro @@ -7,13 +7,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeinfo.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp index 7497417b..682d8513 100644 --- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp +++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -51,7 +52,7 @@ #define SRCDIR "." #endif -class tst_qdeclarativeinfo : public QObject +class tst_qdeclarativeinfo : public QDeclarativeDataTest { Q_OBJECT public: @@ -70,14 +71,9 @@ private: QDeclarativeEngine engine; }; -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - void tst_qdeclarativeinfo::qmlObject() { - QDeclarativeComponent component(&engine, TEST_FILE("qmlObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qmlObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -96,7 +92,7 @@ void tst_qdeclarativeinfo::qmlObject() void tst_qdeclarativeinfo::nestedQmlObject() { - QDeclarativeComponent component(&engine, TEST_FILE("nestedQmlObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nestedQmlObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -110,7 +106,7 @@ void tst_qdeclarativeinfo::nestedQmlObject() QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(nested) << "Outer Object"; - message = TEST_FILE("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object"; + message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); qmlInfo(nested2) << "Inner Object"; } diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro index 14439a38..5ae75462 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro +++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro @@ -10,16 +10,9 @@ SOURCES += tst_qdeclarativelanguage.cpp \ testtypes.cpp HEADERS += testtypes.h -INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index d825a479..1fe52ee2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -54,10 +55,6 @@ #include "testhttpserver.h" -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) @@ -68,7 +65,7 @@ involve evaluating ECMAScript expressions and bindings. Evaluation of expressions and bindings is covered in qmlecmascript */ -class tst_qdeclarativelanguage : public QObject +class tst_qdeclarativelanguage : public QDeclarativeDataTest { Q_OBJECT public: @@ -173,7 +170,7 @@ private: QVERIFY(!component.isError()); \ QVERIFY(component.errors().isEmpty()); \ } else { \ - QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \ + QFile file(testFile(errorfile)); \ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ QByteArray data = file.readAll(); \ file.close(); \ @@ -202,20 +199,9 @@ private: } \ } -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename)); -} - -inline QUrl TEST_FILE(const char *filename) -{ - return TEST_FILE(QLatin1String(filename)); -} - void tst_qdeclarativelanguage::cleanupTestCase() { - QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile())); + QVERIFY(QFile::remove(testFileUrl(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile())); } void tst_qdeclarativelanguage::insertedSemicolon_data() @@ -233,7 +219,7 @@ void tst_qdeclarativelanguage::insertedSemicolon() QFETCH(QString, errorFile); QFETCH(bool, create); - QDeclarativeComponent component(&engine, TEST_FILE(file)); + QDeclarativeComponent component(&engine, testFileUrl(file)); if(create) { QObject *object = component.create(); @@ -438,7 +424,7 @@ void tst_qdeclarativelanguage::errors() QFETCH(QString, errorFile); QFETCH(bool, create); - QDeclarativeComponent component(&engine, TEST_FILE(file)); + QDeclarativeComponent component(&engine, testFileUrl(file)); if(create) { QObject *object = component.create(); @@ -450,7 +436,7 @@ void tst_qdeclarativelanguage::errors() void tst_qdeclarativelanguage::simpleObject() { - QDeclarativeComponent component(&engine, TEST_FILE("simpleObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("simpleObject.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -458,7 +444,7 @@ void tst_qdeclarativelanguage::simpleObject() void tst_qdeclarativelanguage::simpleContainer() { - QDeclarativeComponent component(&engine, TEST_FILE("simpleContainer.qml")); + QDeclarativeComponent component(&engine, testFileUrl("simpleContainer.qml")); VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); @@ -467,7 +453,7 @@ void tst_qdeclarativelanguage::simpleContainer() void tst_qdeclarativelanguage::interfaceProperty() { - QDeclarativeComponent component(&engine, TEST_FILE("interfaceProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("interfaceProperty.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -477,7 +463,7 @@ void tst_qdeclarativelanguage::interfaceProperty() void tst_qdeclarativelanguage::interfaceQList() { - QDeclarativeComponent component(&engine, TEST_FILE("interfaceQList.qml")); + QDeclarativeComponent component(&engine, testFileUrl("interfaceQList.qml")); VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); @@ -488,7 +474,7 @@ void tst_qdeclarativelanguage::interfaceQList() void tst_qdeclarativelanguage::assignObjectToSignal() { - QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToSignal.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignObjectToSignal.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -498,7 +484,7 @@ void tst_qdeclarativelanguage::assignObjectToSignal() void tst_qdeclarativelanguage::assignObjectToVariant() { - QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToVariant.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignObjectToVariant.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -508,7 +494,7 @@ void tst_qdeclarativelanguage::assignObjectToVariant() void tst_qdeclarativelanguage::assignLiteralSignalProperty() { - QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignLiteralSignalProperty.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -518,7 +504,7 @@ void tst_qdeclarativelanguage::assignLiteralSignalProperty() // Test is an external component can be loaded and assigned (to a qlist) void tst_qdeclarativelanguage::assignQmlComponent() { - QDeclarativeComponent component(&engine, TEST_FILE("assignQmlComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignQmlComponent.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -531,7 +517,7 @@ void tst_qdeclarativelanguage::assignQmlComponent() // Test literal assignment to all the basic types void tst_qdeclarativelanguage::assignBasicTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -566,7 +552,7 @@ void tst_qdeclarativelanguage::assignBasicTypes() // Test edge case type assignments void tst_qdeclarativelanguage::assignTypeExtremes() { - QDeclarativeComponent component(&engine, TEST_FILE("assignTypeExtremes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignTypeExtremes.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -577,7 +563,7 @@ void tst_qdeclarativelanguage::assignTypeExtremes() // Test that a composite type can assign to a property of its base type void tst_qdeclarativelanguage::assignCompositeToType() { - QDeclarativeComponent component(&engine, TEST_FILE("assignCompositeToType.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignCompositeToType.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -586,7 +572,7 @@ void tst_qdeclarativelanguage::assignCompositeToType() // Test that literals are stored correctly in variant properties void tst_qdeclarativelanguage::assignLiteralToVariant() { - QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignLiteralToVariant.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -621,7 +607,7 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() // Tests that custom parser types can be instantiated void tst_qdeclarativelanguage::customParserTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("customParserTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("customParserTypes.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -631,7 +617,7 @@ void tst_qdeclarativelanguage::customParserTypes() // Tests that the root item can be a custom component void tst_qdeclarativelanguage::rootAsQmlComponent() { - QDeclarativeComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rootAsQmlComponent.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -642,7 +628,7 @@ void tst_qdeclarativelanguage::rootAsQmlComponent() // Tests that components can be specified inline void tst_qdeclarativelanguage::inlineQmlComponents() { - QDeclarativeComponent component(&engine, TEST_FILE("inlineQmlComponents.qml")); + QDeclarativeComponent component(&engine, testFileUrl("inlineQmlComponents.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -657,7 +643,7 @@ void tst_qdeclarativelanguage::inlineQmlComponents() // Tests that types that have an id property have it set void tst_qdeclarativelanguage::idProperty() { - QDeclarativeComponent component(&engine, TEST_FILE("idProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("idProperty.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -673,7 +659,7 @@ void tst_qdeclarativelanguage::idProperty() // even if the notify signal for "blah" is not called "blahChanged" void tst_qdeclarativelanguage::autoNotifyConnection() { - QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoNotifyConnection.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -688,7 +674,7 @@ void tst_qdeclarativelanguage::autoNotifyConnection() // Tests that signals can be assigned to void tst_qdeclarativelanguage::assignSignal() { - QDeclarativeComponent component(&engine, TEST_FILE("assignSignal.qml")); + QDeclarativeComponent component(&engine, testFileUrl("assignSignal.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -701,7 +687,7 @@ void tst_qdeclarativelanguage::assignSignal() // Tests the creation and assignment of dynamic properties void tst_qdeclarativelanguage::dynamicProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -710,7 +696,7 @@ void tst_qdeclarativelanguage::dynamicProperties() QCOMPARE(object->property("doubleProperty"), QVariant(-10.1)); QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9)); QCOMPARE(object->property("stringProperty"), QVariant("Hello World!")); - QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml"))); + QCOMPARE(object->property("urlProperty"), QVariant(testFileUrl("main.qml"))); QCOMPARE(object->property("colorProperty"), QVariant(QColor("red"))); QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2))); QCOMPARE(object->property("varProperty"), QVariant("Hello World!")); @@ -719,7 +705,7 @@ void tst_qdeclarativelanguage::dynamicProperties() // Test that nested types can use dynamic properties void tst_qdeclarativelanguage::dynamicPropertiesNested() { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicPropertiesNested.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -735,7 +721,7 @@ void tst_qdeclarativelanguage::dynamicPropertiesNested() // Tests the creation and assignment to dynamic list properties void tst_qdeclarativelanguage::listProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("listProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -748,7 +734,7 @@ void tst_qdeclarativelanguage::listProperties() void tst_qdeclarativelanguage::dynamicObjectProperties() { { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicObjectProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -757,7 +743,7 @@ void tst_qdeclarativelanguage::dynamicObjectProperties() QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); } { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicObjectProperties.2.qml")); QEXPECT_FAIL("", "QTBUG-10822", Abort); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -772,7 +758,7 @@ void tst_qdeclarativelanguage::dynamicSignalsAndSlots() { QTest::ignoreMessage(QtDebugMsg, "1921"); - QDeclarativeComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicSignalsAndSlots.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -788,7 +774,7 @@ void tst_qdeclarativelanguage::dynamicSignalsAndSlots() void tst_qdeclarativelanguage::simpleBindings() { - QDeclarativeComponent component(&engine, TEST_FILE("simpleBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("simpleBindings.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -801,7 +787,7 @@ void tst_qdeclarativelanguage::simpleBindings() void tst_qdeclarativelanguage::autoComponentCreation() { - QDeclarativeComponent component(&engine, TEST_FILE("autoComponentCreation.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoComponentCreation.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -814,7 +800,7 @@ void tst_qdeclarativelanguage::autoComponentCreation() void tst_qdeclarativelanguage::propertyValueSource() { { - QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.qml")); + QDeclarativeComponent component(&engine, testFileUrl("propertyValueSource.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -835,7 +821,7 @@ void tst_qdeclarativelanguage::propertyValueSource() } { - QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("propertyValueSource.2.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -858,7 +844,7 @@ void tst_qdeclarativelanguage::propertyValueSource() void tst_qdeclarativelanguage::attachedProperties() { - QDeclarativeComponent component(&engine, TEST_FILE("attachedProperties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("attachedProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -871,7 +857,7 @@ void tst_qdeclarativelanguage::attachedProperties() // Tests non-static object properties void tst_qdeclarativelanguage::dynamicObjects() { - QDeclarativeComponent component(&engine, TEST_FILE("dynamicObject.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dynamicObject.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -880,7 +866,7 @@ void tst_qdeclarativelanguage::dynamicObjects() // Tests the registration of custom variant string converters void tst_qdeclarativelanguage::customVariantTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("customVariantTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("customVariantTypes.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -889,7 +875,7 @@ void tst_qdeclarativelanguage::customVariantTypes() void tst_qdeclarativelanguage::valueTypes() { - QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("valueTypes.qml")); VERIFY_ERRORS(0); QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\""; @@ -925,7 +911,7 @@ void tst_qdeclarativelanguage::valueTypes() void tst_qdeclarativelanguage::cppnamespace() { { - QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.qml")); + QDeclarativeComponent component(&engine, testFileUrl("cppnamespace.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -933,7 +919,7 @@ void tst_qdeclarativelanguage::cppnamespace() } { - QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("cppnamespace.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -945,7 +931,7 @@ void tst_qdeclarativelanguage::aliasProperties() { // Simple "int" alias { - QDeclarativeComponent component(&engine, TEST_FILE("alias.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -965,7 +951,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Complex object alias { - QDeclarativeComponent component(&engine, TEST_FILE("alias.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -990,7 +976,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Nested aliases { - QDeclarativeComponent component(&engine, TEST_FILE("alias.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.3.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1011,7 +997,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Enum aliases { - QDeclarativeComponent component(&engine, TEST_FILE("alias.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.4.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1023,7 +1009,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Id aliases { - QDeclarativeComponent component(&engine, TEST_FILE("alias.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.5.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1045,7 +1031,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Nested aliases - this used to cause a crash { - QDeclarativeComponent component(&engine, TEST_FILE("alias.6.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.6.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1056,7 +1042,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Ptr Alias Cleanup - check that aliases to ptr types return 0 // if the object aliased to is removed { - QDeclarativeComponent component(&engine, TEST_FILE("alias.7.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.7.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1082,7 +1068,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Simple composite type { - QDeclarativeComponent component(&engine, TEST_FILE("alias.8.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.8.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1094,7 +1080,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Complex composite type { - QDeclarativeComponent component(&engine, TEST_FILE("alias.9.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.9.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1107,7 +1093,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Valuetype alias // Simple "int" alias { - QDeclarativeComponent component(&engine, TEST_FILE("alias.10.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.10.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1127,7 +1113,7 @@ void tst_qdeclarativelanguage::aliasProperties() // Valuetype sub-alias { - QDeclarativeComponent component(&engine, TEST_FILE("alias.11.qml")); + QDeclarativeComponent component(&engine, testFileUrl("alias.11.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1149,7 +1135,7 @@ void tst_qdeclarativelanguage::aliasProperties() // QTBUG-13374 Test that alias properties and signals can coexist void tst_qdeclarativelanguage::aliasPropertiesAndSignals() { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertiesAndSignals.qml")); VERIFY_ERRORS(0); QObject *o = component.create(); QVERIFY(o); @@ -1160,7 +1146,7 @@ void tst_qdeclarativelanguage::aliasPropertiesAndSignals() // Test that the root element in a composite type can be a Component void tst_qdeclarativelanguage::componentCompositeType() { - QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml")); + QDeclarativeComponent component(&engine, testFileUrl("componentCompositeType.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1194,7 +1180,7 @@ void tst_qdeclarativelanguage::i18n() { QFETCH(QString, file); QFETCH(QString, stringProperty); - QDeclarativeComponent component(&engine, TEST_FILE(file)); + QDeclarativeComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1206,7 +1192,7 @@ void tst_qdeclarativelanguage::i18n() // Check that the Component::onCompleted attached property works void tst_qdeclarativelanguage::onCompleted() { - QDeclarativeComponent component(&engine, TEST_FILE("onCompleted.qml")); + QDeclarativeComponent component(&engine, testFileUrl("onCompleted.qml")); VERIFY_ERRORS(0); QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); @@ -1218,7 +1204,7 @@ void tst_qdeclarativelanguage::onCompleted() // Check that the Component::onDestruction attached property works void tst_qdeclarativelanguage::onDestruction() { - QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml")); + QDeclarativeComponent component(&engine, testFileUrl("onDestruction.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1233,7 +1219,7 @@ void tst_qdeclarativelanguage::onDestruction() void tst_qdeclarativelanguage::scriptString() { { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptString.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); @@ -1249,7 +1235,7 @@ void tst_qdeclarativelanguage::scriptString() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptString2.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); @@ -1258,7 +1244,7 @@ void tst_qdeclarativelanguage::scriptString() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptString3.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); @@ -1267,7 +1253,7 @@ void tst_qdeclarativelanguage::scriptString() } { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptString4.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); @@ -1280,7 +1266,7 @@ void tst_qdeclarativelanguage::scriptString() // property assignments void tst_qdeclarativelanguage::defaultPropertyListOrder() { - QDeclarativeComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml")); + QDeclarativeComponent component(&engine, testFileUrl("defaultPropertyListOrder.qml")); VERIFY_ERRORS(0); MyContainer *container = qobject_cast(component.create()); @@ -1297,13 +1283,13 @@ void tst_qdeclarativelanguage::defaultPropertyListOrder() void tst_qdeclarativelanguage::declaredPropertyValues() { - QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml")); + QDeclarativeComponent component(&engine, testFileUrl("declaredPropertyValues.qml")); VERIFY_ERRORS(0); } void tst_qdeclarativelanguage::dontDoubleCallClassBegin() { - QDeclarativeComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml")); + QDeclarativeComponent component(&engine, testFileUrl("dontDoubleCallClassBegin.qml")); QObject *o = component.create(); QVERIFY(o); @@ -1393,7 +1379,7 @@ void tst_qdeclarativelanguage::reservedWords() void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror) { QDeclarativeComponent component(&engine); - component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports + component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports QTRY_VERIFY(!component.isLoading()); @@ -1417,7 +1403,7 @@ void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, // QTBUG-17276 void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings() { - QDeclarativeComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("inlineAssignmentsOverrideBindings.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -1428,7 +1414,7 @@ void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings() // QTBUG-19354 void tst_qdeclarativelanguage::nestedComponentRoots() { - QDeclarativeComponent component(&engine, TEST_FILE("nestedComponentRoots.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nestedComponentRoots.qml")); } // Import tests (QT-558) @@ -1631,7 +1617,7 @@ void tst_qdeclarativelanguage::basicRemote() QFETCH(QString, error); TestHTTPServer server(14447); - server.serveDirectory(SRCDIR); + server.serveDirectory(directory()); QDeclarativeComponent component(&engine, url); @@ -1675,7 +1661,7 @@ void tst_qdeclarativelanguage::importsRemote() QFETCH(QString, error); TestHTTPServer server(14447); - server.serveDirectory(SRCDIR); + server.serveDirectory(directory()); testType(qml,type,error); } @@ -1830,7 +1816,7 @@ void tst_qdeclarativelanguage::importsOrder() void tst_qdeclarativelanguage::importIncorrectCase() { - QDeclarativeComponent component(&engine, TEST_FILE("importIncorrectCase.qml")); + QDeclarativeComponent component(&engine, testFileUrl("importIncorrectCase.qml")); QList errors = component.errors(); QCOMPARE(errors.count(), 1); @@ -1852,7 +1838,7 @@ void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() QCOMPARE(qmlAttachedPropertiesObject(&object, true), (QObject *)0); { - QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qmlAttachedPropertiesObjectMethod.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1862,7 +1848,7 @@ void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() } { - QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qmlAttachedPropertiesObjectMethod.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -1880,13 +1866,13 @@ void tst_qdeclarativelanguage::crash1() void tst_qdeclarativelanguage::crash2() { - QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("crash2.qml")); } // QTBUG-8676 void tst_qdeclarativelanguage::customOnProperty() { - QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("customOnProperty.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1900,7 +1886,7 @@ void tst_qdeclarativelanguage::customOnProperty() // QTBUG-12601 void tst_qdeclarativelanguage::variantNotify() { - QDeclarativeComponent component(&engine, TEST_FILE("variantNotify.qml")); + QDeclarativeComponent component(&engine, testFileUrl("variantNotify.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1914,7 +1900,7 @@ void tst_qdeclarativelanguage::variantNotify() void tst_qdeclarativelanguage::revisions() { { - QDeclarativeComponent component(&engine, TEST_FILE("revisions11.qml")); + QDeclarativeComponent component(&engine, testFileUrl("revisions11.qml")); VERIFY_ERRORS(0); MyRevisionedClass *object = qobject_cast(component.create()); @@ -1926,7 +1912,7 @@ void tst_qdeclarativelanguage::revisions() } { QDeclarativeEngine myEngine; - QDeclarativeComponent component(&myEngine, TEST_FILE("revisionssub11.qml")); + QDeclarativeComponent component(&myEngine, testFileUrl("revisionssub11.qml")); VERIFY_ERRORS(0); MyRevisionedSubclass *object = qobject_cast(component.create()); @@ -1940,7 +1926,7 @@ void tst_qdeclarativelanguage::revisions() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("versionedbase.qml")); + QDeclarativeComponent component(&engine, testFileUrl("versionedbase.qml")); VERIFY_ERRORS(0); MySubclass *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -1955,11 +1941,11 @@ void tst_qdeclarativelanguage::revisions() void tst_qdeclarativelanguage::revisionOverloads() { { - QDeclarativeComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml")); + QDeclarativeComponent component(&engine, testFileUrl("allowedRevisionOverloads.qml")); VERIFY_ERRORS(0); } { - QDeclarativeComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml")); + QDeclarativeComponent component(&engine, testFileUrl("disallowedRevisionOverloads.qml")); QEXPECT_FAIL("", "QTBUG-13849", Abort); QVERIFY(0); VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt"); @@ -1968,6 +1954,7 @@ void tst_qdeclarativelanguage::revisionOverloads() void tst_qdeclarativelanguage::initTestCase() { + QDeclarativeDataTest::initTestCase(); registerTypes(); // Registering the TestType class in other modules should have no adverse effects @@ -1987,9 +1974,9 @@ void tst_qdeclarativelanguage::initTestCase() // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded - QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile()); + QFile in(testFileUrl(QLatin1String("I18nType30.qml")).toLocalFile()); QVERIFY(in.open(QIODevice::ReadOnly)); - QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()); + QFile out(testFileUrl(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()); QVERIFY(out.open(QIODevice::WriteOnly)); out.write(in.readAll()); } @@ -1997,7 +1984,7 @@ void tst_qdeclarativelanguage::initTestCase() void tst_qdeclarativelanguage::aliasPropertyChangeSignals() { { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyChangeSignals.qml")); VERIFY_ERRORS(0); QObject *o = component.create(); @@ -2010,7 +1997,7 @@ void tst_qdeclarativelanguage::aliasPropertyChangeSignals() // QTCREATORBUG-2769 { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyChangeSignals.2.qml")); VERIFY_ERRORS(0); QObject *o = component.create(); diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro index cc87f2d5..b2c2222c 100644 --- a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro +++ b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro @@ -7,5 +7,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistreference.cpp +include(../shared/qdeclarativedatatest.pri) + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp index 8681592d..3925b5a6 100644 --- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp +++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -50,18 +51,7 @@ #include #include -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename)); -} - -inline QUrl TEST_FILE(const char *filename) -{ - return TEST_FILE(QLatin1String(filename)); -} - -class tst_qdeclarativelistreference : public QObject +class tst_qdeclarativelistreference : public QDeclarativeDataTest { Q_OBJECT public: @@ -105,6 +95,7 @@ public: void tst_qdeclarativelistreference::initTestCase() { + QDeclarativeDataTest::initTestCase(); qmlRegisterType(); } @@ -540,7 +531,7 @@ void tst_qdeclarativelistreference::qmlmetaproperty() void tst_qdeclarativelistreference::engineTypes() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("engineTypes.qml")); + QDeclarativeComponent component(&engine, testFileUrl("engineTypes.qml")); QObject *o = component.create(); QVERIFY(o); @@ -563,7 +554,7 @@ void tst_qdeclarativelistreference::engineTypes() void tst_qdeclarativelistreference::variantToList() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("variantToList.qml")); + QDeclarativeComponent component(&engine, testFileUrl("variantToList.qml")); QObject *o = component.create(); QVERIFY(o); diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro index 7d092524..6d37ce06 100644 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro @@ -5,18 +5,11 @@ QT += testlib contains(QT_CONFIG,quick1): QT += quick1 quick1-private gui network widgets macx:CONFIG -= app_bundle -INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeloader.cpp \ ../shared/testhttpserver.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index d0142a67..37f496a6 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include @@ -50,17 +51,7 @@ #define SERVER_PORT 14450 -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -class tst_QDeclarativeLoader : public QObject +class tst_QDeclarativeLoader : public QDeclarativeDataTest { Q_OBJECT @@ -128,7 +119,7 @@ void tst_QDeclarativeLoader::sourceOrComponent() " onProgressChanged: onProgressChangedCount += 1\n" " onLoaded: onLoadedCount += 1\n" "}") - , TEST_FILE("")); + , testFileUrl("")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); @@ -161,11 +152,18 @@ void tst_QDeclarativeLoader::sourceOrComponent_data() QTest::addColumn("sourceUrl"); QTest::addColumn("errorString"); - QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << ""; - QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; - - QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml") - << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found"); + QTest::newRow("source") + << "source: 'Rect120x60.qml'\n" + << testFileUrl("Rect120x60.qml") << QString(); + QTest::newRow("sourceComponent") + << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" + << QUrl() << QString(); + + QTest::newRow("invalid source") + << "source: 'IDontExist.qml'\n" + << testFileUrl("IDontExist.qml") + << (testFileUrl("IDontExist.qml").toString() + + QStringLiteral(": File not found")); } void tst_QDeclarativeLoader::clear() @@ -178,7 +176,7 @@ void tst_QDeclarativeLoader::clear() " source: 'Rect120x60.qml'\n" " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" " }") - , TEST_FILE("")); + , testFileUrl("")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); @@ -193,7 +191,7 @@ void tst_QDeclarativeLoader::clear() delete loader; } { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -213,7 +211,7 @@ void tst_QDeclarativeLoader::clear() delete item; } { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -244,7 +242,7 @@ void tst_QDeclarativeLoader::urlToComponent() " source: \"Rect120x60.qml\"\n" " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" "}" ) - , TEST_FILE("")); + , testFileUrl("")); QDeclarativeLoader *loader = qobject_cast(component.create()); QTest::qWait(200); QTRY_VERIFY(loader != 0); @@ -259,7 +257,7 @@ void tst_QDeclarativeLoader::urlToComponent() void tst_QDeclarativeLoader::componentToUrl() { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -269,7 +267,7 @@ void tst_QDeclarativeLoader::componentToUrl() QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast(loader)->children().count(), 1); - loader->setSource(TEST_FILE("/Rect120x60.qml")); + loader->setSource(testFileUrl("/Rect120x60.qml")); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast(loader)->children().count(), 1); @@ -281,7 +279,7 @@ void tst_QDeclarativeLoader::componentToUrl() void tst_QDeclarativeLoader::anchoredLoader() { - QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml")); QDeclarativeItem *rootItem = qobject_cast(component.create()); QVERIFY(rootItem != 0); QDeclarativeItem *loader = rootItem->findChild("loader"); @@ -302,7 +300,7 @@ void tst_QDeclarativeLoader::anchoredLoader() void tst_QDeclarativeLoader::sizeLoaderToItem() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 120.0); @@ -343,7 +341,7 @@ void tst_QDeclarativeLoader::sizeLoaderToItem() void tst_QDeclarativeLoader::sizeItemToLoader() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml")); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 200.0); @@ -373,7 +371,7 @@ void tst_QDeclarativeLoader::sizeItemToLoader() void tst_QDeclarativeLoader::noResize() { - QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml")); QDeclarativeItem* item = qobject_cast(component.create()); QVERIFY(item != 0); QCOMPARE(item->width(), 200.0); @@ -384,7 +382,7 @@ void tst_QDeclarativeLoader::noResize() void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeLoaderToGraphicsWidget.qml")); QDeclarativeLoader *loader = qobject_cast(component.create()); QGraphicsScene scene; scene.addItem(loader); @@ -411,7 +409,7 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeGraphicsWidgetToLoader.qml")); QDeclarativeLoader *loader = qobject_cast(component.create()); QGraphicsScene scene; scene.addItem(loader); @@ -443,7 +441,7 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() void tst_QDeclarativeLoader::noResizeGraphicsWidget() { - QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/NoResizeGraphicsWidget.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QGraphicsScene scene; scene.addItem(item); @@ -459,10 +457,11 @@ void tst_QDeclarativeLoader::networkRequestUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); + component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), + QUrl::fromLocalFile(directory() + QStringLiteral("/dummy.qml"))); if (component.isError()) qDebug() << component.errors(); QDeclarativeLoader *loader = qobject_cast(component.create()); @@ -492,7 +491,7 @@ void tst_QDeclarativeLoader::networkComponent() "Item {\n" " Component { id: comp; NW.SlowRect {} }\n" " Loader { sourceComponent: comp } }") - , TEST_FILE("")); + , testFileUrl("")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -514,7 +513,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); + server.serveDirectory(dataDirectory()); QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found"); @@ -536,7 +535,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() // QTBUG-9241 void tst_QDeclarativeLoader::deleteComponentCrash() { - QDeclarativeComponent component(&engine, TEST_FILE("crash.qml")); + QDeclarativeComponent component(&engine, testFileUrl("crash.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -549,15 +548,16 @@ void tst_QDeclarativeLoader::deleteComponentCrash() QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QDeclarativeLoader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); - QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml")); + QVERIFY(loader->source() == testFileUrl("BlueRect.qml")); delete item; } void tst_QDeclarativeLoader::nonItem() { - QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); - QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/nonItem.qml:3:1: QML Loader: Loader does not support loading non-visual elements."; + const QUrl url = testFileUrl("nonItem.qml"); + QDeclarativeComponent component(&engine, url); + QString err =url.toString() + QStringLiteral(":3:1: QML Loader: Loader does not support loading non-visual elements."); QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); QDeclarativeLoader *loader = qobject_cast(component.create()); @@ -569,11 +569,11 @@ void tst_QDeclarativeLoader::nonItem() void tst_QDeclarativeLoader::vmeErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml")); - QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/VmeError.qml:6: Cannot assign object type QObject with no default method"; + QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml")); + QString err = dataDirectoryUrl().toString() + QStringLiteral("VmeError.qml:6: Cannot assign object type QObject with no default method"); QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); QDeclarativeLoader *loader = qobject_cast(component.create()); - QVERIFY(loader); + QVERIFY2(loader, msgComponentError(component).constData()); QVERIFY(loader->item() == 0); delete loader; @@ -582,7 +582,7 @@ void tst_QDeclarativeLoader::vmeErrors() // QTBUG-13481 void tst_QDeclarativeLoader::creationContext() { - QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml")); + QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -594,7 +594,7 @@ void tst_QDeclarativeLoader::creationContext() void tst_QDeclarativeLoader::QTBUG_16928() { - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml")); + QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -606,7 +606,7 @@ void tst_QDeclarativeLoader::QTBUG_16928() void tst_QDeclarativeLoader::implicitSize() { - QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml")); + QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -621,7 +621,7 @@ void tst_QDeclarativeLoader::implicitSize() void tst_QDeclarativeLoader::QTBUG_17114() { - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml")); + QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index b77a36e4..9dc29226 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -51,7 +52,7 @@ #define SERVER_PORT 14450 -class tst_qdeclarativemoduleplugin : public QObject +class tst_qdeclarativemoduleplugin : public QDeclarativeDataTest { Q_OBJECT public: @@ -79,7 +80,7 @@ private slots: QVERIFY(!component.isError()); \ QVERIFY(component.errors().isEmpty()); \ } else { \ - QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ + QFile file(testFile(errorfile)); \ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ QByteArray data = file.readAll(); \ file.close(); \ @@ -97,7 +98,7 @@ private slots: if (qgetenv("DEBUG") != "" && expected != actual) \ qWarning() << "Expected:" << expected << "Actual:" << actual; \ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\ - QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ + QFile file(testFile(errorfile)); \ QVERIFY(file.open(QIODevice::WriteOnly)); \ for (int ii = 0; ii < actual.count(); ++ii) { \ file.write(actual.at(ii)); file.write("\n"); \ @@ -108,20 +109,13 @@ private slots: } \ } -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); -} - - void tst_qdeclarativemoduleplugin::importsPlugin() { QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); QTest::ignoreMessage(QtWarningMsg, "plugin created"); QTest::ignoreMessage(QtWarningMsg, "import worked"); - QDeclarativeComponent component(&engine, TEST_FILE("data/works.qml")); + QDeclarativeComponent component(&engine, testFileUrl("works.qml")); foreach (QDeclarativeError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -134,10 +128,10 @@ void tst_qdeclarativemoduleplugin::importsPlugin() void tst_qdeclarativemoduleplugin::importsPlugin2() { QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); QTest::ignoreMessage(QtWarningMsg, "import2 worked"); - QDeclarativeComponent component(&engine, TEST_FILE("data/works2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("works2.qml")); foreach (QDeclarativeError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -150,10 +144,10 @@ void tst_qdeclarativemoduleplugin::importsPlugin2() void tst_qdeclarativemoduleplugin::importsPlugin21() { QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); - QDeclarativeComponent component(&engine, TEST_FILE("data/works21.qml")); + QDeclarativeComponent component(&engine, testFileUrl("works21.qml")); foreach (QDeclarativeError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -166,9 +160,9 @@ void tst_qdeclarativemoduleplugin::importsPlugin21() void tst_qdeclarativemoduleplugin::incorrectPluginCase() { QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); - QDeclarativeComponent component(&engine, TEST_FILE("data/incorrectCase.qml")); + QDeclarativeComponent component(&engine, testFileUrl("incorrectCase.qml")); QList errors = component.errors(); QCOMPARE(errors.count(), 1); @@ -189,7 +183,7 @@ void tst_qdeclarativemoduleplugin::incorrectPluginCase() void tst_qdeclarativemoduleplugin::importPluginWithQmlFile() { - QString path = QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"); + QString path = directory() + QDir::separator() + QLatin1String("imports"); // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure // (this only happens if the plugin includes pure QML files) @@ -201,7 +195,7 @@ void tst_qdeclarativemoduleplugin::importPluginWithQmlFile() QDeclarativeEngine engine; engine.addImportPath(path); - QDeclarativeComponent component(&engine, TEST_FILE("data/pluginWithQmlFile.qml")); + QDeclarativeComponent component(&engine, testFileUrl("pluginWithQmlFile.qml")); foreach (QDeclarativeError err, component.errors()) qWarning() << err; VERIFY_ERRORS(0); @@ -214,7 +208,7 @@ void tst_qdeclarativemoduleplugin::remoteImportWithQuotedUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/imports"); + server.serveDirectory(directory() + QStringLiteral("/imports")); QDeclarativeEngine engine; QDeclarativeComponent component(&engine); @@ -235,10 +229,10 @@ void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/imports"); + server.serveDirectory(directory() + QStringLiteral("/imports")); QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); QDeclarativeComponent component(&engine); component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl()); @@ -258,19 +252,19 @@ void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri() void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin() { QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); { - QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.qml")); + QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.qml")); QObject *o = component.create(); - QVERIFY(o != 0); + QVERIFY2(o, msgComponentError(component, &engine).constData()); QCOMPARE(o->property("test").toBool(), true); delete o; } { - QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.2.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -287,8 +281,8 @@ void tst_qdeclarativemoduleplugin::versionNotInstalled_data() QTest::addColumn("file"); QTest::addColumn("errorFile"); - QTest::newRow("versionNotInstalled") << "data/versionNotInstalled.qml" << "versionNotInstalled.errors.txt"; - QTest::newRow("versionNotInstalled") << "data/versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt"; + QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt"; + QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt"; } void tst_qdeclarativemoduleplugin::versionNotInstalled() @@ -297,9 +291,9 @@ void tst_qdeclarativemoduleplugin::versionNotInstalled() QFETCH(QString, errorFile); QDeclarativeEngine engine; - engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + engine.addImportPath(directory() + QDir::separator() + QLatin1String("imports")); - QDeclarativeComponent component(&engine, TEST_FILE(file)); + QDeclarativeComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(errorFile.toLatin1().constData()); } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index 79116058..0bec2015 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -8,10 +8,4 @@ HEADERS = ../shared/testhttpserver.h SOURCES = tst_qdeclarativemoduleplugin.cpp \ ../shared/testhttpserver.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 6c4d5604..09f93288 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -7,13 +7,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 4fb519f5..e906dfb0 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -48,17 +49,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename)); -} - class MyQmlObject : public QObject { Q_OBJECT @@ -66,7 +56,7 @@ public: MyQmlObject() {} }; -QML_DECLARE_TYPE(MyQmlObject); +QML_DECLARE_TYPE(MyQmlObject) class MyAttached : public QObject { @@ -99,10 +89,10 @@ private: QList m_children; }; -QML_DECLARE_TYPE(MyContainer); +QML_DECLARE_TYPE(MyContainer) QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) -class tst_qdeclarativeproperty : public QObject +class tst_qdeclarativeproperty : public QDeclarativeDataTest { Q_OBJECT public: @@ -1004,7 +994,7 @@ void tst_qdeclarativeproperty::read() QVERIFY(qvariant_cast(v) == o.qmlObject()); } { - QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1019,7 +1009,7 @@ void tst_qdeclarativeproperty::read() QCOMPARE(qvariant_cast(v)->property("b").toInt(), 19); } { // static - QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1374,7 +1364,7 @@ void tst_qdeclarativeproperty::crashOnValueProperty() // QTBUG-13719 void tst_qdeclarativeproperty::aliasPropertyBindings() { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyBindings.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1483,6 +1473,7 @@ void tst_qdeclarativeproperty::copy() void tst_qdeclarativeproperty::initTestCase() { + QDeclarativeDataTest::initTestCase(); qmlRegisterType("Test",1,0,"MyQmlObject"); qmlRegisterType("Test",1,0,"PropertyObject"); qmlRegisterType("Test",1,0,"MyContainer"); diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro index 613188e4..9442f672 100644 --- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro +++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro @@ -6,13 +6,7 @@ contains(QT_CONFIG,quick1): QT += quick1 quick1-private script script-private co SOURCES += tst_qdeclarativeqt.cpp macx:CONFIG -= app_bundle -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 38c7d90f..6cf6ccec 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -53,12 +54,7 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -class tst_qdeclarativeqt : public QObject +class tst_qdeclarativeqt : public QDeclarativeDataTest { Q_OBJECT public: @@ -94,14 +90,9 @@ private: QDeclarativeEngine engine; }; -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - void tst_qdeclarativeqt::enums() { - QDeclarativeComponent component(&engine, TEST_FILE("enums.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -115,7 +106,7 @@ void tst_qdeclarativeqt::enums() void tst_qdeclarativeqt::rgba() { - QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rgba.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments"; @@ -138,7 +129,7 @@ void tst_qdeclarativeqt::rgba() void tst_qdeclarativeqt::hsla() { - QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml")); + QDeclarativeComponent component(&engine, testFileUrl("hsla.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments"; @@ -160,7 +151,7 @@ void tst_qdeclarativeqt::hsla() void tst_qdeclarativeqt::rect() { - QDeclarativeComponent component(&engine, TEST_FILE("rect.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rect.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments"; @@ -181,7 +172,7 @@ void tst_qdeclarativeqt::rect() void tst_qdeclarativeqt::point() { - QDeclarativeComponent component(&engine, TEST_FILE("point.qml")); + QDeclarativeComponent component(&engine, testFileUrl("point.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments"; @@ -201,7 +192,7 @@ void tst_qdeclarativeqt::point() void tst_qdeclarativeqt::size() { - QDeclarativeComponent component(&engine, TEST_FILE("size.qml")); + QDeclarativeComponent component(&engine, testFileUrl("size.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments"; QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments"; @@ -222,7 +213,7 @@ void tst_qdeclarativeqt::size() void tst_qdeclarativeqt::vector() { - QDeclarativeComponent component(&engine, TEST_FILE("vector.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments"; @@ -242,7 +233,7 @@ void tst_qdeclarativeqt::vector() void tst_qdeclarativeqt::lighter() { - QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); + QDeclarativeComponent component(&engine, testFileUrl("lighter.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments"; @@ -264,7 +255,7 @@ void tst_qdeclarativeqt::lighter() void tst_qdeclarativeqt::darker() { - QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); + QDeclarativeComponent component(&engine, testFileUrl("darker.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments"; @@ -286,7 +277,7 @@ void tst_qdeclarativeqt::darker() void tst_qdeclarativeqt::tint() { - QDeclarativeComponent component(&engine, TEST_FILE("tint.qml")); + QDeclarativeComponent component(&engine, testFileUrl("tint.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments"; QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments"; @@ -326,7 +317,7 @@ void tst_qdeclarativeqt::openUrlExternally() QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler("file", &handler, "noteCall"); - QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally.qml")); + QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(handler.called,1); @@ -335,7 +326,7 @@ void tst_qdeclarativeqt::openUrlExternally() object->setProperty("testFile", true); QCOMPARE(handler.called,2); - QCOMPARE(handler.last, TEST_FILE("test.html")); + QCOMPARE(handler.last, testFileUrl("test.html")); QDesktopServices::unsetUrlHandler("test"); QDesktopServices::unsetUrlHandler("file"); @@ -348,7 +339,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler("file", &handler, "noteCall"); - QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally_lib.qml")); + QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(handler.called,1); @@ -357,7 +348,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() object->setProperty("testFile", true); QCOMPARE(handler.called,2); - QCOMPARE(handler.last, TEST_FILE("test.html")); + QCOMPARE(handler.last, testFileUrl("test.html")); QDesktopServices::unsetUrlHandler("test"); QDesktopServices::unsetUrlHandler("file"); @@ -365,7 +356,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() void tst_qdeclarativeqt::md5() { - QDeclarativeComponent component(&engine, TEST_FILE("md5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("md5.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -380,7 +371,7 @@ void tst_qdeclarativeqt::md5() void tst_qdeclarativeqt::createComponent() { - QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createComponent.qml")); QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments"; @@ -391,7 +382,7 @@ void tst_qdeclarativeqt::createComponent() QVERIFY(object != 0); QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); - QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString()); + QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString()); delete object; } @@ -399,7 +390,7 @@ void tst_qdeclarativeqt::createComponent() void tst_qdeclarativeqt::createComponent_pragmaLibrary() { // Currently, just loading createComponent_lib.qml causes crash on some platforms - QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createComponent_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); @@ -409,14 +400,14 @@ void tst_qdeclarativeqt::createComponent_pragmaLibrary() void tst_qdeclarativeqt::createQmlObject() { - QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createQmlObject.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments"; - QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n"; - QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n"; + QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject() failed to create object: " + testFileUrl("inline").toString() + ":2:10: Blah is not a type\n"; + QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject() failed to create object: " + testFileUrl("main.qml").toString() + ":4:1: Duplicate property name\n"; QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object"; QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments"; - QString warning6 = "RunTimeError: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n"; + QString warning6 = "RunTimeError: Qt.createQmlObject() failed to create object: " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method\n"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -442,7 +433,7 @@ void tst_qdeclarativeqt::consoleLog() { QTest::ignoreMessage(QtDebugMsg, "completed ok"); QTest::ignoreMessage(QtDebugMsg, "completed ok"); - QDeclarativeComponent component(&engine, TEST_FILE("consoleLog.qml")); + QDeclarativeComponent component(&engine, testFileUrl("consoleLog.qml")); QObject *object = component.create(); QVERIFY(object != 0); delete object; @@ -464,7 +455,7 @@ void tst_qdeclarativeqt::dateTimeFormatting() eng.rootContext()->setContextProperty("qtime", time); eng.rootContext()->setContextProperty("qdatetime", dateTime); - QDeclarativeComponent component(&eng, TEST_FILE("formatting.qml")); + QDeclarativeComponent component(&eng, testFileUrl("formatting.qml")); QStringList warnings; warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format" @@ -532,7 +523,7 @@ void tst_qdeclarativeqt::dateTimeFormatting_data() void tst_qdeclarativeqt::isQtObject() { - QDeclarativeComponent component(&engine, TEST_FILE("isQtObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("isQtObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -547,7 +538,7 @@ void tst_qdeclarativeqt::isQtObject() void tst_qdeclarativeqt::btoa() { - QDeclarativeComponent component(&engine, TEST_FILE("btoa.qml")); + QDeclarativeComponent component(&engine, testFileUrl("btoa.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -562,7 +553,7 @@ void tst_qdeclarativeqt::btoa() void tst_qdeclarativeqt::atob() { - QDeclarativeComponent component(&engine, TEST_FILE("atob.qml")); + QDeclarativeComponent component(&engine, testFileUrl("atob.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -577,7 +568,7 @@ void tst_qdeclarativeqt::atob() void tst_qdeclarativeqt::fontFamilies() { - QDeclarativeComponent component(&engine, TEST_FILE("fontFamilies.qml")); + QDeclarativeComponent component(&engine, testFileUrl("fontFamilies.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -593,7 +584,7 @@ void tst_qdeclarativeqt::fontFamilies() void tst_qdeclarativeqt::quit() { - QDeclarativeComponent component(&engine, TEST_FILE("quit.qml")); + QDeclarativeComponent component(&engine, testFileUrl("quit.qml")); QSignalSpy spy(&engine, SIGNAL(quit())); QObject *object = component.create(); diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro index dcedb155..45a77c61 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro @@ -7,12 +7,6 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativerepeater.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 9a51acbe..0caf944e 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include #include #include @@ -49,17 +50,7 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -class tst_QDeclarativeRepeater : public QObject +class tst_QDeclarativeRepeater : public QDeclarativeDataTest { Q_OBJECT public: @@ -185,7 +176,7 @@ void tst_QDeclarativeRepeater::numberModel() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml")); + canvas->setSource(testFileUrl("intmodel.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -226,7 +217,7 @@ void tst_QDeclarativeRepeater::objectList() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", QVariant::fromValue(data)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml")); + canvas->setSource(testFileUrl("objlist.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -267,7 +258,7 @@ void tst_QDeclarativeRepeater::stringList() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", data); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); + canvas->setSource(testFileUrl("repeater1.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -315,7 +306,7 @@ void tst_QDeclarativeRepeater::dataModel_adding() TestModel testModel; ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -383,7 +374,7 @@ void tst_QDeclarativeRepeater::dataModel_removing() testModel.addItem("five", "5"); ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -449,7 +440,7 @@ void tst_QDeclarativeRepeater::dataModel_changes() testModel.addItem("three", "3"); ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -483,7 +474,7 @@ void tst_QDeclarativeRepeater::itemModel() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); + canvas->setSource(testFileUrl("itemlist.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); @@ -527,7 +518,7 @@ void tst_QDeclarativeRepeater::resetModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", dataA); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); + canvas->setSource(testFileUrl("repeater1.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); @@ -584,7 +575,7 @@ void tst_QDeclarativeRepeater::resetModel() void tst_QDeclarativeRepeater::modelChanged() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("/modelChanged.qml")); + QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml")); QDeclarativeItem *rootObject = qobject_cast(component.create()); QVERIFY(rootObject); @@ -607,7 +598,7 @@ void tst_QDeclarativeRepeater::modelChanged() void tst_QDeclarativeRepeater::properties() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("properties.qml")); QDeclarativeItem *rootObject = qobject_cast(component.create()); QVERIFY(rootObject); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro index f2193bc9..ff64bb25 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro +++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro @@ -10,13 +10,7 @@ HEADERS += testtypes.h SOURCES += tst_qdeclarativevaluetypes.cpp \ testtypes.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 9d39c2bb..ea87d7ac 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -45,17 +45,13 @@ #include #include #include "testtypes.h" - -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif +#include QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE -class tst_qdeclarativevaluetypes : public QObject +class tst_qdeclarativevaluetypes : public QDeclarativeDataTest { Q_OBJECT public: @@ -103,18 +99,14 @@ private: void tst_qdeclarativevaluetypes::initTestCase() { + QDeclarativeDataTest::initTestCase(); registerTypes(); } -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - void tst_qdeclarativevaluetypes::point() { { - QDeclarativeComponent component(&engine, TEST_FILE("point_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("point_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -126,7 +118,7 @@ void tst_qdeclarativevaluetypes::point() } { - QDeclarativeComponent component(&engine, TEST_FILE("point_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("point_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -139,7 +131,7 @@ void tst_qdeclarativevaluetypes::point() void tst_qdeclarativevaluetypes::pointf() { { - QDeclarativeComponent component(&engine, TEST_FILE("pointf_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("pointf_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -151,7 +143,7 @@ void tst_qdeclarativevaluetypes::pointf() } { - QDeclarativeComponent component(&engine, TEST_FILE("pointf_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("pointf_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -164,7 +156,7 @@ void tst_qdeclarativevaluetypes::pointf() void tst_qdeclarativevaluetypes::size() { { - QDeclarativeComponent component(&engine, TEST_FILE("size_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("size_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -176,7 +168,7 @@ void tst_qdeclarativevaluetypes::size() } { - QDeclarativeComponent component(&engine, TEST_FILE("size_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("size_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -189,7 +181,7 @@ void tst_qdeclarativevaluetypes::size() void tst_qdeclarativevaluetypes::sizef() { { - QDeclarativeComponent component(&engine, TEST_FILE("sizef_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizef_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -201,7 +193,7 @@ void tst_qdeclarativevaluetypes::sizef() } { - QDeclarativeComponent component(&engine, TEST_FILE("sizef_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizef_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -213,7 +205,7 @@ void tst_qdeclarativevaluetypes::sizef() void tst_qdeclarativevaluetypes::variant() { - QDeclarativeComponent component(&engine, TEST_FILE("variant_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("variant_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -227,7 +219,7 @@ void tst_qdeclarativevaluetypes::variant() void tst_qdeclarativevaluetypes::sizereadonly() { { - QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -239,25 +231,25 @@ void tst_qdeclarativevaluetypes::sizereadonly() } { - QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml")); QVERIFY(component.isError()); QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); } { - QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml")); QVERIFY(component.isError()); QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); } { - QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml")); QVERIFY(component.isError()); QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); } { - QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml")); QObject *object = component.create(); QVERIFY(object); @@ -271,7 +263,7 @@ void tst_qdeclarativevaluetypes::sizereadonly() void tst_qdeclarativevaluetypes::rect() { { - QDeclarativeComponent component(&engine, TEST_FILE("rect_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rect_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -285,7 +277,7 @@ void tst_qdeclarativevaluetypes::rect() } { - QDeclarativeComponent component(&engine, TEST_FILE("rect_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rect_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -298,7 +290,7 @@ void tst_qdeclarativevaluetypes::rect() void tst_qdeclarativevaluetypes::rectf() { { - QDeclarativeComponent component(&engine, TEST_FILE("rectf_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rectf_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -312,7 +304,7 @@ void tst_qdeclarativevaluetypes::rectf() } { - QDeclarativeComponent component(&engine, TEST_FILE("rectf_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rectf_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -325,7 +317,7 @@ void tst_qdeclarativevaluetypes::rectf() void tst_qdeclarativevaluetypes::vector2d() { { - QDeclarativeComponent component(&engine, TEST_FILE("vector2d_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector2d_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -337,7 +329,7 @@ void tst_qdeclarativevaluetypes::vector2d() } { - QDeclarativeComponent component(&engine, TEST_FILE("vector2d_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector2d_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -350,7 +342,7 @@ void tst_qdeclarativevaluetypes::vector2d() void tst_qdeclarativevaluetypes::vector3d() { { - QDeclarativeComponent component(&engine, TEST_FILE("vector3d_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector3d_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -363,7 +355,7 @@ void tst_qdeclarativevaluetypes::vector3d() } { - QDeclarativeComponent component(&engine, TEST_FILE("vector3d_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector3d_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -376,7 +368,7 @@ void tst_qdeclarativevaluetypes::vector3d() void tst_qdeclarativevaluetypes::vector4d() { { - QDeclarativeComponent component(&engine, TEST_FILE("vector4d_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector4d_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -390,7 +382,7 @@ void tst_qdeclarativevaluetypes::vector4d() } { - QDeclarativeComponent component(&engine, TEST_FILE("vector4d_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector4d_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -403,7 +395,7 @@ void tst_qdeclarativevaluetypes::vector4d() void tst_qdeclarativevaluetypes::quaternion() { { - QDeclarativeComponent component(&engine, TEST_FILE("quaternion_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("quaternion_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -417,7 +409,7 @@ void tst_qdeclarativevaluetypes::quaternion() } { - QDeclarativeComponent component(&engine, TEST_FILE("quaternion_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("quaternion_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -430,7 +422,7 @@ void tst_qdeclarativevaluetypes::quaternion() void tst_qdeclarativevaluetypes::matrix4x4() { { - QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -460,7 +452,7 @@ void tst_qdeclarativevaluetypes::matrix4x4() } { - QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -476,7 +468,7 @@ void tst_qdeclarativevaluetypes::matrix4x4() void tst_qdeclarativevaluetypes::font() { { - QDeclarativeComponent component(&engine, TEST_FILE("font_read.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_read.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -499,7 +491,7 @@ void tst_qdeclarativevaluetypes::font() } { - QDeclarativeComponent component(&engine, TEST_FILE("font_write.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_write.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -532,7 +524,7 @@ void tst_qdeclarativevaluetypes::font() // Test pixelSize { - QDeclarativeComponent component(&engine, TEST_FILE("font_write.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_write.2.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -543,7 +535,7 @@ void tst_qdeclarativevaluetypes::font() // Test pixelSize and pointSize { - QDeclarativeComponent component(&engine, TEST_FILE("font_write.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_write.3.qml")); QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -553,7 +545,7 @@ void tst_qdeclarativevaluetypes::font() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("font_write.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_write.4.qml")); QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -563,7 +555,7 @@ void tst_qdeclarativevaluetypes::font() delete object; } { - QDeclarativeComponent component(&engine, TEST_FILE("font_write.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("font_write.5.qml")); QObject *object = qobject_cast(component.create()); QVERIFY(object != 0); MyTypeObject *object1 = object->findChild("object1"); @@ -581,7 +573,7 @@ void tst_qdeclarativevaluetypes::font() // Test bindings can write to value types void tst_qdeclarativevaluetypes::bindingAssignment() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingAssignment.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingAssignment.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -597,7 +589,7 @@ void tst_qdeclarativevaluetypes::bindingAssignment() // Test bindings can read from value types void tst_qdeclarativevaluetypes::bindingRead() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingRead.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingRead.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -613,7 +605,7 @@ void tst_qdeclarativevaluetypes::bindingRead() // Test static values can assign to value types void tst_qdeclarativevaluetypes::staticAssignment() { - QDeclarativeComponent component(&engine, TEST_FILE("staticAssignment.qml")); + QDeclarativeComponent component(&engine, testFileUrl("staticAssignment.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -625,7 +617,7 @@ void tst_qdeclarativevaluetypes::staticAssignment() // Test scripts can read/write value types void tst_qdeclarativevaluetypes::scriptAccess() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptAccess.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptAccess.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -640,7 +632,7 @@ void tst_qdeclarativevaluetypes::scriptAccess() void tst_qdeclarativevaluetypes::autoBindingRemoval() { { - QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -663,7 +655,7 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() /* { - QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -685,7 +677,7 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() } { - QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -709,7 +701,7 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() // Test that property value sources assign to value types void tst_qdeclarativevaluetypes::valueSources() { - QDeclarativeComponent component(&engine, TEST_FILE("valueSources.qml")); + QDeclarativeComponent component(&engine, testFileUrl("valueSources.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -732,7 +724,7 @@ static void checkNoErrors(QDeclarativeComponent& component) // Test that property value interceptors can be applied to value types void tst_qdeclarativevaluetypes::valueInterceptors() { - QDeclarativeComponent component(&engine, TEST_FILE("valueInterceptors.qml")); + QDeclarativeComponent component(&engine, testFileUrl("valueInterceptors.qml")); MyTypeObject *object = qobject_cast(component.create()); checkNoErrors(component); QVERIFY(object != 0); @@ -749,7 +741,7 @@ void tst_qdeclarativevaluetypes::valueInterceptors() // Test that you can't assign a binding to the "root" value type, and a sub-property void tst_qdeclarativevaluetypes::bindingConflict() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingConflict.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingConflict.qml")); QCOMPARE(component.isError(), true); } @@ -766,7 +758,7 @@ void tst_qdeclarativevaluetypes::bindingConflict() // doesn't crash void tst_qdeclarativevaluetypes::deletedObject() { - QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml")); QTest::ignoreMessage(QtDebugMsg, "Test: 2"); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -784,7 +776,7 @@ void tst_qdeclarativevaluetypes::deletedObject() // Test that value types can be assigned to another value type property in a binding void tst_qdeclarativevaluetypes::bindingVariantCopy() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingVariantCopy.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingVariantCopy.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -796,7 +788,7 @@ void tst_qdeclarativevaluetypes::bindingVariantCopy() // Test that value types can be assigned to another value type property in script void tst_qdeclarativevaluetypes::scriptVariantCopy() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptVariantCopy.qml")); + QDeclarativeComponent component(&engine, testFileUrl("scriptVariantCopy.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -832,7 +824,7 @@ void tst_qdeclarativevaluetypes::cppClasses() void tst_qdeclarativevaluetypes::enums() { { - QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->font().capitalization() == QFont::AllUppercase); @@ -840,7 +832,7 @@ void tst_qdeclarativevaluetypes::enums() } { - QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->font().capitalization() == QFont::AllUppercase); @@ -848,7 +840,7 @@ void tst_qdeclarativevaluetypes::enums() } { - QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.3.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->font().capitalization() == QFont::AllUppercase); @@ -856,7 +848,7 @@ void tst_qdeclarativevaluetypes::enums() } { - QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.4.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->font().capitalization() == QFont::AllUppercase); @@ -864,7 +856,7 @@ void tst_qdeclarativevaluetypes::enums() } { - QDeclarativeComponent component(&engine, TEST_FILE("enums.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.5.qml")); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->font().capitalization() == QFont::AllUppercase); @@ -877,7 +869,7 @@ void tst_qdeclarativevaluetypes::enums() void tst_qdeclarativevaluetypes::conflictingBindings() { { - QDeclarativeComponent component(&engine, TEST_FILE("conflicting.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("conflicting.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -895,7 +887,7 @@ void tst_qdeclarativevaluetypes::conflictingBindings() } { - QDeclarativeComponent component(&engine, TEST_FILE("conflicting.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("conflicting.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -913,7 +905,7 @@ void tst_qdeclarativevaluetypes::conflictingBindings() } { - QDeclarativeComponent component(&engine, TEST_FILE("conflicting.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("conflicting.3.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -933,7 +925,7 @@ void tst_qdeclarativevaluetypes::conflictingBindings() void tst_qdeclarativevaluetypes::returnValues() { - QDeclarativeComponent component(&engine, TEST_FILE("returnValues.qml")); + QDeclarativeComponent component(&engine, testFileUrl("returnValues.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -946,7 +938,7 @@ void tst_qdeclarativevaluetypes::returnValues() void tst_qdeclarativevaluetypes::varAssignment() { - QDeclarativeComponent component(&engine, TEST_FILE("varAssignment.qml")); + QDeclarativeComponent component(&engine, testFileUrl("varAssignment.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -961,7 +953,7 @@ void tst_qdeclarativevaluetypes::varAssignment() void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() { { - QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -971,7 +963,7 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() } { - QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -982,7 +974,7 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() { - QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -992,7 +984,7 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() } { - QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1002,7 +994,7 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() } { - QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml")); QObject *object = component.create(); QVERIFY(object != 0); diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro index f86dcb02..3015d3d8 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -7,13 +7,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeworkerscript.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index ee176f90..b11564cd 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -54,19 +55,7 @@ Q_DECLARE_METATYPE(QScriptValue) -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); -} - - -class tst_QDeclarativeWorkerScript : public QObject +class tst_QDeclarativeWorkerScript : public QDeclarativeDataTest { Q_OBJECT public: @@ -99,7 +88,7 @@ private: void tst_QDeclarativeWorkerScript::source() { - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); const QMetaObject *mo = worker->metaObject(); @@ -109,7 +98,7 @@ void tst_QDeclarativeWorkerScript::source() waitForEchoMessage(worker); QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value(), value); - QUrl source = QUrl::fromLocalFile(SRCDIR "/data/script_fixed_return.js"); + const QUrl source = testFileUrl("script_fixed_return.js"); worker->setSource(source); QCOMPARE(worker->source(), source); QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); @@ -124,7 +113,7 @@ void tst_QDeclarativeWorkerScript::messaging() { QFETCH(QVariant, value); - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -161,7 +150,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendQObjectList() // instances. If objects are sent in a list, they will be sent as 'undefined' // js values. - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -182,7 +171,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendQObjectList() void tst_QDeclarativeWorkerScript::messaging_sendJsObject() { - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -212,7 +201,7 @@ void tst_QDeclarativeWorkerScript::script_with_pragma() { QVariant value(100); - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_pragma.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker_pragma.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -228,7 +217,7 @@ void tst_QDeclarativeWorkerScript::script_with_pragma() void tst_QDeclarativeWorkerScript::script_included() { - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_include.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker_include.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -253,14 +242,14 @@ static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char void tst_QDeclarativeWorkerScript::scriptError_onLoad() { - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onLoad.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml")); QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, - TEST_FILE("data/script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error")); + testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error")); qInstallMsgHandler(previousMsgHandler); qApp->processEvents(); @@ -269,7 +258,7 @@ void tst_QDeclarativeWorkerScript::scriptError_onLoad() void tst_QDeclarativeWorkerScript::scriptError_onCall() { - QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onCall.qml"); + QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onCall.qml")); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); @@ -278,7 +267,7 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall() QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, - TEST_FILE("data/script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); + testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); qInstallMsgHandler(previousMsgHandler); qApp->processEvents(); diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro index 0c1347e2..843528cd 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro @@ -5,19 +5,12 @@ QT += testlib contains(QT_CONFIG,quick1): QT += quick1 network macx:CONFIG -= app_bundle -INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativexmlhttprequest.cpp \ ../shared/testhttpserver.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index 6c584bd9..d8f46cc7 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -48,12 +49,7 @@ #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: @@ -123,15 +119,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); @@ -173,10 +164,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"); @@ -192,7 +183,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); @@ -208,7 +199,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); @@ -224,7 +215,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); @@ -237,7 +228,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); @@ -261,9 +252,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); @@ -290,18 +281,18 @@ void tst_qdeclarativexmlhttprequest::open_data() QTest::addColumn("url"); QTest::addColumn("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); @@ -313,7 +304,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); @@ -326,7 +317,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); @@ -336,7 +327,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); @@ -351,11 +342,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,7 +360,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader() // 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); @@ -413,11 +404,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"); @@ -441,11 +432,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"); @@ -461,7 +452,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); @@ -473,7 +464,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); @@ -485,7 +476,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); @@ -501,11 +492,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"); @@ -520,11 +511,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"); @@ -545,11 +536,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"); @@ -577,7 +568,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"); @@ -598,7 +589,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"); @@ -621,11 +612,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"); @@ -647,12 +638,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"); @@ -683,7 +674,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); @@ -695,7 +686,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); @@ -707,7 +698,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); @@ -722,11 +713,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"); @@ -751,7 +742,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); @@ -763,7 +754,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); @@ -775,7 +766,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); @@ -791,11 +782,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"); @@ -820,8 +811,8 @@ void tst_qdeclarativexmlhttprequest::status_data() QTest::addColumn("replyUrl"); QTest::addColumn("status"); - QTest::newRow("OK") << TEST_FILE("status.200.reply") << 200; - QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << 404; + QTest::newRow("OK") << testFileUrl("status.200.reply") << 200; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404; } void tst_qdeclarativexmlhttprequest::statusText() @@ -831,11 +822,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"); @@ -860,8 +851,8 @@ void tst_qdeclarativexmlhttprequest::statusText_data() QTest::addColumn("replyUrl"); QTest::addColumn("statusText"); - QTest::newRow("OK") << TEST_FILE("status.200.reply") << "OK"; - QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << "Document not found"; + QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK"; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found"; } void tst_qdeclarativexmlhttprequest::responseText() @@ -872,11 +863,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"); @@ -902,9 +893,9 @@ void tst_qdeclarativexmlhttprequest::responseText_data() QTest::addColumn("bodyUrl"); QTest::addColumn("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("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") << ""; } void tst_qdeclarativexmlhttprequest::nonUtf8() @@ -913,7 +904,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); @@ -952,7 +943,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); @@ -980,9 +971,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"); @@ -999,9 +990,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"); @@ -1018,9 +1009,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"); @@ -1041,7 +1032,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); @@ -1055,7 +1046,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); @@ -1069,7 +1060,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); @@ -1083,7 +1074,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); @@ -1097,7 +1088,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); @@ -1111,7 +1102,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); diff --git a/tests/auto/declarative/qmlshadersplugin/data/main.qml b/tests/auto/declarative/qmlshadersplugin/data/main.qml new file mode 100644 index 00000000..135dda7d --- /dev/null +++ b/tests/auto/declarative/qmlshadersplugin/data/main.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + + Rectangle { + width: 300 + height: 300 + + Text { + id: textLabel + text: "Hello World" + anchors.centerIn: parent + font.pixelSize: 48 + } + + ShaderEffectItem { + objectName: "effectItem" + property variant source: ShaderEffectSource { objectName: "effectSource"; sourceItem: textLabel; hideSource: true } + property real wiggleAmount: 0.01 + anchors.fill: textLabel + + SequentialAnimation on wiggleAmount { + loops: Animation.Infinite + NumberAnimation { to: -0.01; duration: 500 } + NumberAnimation { to: 0.01; duration: 500 } + } + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + uniform highp float wiggleAmount; + void main(void) + { + highp vec2 wiggledTexCoord = qt_TexCoord0; + wiggledTexCoord.s += sin(4.0 * 3.141592653589 * wiggledTexCoord.t) * wiggleAmount; + gl_FragColor = texture2D(source, wiggledTexCoord.st); + } + " + } + } diff --git a/tests/auto/declarative/qmlshadersplugin/main.qml b/tests/auto/declarative/qmlshadersplugin/main.qml deleted file mode 100644 index 135dda7d..00000000 --- a/tests/auto/declarative/qmlshadersplugin/main.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - - Rectangle { - width: 300 - height: 300 - - Text { - id: textLabel - text: "Hello World" - anchors.centerIn: parent - font.pixelSize: 48 - } - - ShaderEffectItem { - objectName: "effectItem" - property variant source: ShaderEffectSource { objectName: "effectSource"; sourceItem: textLabel; hideSource: true } - property real wiggleAmount: 0.01 - anchors.fill: textLabel - - SequentialAnimation on wiggleAmount { - loops: Animation.Infinite - NumberAnimation { to: -0.01; duration: 500 } - NumberAnimation { to: 0.01; duration: 500 } - } - - fragmentShader: " - varying highp vec2 qt_TexCoord0; - uniform sampler2D source; - uniform highp float wiggleAmount; - void main(void) - { - highp vec2 wiggledTexCoord = qt_TexCoord0; - wiggledTexCoord.s += sin(4.0 * 3.141592653589 * wiggledTexCoord.t) * wiggleAmount; - gl_FragColor = texture2D(source, wiggledTexCoord.st); - } - " - } - } diff --git a/tests/auto/declarative/qmlshadersplugin/qmlshadersplugin.pro b/tests/auto/declarative/qmlshadersplugin/qmlshadersplugin.pro index fdd2d784..252d8553 100644 --- a/tests/auto/declarative/qmlshadersplugin/qmlshadersplugin.pro +++ b/tests/auto/declarative/qmlshadersplugin/qmlshadersplugin.pro @@ -18,3 +18,5 @@ HEADERS += \ ../../../../src/imports/shaders/shadereffect.h \ ../../../../src/imports/shaders/shadereffectbuffer.h \ ../../../../src/imports/shaders/scenegraph/qsggeometry.h + +include(../shared/qdeclarativedatatest.pri) diff --git a/tests/auto/declarative/qmlshadersplugin/tst_qmlshadersplugin.cpp b/tests/auto/declarative/qmlshadersplugin/tst_qmlshadersplugin.cpp index d92a22db..f4fb0170 100644 --- a/tests/auto/declarative/qmlshadersplugin/tst_qmlshadersplugin.cpp +++ b/tests/auto/declarative/qmlshadersplugin/tst_qmlshadersplugin.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include #include "../../../../src/imports/shaders/shadereffectitem.h" #include "../../../../src/imports/shaders/shadereffectsource.h" @@ -64,7 +65,7 @@ static const char qt_default_fragment_code[] = "gl_FragColor = texture2D(source, qt_TexCoord0.st);\n" "}\n"; -class tst_qmlshadersplugin : public QObject +class tst_qmlshadersplugin : public QDeclarativeDataTest { Q_OBJECT @@ -80,6 +81,8 @@ private: void tst_qmlshadersplugin::initTestCase() { + QDeclarativeDataTest::initTestCase(); + const char *uri ="Qt.labs.shaders"; qmlRegisterType(uri, 1, 0, "ShaderEffectItem"); qmlRegisterType(uri, 1, 0, "ShaderEffectSource"); @@ -96,7 +99,7 @@ void tst_qmlshadersplugin::shaderEffectItemAPI() "width: 200; height: 300\n" "}"; QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + component.setData(componentStr.toLatin1(), testFileUrl("")); QObject *obj = component.create(); QTest::qWait(100); @@ -134,7 +137,7 @@ void tst_qmlshadersplugin::shaderEffectSourceAPI() "import Qt.labs.shaders 1.0\n" "ShaderEffectSource {}"; QDeclarativeComponent shaderEffectSourceComponent(&engine); - shaderEffectSourceComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + shaderEffectSourceComponent.setData(componentStr.toLatin1(), testFileUrl("")); QObject *obj = shaderEffectSourceComponent.create(); QTest::qWait(100); @@ -151,7 +154,7 @@ void tst_qmlshadersplugin::shaderEffectSourceAPI() componentStr = "import QtQuick 1.0\n" "Item {}"; QDeclarativeComponent itemComponent(&engine); - itemComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + itemComponent.setData(componentStr.toLatin1(), testFileUrl("")); QDeclarativeItem *item = qobject_cast (itemComponent.create()); QVERIFY(item != 0); @@ -187,7 +190,7 @@ void tst_qmlshadersplugin::combined() view.setAttribute(Qt::WA_OpaquePaintEvent); view.setAttribute(Qt::WA_NoSystemBackground); view.setViewport(glWidget); - view.setSource(QUrl::fromLocalFile("main.qml")); + view.setSource(testFileUrl("main.qml")); view.show(); QTest::qWait(1000); diff --git a/tests/auto/declarative/shared/qdeclarativedatatest.cpp b/tests/auto/declarative/shared/qdeclarativedatatest.cpp new file mode 100644 index 00000000..12fc9d13 --- /dev/null +++ b/tests/auto/declarative/shared/qdeclarativedatatest.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativedatatest.h" + +#include +#include +#include +#include +#include + +QDeclarativeDataTest *QDeclarativeDataTest::m_instance = 0; + +QDeclarativeDataTest::QDeclarativeDataTest() : +#ifdef QT_TESTCASE_BUILDDIR + m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)), +#else + m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0)), +#endif + + m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/'))) +{ + m_instance = this; +} + +QDeclarativeDataTest::~QDeclarativeDataTest() +{ + m_instance = 0; +} + +void QDeclarativeDataTest::initTestCase() +{ + QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found"); + m_directory = QFileInfo(m_dataDirectory).absolutePath(); + QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory)); +} + +QString QDeclarativeDataTest::testFile(const QString &fileName) const +{ + if (m_directory.isEmpty()) + qFatal("QDeclarativeDataTest::initTestCase() not called."); + QString result = m_dataDirectory; + result += QLatin1Char('/'); + result += fileName; + return result; +} + +QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &c, + const QDeclarativeEngine *engine /* = 0 */) +{ + QString result; + const QList errors = c.errors(); + QTextStream str(&result); + str << "Component '" << c.url().toString() << "' has " << errors.size() + << " errors: '"; + for (int i = 0; i < errors.size(); ++i) { + if (i) + str << ", '"; + str << errors.at(i).toString() << '\''; + + } + if (!engine) + if (QDeclarativeContext *context = c.creationContext()) + engine = context->engine(); + if (engine) { + str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", ")) + << ") Plugin paths: (" << engine->pluginPathList().join(QStringLiteral(", ")) + << ')'; + } + return result.toLocal8Bit(); +} diff --git a/tests/auto/declarative/shared/qdeclarativedatatest.h b/tests/auto/declarative/shared/qdeclarativedatatest.h new file mode 100644 index 00000000..9f73d9eb --- /dev/null +++ b/tests/auto/declarative/shared/qdeclarativedatatest.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETESTUTILS_H +#define QDECLARATIVETESTUTILS_H + +#include +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QDeclarativeComponent) +QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine) + +/* Base class for tests with data that are located in a "data" subfolder. */ + +class QDeclarativeDataTest : public QObject +{ + Q_OBJECT +public: + QDeclarativeDataTest(); + virtual ~QDeclarativeDataTest(); + + QString testFile(const QString &fileName) const; + inline QString testFile(const char *fileName) const + { return testFile(QLatin1String(fileName)); } + inline QUrl testFileUrl(const QString &fileName) const + { return QUrl::fromLocalFile(testFile(fileName)); } + inline QUrl testFileUrl(const char *fileName) const + { return testFileUrl(QLatin1String(fileName)); } + + inline QString dataDirectory() const { return m_dataDirectory; } + inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; } + inline QString directory() const { return m_directory; } + + static inline QDeclarativeDataTest *instance() { return m_instance; } + + static QByteArray msgComponentError(const QDeclarativeComponent &, + const QDeclarativeEngine *engine = 0); + +public slots: + virtual void initTestCase(); + +private: + static QDeclarativeDataTest *m_instance; + + const QString m_dataDirectory; + const QUrl m_dataDirectoryUrl; + QString m_directory; +}; + +#endif // QDECLARATIVETESTUTILS_H diff --git a/tests/auto/declarative/shared/qdeclarativedatatest.pri b/tests/auto/declarative/shared/qdeclarativedatatest.pri new file mode 100644 index 00000000..9275f50d --- /dev/null +++ b/tests/auto/declarative/shared/qdeclarativedatatest.pri @@ -0,0 +1,6 @@ +HEADERS += $$PWD/qdeclarativedatatest.h +SOURCES += $$PWD/qdeclarativedatatest.cpp + +INCLUDEPATH += $$PWD + +DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" -- cgit v1.2.3