diff options
Diffstat (limited to 'tests/auto/qtquick2')
68 files changed, 926 insertions, 1010 deletions
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro index fd35266f66..f5bebb3f49 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro @@ -1,6 +1,9 @@ CONFIG += testcase TARGET = tst_qdeclarativeanimations -SOURCES += tst_qdeclarativeanimations.cpp +SOURCES += tst_qdeclarativeanimations.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 2a2055ebbf..190143287a 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -56,14 +56,18 @@ #include "../../shared/util.h" -class tst_qdeclarativeanimations : public QObject +class tst_qdeclarativeanimations : public QDeclarativeDataTest { Q_OBJECT public: tst_qdeclarativeanimations() {} private slots: - void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered + void initTestCase() + { + QDeclarativeEngine engine; // ensure types are registered + QDeclarativeDataTest::initTestCase(); + } void simpleProperty(); void simpleNumber(); @@ -223,7 +227,7 @@ void tst_qdeclarativeanimations::simplePath() { { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -259,7 +263,7 @@ void tst_qdeclarativeanimations::simplePath() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -291,7 +295,7 @@ void tst_qdeclarativeanimations::simplePath() void tst_qdeclarativeanimations::pathInterpolator() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolator.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml")); QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create()); QVERIFY(interpolator); @@ -316,7 +320,7 @@ void tst_qdeclarativeanimations::pathInterpolator() void tst_qdeclarativeanimations::pathInterpolatorBackwardJump() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolatorBack.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml")); QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create()); QVERIFY(interpolator); @@ -348,7 +352,7 @@ void tst_qdeclarativeanimations::pathInterpolatorBackwardJump() void tst_qdeclarativeanimations::pathWithNoStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimationNoStart.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -471,7 +475,7 @@ void tst_qdeclarativeanimations::badTypes() //don't crash { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("badtype1.qml"))); + view->setSource(testFileUrl("badtype1.qml")); qApp->processEvents(); @@ -481,7 +485,7 @@ void tst_qdeclarativeanimations::badTypes() //make sure we get a compiler error { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml")); QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); c.create(); @@ -492,7 +496,7 @@ void tst_qdeclarativeanimations::badTypes() //make sure we get a compiler error { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml")); QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); c.create(); @@ -503,7 +507,7 @@ void tst_qdeclarativeanimations::badTypes() //don't crash { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype4.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -521,14 +525,14 @@ void tst_qdeclarativeanimations::badProperties() { QDeclarativeEngine engine; - QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(TESTDATA("badproperty1.qml"))); - QByteArray message = QUrl::fromLocalFile(TESTDATA("badproperty1.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; + QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml")); + QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create()); QVERIFY(rect); - QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(TESTDATA("badproperty2.qml"))); - message = QUrl::fromLocalFile(TESTDATA("badproperty2.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; + QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml")); + message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; QTest::ignoreMessage(QtWarningMsg, message); rect = qobject_cast<QQuickRectangle*>(c2.create()); QVERIFY(rect); @@ -545,7 +549,7 @@ void tst_qdeclarativeanimations::mixedTypes() //assumes border.width stays a real -- not real robust { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype1.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -561,7 +565,7 @@ void tst_qdeclarativeanimations::mixedTypes() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -581,7 +585,7 @@ void tst_qdeclarativeanimations::properties() const int waitDuration = 300; { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("properties.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -593,7 +597,7 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("properties2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -605,7 +609,7 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("properties3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -617,7 +621,7 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties4.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("properties4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -630,7 +634,7 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties5.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("properties5.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -647,7 +651,7 @@ void tst_qdeclarativeanimations::propertiesTransition() const int waitDuration = 300; { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -660,7 +664,7 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -675,7 +679,7 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -688,7 +692,7 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition4.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -702,7 +706,7 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition5.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -716,7 +720,7 @@ void tst_qdeclarativeanimations::propertiesTransition() /*{ QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition6.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -730,7 +734,7 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition7.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -746,7 +750,7 @@ void tst_qdeclarativeanimations::propertiesTransition() void tst_qdeclarativeanimations::pathTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathTransition.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -766,7 +770,7 @@ void tst_qdeclarativeanimations::pathTransition() void tst_qdeclarativeanimations::disabledTransition() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("disabledTransition.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -806,7 +810,7 @@ void tst_qdeclarativeanimations::attached() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("attached.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("attached.qml")); QTest::ignoreMessage(QtDebugMsg, "off"); QTest::ignoreMessage(QtDebugMsg, "on"); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); @@ -818,7 +822,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -831,7 +835,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -844,7 +848,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontAutoStart.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -861,7 +865,7 @@ void tst_qdeclarativeanimations::dontStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml")); QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -876,7 +880,7 @@ void tst_qdeclarativeanimations::dontStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml")); QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -959,7 +963,7 @@ void tst_qdeclarativeanimations::easingProperties() void tst_qdeclarativeanimations::rotation() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("rotation.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("rotation.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -990,7 +994,7 @@ void tst_qdeclarativeanimations::runningTrueBug() { //ensure we start correctly when "running: true" is explicitly set QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("runningTrueBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -1007,7 +1011,7 @@ void tst_qdeclarativeanimations::nonTransitionBug() //in the case where an animation in the transition doesn't match anything (but previously did) QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("nonTransitionBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1033,7 +1037,7 @@ void tst_qdeclarativeanimations::registrationBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("registrationBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QTRY_COMPARE(rect->property("value"), QVariant(int(100))); @@ -1043,7 +1047,7 @@ void tst_qdeclarativeanimations::doubleRegistrationBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("doubleRegistrationBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1081,7 +1085,7 @@ void tst_qdeclarativeanimations::transitionAssignmentBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("transitionAssignmentBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1093,7 +1097,7 @@ void tst_qdeclarativeanimations::pauseBindingBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBindingBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation"); @@ -1107,7 +1111,7 @@ void tst_qdeclarativeanimations::pauseBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBug.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml")); QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create()); QVERIFY(anim != 0); QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused); diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro index 3ac9446a4c..e68c68a96c 100644 --- a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -1,6 +1,9 @@ CONFIG += testcase TARGET = tst_qdeclarativebehaviors -SOURCES += tst_qdeclarativebehaviors.cpp +SOURCES += tst_qdeclarativebehaviors.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 526a23f262..f96f0949a1 100644 --- a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -50,7 +50,7 @@ #include <private/qquickitem_p.h> #include "../../shared/util.h" -class tst_qdeclarativebehaviors : public QObject +class tst_qdeclarativebehaviors : public QDeclarativeDataTest { Q_OBJECT public: @@ -85,7 +85,7 @@ private slots: void tst_qdeclarativebehaviors::simpleBehavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("simple.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("simple.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation()); @@ -101,7 +101,7 @@ void tst_qdeclarativebehaviors::simpleBehavior() void tst_qdeclarativebehaviors::scriptTriggered() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("scripttrigger.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("scripttrigger.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -116,7 +116,7 @@ void tst_qdeclarativebehaviors::scriptTriggered() void tst_qdeclarativebehaviors::cppTriggered() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("cpptrigger.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("cpptrigger.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -133,7 +133,7 @@ void tst_qdeclarativebehaviors::cppTriggered() void tst_qdeclarativebehaviors::loop() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("loop.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("loop.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -146,7 +146,7 @@ void tst_qdeclarativebehaviors::loop() void tst_qdeclarativebehaviors::colorBehavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("color.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("color.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -161,7 +161,7 @@ void tst_qdeclarativebehaviors::colorBehavior() void tst_qdeclarativebehaviors::parentBehavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("parent.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("parent.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -175,7 +175,7 @@ void tst_qdeclarativebehaviors::parentBehavior() void tst_qdeclarativebehaviors::replaceBinding() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("binding.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("binding.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -208,7 +208,7 @@ void tst_qdeclarativebehaviors::group() /* XXX TODO Create a test element for this case. { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupProperty.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("groupProperty.qml"))); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); qDebug() << c.errorString(); QTRY_VERIFY(rect); @@ -225,7 +225,7 @@ void tst_qdeclarativebehaviors::group() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupProperty2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("groupProperty2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QTRY_VERIFY(rect); @@ -241,7 +241,7 @@ void tst_qdeclarativebehaviors::group() void tst_qdeclarativebehaviors::valueType() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valueType.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("valueType.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -254,7 +254,7 @@ void tst_qdeclarativebehaviors::valueType() void tst_qdeclarativebehaviors::emptyBehavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("empty.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("empty.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -268,7 +268,7 @@ void tst_qdeclarativebehaviors::emptyBehavior() void tst_qdeclarativebehaviors::explicitSelection() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("explicit.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("explicit.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -283,7 +283,7 @@ void tst_qdeclarativebehaviors::explicitSelection() void tst_qdeclarativebehaviors::nonSelectingBehavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("nonSelecting2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("nonSelecting2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -297,8 +297,8 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() void tst_qdeclarativebehaviors::reassignedAnimation() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("reassignedAnimation.qml"))); - QString warning = QUrl::fromLocalFile(TESTDATA("reassignedAnimation.qml")).toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; + QDeclarativeComponent c(&engine, testFileUrl("reassignedAnimation.qml")); + QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -311,7 +311,7 @@ void tst_qdeclarativebehaviors::reassignedAnimation() void tst_qdeclarativebehaviors::disabled() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("disabled.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("disabled.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false); @@ -327,7 +327,7 @@ void tst_qdeclarativebehaviors::dontStart() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml")); QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -345,7 +345,7 @@ void tst_qdeclarativebehaviors::startup() { { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startup.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("startup.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -359,7 +359,7 @@ void tst_qdeclarativebehaviors::startup() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startup2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("startup2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -379,7 +379,7 @@ void tst_qdeclarativebehaviors::startup() void tst_qdeclarativebehaviors::groupedPropertyCrash() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupedPropertyCrash.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("groupedPropertyCrash.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); //don't crash @@ -390,7 +390,7 @@ void tst_qdeclarativebehaviors::groupedPropertyCrash() void tst_qdeclarativebehaviors::runningTrue() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("runningTrue.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("runningTrue.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -408,7 +408,7 @@ void tst_qdeclarativebehaviors::runningTrue() void tst_qdeclarativebehaviors::sameValue() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("qtbug12295.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("qtbug12295.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -438,7 +438,7 @@ void tst_qdeclarativebehaviors::delayedRegistration() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("delayedRegistration.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("delayedRegistration.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -455,7 +455,7 @@ void tst_qdeclarativebehaviors::startOnCompleted() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startOnCompleted.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("startOnCompleted.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); diff --git a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro index de9461f7ac..e257696cc2 100644 --- a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro @@ -2,8 +2,11 @@ CONFIG += testcase TARGET = tst_qdeclarativefontloader macx:CONFIG -= app_bundle -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativefontloader.cpp ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += tst_qdeclarativefontloader.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index 86789068ad..5b8ae05b28 100644 --- a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -51,14 +51,14 @@ #define SERVER_PORT 14448 -class tst_qdeclarativefontloader : public QObject +class tst_qdeclarativefontloader : public QDeclarativeDataTest { Q_OBJECT public: tst_qdeclarativefontloader(); private slots: - void init(); + void initTestCase(); void noFont(); void namedFont(); void localFont(); @@ -77,11 +77,12 @@ private: tst_qdeclarativefontloader::tst_qdeclarativefontloader() : server(SERVER_PORT) { - server.serveDirectory(TESTDATA("")); } -void tst_qdeclarativefontloader::init() +void tst_qdeclarativefontloader::initTestCase() { + QDeclarativeDataTest::initTestCase(); + server.serveDirectory(dataDirectory()); QVERIFY(server.isValid()); } @@ -115,7 +116,7 @@ void tst_qdeclarativefontloader::namedFont() void tst_qdeclarativefontloader::localFont() { - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + TESTDATA("tarzeau_ocr_a.ttf") + "\" }"; + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); @@ -128,8 +129,8 @@ void tst_qdeclarativefontloader::localFont() void tst_qdeclarativefontloader::failLocalFont() { - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + QUrl::fromLocalFile(TESTDATA("dummy.ttf")).toString() + "\" }"; - QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(TESTDATA("dummy.ttf")).toString() + "\"").toUtf8().constData()); + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }"; + QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData()); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); @@ -188,7 +189,7 @@ void tst_qdeclarativefontloader::changeFont() { QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("font", QUrl::fromLocalFile(TESTDATA("tarzeau_ocr_a.ttf"))); + ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); @@ -210,7 +211,7 @@ void tst_qdeclarativefontloader::changeFont() QCOMPARE(statusSpy.count(), 2); QTRY_COMPARE(fontObject->name(), QString("Daniel")); - ctxt->setContextProperty("font", QUrl::fromLocalFile(TESTDATA("tarzeau_ocr_a.ttf"))); + ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); QCOMPARE(nameSpy.count(), 2); QCOMPARE(statusSpy.count(), 2); @@ -225,7 +226,7 @@ void tst_qdeclarativefontloader::changeFont() void tst_qdeclarativefontloader::changeFontSourceViaState() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("qtbug-20268.qml"))); + QQuickView canvas(testFileUrl("qtbug-20268.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -240,7 +241,7 @@ void tst_qdeclarativefontloader::changeFontSourceViaState() canvas.rootObject()->setProperty("usename", true); // This warning should probably not be printed once QTBUG-20268 is fixed - QString warning = QString(QUrl::fromLocalFile(TESTDATA("qtbug-20268.qml")).toString()) + + QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) + QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\""); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); diff --git a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro b/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro index 9f4204efa3..caadcbd728 100644 --- a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro +++ b/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qdeclarativepath macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativepath.cpp +SOURCES += tst_qdeclarativepath.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp index bf4f70b292..9a21e56aab 100644 --- a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp +++ b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp @@ -46,7 +46,7 @@ #include "../../shared/util.h" -class tst_QDeclarativePath : public QObject +class tst_QDeclarativePath : public QDeclarativeDataTest { Q_OBJECT public: @@ -61,7 +61,7 @@ private slots: void tst_QDeclarativePath::arc() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("arc.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("arc.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj != 0); @@ -96,7 +96,7 @@ void tst_QDeclarativePath::arc() void tst_QDeclarativePath::catmullromCurve() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("curve.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("curve.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj != 0); @@ -131,7 +131,7 @@ void tst_QDeclarativePath::catmullromCurve() void tst_QDeclarativePath::svg() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("svg.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("svg.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj != 0); diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro index 391c28c10a..1cc8149e85 100644 --- a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ b/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro @@ -2,11 +2,12 @@ CONFIG += testcase TARGET = tst_qdeclarativepixmapcache macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativepixmapcache.cpp - +SOURCES += tst_qdeclarativepixmapcache.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h -SOURCES += ../../shared/testhttpserver.cpp importFiles.files = data importFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index 4dd384748f..e7710b8691 100644 --- a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -54,22 +54,14 @@ #define PIXMAP_DATA_LEAK_TEST 0 -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(TESTDATA(filename)); -} - -class tst_qdeclarativepixmapcache : public QObject +class tst_qdeclarativepixmapcache : public QDeclarativeDataTest { Q_OBJECT public: - tst_qdeclarativepixmapcache() : - server(14452) - { - server.serveDirectory(TESTDATA("http")); - } + tst_qdeclarativepixmapcache() : server(14452) {} private slots: + void initTestCase(); void single(); void single_data(); void parallel(); @@ -118,6 +110,13 @@ static const bool localfile_optimized = true; static const bool localfile_optimized = false; #endif + +void tst_qdeclarativepixmapcache::initTestCase() +{ + QDeclarativeDataTest::initTestCase(); + server.serveDirectory(testFile("http")); +} + void tst_qdeclarativepixmapcache::single_data() { // Note, since QDeclarativePixmapCache is shared, tests affect each other! @@ -129,8 +128,8 @@ void tst_qdeclarativepixmapcache::single_data() QTest::addColumn<bool>("neterror"); // File URLs are optimized - QTest::newRow("local") << TEST_FILE("exists.png") << localfile_optimized << true << false; - QTest::newRow("local") << TEST_FILE("notexists.png") << localfile_optimized << false << false; + QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false; + QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false; QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false; QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true; } @@ -193,8 +192,8 @@ void tst_qdeclarativepixmapcache::parallel_data() QTest::addColumn<int>("cancel"); // which one to cancel QTest::newRow("local") - << TEST_FILE("exists1.png") - << TEST_FILE("exists2.png") + << testFileUrl("exists1.png") + << testFileUrl("exists2.png") << (localfile_optimized ? 2 : 0) << -1; @@ -290,7 +289,7 @@ void tst_qdeclarativepixmapcache::parallel() void tst_qdeclarativepixmapcache::massive() { QDeclarativeEngine engine; - QUrl url = TEST_FILE("massive.png"); + QUrl url = testFileUrl("massive.png"); // Confirm that massive images remain in the cache while they are // in use by the application. @@ -368,7 +367,7 @@ void createNetworkServer() { QEventLoop eventLoop; TestHTTPServer server(14453); - server.serveDirectory(TESTDATA("http")); + server.serveDirectory(QDeclarativeDataTest::instance()->testFile("http")); QTimer::singleShot(100, &eventLoop, SLOT(quit())); eventLoop.exec(); } @@ -396,7 +395,7 @@ void tst_qdeclarativepixmapcache::networkCrash() void tst_qdeclarativepixmapcache::lockingCrash() { TestHTTPServer server(14453); - server.serveDirectory(TESTDATA("http"), TestHTTPServer::Delay); + server.serveDirectory(testFile("http"), TestHTTPServer::Delay); { QDeclarativePixmap* p = new QDeclarativePixmap; @@ -422,7 +421,7 @@ class DataLeakView : public QQuickView public: explicit DataLeakView() : QQuickView() { - setSource(TEST_FILE("dataLeak.qml")); + setSource(testFileUrl("dataLeak.qml")); } void showFor2Seconds() @@ -449,9 +448,9 @@ void tst_qdeclarativepixmapcache::dataLeak() { QScopedPointer<DataLeakView> test(new DataLeakView); test->showFor2Seconds(); - dataLeakPixmap()->load(test->engine(), TEST_FILE("exists.png")); - p1->load(test->engine(), TEST_FILE("exists.png")); - p2->load(test->engine(), TEST_FILE("exists2.png")); + dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png")); + p1->load(test->engine(), testFileUrl("exists.png")); + p2->load(test->engine(), testFileUrl("exists2.png")); QTest::qWait(2005); // 2 seconds + a few more millis. } diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro index 1e8a7d5ba6..044a7968f3 100644 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ b/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qdeclarativesmoothedanimation macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativesmoothedanimation.cpp +SOURCES += tst_qdeclarativesmoothedanimation.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp index 632bcda091..2736377218 100644 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -46,7 +46,7 @@ #include <private/qdeclarativevaluetype_p.h> #include "../../shared/util.h" -class tst_qdeclarativesmoothedanimation : public QObject +class tst_qdeclarativesmoothedanimation : public QDeclarativeDataTest { Q_OBJECT public: @@ -71,7 +71,7 @@ tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation() void tst_qdeclarativesmoothedanimation::defaultValues() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation1.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation1.qml")); QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create()); QVERIFY(obj != 0); @@ -88,7 +88,7 @@ void tst_qdeclarativesmoothedanimation::defaultValues() void tst_qdeclarativesmoothedanimation::values() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation2.qml")); QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create()); QVERIFY(obj != 0); @@ -105,7 +105,7 @@ void tst_qdeclarativesmoothedanimation::values() void tst_qdeclarativesmoothedanimation::disabled() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation3.qml")); QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create()); QVERIFY(obj != 0); @@ -148,7 +148,7 @@ void tst_qdeclarativesmoothedanimation::valueSource() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimationValueSource.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); @@ -180,7 +180,7 @@ void tst_qdeclarativesmoothedanimation::behavior() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimationBehavior.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect); diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro index 3ac2551380..9c7000a247 100644 --- a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro +++ b/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qdeclarativespringanimation macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativespringanimation.cpp +SOURCES += tst_qdeclarativespringanimation.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp index f7acc2a3e0..1e747e4951 100644 --- a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp +++ b/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp @@ -45,7 +45,7 @@ #include <private/qdeclarativevaluetype_p.h> #include "../../shared/util.h" -class tst_qdeclarativespringanimation : public QObject +class tst_qdeclarativespringanimation : public QDeclarativeDataTest { Q_OBJECT public: @@ -67,7 +67,7 @@ tst_qdeclarativespringanimation::tst_qdeclarativespringanimation() void tst_qdeclarativespringanimation::defaultValues() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation1.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("springanimation1.qml")); QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); @@ -87,7 +87,7 @@ void tst_qdeclarativespringanimation::defaultValues() void tst_qdeclarativespringanimation::values() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("springanimation2.qml")); QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); @@ -109,7 +109,7 @@ void tst_qdeclarativespringanimation::values() void tst_qdeclarativespringanimation::disabled() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("springanimation3.qml")); QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create()); QVERIFY(obj != 0); diff --git a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro index f799f7066b..dbf7441d3b 100644 --- a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qdeclarativestates macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativestates.cpp +SOURCES += tst_qdeclarativestates.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp index 663d78d402..69142daeff 100644 --- a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp @@ -92,14 +92,14 @@ private: QML_DECLARE_TYPE(MyRect) QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) -class tst_qdeclarativestates : public QObject +class tst_qdeclarativestates : public QDeclarativeDataTest { Q_OBJECT public: tst_qdeclarativestates() {} private: - static QByteArray fullDataPath(const QString &path); + QByteArray fullDataPath(const QString &path) const; private slots: void initTestCase(); @@ -151,12 +151,13 @@ private slots: void tst_qdeclarativestates::initTestCase() { + QDeclarativeDataTest::initTestCase(); qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle"); } -QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) +QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) const { - return QUrl::fromLocalFile(TESTDATA(path)).toString().toUtf8(); + return testFileUrl(path).toString().toUtf8(); } void tst_qdeclarativestates::basicChanges() @@ -164,7 +165,7 @@ void tst_qdeclarativestates::basicChanges() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -179,7 +180,7 @@ void tst_qdeclarativestates::basicChanges() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -200,7 +201,7 @@ void tst_qdeclarativestates::basicChanges() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -236,7 +237,7 @@ void tst_qdeclarativestates::basicChanges() // signal using 'onPropertyWithNotifyChanged' even though the signal name is // actually 'oddlyNamedNotifySignal' - QDeclarativeComponent component(&engine, TESTDATA("basicChanges4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("basicChanges4.qml")); QVERIFY(component.isReady()); MyRect *rect = qobject_cast<MyRect*>(component.create()); @@ -258,7 +259,7 @@ void tst_qdeclarativestates::attachedPropertyChanges() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TESTDATA("attachedPropertyChanges.qml")); + QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyChanges.qml")); QVERIFY(component.isReady()); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); @@ -280,7 +281,7 @@ void tst_qdeclarativestates::basicExtension() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicExtension.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicExtension.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -314,7 +315,7 @@ void tst_qdeclarativestates::basicExtension() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("fakeExtension.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("fakeExtension.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -346,7 +347,7 @@ void tst_qdeclarativestates::basicBinding() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -374,7 +375,7 @@ void tst_qdeclarativestates::basicBinding() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -405,7 +406,7 @@ void tst_qdeclarativestates::basicBinding() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -430,7 +431,7 @@ void tst_qdeclarativestates::basicBinding() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding4.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); QVERIFY(rect != 0); @@ -463,7 +464,7 @@ void tst_qdeclarativestates::signalOverride() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverride.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride.qml")); MyRect *rect = qobject_cast<MyRect*>(rectComponent.create()); QVERIFY(rect != 0); @@ -477,7 +478,7 @@ void tst_qdeclarativestates::signalOverride() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverride2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride2.qml")); MyRect *rect = qobject_cast<MyRect*>(rectComponent.create()); QVERIFY(rect != 0); @@ -498,7 +499,7 @@ void tst_qdeclarativestates::signalOverrideCrash() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml")); MyRect *rect = qobject_cast<MyRect*>(rectComponent.create()); QVERIFY(rect != 0); @@ -510,7 +511,7 @@ void tst_qdeclarativestates::signalOverrideCrash2() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -525,7 +526,7 @@ void tst_qdeclarativestates::signalOverrideCrash3() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -542,7 +543,7 @@ void tst_qdeclarativestates::parentChange() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange1.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange1.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -569,7 +570,7 @@ void tst_qdeclarativestates::parentChange() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -584,7 +585,7 @@ void tst_qdeclarativestates::parentChange() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -606,7 +607,7 @@ void tst_qdeclarativestates::parentChange() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange6.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange6.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -626,7 +627,7 @@ void tst_qdeclarativestates::parentChangeErrors() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange4.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -642,7 +643,7 @@ void tst_qdeclarativestates::parentChangeErrors() } { - QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange5.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange5.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -662,7 +663,7 @@ void tst_qdeclarativestates::anchorChanges() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges1.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -695,7 +696,7 @@ void tst_qdeclarativestates::anchorChanges2() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -716,7 +717,7 @@ void tst_qdeclarativestates::anchorChanges3() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -767,7 +768,7 @@ void tst_qdeclarativestates::anchorChanges4() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges4.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -802,7 +803,7 @@ void tst_qdeclarativestates::anchorChanges5() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges5.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -846,7 +847,7 @@ void tst_qdeclarativestates::anchorChangesRTL() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges1.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -880,7 +881,7 @@ void tst_qdeclarativestates::anchorChangesRTL2() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -902,7 +903,7 @@ void tst_qdeclarativestates::anchorChangesRTL3() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges3.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -957,7 +958,7 @@ void tst_qdeclarativestates::anchorChangesCrash() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChangesCrash.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -970,7 +971,7 @@ void tst_qdeclarativestates::anchorChangesCrash() void tst_qdeclarativestates::anchorRewindBug() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("anchorRewindBug.qml"))); + view->setSource(testFileUrl("anchorRewindBug.qml")); view->show(); view->requestActivateWindow(); @@ -1010,7 +1011,7 @@ void tst_qdeclarativestates::anchorRewindBug2() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorRewindBug2.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -1036,7 +1037,7 @@ void tst_qdeclarativestates::script() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, TESTDATA("script.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("script.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1054,7 +1055,7 @@ void tst_qdeclarativestates::restoreEntryValues() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("restoreEntryValues.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1071,7 +1072,7 @@ void tst_qdeclarativestates::explicitChanges() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("explicit.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("explicit.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1104,7 +1105,7 @@ void tst_qdeclarativestates::explicitChanges() void tst_qdeclarativestates::propertyErrors() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("propertyErrors.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("propertyErrors.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -1119,7 +1120,7 @@ void tst_qdeclarativestates::incorrectRestoreBug() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1145,7 +1146,7 @@ void tst_qdeclarativestates::autoStateAtStartupRestoreBug() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TESTDATA("autoStateAtStartupRestoreBug.qml")); + QDeclarativeComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml")); QObject *obj = component.create(); QVERIFY(obj != 0); @@ -1162,7 +1163,7 @@ void tst_qdeclarativestates::deletingChange() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("deleting.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("deleting.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1194,7 +1195,7 @@ void tst_qdeclarativestates::deletingState() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("deletingState.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("deletingState.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -1225,7 +1226,7 @@ void tst_qdeclarativestates::tempState() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("legalTempState.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("legalTempState.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1239,7 +1240,7 @@ void tst_qdeclarativestates::illegalTempState() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("illegalTempState.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("illegalTempState.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1252,7 +1253,7 @@ void tst_qdeclarativestates::nonExistantProperty() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, TESTDATA("nonExistantProp.qml")); + QDeclarativeComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1265,7 +1266,7 @@ void tst_qdeclarativestates::reset() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("reset.qml")); + QDeclarativeComponent c(&engine, testFileUrl("reset.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1286,7 +1287,7 @@ void tst_qdeclarativestates::illegalObjectCreation() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TESTDATA("illegalObj.qml")); + QDeclarativeComponent component(&engine, testFileUrl("illegalObj.qml")); QList<QDeclarativeError> errors = component.errors(); QVERIFY(errors.count() == 1); const QDeclarativeError &error = errors.at(0); @@ -1299,7 +1300,7 @@ void tst_qdeclarativestates::whenOrdering() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("whenOrdering.qml")); + QDeclarativeComponent c(&engine, testFileUrl("whenOrdering.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1322,7 +1323,7 @@ void tst_qdeclarativestates::urlResolution() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("urlResolution.qml")); + QDeclarativeComponent c(&engine, testFileUrl("urlResolution.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1333,7 +1334,7 @@ void tst_qdeclarativestates::urlResolution() QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); QQuickItemPrivate::get(myType)->setState("SetImageState"); - QUrl resolved = QUrl::fromLocalFile(TESTDATA("Implementation/images/qt-logo.png")); + QUrl resolved = testFileUrl("Implementation/images/qt-logo.png"); QCOMPARE(image1->source(), resolved); QCOMPARE(image2->source(), resolved); QCOMPARE(image3->source(), resolved); @@ -1345,7 +1346,7 @@ void tst_qdeclarativestates::unnamedWhen() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("unnamedWhen.qml")); + QDeclarativeComponent c(&engine, testFileUrl("unnamedWhen.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1364,7 +1365,7 @@ void tst_qdeclarativestates::returnToBase() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("returnToBase.qml")); + QDeclarativeComponent c(&engine, testFileUrl("returnToBase.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1384,7 +1385,7 @@ void tst_qdeclarativestates::extendsBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("extendsBug.qml")); + QDeclarativeComponent c(&engine, testFileUrl("extendsBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); @@ -1399,7 +1400,7 @@ void tst_qdeclarativestates::editProperties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("editProperties.qml")); + QDeclarativeComponent c(&engine, testFileUrl("editProperties.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1527,7 +1528,7 @@ void tst_qdeclarativestates::QTBUG_14830() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("QTBUG-14830.qml")); + QDeclarativeComponent c(&engine, testFileUrl("QTBUG-14830.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); QQuickItem *item = rect->findChild<QQuickItem*>("area"); @@ -1540,7 +1541,7 @@ void tst_qdeclarativestates::avoidFastForward() QDeclarativeEngine engine; //shouldn't fast forward if there isn't a transition - QDeclarativeComponent c(&engine, TESTDATA("avoidFastForward.qml")); + QDeclarativeComponent c(&engine, testFileUrl("avoidFastForward.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); @@ -1554,7 +1555,7 @@ void tst_qdeclarativestates::revertListBug() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, TESTDATA("revertListBug.qml")); + QDeclarativeComponent c(&engine, testFileUrl("revertListBug.qml")); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); QVERIFY(rect != 0); diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro index 10944bcb41..f5628fbd00 100644 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ b/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -2,7 +2,10 @@ CONFIG += testcase TARGET = tst_qdeclarativexmllistmodel macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativexmllistmodel.cpp +SOURCES += tst_qdeclarativexmllistmodel.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 316ac50c5e..4668af408f 100644 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -66,7 +66,7 @@ Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>) Q_DECLARE_METATYPE(QDeclarativeXmlModelData) Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status) -class tst_qdeclarativexmllistmodel : public QObject +class tst_qdeclarativexmllistmodel : public QDeclarativeDataTest { Q_OBJECT @@ -75,6 +75,7 @@ public: private slots: void initTestCase() { + QDeclarativeDataTest::initTestCase(); qRegisterMetaType<QDeclarativeXmlListModel::Status>(); } @@ -194,7 +195,7 @@ QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent void tst_qdeclarativexmllistmodel::buildModel() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -213,7 +214,7 @@ void tst_qdeclarativexmllistmodel::testTypes() QFETCH(QString, roleName); QFETCH(QVariant, expectedValue); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("testtypes.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("testtypes.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); model->setProperty("xml",xml.toUtf8()); @@ -273,7 +274,7 @@ void tst_qdeclarativexmllistmodel::testTypes_data() void tst_qdeclarativexmllistmodel::cdata() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("recipes.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 5); @@ -285,7 +286,7 @@ void tst_qdeclarativexmllistmodel::cdata() void tst_qdeclarativexmllistmodel::attributes() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("recipes.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 5); @@ -296,7 +297,7 @@ void tst_qdeclarativexmllistmodel::attributes() void tst_qdeclarativexmllistmodel::roles() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -313,9 +314,9 @@ void tst_qdeclarativexmllistmodel::roles() void tst_qdeclarativexmllistmodel::roleErrors() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleErrors.qml"))); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); + QDeclarativeComponent component(&engine, testFileUrl("roleErrors.qml")); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); //### make sure we receive all expected warning messages. QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); @@ -336,8 +337,8 @@ void tst_qdeclarativexmllistmodel::roleErrors() void tst_qdeclarativexmllistmodel::uniqueRoleNames() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("unique.qml"))); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("unique.qml")).toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); + QDeclarativeComponent component(&engine, testFileUrl("unique.qml")); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -354,7 +355,7 @@ void tst_qdeclarativexmllistmodel::xml() QFETCH(QString, xml); QFETCH(int, count); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); @@ -409,7 +410,7 @@ void tst_qdeclarativexmllistmodel::headers() CustomNetworkAccessManagerFactory factory; qmlEng.setNetworkAccessManagerFactory(&factory); - QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&qmlEng, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")), @@ -433,7 +434,7 @@ void tst_qdeclarativexmllistmodel::source() QFETCH(int, count); QFETCH(QDeclarativeXmlListModel::Status, status); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); @@ -489,7 +490,7 @@ void tst_qdeclarativexmllistmodel::source_data() QTest::addColumn<int>("count"); QTest::addColumn<QDeclarativeXmlListModel::Status>("status"); - QTest::newRow("valid") << QUrl::fromLocalFile(TESTDATA("model2.xml")) << 2 + QTest::newRow("valid") << testFileUrl("model2.xml") << 2 << QDeclarativeXmlListModel::Ready; QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error; @@ -504,7 +505,7 @@ void tst_qdeclarativexmllistmodel::source_data() void tst_qdeclarativexmllistmodel::data() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); @@ -520,7 +521,7 @@ void tst_qdeclarativexmllistmodel::data() void tst_qdeclarativexmllistmodel::get() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("get.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("get.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); @@ -541,7 +542,7 @@ void tst_qdeclarativexmllistmodel::reload() // If no keys are used, the model should be rebuilt from scratch when // reload() is called. - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("model.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -581,7 +582,7 @@ void tst_qdeclarativexmllistmodel::useKeys() QFETCH(QList<QDeclarativeXmlListRange>, insertRanges); QFETCH(QList<QDeclarativeXmlListRange>, removeRanges); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); @@ -732,7 +733,7 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges() // If a 'sport' value is changed, the model should not be reloaded, // since 'sport' is not marked as a key. - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); @@ -770,7 +771,7 @@ void tst_qdeclarativexmllistmodel::keysChanged() // delete all its data and build a clean model (i.e. same behaviour as // if no keys are set). - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); @@ -806,7 +807,7 @@ void tst_qdeclarativexmllistmodel::threading() { QFETCH(int, xmlDataCount); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(m1 != 0); @@ -879,7 +880,7 @@ void tst_qdeclarativexmllistmodel::threading_data() void tst_qdeclarativexmllistmodel::propertyChanges() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("propertychanges.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -950,7 +951,7 @@ void tst_qdeclarativexmllistmodel::propertyChanges() void tst_qdeclarativexmllistmodel::roleCrash() { // don't crash - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleCrash.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("roleCrash.qml")); QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create()); QVERIFY(model != 0); delete model; diff --git a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro b/tests/auto/qtquick2/qquickanchors/qquickanchors.pro index 92f24cff07..03b99e1dec 100644 --- a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro +++ b/tests/auto/qtquick2/qquickanchors/qquickanchors.pro @@ -1,6 +1,9 @@ TARGET = tst_qquickanchors CONFIG += testcase -SOURCES += tst_qquickanchors.cpp +SOURCES += tst_qquickanchors.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp index cae1421573..1b30c63d5f 100644 --- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp +++ b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp @@ -53,7 +53,7 @@ Q_DECLARE_METATYPE(QQuickAnchors::Anchor) Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine) -class tst_qquickanchors : public QObject +class tst_qquickanchors : public QDeclarativeDataTest { Q_OBJECT public: @@ -111,7 +111,7 @@ T *findItem(QQuickItem *parent, const QString &objectName) void tst_qquickanchors::basicAnchors() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("anchors.qml"))); + view->setSource(testFileUrl("anchors.qml")); qApp->processEvents(); @@ -196,7 +196,7 @@ void mirrorAnchors(QQuickItem *item) { void tst_qquickanchors::basicAnchorsRTL() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("anchors.qml"))); + view->setSource(testFileUrl("anchors.qml")); qApp->processEvents(); @@ -278,7 +278,7 @@ void tst_qquickanchors::basicAnchorsRTL() void tst_qquickanchors::loops() { { - QUrl source(QUrl::fromLocalFile(TESTDATA("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()); @@ -292,7 +292,7 @@ void tst_qquickanchors::loops() } { - QUrl source(QUrl::fromLocalFile(TESTDATA("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()); @@ -480,7 +480,7 @@ void tst_qquickanchors::nullItem_data() //QTBUG-5428 void tst_qquickanchors::crash1() { - QUrl source(QUrl::fromLocalFile(TESTDATA("crash1.qml"))); + QUrl source(testFileUrl("crash1.qml")); QString expect = source.toString() + ":3:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"; @@ -494,7 +494,7 @@ void tst_qquickanchors::crash1() void tst_qquickanchors::fill() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("fill.qml"))); + QQuickView *view = new QQuickView(testFileUrl("fill.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler")); @@ -518,7 +518,7 @@ void tst_qquickanchors::fill() void tst_qquickanchors::fillRTL() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("fill.qml"))); + QQuickView *view = new QQuickView(testFileUrl("fill.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler")); @@ -544,7 +544,7 @@ void tst_qquickanchors::fillRTL() void tst_qquickanchors::centerIn() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerin.qml"))); + QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered")); @@ -563,7 +563,7 @@ void tst_qquickanchors::centerIn() void tst_qquickanchors::centerInRTL() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerin.qml"))); + QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered")); @@ -584,7 +584,7 @@ void tst_qquickanchors::centerInRTL() //QTBUG-12441 void tst_qquickanchors::centerInRotation() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerinRotation.qml"))); + QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml")); qApp->processEvents(); QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer")); @@ -601,7 +601,7 @@ void tst_qquickanchors::centerInRotation() void tst_qquickanchors::hvCenter() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("hvCenter.qml"))); + QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered")); @@ -621,7 +621,7 @@ void tst_qquickanchors::hvCenter() void tst_qquickanchors::hvCenterRTL() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("hvCenter.qml"))); + QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered")); @@ -641,7 +641,7 @@ void tst_qquickanchors::hvCenterRTL() } void tst_qquickanchors::margins() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("margins.qml"))); + QQuickView *view = new QQuickView(testFileUrl("margins.qml")); qApp->processEvents(); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler")); @@ -664,7 +664,7 @@ void tst_qquickanchors::margins() void tst_qquickanchors::marginsRTL() { - QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("margins.qml"))); + QQuickView *view = new QQuickView(testFileUrl("margins.qml")); QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); diff --git a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro index 56394592b8..c8c3bdb9f4 100644 --- a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro +++ b/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro @@ -1,7 +1,11 @@ CONFIG += testcase TARGET = tst_qquickanimatedimage -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickanimatedimage.cpp ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += tst_qquickanimatedimage.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp index bf1017fe21..c2b554cac9 100644 --- a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -53,7 +53,7 @@ Q_DECLARE_METATYPE(QQuickImageBase::Status) -class tst_qquickanimatedimage : public QObject +class tst_qquickanimatedimage : public QDeclarativeDataTest { Q_OBJECT public: @@ -81,7 +81,7 @@ private slots: void tst_qquickanimatedimage::play() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickman.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("stickman.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -92,7 +92,7 @@ void tst_qquickanimatedimage::play() void tst_qquickanimatedimage::pause() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -104,7 +104,7 @@ void tst_qquickanimatedimage::pause() void tst_qquickanimatedimage::stopped() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QVERIFY(!anim->isPlaying()); @@ -116,7 +116,7 @@ void tst_qquickanimatedimage::stopped() void tst_qquickanimatedimage::setFrame() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -128,7 +128,7 @@ void tst_qquickanimatedimage::setFrame() void tst_qquickanimatedimage::frameCount() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("colors.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("colors.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -144,7 +144,7 @@ void tst_qquickanimatedimage::mirror_running() QQuickView *canvas = new QQuickView; canvas->show(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("hearts.qml"))); + canvas->setSource(testFileUrl("hearts.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas->rootObject()); QVERIFY(anim); @@ -224,8 +224,8 @@ void tst_qquickanimatedimage::mirror_notRunning_data() { QTest::addColumn<QUrl>("fileUrl"); - QTest::newRow("paused") << QUrl::fromLocalFile(TESTDATA("stickmanpause.qml")); - QTest::newRow("stopped") << QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml")); + QTest::newRow("paused") << testFileUrl("stickmanpause.qml"); + QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml"); } void tst_qquickanimatedimage::remote() @@ -235,7 +235,7 @@ void tst_qquickanimatedimage::remote() TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); @@ -257,7 +257,7 @@ void tst_qquickanimatedimage::remote() void tst_qquickanimatedimage::sourceSize() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanscaled.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml")); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); QVERIFY(anim); QCOMPARE(anim->width(),240.0); @@ -270,7 +270,7 @@ void tst_qquickanimatedimage::sourceSize() void tst_qquickanimatedimage::sourceSizeReadOnly() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("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")); } @@ -307,10 +307,10 @@ void tst_qquickanimatedimage::qtbug_16520() { TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("qtbug-16520.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml")); QTRY_VERIFY(component.isReady()); QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create()); @@ -329,12 +329,12 @@ void tst_qquickanimatedimage::progressAndStatusChanges() { TestHTTPServer server(14449); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); QDeclarativeEngine engine; QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("stickman.gif"))); + ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -348,7 +348,7 @@ void tst_qquickanimatedimage::progressAndStatusChanges() QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.gif"))); + ctxt->setContextProperty("srcImage", testFileUrl("colors.gif")); QTRY_VERIFY(obj->status() == QQuickImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 1); diff --git a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro b/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro index 34d08aa37f..23c504df83 100644 --- a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro +++ b/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro @@ -2,8 +2,11 @@ CONFIG += testcase TARGET = tst_qquickborderimage macx:CONFIG -= app_bundle -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickborderimage.cpp ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += tst_qquickborderimage.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp index b9fd91d7fb..cd580dd78c 100644 --- a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp @@ -61,7 +61,7 @@ #define SERVER_PORT 14446 #define SERVER_ADDR "http://127.0.0.1:14446" -class tst_qquickborderimage : public QObject +class tst_qquickborderimage : public QDeclarativeDataTest { Q_OBJECT @@ -113,9 +113,9 @@ void tst_qquickborderimage::imageSource_data() QTest::addColumn<bool>("remote"); QTest::addColumn<QString>("error"); - QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << false << ""; - QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString() << false - << "file::2:1: QML BorderImage: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString(); + QTest::newRow("local") << testFileUrl("colors.png").toString() << false << ""; + QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false + << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; @@ -131,7 +131,7 @@ void tst_qquickborderimage::imageSource() if (remote) { server = new TestHTTPServer(SERVER_PORT); QVERIFY(server->isValid()); - server->serveDirectory(TESTDATA("")); + server->serveDirectory(dataDirectory()); } if (!error.isEmpty()) @@ -168,7 +168,7 @@ void tst_qquickborderimage::clearSource() { QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); @@ -186,7 +186,7 @@ void tst_qquickborderimage::clearSource() void tst_qquickborderimage::resized() { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(TESTDATA("colors.png")).toString() + "\"; width: 300; height: 300 }"; + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); @@ -203,7 +203,7 @@ void tst_qquickborderimage::resized() void tst_qquickborderimage::smooth() { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); @@ -222,7 +222,7 @@ void tst_qquickborderimage::mirror() QQuickView *canvas = new QQuickView; canvas->show(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("mirror.qml"))); + canvas->setSource(testFileUrl("mirror.qml")); QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject()); QVERIFY(image != 0); canvas->show(); @@ -244,7 +244,7 @@ void tst_qquickborderimage::mirror() void tst_qquickborderimage::tileModes() { { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); @@ -257,7 +257,7 @@ void tst_qquickborderimage::tileModes() delete obj; } { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); @@ -281,7 +281,7 @@ void tst_qquickborderimage::sciSource() if (remote) { server = new TestHTTPServer(SERVER_PORT); QVERIFY(server->isValid()); - server->serveDirectory(TESTDATA("")); + server->serveDirectory(dataDirectory()); } QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; @@ -318,9 +318,9 @@ void tst_qquickborderimage::sciSource_data() QTest::addColumn<QString>("source"); QTest::addColumn<bool>("valid"); - QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors-round.sci")).toString() << true; - QTest::newRow("local quoted filename") << QUrl::fromLocalFile(TESTDATA("colors-round-quotes.sci")).toString() << true; - QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.sci")).toString() << false; + QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true; + QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; @@ -332,7 +332,7 @@ void tst_qquickborderimage::invalidSciFile() QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(TESTDATA("invalid.sci")).toString() +"\"; width: 300; height: 300 }"; + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create()); diff --git a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro b/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro index 95236970f8..3aa38949bf 100644 --- a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro +++ b/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qquickcanvas -SOURCES += tst_qquickcanvas.cpp +SOURCES += tst_qquickcanvas.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h macx:CONFIG -= app_bundle diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp index 780f58cc37..9ded975805 100644 --- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp @@ -170,16 +170,12 @@ protected: } }; -class tst_qquickcanvas : public QObject +class tst_qquickcanvas : public QDeclarativeDataTest { Q_OBJECT public: - tst_qquickcanvas(); private slots: - void initTestCase(); - void cleanupTestCase(); - void constantUpdates(); void touchEvent_basic(); @@ -200,18 +196,6 @@ private slots: void headless(); }; -tst_qquickcanvas::tst_qquickcanvas() -{ -} - -void tst_qquickcanvas::initTestCase() -{ -} - -void tst_qquickcanvas::cleanupTestCase() -{ -} - //If the item calls update inside updatePaintNode, it should schedule another update void tst_qquickcanvas::constantUpdates() { @@ -532,7 +516,7 @@ void tst_qquickcanvas::qmlCreation() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.loadUrl(TESTDATA("window.qml")); + component.loadUrl(testFileUrl("window.qml")); QObject* created = component.create(); QVERIFY(created); @@ -606,7 +590,7 @@ void tst_qquickcanvas::animationsWhileHidden() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.loadUrl(TESTDATA("AnimationsWhileHidden.qml")); + component.loadUrl(testFileUrl("AnimationsWhileHidden.qml")); QObject* created = component.create(); QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created); @@ -648,7 +632,7 @@ void tst_qquickcanvas::headless() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.loadUrl(TESTDATA("Headless.qml")); + component.loadUrl(testFileUrl("Headless.qml")); QObject* created = component.create(); QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created); diff --git a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro b/tests/auto/qtquick2/qquickflickable/qquickflickable.pro index 7376f593fd..6c2a2a6fc2 100644 --- a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro +++ b/tests/auto/qtquick2/qquickflickable/qquickflickable.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickflickable macx:CONFIG -= app_bundle -SOURCES += tst_qquickflickable.cpp +SOURCES += tst_qquickflickable.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp b/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp index 1827e0af1c..f7543d0fd7 100644 --- a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp @@ -49,16 +49,12 @@ #include "../../shared/util.h" #include <QtOpenGL/QGLShaderProgram> -class tst_qquickflickable : public QObject +class tst_qquickflickable : public QDeclarativeDataTest { Q_OBJECT public: - tst_qquickflickable(); private slots: - void initTestCase(); - void cleanupTestCase(); - void create(); void horizontalViewportSize(); void verticalViewportSize(); @@ -85,24 +81,10 @@ private: T *findItem(QQuickItem *parent, const QString &objectName); }; -tst_qquickflickable::tst_qquickflickable() -{ -} - -void tst_qquickflickable::initTestCase() -{ - -} - -void tst_qquickflickable::cleanupTestCase() -{ - -} - void tst_qquickflickable::create() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable01.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("flickable01.qml")); QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create()); QVERIFY(obj != 0); @@ -127,7 +109,7 @@ void tst_qquickflickable::create() void tst_qquickflickable::horizontalViewportSize() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable02.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("flickable02.qml")); QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create()); QVERIFY(obj != 0); @@ -144,7 +126,7 @@ void tst_qquickflickable::horizontalViewportSize() void tst_qquickflickable::verticalViewportSize() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable03.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("flickable03.qml")); QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create()); QVERIFY(obj != 0); @@ -161,7 +143,7 @@ void tst_qquickflickable::verticalViewportSize() void tst_qquickflickable::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable04.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("flickable04.qml")); QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create()); QVERIFY(obj != 0); @@ -261,7 +243,7 @@ void tst_qquickflickable::pressDelay() void tst_qquickflickable::nestedPressDelay() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("nestedPressDelay.qml"))); + canvas->setSource(testFileUrl("nestedPressDelay.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -316,7 +298,7 @@ void tst_qquickflickable::flickableDirection() void tst_qquickflickable::resizeContent() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("resize.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("resize.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(c.create()); QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick"); @@ -340,7 +322,7 @@ void tst_qquickflickable::resizeContent() void tst_qquickflickable::returnToBounds() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("resize.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("resize.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(c.create()); QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick"); @@ -366,7 +348,7 @@ void tst_qquickflickable::returnToBounds() void tst_qquickflickable::wheel() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("wheel.qml"))); + canvas->setSource(testFileUrl("wheel.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -401,7 +383,7 @@ void tst_qquickflickable::wheel() void tst_qquickflickable::movingAndDragging() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("flickable03.qml"))); + canvas->setSource(testFileUrl("flickable03.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -506,7 +488,7 @@ void tst_qquickflickable::movingAndDragging() void tst_qquickflickable::disabled() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("disabled.qml"))); + canvas->setSource(testFileUrl("disabled.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -538,7 +520,7 @@ void tst_qquickflickable::flickVelocity() #endif QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("flickable03.qml"))); + canvas->setSource(testFileUrl("flickable03.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -562,7 +544,7 @@ void tst_qquickflickable::flickVelocity() void tst_qquickflickable::margins() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("margins.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("margins.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(c.create()); QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root); QVERIFY(obj != 0); diff --git a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro index 532c42f79b..d1932fc3d5 100644 --- a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro +++ b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickflipable macx:CONFIG -= app_bundle -SOURCES += tst_qquickflipable.cpp +SOURCES += tst_qquickflipable.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp index a217e26714..5624cf82b6 100644 --- a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp +++ b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp @@ -50,15 +50,12 @@ #include <QtOpenGL/QGLShaderProgram> #include "../../shared/util.h" -class tst_qquickflipable : public QObject +class tst_qquickflipable : public QDeclarativeDataTest { Q_OBJECT public: - tst_qquickflipable(); private slots: - void initTestCase(); - void cleanupTestCase(); void create(); void checkFrontAndBack(); void setFrontAndBack(); @@ -71,22 +68,10 @@ private: QDeclarativeEngine engine; }; -tst_qquickflipable::tst_qquickflipable() -{ -} -void tst_qquickflipable::initTestCase() -{ -} - -void tst_qquickflipable::cleanupTestCase() -{ - -} - void tst_qquickflipable::create() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -96,7 +81,7 @@ void tst_qquickflipable::create() void tst_qquickflipable::checkFrontAndBack() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -108,7 +93,7 @@ void tst_qquickflipable::checkFrontAndBack() void tst_qquickflipable::setFrontAndBack() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -128,7 +113,7 @@ void tst_qquickflipable::setFrontAndBack() void tst_qquickflipable::QTBUG_9161_crash() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("crash.qml"))); + canvas->setSource(testFileUrl("crash.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); canvas->show(); @@ -138,7 +123,7 @@ void tst_qquickflipable::QTBUG_9161_crash() void tst_qquickflipable::QTBUG_8474_qgv_abort() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("flipable-abort.qml"))); + canvas->setSource(testFileUrl("flipable-abort.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); canvas->show(); diff --git a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro b/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro index 138750db3c..1167643f46 100644 --- a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro +++ b/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro @@ -1,6 +1,9 @@ CONFIG += testcase TARGET = tst_qquickfocusscope -SOURCES += tst_qquickfocusscope.cpp +SOURCES += tst_qquickfocusscope.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp index 11cc7a15e0..6073f8c320 100644 --- a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp +++ b/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp @@ -49,7 +49,7 @@ #include <QtQuick/private/qquickfocusscope_p.h> #include "../../shared/util.h" -class tst_qquickfocusscope : public QObject +class tst_qquickfocusscope : public QDeclarativeDataTest { Q_OBJECT public: @@ -59,8 +59,6 @@ public: T *findItem(QQuickItem *parent, const QString &id); private slots: - void initTestCase(); - void cleanupTestCase(); void basic(); void nested(); void noFocus(); @@ -72,14 +70,6 @@ private slots: void forceActiveFocus(); void canvasFocus(); }; -void tst_qquickfocusscope::initTestCase() -{ -} - -void tst_qquickfocusscope::cleanupTestCase() -{ - -} /* Find an item with the specified id. @@ -106,7 +96,7 @@ T *tst_qquickfocusscope::findItem(QQuickItem *parent, const QString &objectName) void tst_qquickfocusscope::basic() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("test.qml"))); + view->setSource(testFileUrl("test.qml")); QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0")); QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1")); @@ -149,7 +139,7 @@ void tst_qquickfocusscope::basic() void tst_qquickfocusscope::nested() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("test2.qml"))); + view->setSource(testFileUrl("test2.qml")); QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1")); QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2")); @@ -179,7 +169,7 @@ void tst_qquickfocusscope::nested() void tst_qquickfocusscope::noFocus() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("test4.qml"))); + view->setSource(testFileUrl("test4.qml")); QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0")); QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1")); @@ -218,7 +208,7 @@ void tst_qquickfocusscope::noFocus() void tst_qquickfocusscope::textEdit() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("test5.qml"))); + view->setSource(testFileUrl("test5.qml")); QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0")); QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1")); @@ -268,7 +258,7 @@ void tst_qquickfocusscope::textEdit() void tst_qquickfocusscope::forceFocus() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("forcefocus.qml"))); + view->setSource(testFileUrl("forcefocus.qml")); QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0")); QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1")); @@ -317,7 +307,7 @@ void tst_qquickfocusscope::forceFocus() void tst_qquickfocusscope::noParentFocus() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("chain.qml"))); + view->setSource(testFileUrl("chain.qml")); QVERIFY(view->rootObject()); view->show(); @@ -337,7 +327,7 @@ void tst_qquickfocusscope::noParentFocus() void tst_qquickfocusscope::signalEmission() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("signalEmission.qml"))); + view->setSource(testFileUrl("signalEmission.qml")); QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1")); QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2")); @@ -393,7 +383,7 @@ void tst_qquickfocusscope::signalEmission() void tst_qquickfocusscope::qtBug13380() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("qtBug13380.qml"))); + view->setSource(testFileUrl("qtBug13380.qml")); view->show(); QVERIFY(view->rootObject()); @@ -414,7 +404,7 @@ void tst_qquickfocusscope::qtBug13380() void tst_qquickfocusscope::forceActiveFocus() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("forceActiveFocus.qml"))); + view->setSource(testFileUrl("forceActiveFocus.qml")); view->show(); view->requestActivateWindow(); @@ -528,7 +518,7 @@ void tst_qquickfocusscope::forceActiveFocus() void tst_qquickfocusscope::canvasFocus() { QQuickView *view = new QQuickView; - view->setSource(QUrl::fromLocalFile(TESTDATA("canvasFocus.qml"))); + view->setSource(testFileUrl("canvasFocus.qml")); QQuickView alternateView; diff --git a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro b/tests/auto/qtquick2/qquickgridview/qquickgridview.pro index b34cfdf936..32bf0ecaf9 100644 --- a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro +++ b/tests/auto/qtquick2/qquickgridview/qquickgridview.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickgridview macx:CONFIG -= app_bundle -SOURCES += tst_qquickgridview.cpp +SOURCES += tst_qquickgridview.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 5a1f482f49..babfe4c649 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -58,15 +58,13 @@ Q_DECLARE_METATYPE(Qt::LayoutDirection) Q_DECLARE_METATYPE(QQuickGridView::Flow) -class tst_QQuickGridView : public QObject +class tst_QQuickGridView : public QDeclarativeDataTest { Q_OBJECT public: tst_QQuickGridView(); private slots: - void initTestCase(); - void cleanupTestCase(); void items(); void changed(); void inserted(); @@ -159,16 +157,6 @@ void tst_qquickgridview_move(int from, int to, int n, T *items) *t = *f; } -void tst_QQuickGridView::initTestCase() -{ -} - -void tst_QQuickGridView::cleanupTestCase() -{ - -} - - class TestModel : public QAbstractListModel { public: @@ -286,7 +274,7 @@ void tst_QQuickGridView::items() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -336,7 +324,7 @@ void tst_QQuickGridView::changed() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid"); @@ -371,7 +359,7 @@ void tst_QQuickGridView::inserted() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -457,7 +445,7 @@ void tst_QQuickGridView::inserted_more() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -626,7 +614,7 @@ void tst_QQuickGridView::insertBeforeVisible() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -710,7 +698,7 @@ void tst_QQuickGridView::removed() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -861,7 +849,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); @@ -940,7 +928,7 @@ void tst_QQuickGridView::clear() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -987,7 +975,7 @@ void tst_QQuickGridView::moved() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -1192,7 +1180,7 @@ void tst_QQuickGridView::multipleChanges() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -1409,7 +1397,7 @@ void tst_QQuickGridView::swapWithFirstItem() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -1436,7 +1424,7 @@ void tst_QQuickGridView::currentIndex() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - QString filename(TESTDATA("gridview-initCurrent.qml")); + QString filename(testFile("gridview-initCurrent.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -1681,7 +1669,7 @@ void tst_QQuickGridView::noCurrentIndex() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - QString filename(TESTDATA("gridview-noCurrent.qml")); + QString filename(testFile("gridview-noCurrent.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -1719,7 +1707,7 @@ void tst_QQuickGridView::changeFlow() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -1806,7 +1794,7 @@ void tst_QQuickGridView::changeFlow() void tst_QQuickGridView::defaultValues() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("gridview3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("gridview3.qml")); QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create()); QTRY_VERIFY(obj != 0); @@ -1829,7 +1817,7 @@ void tst_QQuickGridView::defaultValues() void tst_QQuickGridView::properties() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("gridview2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("gridview2.qml")); QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create()); QTRY_VERIFY(obj != 0); @@ -1853,7 +1841,7 @@ void tst_QQuickGridView::propertyChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView"); QTRY_VERIFY(gridView); @@ -1926,7 +1914,7 @@ void tst_QQuickGridView::componentChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView"); QTRY_VERIFY(gridView); @@ -1974,7 +1962,7 @@ void tst_QQuickGridView::modelChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView"); QTRY_VERIFY(gridView); @@ -2009,7 +1997,7 @@ void tst_QQuickGridView::positionViewAtIndex() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2210,7 +2198,7 @@ void tst_QQuickGridView::snapping() ctxt->setContextProperty("testTopToBottom", QVariant(false)); ctxt->setContextProperty("testRightToLeft", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2241,12 +2229,12 @@ void tst_QQuickGridView::snapping() void tst_QQuickGridView::mirroring() { QQuickView *canvasA = createView(); - canvasA->setSource(QUrl::fromLocalFile(TESTDATA("mirroring.qml"))); + canvasA->setSource(testFileUrl("mirroring.qml")); QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view"); QTRY_VERIFY(gridviewA != 0); QQuickView *canvasB = createView(); - canvasB->setSource(QUrl::fromLocalFile(TESTDATA("mirroring.qml"))); + canvasB->setSource(testFileUrl("mirroring.qml")); QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view"); QTRY_VERIFY(gridviewA != 0); qApp->processEvents(); @@ -2312,7 +2300,7 @@ void tst_QQuickGridView::positionViewAtIndex_rightToLeft() ctxt->setContextProperty("testTopToBottom", QVariant(true)); ctxt->setContextProperty("testRightToLeft", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2442,7 +2430,7 @@ void tst_QQuickGridView::resetModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaygrid.qml"))); + canvas->setSource(testFileUrl("displaygrid.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2487,7 +2475,7 @@ void tst_QQuickGridView::enforceRange() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview-enforcerange.qml"))); + canvas->setSource(testFileUrl("gridview-enforcerange.qml")); qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); @@ -2543,7 +2531,7 @@ void tst_QQuickGridView::enforceRange_rightToLeft() ctxt->setContextProperty("testRightToLeft", QVariant(true)); ctxt->setContextProperty("testTopToBottom", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview-enforcerange.qml"))); + canvas->setSource(testFileUrl("gridview-enforcerange.qml")); qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); @@ -2592,7 +2580,7 @@ void tst_QQuickGridView::QTBUG_8456() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("setindex.qml"))); + canvas->setSource(testFileUrl("setindex.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2607,7 +2595,7 @@ void tst_QQuickGridView::manualHighlight() { QQuickView *canvas = createView(); - QString filename(TESTDATA("manual-highlight.qml")); + QString filename(testFile("manual-highlight.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -2671,7 +2659,7 @@ void tst_QQuickGridView::footer() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("footer.qml"))); + canvas->setSource(testFileUrl("footer.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -2830,7 +2818,7 @@ void tst_QQuickGridView::header() canvas->rootContext()->setContextProperty("testModel", &model); canvas->rootContext()->setContextProperty("initialViewWidth", 240); canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml"))); + canvas->setSource(testFileUrl("header.qml")); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); @@ -2894,7 +2882,7 @@ void tst_QQuickGridView::header() canvas->rootContext()->setContextProperty("testModel", &model); canvas->rootContext()->setContextProperty("initialViewWidth", 240); canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml"))); + canvas->setSource(testFileUrl("header.qml")); gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); @@ -2975,7 +2963,7 @@ void tst_QQuickGridView::resizeViewAndRepaint() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("initialHeight", 100); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml"))); + canvas->setSource(testFileUrl("resizeview.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -3013,7 +3001,7 @@ void tst_QQuickGridView::indexAt() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -3052,7 +3040,7 @@ void tst_QQuickGridView::onAdd() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("delegateWidth", delegateWidth); ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml"))); + canvas->setSource(testFileUrl("attachedSignals.qml")); QObject *object = canvas->rootObject(); object->setProperty("width", canvas->width()); @@ -3110,7 +3098,7 @@ void tst_QQuickGridView::onRemove() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("delegateWidth", delegateWidth); ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml"))); + canvas->setSource(testFileUrl("attachedSignals.qml")); QObject *object = canvas->rootObject(); model.removeItems(indexToRemove, removeCount); @@ -3146,7 +3134,7 @@ void tst_QQuickGridView::onRemove_data() void tst_QQuickGridView::columnCount() { QQuickView canvas; - canvas.setSource(QUrl::fromLocalFile(TESTDATA("gridview4.qml"))); + canvas.setSource(testFileUrl("gridview4.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -3176,7 +3164,7 @@ void tst_QQuickGridView::margins() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testRightToLeft", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml"))); + canvas->setSource(testFileUrl("margins.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -3239,7 +3227,7 @@ void tst_QQuickGridView::margins() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testRightToLeft", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml"))); + canvas->setSource(testFileUrl("margins.qml")); qApp->processEvents(); QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid"); @@ -3296,7 +3284,7 @@ void tst_QQuickGridView::creationContext() { QQuickView canvas; canvas.setGeometry(0,0,240,320); - canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml"))); + canvas.setSource(testFileUrl("creationContext.qml")); qApp->processEvents(); QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject()); @@ -3355,7 +3343,7 @@ void tst_QQuickGridView::snapToRow() QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapToRow.qml"))); + canvas->setSource(testFileUrl("snapToRow.qml")); canvas->show(); qApp->processEvents(); @@ -3449,7 +3437,7 @@ void tst_QQuickGridView::snapOneRow() QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapOneRow.qml"))); + canvas->setSource(testFileUrl("snapOneRow.qml")); canvas->show(); qApp->processEvents(); @@ -3530,7 +3518,7 @@ void tst_QQuickGridView::unaligned() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("unaligned.qml"))); + canvas->setSource(testFileUrl("unaligned.qml")); qApp->processEvents(); QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject()); @@ -3617,7 +3605,7 @@ void tst_QQuickGridView::cacheBuffer() ctxt->setContextProperty("testRightToLeft", QVariant(false)); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml"))); + canvas->setSource(testFileUrl("gridview1.qml")); canvas->show(); qApp->processEvents(); @@ -3708,7 +3696,7 @@ void tst_QQuickGridView::asynchronous() QDeclarativeIncubationController controller; canvas->engine()->setIncubationController(&controller); - canvas->setSource(TESTDATA("asyncloader.qml")); + canvas->setSource(testFile("asyncloader.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(rootObject); @@ -3761,8 +3749,7 @@ void tst_QQuickGridView::unrequestedVisibility() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testWrap", QVariant(false)); - QString filename(TESTDATA("unrequestedItems.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->setSource(testFileUrl("unrequestedItems.qml")); canvas->show(); diff --git a/tests/auto/qtquick2/qquickimage/qquickimage.pro b/tests/auto/qtquick2/qquickimage/qquickimage.pro index fd2af3b677..07dd5fe1e7 100644 --- a/tests/auto/qtquick2/qquickimage/qquickimage.pro +++ b/tests/auto/qtquick2/qquickimage/qquickimage.pro @@ -2,8 +2,11 @@ CONFIG += testcase TARGET = tst_qquickimage macx:CONFIG -= app_bundle -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickimage.cpp ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += tst_qquickimage.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp b/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp index a7883626c6..630ad0c8aa 100644 --- a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp @@ -64,7 +64,7 @@ Q_DECLARE_METATYPE(QQuickImageBase::Status) -class tst_qquickimage : public QObject +class tst_qquickimage : public QDeclarativeDataTest { Q_OBJECT public: @@ -130,13 +130,13 @@ void tst_qquickimage::imageSource_data() QTest::addColumn<bool>("cache"); QTest::addColumn<QString>("error"); - QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << 120.0 << 120.0 << false << false << true << ""; - QTest::newRow("local no cache") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << 120.0 << 120.0 << false << false << false << ""; - QTest::newRow("local async") << QUrl::fromLocalFile(TESTDATA("colors1.png")).toString() << 120.0 << 120.0 << false << true << true << ""; - QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString() << 0.0 << 0.0 << false - << false << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString(); - QTest::newRow("local async not found") << QUrl::fromLocalFile(TESTDATA("no-such-file-1.png")).toString() << 0.0 << 0.0 << false - << true << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file-1.png")).toString(); + QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << ""; + QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << ""; + QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << ""; + QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false + << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString(); + QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false + << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << ""; QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << ""; if (QImageReader::supportedImageFormats().contains("svg")) @@ -160,7 +160,7 @@ void tst_qquickimage::imageSource() TestHTTPServer server(SERVER_PORT); if (remote) { QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); } @@ -207,7 +207,7 @@ void tst_qquickimage::clearSource() { QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -229,7 +229,7 @@ void tst_qquickimage::clearSource() void tst_qquickimage::resized() { - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + TESTDATA("colors.png") + "\"; width: 300; height: 300 }"; + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -246,14 +246,14 @@ void tst_qquickimage::preserveAspectRatio() QQuickView *canvas = new QQuickView(0); canvas->show(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("aspectratio.qml"))); + canvas->setSource(testFileUrl("aspectratio.qml")); QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject()); QVERIFY(image != 0); image->setWidth(80.0); QCOMPARE(image->width(), 80.); QCOMPARE(image->height(), 80.); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("aspectratio.qml"))); + canvas->setSource(testFileUrl("aspectratio.qml")); image = qobject_cast<QQuickImage*>(canvas->rootObject()); image->setHeight(60.0); QVERIFY(image != 0); @@ -264,7 +264,7 @@ void tst_qquickimage::preserveAspectRatio() void tst_qquickimage::smooth() { - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + TESTDATA("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -291,7 +291,7 @@ void tst_qquickimage::mirror() foreach (QQuickImage::FillMode fillMode, fillModes) { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("mirror.qml"))); + canvas->setSource(testFileUrl("mirror.qml")); QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image"); QVERIFY(obj != 0); @@ -307,7 +307,7 @@ void tst_qquickimage::mirror() foreach (QQuickImage::FillMode fillMode, fillModes) { QPixmap srcPixmap; - QVERIFY(srcPixmap.load(TESTDATA("pattern.png"))); + QVERIFY(srcPixmap.load(testFile("pattern.png"))); QPixmap expected(width, height); expected.fill(); @@ -359,7 +359,7 @@ void tst_qquickimage::svg() if (!QImageReader::supportedImageFormats().contains("svg")) QSKIP("svg support not available"); - QString src = QUrl::fromLocalFile(TESTDATA("heart.svg")).toString(); + QString src = testFileUrl("heart.svg").toString(); QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); @@ -423,7 +423,7 @@ void tst_qquickimage::geometry() QFETCH(double, boundingWidth); QFETCH(double, boundingHeight); - QString src = QUrl::fromLocalFile(TESTDATA("rect.png")).toString(); + QString src = testFileUrl("rect.png").toString(); QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; "; if (explicitWidth) @@ -451,7 +451,7 @@ void tst_qquickimage::big() // If the JPEG loader does not implement scaling efficiently, it would // have to build a 400 MB image. That would be a bug in the JPEG loader. - QString src = QUrl::fromLocalFile(TESTDATA("big.jpeg")).toString(); + QString src = testFileUrl("big.jpeg").toString(); QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }"; QDeclarativeComponent component(&engine); @@ -484,7 +484,7 @@ void tst_qquickimage::tiling_QTBUG_6716() QQuickView *canvas = new QQuickView(0); AutoDelete<QQuickView> del(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA(source))); + canvas->setSource(testFileUrl(source)); canvas->show(); qApp->processEvents(); @@ -512,12 +512,12 @@ void tst_qquickimage::noLoading() TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("heart.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -529,7 +529,7 @@ void tst_qquickimage::noLoading() QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("green.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("green.png")); QTRY_VERIFY(obj->status() == QQuickImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 1); @@ -547,7 +547,7 @@ void tst_qquickimage::noLoading() QTRY_COMPARE(statusSpy.count(), 2); // Loading remote file again - should not go through 'Loading' state. - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("green.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("green.png")); ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); QTRY_VERIFY(obj->status() == QQuickImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); @@ -561,7 +561,7 @@ void tst_qquickimage::noLoading() void tst_qquickimage::paintedWidthHeight() { { - QString src = QUrl::fromLocalFile(TESTDATA("heart.png")).toString(); + QString src = testFileUrl("heart.png").toString(); QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }"; QDeclarativeComponent component(&engine); @@ -577,7 +577,7 @@ void tst_qquickimage::paintedWidthHeight() } { - QString src = QUrl::fromLocalFile(TESTDATA("heart.png")).toString(); + QString src = testFileUrl("heart.png").toString(); QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); @@ -596,7 +596,7 @@ void tst_qquickimage::sourceSize_QTBUG_14303() { QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart200.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); @@ -610,12 +610,12 @@ void tst_qquickimage::sourceSize_QTBUG_14303() QTRY_COMPARE(obj->sourceSize().height(), 200); QTRY_COMPARE(sourceSizeSpy.count(), 0); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); QTRY_COMPARE(obj->sourceSize().width(), 120); QTRY_COMPARE(obj->sourceSize().height(), 120); QTRY_COMPARE(sourceSizeSpy.count(), 1); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart200.png"))); + ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); QTRY_COMPARE(obj->sourceSize().width(), 200); QTRY_COMPARE(obj->sourceSize().height(), 200); QTRY_COMPARE(sourceSizeSpy.count(), 2); @@ -626,7 +626,7 @@ void tst_qquickimage::sourceSize_QTBUG_14303() void tst_qquickimage::sourceSize_QTBUG_16389() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug_16389.qml"))); + canvas->setSource(testFileUrl("qtbug_16389.qml")); canvas->show(); qApp->processEvents(); @@ -659,7 +659,7 @@ static void checkWarnings(QtMsgType, const char *msg) void tst_qquickimage::nullPixmapPaint() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("nullpixmap.qml"))); + canvas->setSource(testFileUrl("nullpixmap.qml")); canvas->show(); QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject()); @@ -679,10 +679,10 @@ void tst_qquickimage::imageCrash_QTBUG_22125() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA(""), TestHTTPServer::Delay); + server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); { - QQuickView view(QUrl::fromLocalFile(TESTDATA("qtbug_22125.qml"))); + QQuickView view(testFileUrl("qtbug_22125.qml")); view.show(); qApp->processEvents(); qApp->processEvents(); diff --git a/tests/auto/qtquick2/qquickitem/qquickitem.pro b/tests/auto/qtquick2/qquickitem/qquickitem.pro index 2ebe76b09c..a29641c02b 100644 --- a/tests/auto/qtquick2/qquickitem/qquickitem.pro +++ b/tests/auto/qtquick2/qquickitem/qquickitem.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qquickitem -SOURCES += tst_qquickitem.cpp +SOURCES += tst_qquickitem.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h macx:CONFIG -= app_bundle diff --git a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp index fd7433b64e..688f5e5024 100644 --- a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp @@ -103,16 +103,12 @@ protected: virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } }; -class tst_qquickitem : public QObject +class tst_qquickitem : public QDeclarativeDataTest { Q_OBJECT public: - tst_qquickitem(); private slots: - void initTestCase(); - void cleanupTestCase(); - void noCanvas(); void simpleFocus(); void scopedFocus(); @@ -150,18 +146,6 @@ private: } }; -tst_qquickitem::tst_qquickitem() -{ -} - -void tst_qquickitem::initTestCase() -{ -} - -void tst_qquickitem::cleanupTestCase() -{ -} - // Focus has no effect when outside a canvas void tst_qquickitem::noCanvas() { @@ -1075,56 +1059,59 @@ void tst_qquickitem::hoverEventInParent() void tst_qquickitem::paintOrder_data() { + const QUrl order1Url = testFileUrl("order.1.qml"); + const QUrl order2Url = testFileUrl("order.2.qml"); + QTest::addColumn<QUrl>("source"); QTest::addColumn<int>("op"); QTest::addColumn<QVariant>("param1"); QTest::addColumn<QVariant>("param2"); QTest::addColumn<QStringList>("expected"); - QTest::newRow("test 1 noop") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 noop") << order1Url << int(NoOp) << QVariant() << QVariant() << (QStringList() << "1" << "2" << "3"); - QTest::newRow("test 1 add") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 add") << order1Url << int(Append) << QVariant("new") << QVariant() << (QStringList() << "1" << "2" << "3" << "new"); - QTest::newRow("test 1 remove") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 remove") << order1Url << int(Remove) << QVariant(1) << QVariant() << (QStringList() << "1" << "3"); - QTest::newRow("test 1 stack before") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 stack before") << order1Url << int(StackBefore) << QVariant(2) << QVariant(1) << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 1 stack after") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 stack after") << order1Url << int(StackAfter) << QVariant(0) << QVariant(1) << (QStringList() << "2" << "1" << "3"); - QTest::newRow("test 1 set z") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 set z") << order1Url << int(SetZ) << QVariant(1) << QVariant(qreal(1.)) << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 noop") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 noop") << order2Url << int(NoOp) << QVariant() << QVariant() << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 add") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 add") << order2Url << int(Append) << QVariant("new") << QVariant() << (QStringList() << "1" << "3" << "new" << "2"); - QTest::newRow("test 2 remove 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 remove 1") << order2Url << int(Remove) << QVariant(1) << QVariant() << (QStringList() << "1" << "3"); - QTest::newRow("test 2 remove 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 remove 2") << order2Url << int(Remove) << QVariant(2) << QVariant() << (QStringList() << "1" << "2"); - QTest::newRow("test 2 stack before 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 stack before 1") << order2Url << int(StackBefore) << QVariant(1) << QVariant(0) << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 stack before 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 stack before 2") << order2Url << int(StackBefore) << QVariant(2) << QVariant(0) << (QStringList() << "3" << "1" << "2"); - QTest::newRow("test 2 stack after 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 stack after 1") << order2Url << int(StackAfter) << QVariant(0) << QVariant(1) << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 stack after 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml")) + QTest::newRow("test 2 stack after 2") << order2Url << int(StackAfter) << QVariant(0) << QVariant(2) << (QStringList() << "3" << "1" << "2"); - QTest::newRow("test 1 set z") << QUrl::fromLocalFile(TESTDATA("order.1.qml")) + QTest::newRow("test 1 set z") << order1Url << int(SetZ) << QVariant(2) << QVariant(qreal(2.)) << (QStringList() << "1" << "2" << "3"); } diff --git a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro index 2a1d63633c..75a6d88858 100644 --- a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro +++ b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickitem2 macx:CONFIG -= app_bundle -SOURCES += tst_qquickitem.cpp +SOURCES += tst_qquickitem.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp index 959710e0db..334f5456f2 100644 --- a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp @@ -48,7 +48,7 @@ #include <private/qquickitem_p.h> #include "../../shared/util.h" -class tst_QQuickItem : public QObject +class tst_QQuickItem : public QDeclarativeDataTest { Q_OBJECT public: @@ -197,6 +197,7 @@ tst_QQuickItem::tst_QQuickItem() void tst_QQuickItem::initTestCase() { + QDeclarativeDataTest::initTestCase(); qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem"); } @@ -211,7 +212,7 @@ void tst_QQuickItem::keys() canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keystest.qml"))); + canvas->setSource(testFileUrl("keystest.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -329,7 +330,7 @@ void tst_QQuickItem::keysProcessingOrder() KeysTestObject *testObject = new KeysTestObject; canvas->rootContext()->setContextProperty("keysTestObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keyspriority.qml"))); + canvas->setSource(testFileUrl("keyspriority.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -397,7 +398,7 @@ bool anchorsMirrored(QQuickItem *rootItem, const char * itemString) void tst_QQuickItem::layoutMirroring() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("layoutmirroring.qml"))); + canvas->setSource(testFileUrl("layoutmirroring.qml")); canvas->show(); QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject()); @@ -538,7 +539,7 @@ void tst_QQuickItem::keyNavigation() QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(240,320)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml"))); + canvas->setSource(testFileUrl("keynavigationtest.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -615,7 +616,7 @@ void tst_QQuickItem::keyNavigation_RightToLeft() QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(240,320)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml"))); + canvas->setSource(testFileUrl("keynavigationtest.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -670,7 +671,7 @@ void tst_QQuickItem::keyNavigation_skipNotVisible() QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(240,320)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml"))); + canvas->setSource(testFileUrl("keynavigationtest.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -745,7 +746,7 @@ void tst_QQuickItem::keyNavigation_implicitSetting() QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(240,320)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest_implicit.qml"))); + canvas->setSource(testFileUrl("keynavigationtest_implicit.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -933,7 +934,7 @@ void tst_QQuickItem::mapCoordinates() QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml"))); + canvas->setSource(testFileUrl("mapCoordinates.qml")); canvas->show(); qApp->processEvents(); @@ -962,8 +963,8 @@ void tst_QQuickItem::mapCoordinates() Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y))); - QString warning1 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; - QString warning2 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; + QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; + QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", @@ -1014,7 +1015,7 @@ void tst_QQuickItem::transforms() void tst_QQuickItem::childrenProperty() { - QDeclarativeComponent component(&engine, TESTDATA("childrenProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -1029,7 +1030,7 @@ void tst_QQuickItem::childrenProperty() void tst_QQuickItem::resourcesProperty() { - QDeclarativeComponent component(&engine, TESTDATA("resourcesProperty.qml")); + QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -1046,7 +1047,7 @@ void tst_QQuickItem::propertyChanges() { QQuickView *canvas = new QQuickView(0); canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + canvas->setSource(testFileUrl("propertychanges.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -1127,7 +1128,7 @@ void tst_QQuickItem::propertyChanges() void tst_QQuickItem::childrenRect() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRect.qml"))); + canvas->setSource(testFileUrl("childrenRect.qml")); canvas->setBaseSize(QSize(240,320)); canvas->show(); @@ -1157,11 +1158,11 @@ void tst_QQuickItem::childrenRectBug() { QQuickView *canvas = new QQuickView(0); - QString warning = QUrl::fromLocalFile(TESTDATA("childrenRectBug.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; + QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug.qml"))); + canvas->setSource(testFileUrl("childrenRectBug.qml")); canvas->show(); QQuickItem *o = canvas->rootObject(); @@ -1178,17 +1179,17 @@ void tst_QQuickItem::childrenRectBug2() { QQuickView *canvas = new QQuickView(0); - QString warning1 = QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"width\""; + QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\""; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QString warning2 = QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; + QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml"))); + canvas->setSource(testFileUrl("childrenRectBug2.qml")); canvas->show(); QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject()); @@ -1211,7 +1212,7 @@ void tst_QQuickItem::childrenRectBug2() void tst_QQuickItem::childrenRectBug3() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug3.qml"))); + canvas->setSource(testFileUrl("childrenRectBug3.qml")); canvas->show(); //don't crash on delete @@ -1222,7 +1223,7 @@ void tst_QQuickItem::childrenRectBug3() void tst_QQuickItem::transformCrash() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("transformCrash.qml"))); + canvas->setSource(testFileUrl("transformCrash.qml")); canvas->show(); delete canvas; @@ -1231,7 +1232,7 @@ void tst_QQuickItem::transformCrash() void tst_QQuickItem::implicitSize() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("implicitsize.qml"))); + canvas->setSource(testFileUrl("implicitsize.qml")); canvas->show(); QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject()); @@ -1259,7 +1260,7 @@ void tst_QQuickItem::implicitSize() void tst_QQuickItem::qtbug_16871() { - QDeclarativeComponent component(&engine, TESTDATA("qtbug_16871.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml")); QObject *o = component.create(); QVERIFY(o != 0); delete o; diff --git a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro b/tests/auto/qtquick2/qquicklistview/qquicklistview.pro index be88679c62..16e0695855 100644 --- a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro +++ b/tests/auto/qtquick2/qquicklistview/qquicklistview.pro @@ -2,8 +2,11 @@ CONFIG += testcase TARGET = tst_qquicklistview macx:CONFIG -= app_bundle -HEADERS += incrementalmodel.h -SOURCES += tst_qquicklistview.cpp incrementalmodel.cpp +HEADERS += incrementalmodel.h \ + ../../shared/util.h +SOURCES += tst_qquicklistview.cpp \ + incrementalmodel.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index c6cd692045..73b4d0319d 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -60,15 +60,13 @@ Q_DECLARE_METATYPE(Qt::LayoutDirection) Q_DECLARE_METATYPE(QQuickListView::Orientation) -class tst_QQuickListView : public QObject +class tst_QQuickListView : public QDeclarativeDataTest { Q_OBJECT public: tst_QQuickListView(); private slots: - void initTestCase(); - void cleanupTestCase(); // Test both QListModelInterface and QAbstractItemModel model types void qListModelInterface_items(); void qListModelInterface_package_items(); @@ -184,14 +182,6 @@ private: void moved_data(); }; -void tst_QQuickListView::initTestCase() -{ -} - -void tst_QQuickListView::cleanupTestCase() -{ - -} class TestObject : public QObject { Q_OBJECT @@ -611,7 +601,7 @@ void tst_QQuickListView::inserted(const QUrl &source) ctxt->setContextProperty("testObject", testObject); canvas->setSource(source); - //canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + //canvas->setSource(testFileUrl("listviewtest.qml"))); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -715,7 +705,7 @@ void tst_QQuickListView::inserted_more() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -865,7 +855,7 @@ void tst_QQuickListView::insertBeforeVisible() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1396,7 +1386,7 @@ void tst_QQuickListView::multipleChanges() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1613,7 +1603,7 @@ void tst_QQuickListView::swapWithFirstItem() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1639,7 +1629,7 @@ void tst_QQuickListView::enforceRange() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-enforcerange.qml"))); + canvas->setSource(testFileUrl("listview-enforcerange.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1700,7 +1690,7 @@ void tst_QQuickListView::enforceRange_withoutHighlight() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-enforcerange-nohighlight.qml"))); + canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1742,7 +1732,7 @@ void tst_QQuickListView::spacing() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -1894,7 +1884,7 @@ void tst_QQuickListView::sectionsDelegate() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-sections_delegate.qml"))); + canvas->setSource(testFileUrl("listview-sections_delegate.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -2007,7 +1997,7 @@ void tst_QQuickListView::sectionsPositioning() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-sections_delegate.qml"))); + canvas->setSource(testFileUrl("listview-sections_delegate.qml")); qApp->processEvents(); canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd))); @@ -2136,7 +2126,7 @@ void tst_QQuickListView::currentIndex_delayedItemCreation() // (since the currentItem will have changed and that shares the same index) canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("fillModelOnComponentCompleted.qml"))); + canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -2173,7 +2163,7 @@ void tst_QQuickListView::currentIndex() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testWrap", QVariant(false)); - QString filename(TESTDATA("listview-initCurrent.qml")); + QString filename(testFile("listview-initCurrent.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -2309,7 +2299,7 @@ void tst_QQuickListView::noCurrentIndex() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - QString filename(TESTDATA("listview-noCurrent.qml")); + QString filename(testFile("listview-noCurrent.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -2339,7 +2329,7 @@ void tst_QQuickListView::itemList() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("itemlist.qml"))); + canvas->setSource(testFileUrl("itemlist.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view"); @@ -2390,7 +2380,7 @@ void tst_QQuickListView::cacheBuffer() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); @@ -2491,7 +2481,7 @@ void tst_QQuickListView::positionViewAtIndex() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -2656,7 +2646,7 @@ void tst_QQuickListView::resetModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml"))); + canvas->setSource(testFileUrl("displaylist.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -2692,7 +2682,7 @@ void tst_QQuickListView::propertyChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView"); QTRY_VERIFY(listView); @@ -2760,7 +2750,7 @@ void tst_QQuickListView::componentChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView"); QTRY_VERIFY(listView); @@ -2808,7 +2798,7 @@ void tst_QQuickListView::modelChanges() { QQuickView *canvas = createView(); QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml"))); + canvas->setSource(testFileUrl("propertychangestest.qml")); QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView"); QTRY_VERIFY(listView); @@ -2835,7 +2825,7 @@ void tst_QQuickListView::QTBUG_9791() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("strictlyenforcerange.qml"))); + canvas->setSource(testFileUrl("strictlyenforcerange.qml")); qApp->processEvents(); QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject()); @@ -2871,7 +2861,7 @@ void tst_QQuickListView::manualHighlight() QQuickView *canvas = new QQuickView(0); canvas->setGeometry(0,0,240,320); - QString filename(TESTDATA("manual-highlight.qml")); + QString filename(testFile("manual-highlight.qml")); canvas->setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -2916,7 +2906,7 @@ void tst_QQuickListView::QTBUG_11105() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -2969,7 +2959,7 @@ void tst_QQuickListView::header() canvas->rootContext()->setContextProperty("testModel", &model); canvas->rootContext()->setContextProperty("initialViewWidth", 240); canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml"))); + canvas->setSource(testFileUrl("header.qml")); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -3026,7 +3016,7 @@ void tst_QQuickListView::header() canvas->rootContext()->setContextProperty("testModel", &model); canvas->rootContext()->setContextProperty("initialViewWidth", 0.0); canvas->rootContext()->setContextProperty("initialViewHeight", 0.0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml"))); + canvas->setSource(testFileUrl("header.qml")); listview = findItem<QQuickListView>(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -3102,7 +3092,7 @@ void tst_QQuickListView::header_delayItemCreation() TestModel model; canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("fillModelOnComponentCompleted.qml"))); + canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3143,7 +3133,7 @@ void tst_QQuickListView::footer() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("footer.qml"))); + canvas->setSource(testFileUrl("footer.qml")); canvas->show(); qApp->processEvents(); @@ -3298,7 +3288,7 @@ void tst_QQuickListView::headerFooter() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml"))); + canvas->setSource(testFileUrl("headerfooter.qml")); qApp->processEvents(); QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject()); @@ -3328,7 +3318,7 @@ void tst_QQuickListView::headerFooter() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml"))); + canvas->setSource(testFileUrl("headerfooter.qml")); canvas->rootObject()->setProperty("horizontal", true); qApp->processEvents(); @@ -3359,7 +3349,7 @@ void tst_QQuickListView::headerFooter() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml"))); + canvas->setSource(testFileUrl("headerfooter.qml")); canvas->rootObject()->setProperty("horizontal", true); canvas->rootObject()->setProperty("rtl", true); qApp->processEvents(); @@ -3399,7 +3389,7 @@ void tst_QQuickListView::resizeView() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3443,7 +3433,7 @@ void tst_QQuickListView::resizeViewAndRepaint() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("initialHeight", 100); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml"))); + canvas->setSource(testFileUrl("resizeview.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3477,7 +3467,7 @@ void tst_QQuickListView::sizeLessThan1() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("sizelessthan1.qml"))); + canvas->setSource(testFileUrl("sizelessthan1.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3503,7 +3493,7 @@ void tst_QQuickListView::QTBUG_14821() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug14821.qml"))); + canvas->setSource(testFileUrl("qtbug14821.qml")); qApp->processEvents(); QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject()); @@ -3534,7 +3524,7 @@ void tst_QQuickListView::resizeDelegate() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml"))); + canvas->setSource(testFileUrl("displaylist.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3619,7 +3609,7 @@ void tst_QQuickListView::resizeFirstDelegate() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3678,7 +3668,7 @@ void tst_QQuickListView::QTBUG_16037() QQuickView *canvas = createView(); canvas->show(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug16037.qml"))); + canvas->setSource(testFileUrl("qtbug16037.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview"); @@ -3707,7 +3697,7 @@ void tst_QQuickListView::indexAt() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + canvas->setSource(testFileUrl("listviewtest.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3734,7 +3724,7 @@ void tst_QQuickListView::incrementalModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml"))); + canvas->setSource(testFileUrl("displaylist.qml")); qApp->processEvents(); QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list"); @@ -3769,7 +3759,7 @@ void tst_QQuickListView::onAdd() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml"))); + canvas->setSource(testFileUrl("attachedSignals.qml")); QObject *object = canvas->rootObject(); object->setProperty("width", canvas->width()); @@ -3823,7 +3813,7 @@ void tst_QQuickListView::onRemove() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml"))); + canvas->setSource(testFileUrl("attachedSignals.qml")); QObject *object = canvas->rootObject(); model.removeItems(indexToRemove, removeCount); @@ -3861,7 +3851,7 @@ void tst_QQuickListView::rightToLeft() { QQuickView *canvas = createView(); canvas->setGeometry(0,0,640,320); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml"))); + canvas->setSource(testFileUrl("rightToLeft.qml")); qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); @@ -3911,12 +3901,12 @@ void tst_QQuickListView::rightToLeft() void tst_QQuickListView::test_mirroring() { QQuickView *canvasA = createView(); - canvasA->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml"))); + canvasA->setSource(testFileUrl("rightToLeft.qml")); QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view"); QTRY_VERIFY(listviewA != 0); QQuickView *canvasB = createView(); - canvasB->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml"))); + canvasB->setSource(testFileUrl("rightToLeft.qml")); QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view"); QTRY_VERIFY(listviewA != 0); qApp->processEvents(); @@ -3980,7 +3970,7 @@ void tst_QQuickListView::margins() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml"))); + canvas->setSource(testFileUrl("margins.qml")); canvas->show(); qApp->processEvents(); @@ -4074,7 +4064,7 @@ void tst_QQuickListView::snapToItem() QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapToItem.qml"))); + canvas->setSource(testFileUrl("snapToItem.qml")); canvas->show(); qApp->processEvents(); @@ -4127,42 +4117,42 @@ void tst_QQuickListView::snapToItem() void tst_QQuickListView::qListModelInterface_items() { - items<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); + items<TestModel>(testFileUrl("listviewtest.qml"), false); } void tst_QQuickListView::qListModelInterface_package_items() { - items<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true); + items<TestModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_items() { - items<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); + items<TestModel2>(testFileUrl("listviewtest.qml"), false); } void tst_QQuickListView::qListModelInterface_changed() { - changed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); + changed<TestModel>(testFileUrl("listviewtest.qml"), false); } void tst_QQuickListView::qListModelInterface_package_changed() { - changed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true); + changed<TestModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_changed() { - changed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); + changed<TestModel2>(testFileUrl("listviewtest.qml"), false); } void tst_QQuickListView::qListModelInterface_inserted() { - inserted<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + inserted<TestModel>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qListModelInterface_package_inserted() { - inserted<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml"))); + inserted<TestModel>(testFileUrl("listviewtest-package.qml")); } void tst_QQuickListView::qListModelInterface_inserted_more() @@ -4177,7 +4167,7 @@ void tst_QQuickListView::qListModelInterface_inserted_more_data() void tst_QQuickListView::qAbstractItemModel_inserted() { - inserted<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + inserted<TestModel2>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qAbstractItemModel_inserted_more() @@ -4192,25 +4182,25 @@ void tst_QQuickListView::qAbstractItemModel_inserted_more_data() void tst_QQuickListView::qListModelInterface_removed() { - removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); - removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), true); + removed<TestModel>(testFileUrl("listviewtest.qml"), false); + removed<TestModel>(testFileUrl("listviewtest.qml"), true); } void tst_QQuickListView::qListModelInterface_package_removed() { - removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), false); - removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true); + removed<TestModel>(testFileUrl("listviewtest-package.qml"), false); + removed<TestModel>(testFileUrl("listviewtest-package.qml"), true); } void tst_QQuickListView::qAbstractItemModel_removed() { - removed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false); - removed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), true); + removed<TestModel2>(testFileUrl("listviewtest.qml"), false); + removed<TestModel2>(testFileUrl("listviewtest.qml"), true); } void tst_QQuickListView::qListModelInterface_moved() { - moved<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + moved<TestModel>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qListModelInterface_moved_data() @@ -4220,7 +4210,7 @@ void tst_QQuickListView::qListModelInterface_moved_data() void tst_QQuickListView::qListModelInterface_package_moved() { - moved<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml"))); + moved<TestModel>(testFileUrl("listviewtest-package.qml")); } void tst_QQuickListView::qListModelInterface_package_moved_data() @@ -4230,7 +4220,7 @@ void tst_QQuickListView::qListModelInterface_package_moved_data() void tst_QQuickListView::qAbstractItemModel_moved() { - moved<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + moved<TestModel2>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qAbstractItemModel_moved_data() @@ -4240,39 +4230,39 @@ void tst_QQuickListView::qAbstractItemModel_moved_data() void tst_QQuickListView::qListModelInterface_clear() { - clear<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + clear<TestModel>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qListModelInterface_package_clear() { - clear<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml"))); + clear<TestModel>(testFileUrl("listviewtest-package.qml")); } void tst_QQuickListView::qAbstractItemModel_clear() { - clear<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml"))); + clear<TestModel2>(testFileUrl("listviewtest.qml")); } void tst_QQuickListView::qListModelInterface_sections() { - sections<TestModel>(QUrl::fromLocalFile(TESTDATA("listview-sections.qml"))); + sections<TestModel>(testFileUrl("listview-sections.qml")); } void tst_QQuickListView::qListModelInterface_package_sections() { - sections<TestModel>(QUrl::fromLocalFile(TESTDATA("listview-sections-package.qml"))); + sections<TestModel>(testFileUrl("listview-sections-package.qml")); } void tst_QQuickListView::qAbstractItemModel_sections() { - sections<TestModel2>(QUrl::fromLocalFile(TESTDATA("listview-sections.qml"))); + sections<TestModel2>(testFileUrl("listview-sections.qml")); } void tst_QQuickListView::creationContext() { QQuickView canvas; canvas.setGeometry(0,0,240,320); - canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml"))); + canvas.setSource(testFileUrl("creationContext.qml")); qApp->processEvents(); QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject()); @@ -4294,7 +4284,7 @@ void tst_QQuickListView::QTBUG_21742() { QQuickView canvas; canvas.setGeometry(0,0,200,200); - canvas.setSource(QUrl::fromLocalFile(TESTDATA("qtbug-21742.qml"))); + canvas.setSource(testFileUrl("qtbug-21742.qml")); qApp->processEvents(); QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject()); @@ -4335,7 +4325,7 @@ void tst_QQuickListView::asynchronous() QDeclarativeIncubationController controller; canvas->engine()->setIncubationController(&controller); - canvas->setSource(TESTDATA("asyncloader.qml")); + canvas->setSource(testFileUrl("asyncloader.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(rootObject); @@ -4416,7 +4406,7 @@ void tst_QQuickListView::snapOneItem() QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapOneItem.qml"))); + canvas->setSource(testFileUrl("snapOneItem.qml")); canvas->show(); qApp->processEvents(); @@ -4497,8 +4487,7 @@ void tst_QQuickListView::unrequestedVisibility() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testWrap", QVariant(false)); - QString filename(TESTDATA("unrequestedItems.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->setSource(testFileUrl("unrequestedItems.qml")); canvas->show(); diff --git a/tests/auto/qtquick2/qquickloader/qquickloader.pro b/tests/auto/qtquick2/qquickloader/qquickloader.pro index 6e372692c2..c22ed63b89 100644 --- a/tests/auto/qtquick2/qquickloader/qquickloader.pro +++ b/tests/auto/qtquick2/qquickloader/qquickloader.pro @@ -3,9 +3,12 @@ TARGET = tst_qquickloader macx:CONFIG -= app_bundle INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h + SOURCES += tst_qquickloader.cpp \ - ../../shared/testhttpserver.cpp + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp b/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp index 3df692a6a6..b1d6d07566 100644 --- a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp @@ -51,11 +51,6 @@ #define SERVER_PORT 14450 -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(TESTDATA(filename)); -} - class PeriodicIncubationController : public QObject, public QDeclarativeIncubationController { @@ -70,7 +65,7 @@ protected: } }; -class tst_QQuickLoader : public QObject +class tst_QQuickLoader : public QDeclarativeDataTest { Q_OBJECT @@ -149,7 +144,7 @@ void tst_QQuickLoader::sourceOrComponent() " onProgressChanged: onProgressChangedCount += 1\n" " onLoaded: onLoadedCount += 1\n" "}") - , TEST_FILE("")); + , dataDirectoryUrl()); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader != 0); @@ -194,10 +189,10 @@ void tst_QQuickLoader::sourceOrComponent_data() QTest::addColumn<QUrl>("sourceUrl"); QTest::addColumn<QString>("errorString"); - QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(TESTDATA("Rect120x60.qml")) << ""; + QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << ""; QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; - QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(TESTDATA("IDontExist.qml")) - << QString(QUrl::fromLocalFile(TESTDATA("IDontExist.qml")).toString() + ": File not found"); + QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml") + << QString(testFileUrl("IDontExist.qml").toString() + ": File not found"); } void tst_QQuickLoader::clear() @@ -210,7 +205,7 @@ void tst_QQuickLoader::clear() " source: 'Rect120x60.qml'\n" " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" " }") - , TEST_FILE("")); + , dataDirectoryUrl()); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); @@ -225,7 +220,7 @@ void tst_QQuickLoader::clear() delete loader; } { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -245,7 +240,7 @@ void tst_QQuickLoader::clear() delete item; } { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -276,7 +271,7 @@ void tst_QQuickLoader::urlToComponent() " source: \"Rect120x60.qml\"\n" " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" "}" ) - , TEST_FILE("")); + , dataDirectoryUrl()); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QTest::qWait(200); QTRY_VERIFY(loader != 0); @@ -291,7 +286,7 @@ void tst_QQuickLoader::urlToComponent() void tst_QQuickLoader::componentToUrl() { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -301,7 +296,7 @@ void tst_QQuickLoader::componentToUrl() QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1); - loader->setSource(TEST_FILE("/Rect120x60.qml")); + loader->setSource(testFileUrl("/Rect120x60.qml")); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1); @@ -313,7 +308,7 @@ void tst_QQuickLoader::componentToUrl() void tst_QQuickLoader::anchoredLoader() { - QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml")); QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create()); QVERIFY(rootItem != 0); QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader"); @@ -334,7 +329,7 @@ void tst_QQuickLoader::anchoredLoader() void tst_QQuickLoader::sizeLoaderToItem() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml")); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 120.0); @@ -375,7 +370,7 @@ void tst_QQuickLoader::sizeLoaderToItem() void tst_QQuickLoader::sizeItemToLoader() { - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml")); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 200.0); @@ -405,7 +400,7 @@ void tst_QQuickLoader::sizeItemToLoader() void tst_QQuickLoader::noResize() { - QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml")); + QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml")); QQuickItem* item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item != 0); QCOMPARE(item->width(), 200.0); @@ -418,10 +413,10 @@ void tst_QQuickLoader::networkRequestUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(TESTDATA("../dummy.qml"))); + component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml")); if (component.isError()) qDebug() << component.errors(); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); @@ -451,7 +446,7 @@ void tst_QQuickLoader::networkComponent() "Item {\n" " Component { id: comp; NW.SlowRect {} }\n" " Loader { sourceComponent: comp } }") - , TEST_FILE("")); + , dataDirectoryUrl()); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -473,7 +468,7 @@ void tst_QQuickLoader::failNetworkRequest() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found"); @@ -496,7 +491,7 @@ void tst_QQuickLoader::active() { // check that the item isn't instantiated until active is set to true { - QDeclarativeComponent component(&engine, TEST_FILE("active.1.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.1.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -515,7 +510,7 @@ void tst_QQuickLoader::active() // check that the status is Null if active is set to false { - QDeclarativeComponent component(&engine, TEST_FILE("active.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.2.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -532,7 +527,7 @@ void tst_QQuickLoader::active() // check that the source is not cleared if active is set to false { - QDeclarativeComponent component(&engine, TEST_FILE("active.3.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.3.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -549,7 +544,7 @@ void tst_QQuickLoader::active() // check that the sourceComponent is not cleared if active is set to false { - QDeclarativeComponent component(&engine, TEST_FILE("active.4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.4.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -566,7 +561,7 @@ void tst_QQuickLoader::active() // check that the item is released if active is set to false { - QDeclarativeComponent component(&engine, TEST_FILE("active.5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.5.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -583,7 +578,7 @@ void tst_QQuickLoader::active() // check that the activeChanged signal is emitted correctly { - QDeclarativeComponent component(&engine, TEST_FILE("active.6.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.6.qml")); QObject *object = component.create(); QVERIFY(object != 0); QQuickLoader *loader = object->findChild<QQuickLoader*>("loader"); @@ -613,7 +608,7 @@ void tst_QQuickLoader::active() // check that the component isn't loaded until active is set to true { - QDeclarativeComponent component(&engine, TEST_FILE("active.7.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.7.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("success").toBool(), true); @@ -622,7 +617,7 @@ void tst_QQuickLoader::active() // check that the component is loaded if active is not set (true by default) { - QDeclarativeComponent component(&engine, TEST_FILE("active.8.qml")); + QDeclarativeComponent component(&engine, testFileUrl("active.8.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("success").toBool(), true); @@ -637,42 +632,42 @@ void tst_QQuickLoader::initialPropertyValues_data() QTest::addColumn<QStringList>("propertyNames"); QTest::addColumn<QVariantList>("propertyValues"); - QTest::newRow("source url with value set in onLoaded, initially active = true") << TEST_FILE("initialPropertyValues.1.qml") + QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml") << QStringList() << (QStringList() << "initialValue" << "behaviorCount") << (QVariantList() << 1 << 1); - QTest::newRow("set source with initial property values specified, active = true") << TEST_FILE("initialPropertyValues.2.qml") + QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml") << QStringList() << (QStringList() << "initialValue" << "behaviorCount") << (QVariantList() << 2 << 0); - QTest::newRow("set source with initial property values specified, active = false") << TEST_FILE("initialPropertyValues.3.qml") - << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null"))) + QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml") + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null"))) << (QStringList()) << (QVariantList()); - QTest::newRow("set source with initial property values specified, active = false, with active set true later") << TEST_FILE("initialPropertyValues.4.qml") + QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml") << QStringList() << (QStringList() << "initialValue" << "behaviorCount") << (QVariantList() << 4 << 0); - QTest::newRow("set source without initial property values specified, active = true") << TEST_FILE("initialPropertyValues.5.qml") + QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml") << QStringList() << (QStringList() << "initialValue" << "behaviorCount") << (QVariantList() << 0 << 0); - QTest::newRow("set source with initial property values specified with binding, active = true") << TEST_FILE("initialPropertyValues.6.qml") + QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml") << QStringList() << (QStringList() << "initialValue" << "behaviorCount") << (QVariantList() << 6 << 0); - QTest::newRow("ensure initial property value semantics mimic createObject") << TEST_FILE("initialPropertyValues.7.qml") + QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml") << QStringList() << (QStringList() << "loaderValue" << "createObjectValue") << (QVariantList() << 1 << 1); - QTest::newRow("ensure initial property values aren't disposed prior to component completion") << TEST_FILE("initialPropertyValues.8.qml") + QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml") << QStringList() << (QStringList() << "initialValue") << (QVariantList() << 6); @@ -687,7 +682,7 @@ void tst_QQuickLoader::initialPropertyValues() TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); + server.serveDirectory(dataDirectory()); foreach (const QString &warning, expectedWarnings) QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); @@ -706,7 +701,7 @@ void tst_QQuickLoader::initialPropertyValues() void tst_QQuickLoader::initialPropertyValuesBinding() { - QDeclarativeComponent component(&engine, TEST_FILE("initialPropertyValues.binding.qml")); + QDeclarativeComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -721,18 +716,18 @@ void tst_QQuickLoader::initialPropertyValuesError_data() QTest::addColumn<QUrl>("qmlFile"); QTest::addColumn<QStringList>("expectedWarnings"); - QTest::newRow("invalid initial property values object") << TEST_FILE("initialPropertyValues.error.1.qml") - << (QStringList() << QString(TEST_FILE("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object")); + QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml") + << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object")); - QTest::newRow("nonexistent source url") << TEST_FILE("initialPropertyValues.error.2.qml") - << (QStringList() << QString(TEST_FILE("NonexistentSourceComponent.qml").toString() + ": File not found")); + QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml") + << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found")); - QTest::newRow("invalid source url") << TEST_FILE("initialPropertyValues.error.3.qml") - << (QStringList() << QString(TEST_FILE("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); + QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml") + << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); - QTest::newRow("invalid initial property values object with invalid property access") << TEST_FILE("initialPropertyValues.error.4.qml") - << (QStringList() << QString(TEST_FILE("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object") - << QString(TEST_FILE("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null")); + QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml") + << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object") + << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null")); } void tst_QQuickLoader::initialPropertyValuesError() @@ -755,7 +750,7 @@ void tst_QQuickLoader::initialPropertyValuesError() // QTBUG-9241 void tst_QQuickLoader::deleteComponentCrash() { - QDeclarativeComponent component(&engine, TEST_FILE("crash.qml")); + QDeclarativeComponent component(&engine, testFileUrl("crash.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -769,15 +764,15 @@ void tst_QQuickLoader::deleteComponentCrash() QCOMPARE(loader->status(), QQuickLoader::Ready); qApp->processEvents(QEventLoop::DeferredDeletion); QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1); - QVERIFY(loader->source() == QUrl::fromLocalFile(TESTDATA("BlueRect.qml"))); + QVERIFY(loader->source() == testFileUrl("BlueRect.qml")); delete item; } void tst_QQuickLoader::nonItem() { - QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); - QString err = QUrl::fromLocalFile(TESTDATA("nonItem.qml")).toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements."; + QDeclarativeComponent component(&engine, testFileUrl("nonItem.qml")); + QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements."; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); @@ -789,8 +784,8 @@ void tst_QQuickLoader::nonItem() void tst_QQuickLoader::vmeErrors() { - QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml")); - QString err = QUrl::fromLocalFile(TESTDATA("VmeError.qml")).toString() + ":6: Cannot assign object type QObject with no default method"; + QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml")); + QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method"; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create()); QVERIFY(loader); @@ -802,7 +797,7 @@ void tst_QQuickLoader::vmeErrors() // QTBUG-13481 void tst_QQuickLoader::creationContext() { - QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml")); + QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -814,7 +809,7 @@ void tst_QQuickLoader::creationContext() void tst_QQuickLoader::QTBUG_16928() { - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml")); + QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -826,7 +821,7 @@ void tst_QQuickLoader::QTBUG_16928() void tst_QQuickLoader::implicitSize() { - QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml")); + QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -841,7 +836,7 @@ void tst_QQuickLoader::implicitSize() void tst_QQuickLoader::QTBUG_17114() { - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml")); + QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml")); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -856,14 +851,14 @@ void tst_QQuickLoader::asynchronous_data() QTest::addColumn<QUrl>("qmlFile"); QTest::addColumn<QStringList>("expectedWarnings"); - QTest::newRow("Valid component") << TEST_FILE("BigComponent.qml") + QTest::newRow("Valid component") << testFileUrl("BigComponent.qml") << QStringList(); - QTest::newRow("Non-existant component") << TEST_FILE("IDoNotExist.qml") - << (QStringList() << QString(TEST_FILE("IDoNotExist.qml").toString() + ": File not found")); + QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml") + << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found")); - QTest::newRow("Invalid component") << TEST_FILE("InvalidSourceComponent.qml") - << (QStringList() << QString(TEST_FILE("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); + QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml") + << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); } void tst_QQuickLoader::asynchronous() @@ -873,7 +868,7 @@ void tst_QQuickLoader::asynchronous() if (!engine.incubationController()) engine.setIncubationController(new PeriodicIncubationController); - QDeclarativeComponent component(&engine, TEST_FILE("asynchronous.qml")); + QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(component.create()); QVERIFY(root); @@ -907,7 +902,7 @@ void tst_QQuickLoader::asynchronous_clear() { if (!engine.incubationController()) engine.setIncubationController(new PeriodicIncubationController); - QDeclarativeComponent component(&engine, TEST_FILE("asynchronous.qml")); + QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(component.create()); QVERIFY(root); @@ -948,7 +943,7 @@ void tst_QQuickLoader::asynchronous_clear() void tst_QQuickLoader::parented() { - QDeclarativeComponent component(&engine, TEST_FILE("parented.qml")); + QDeclarativeComponent component(&engine, testFileUrl("parented.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(component.create()); QVERIFY(root); diff --git a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro index fcf166b0ed..cd1a44e91d 100644 --- a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro +++ b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro @@ -2,8 +2,11 @@ CONFIG += testcase TARGET = tst_qquickmousearea macx:CONFIG -= app_bundle -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickmousearea.cpp ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += tst_qquickmousearea.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp index 7c9af4ba64..50ab26e6a1 100644 --- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp @@ -52,12 +52,10 @@ //#define OLDWAY -class tst_QQuickMouseArea: public QObject +class tst_QQuickMouseArea: public QDeclarativeDataTest { Q_OBJECT private slots: - void initTestCase(); - void cleanupTestCase(); void dragProperties(); void resetDrag(); void dragging(); @@ -80,21 +78,11 @@ private: QQuickView *createView(); }; -void tst_QQuickMouseArea::initTestCase() -{ - -} - -void tst_QQuickMouseArea::cleanupTestCase() -{ - -} - void tst_QQuickMouseArea::dragProperties() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragproperties.qml"))); + canvas->setSource(testFileUrl("dragproperties.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -180,7 +168,7 @@ void tst_QQuickMouseArea::resetDrag() QQuickView *canvas = createView(); canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragreset.qml"))); + canvas->setSource(testFileUrl("dragreset.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -210,7 +198,7 @@ void tst_QQuickMouseArea::dragging() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragging.qml"))); + canvas->setSource(testFileUrl("dragging.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWait(20); @@ -277,7 +265,7 @@ QQuickView *tst_QQuickMouseArea::createView() void tst_QQuickMouseArea::updateMouseAreaPosOnClick() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("updateMousePosOnClick.qml"))); + canvas->setSource(testFileUrl("updateMousePosOnClick.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -306,7 +294,7 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnClick() void tst_QQuickMouseArea::updateMouseAreaPosOnResize() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("updateMousePosOnResize.qml"))); + canvas->setSource(testFileUrl("updateMousePosOnResize.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -343,7 +331,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() { // We handle onPressAndHold, therefore no onClicked QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickandhold.qml"))); + canvas->setSource(testFileUrl("clickandhold.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -368,7 +356,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() { // We do not handle onPressAndHold, therefore we get onClicked QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("noclickandhold.qml"))); + canvas->setSource(testFileUrl("noclickandhold.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -392,7 +380,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() void tst_QQuickMouseArea::onMousePressRejected() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("rejectEvent.qml"))); + canvas->setSource(testFileUrl("rejectEvent.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -429,7 +417,7 @@ void tst_QQuickMouseArea::onMousePressRejected() void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pressedCanceled.qml"))); + canvas->setSource(testFileUrl("pressedCanceled.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -474,7 +462,7 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() void tst_QQuickMouseArea::doubleClick() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("doubleclick.qml"))); + canvas->setSource(testFileUrl("doubleclick.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -503,7 +491,7 @@ void tst_QQuickMouseArea::doubleClick() void tst_QQuickMouseArea::clickTwice() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("clicktwice.qml"))); + canvas->setSource(testFileUrl("clicktwice.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -534,7 +522,7 @@ void tst_QQuickMouseArea::clickTwice() void tst_QQuickMouseArea::pressedOrdering() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pressedOrdering.qml"))); + canvas->setSource(testFileUrl("pressedOrdering.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -562,7 +550,7 @@ void tst_QQuickMouseArea::preventStealing() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("preventstealing.qml"))); + canvas->setSource(testFileUrl("preventstealing.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -625,7 +613,7 @@ void tst_QQuickMouseArea::clickThrough() { //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickThrough.qml"))); + canvas->setSource(testFileUrl("clickThrough.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -658,7 +646,7 @@ void tst_QQuickMouseArea::clickThrough() //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickThrough2.qml"))); + canvas->setSource(testFileUrl("clickThrough2.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -776,7 +764,7 @@ void tst_QQuickMouseArea::testQtQuick11Attributes_data() void tst_QQuickMouseArea::hoverPosition() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("hoverPosition.qml"))); + canvas->setSource(testFileUrl("hoverPosition.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); @@ -797,7 +785,7 @@ void tst_QQuickMouseArea::hoverPropagation() { //QTBUG-18175, to behave like GV did. QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("hoverPropagation.qml"))); + canvas->setSource(testFileUrl("hoverPropagation.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); diff --git a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro b/tests/auto/qtquick2/qquickpathview/qquickpathview.pro index 6e16dd4879..7a414cd3ed 100644 --- a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro +++ b/tests/auto/qtquick2/qquickpathview/qquickpathview.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickpathview macx:CONFIG -= app_bundle -SOURCES += tst_qquickpathview.cpp +SOURCES += tst_qquickpathview.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp index 0bfa65b734..53c94ca4a9 100644 --- a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp @@ -78,15 +78,13 @@ static void initStandardTreeModel(QStandardItemModel *model) } -class tst_QQuickPathView : public QObject +class tst_QQuickPathView : public QDeclarativeDataTest { Q_OBJECT public: tst_QQuickPathView(); private slots: - void initTestCase(); - void cleanupTestCase(); void initValues(); void items(); void dataModel(); @@ -129,15 +127,6 @@ private: QList<T*> findItems(QQuickItem *parent, const QString &objectName); }; -void tst_QQuickPathView::initTestCase() -{ -} - -void tst_QQuickPathView::cleanupTestCase() -{ - -} - class TestObject : public QObject { Q_OBJECT @@ -285,7 +274,7 @@ tst_QQuickPathView::tst_QQuickPathView() void tst_QQuickPathView::initValues() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview1.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathview1.qml")); QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create()); QVERIFY(obj != 0); @@ -315,7 +304,7 @@ void tst_QQuickPathView::items() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -350,7 +339,7 @@ void tst_QQuickPathView::items() void tst_QQuickPathView::pathview2() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview2.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathview2.qml")); QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create()); QVERIFY(obj != 0); @@ -370,7 +359,7 @@ void tst_QQuickPathView::pathview2() void tst_QQuickPathView::pathview3() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview3.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathview3.qml")); QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create()); QVERIFY(obj != 0); @@ -449,7 +438,7 @@ void tst_QQuickPathView::insertModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -535,7 +524,7 @@ void tst_QQuickPathView::removeModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -626,7 +615,7 @@ void tst_QQuickPathView::moveModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -649,7 +638,7 @@ void tst_QQuickPathView::moveModel() void tst_QQuickPathView::path() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathtest.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("pathtest.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj != 0); @@ -719,7 +708,7 @@ void tst_QQuickPathView::dataModel() ctxt->setContextProperty("testData", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("datamodel.qml"))); + canvas->setSource(testFileUrl("datamodel.qml")); qApp->processEvents(); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject()); @@ -821,7 +810,7 @@ void tst_QQuickPathView::pathMoved() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -878,7 +867,7 @@ void tst_QQuickPathView::setCurrentIndex() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml"))); + canvas->setSource(testFileUrl("pathview0.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -1005,7 +994,7 @@ void tst_QQuickPathView::resetModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaypath.qml"))); + canvas->setSource(testFileUrl("displaypath.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -1038,7 +1027,7 @@ void tst_QQuickPathView::propertyChanges() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + canvas->setSource(testFileUrl("propertychanges.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1073,7 +1062,7 @@ void tst_QQuickPathView::pathChanges() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + canvas->setSource(testFileUrl("propertychanges.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1135,7 +1124,7 @@ void tst_QQuickPathView::componentChanges() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + canvas->setSource(testFileUrl("propertychanges.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1158,7 +1147,7 @@ void tst_QQuickPathView::modelChanges() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); + canvas->setSource(testFileUrl("propertychanges.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1185,7 +1174,7 @@ void tst_QQuickPathView::pathUpdateOnStartChanged() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathUpdateOnStartChanged.qml"))); + canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1207,7 +1196,7 @@ void tst_QQuickPathView::package() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview_package.qml"))); + canvas->setSource(testFileUrl("pathview_package.qml")); canvas->show(); QTest::qWaitForWindowShown(canvas); @@ -1231,7 +1220,7 @@ void tst_QQuickPathView::emptyModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("emptyModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("emptymodel.qml"))); + canvas->setSource(testFileUrl("emptymodel.qml")); qApp->processEvents(); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject()); @@ -1247,7 +1236,7 @@ void tst_QQuickPathView::closed() QDeclarativeEngine engine; { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("openPath.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("openPath.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj); QCOMPARE(obj->isClosed(), false); @@ -1255,7 +1244,7 @@ void tst_QQuickPathView::closed() } { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("closedPath.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("closedPath.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj); QCOMPARE(obj->isClosed(), true); @@ -1268,7 +1257,7 @@ void tst_QQuickPathView::pathUpdate() { QQuickView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathUpdate.qml"))); + canvas->setSource(testFileUrl("pathUpdate.qml")); QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView"); QVERIFY(pathView); @@ -1283,7 +1272,7 @@ void tst_QQuickPathView::pathUpdate() void tst_QQuickPathView::visualDataModel() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("vdm.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("vdm.qml")); QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create()); QVERIFY(obj != 0); @@ -1303,7 +1292,7 @@ void tst_QQuickPathView::undefinedPath() QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2)); - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("undefinedpath.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("undefinedpath.qml")); QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create()); QVERIFY(obj != 0); @@ -1316,7 +1305,7 @@ void tst_QQuickPathView::undefinedPath() void tst_QQuickPathView::mouseDrag() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragpath.qml"))); + canvas->setSource(testFileUrl("dragpath.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -1355,7 +1344,7 @@ void tst_QQuickPathView::treeModel() initStandardTreeModel(&model); canvas->engine()->rootContext()->setContextProperty("myModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("treemodel.qml"))); + canvas->setSource(testFileUrl("treemodel.qml")); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject()); QVERIFY(pathview != 0); @@ -1378,7 +1367,7 @@ void tst_QQuickPathView::changePreferredHighlight() { QQuickView *canvas = createView(); canvas->setGeometry(0,0,400,200); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragpath.qml"))); + canvas->setSource(testFileUrl("dragpath.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -1417,7 +1406,7 @@ void tst_QQuickPathView::creationContext() { QQuickView canvas; canvas.setGeometry(0,0,240,320); - canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml"))); + canvas.setSource(testFileUrl("creationContext.qml")); QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject()); QVERIFY(rootItem); @@ -1439,7 +1428,7 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathline.qml"))); + canvas->setSource(testFileUrl("pathline.qml")); qApp->processEvents(); QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view"); @@ -1515,7 +1504,7 @@ void tst_QQuickPathView::asynchronous() QDeclarativeIncubationController controller; canvas->engine()->setIncubationController(&controller); - canvas->setSource(TESTDATA("asyncloader.qml")); + canvas->setSource(testFileUrl("asyncloader.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(rootObject); @@ -1625,7 +1614,7 @@ QList<T*> tst_QQuickPathView::findItems(QQuickItem *parent, const QString &objec void tst_QQuickPathView::missingPercent() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("missingPercent.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("missingPercent.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj); QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0)); diff --git a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro b/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro index 6e2ff59512..f5fb246ae8 100644 --- a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro +++ b/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickpincharea macx:CONFIG -= app_bundle -SOURCES += tst_qquickpincharea.cpp +SOURCES += tst_qquickpincharea.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp index c34565e953..53d7c2c2ce 100644 --- a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp +++ b/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp @@ -47,7 +47,7 @@ #include <QtDeclarative/qdeclarativecontext.h> #include "../../shared/util.h" -class tst_QQuickPinchArea: public QObject +class tst_QQuickPinchArea: public QDeclarativeDataTest { Q_OBJECT public: @@ -66,6 +66,7 @@ private: }; void tst_QQuickPinchArea::initTestCase() { + QDeclarativeDataTest::initTestCase(); if (!device) { device = new QTouchDevice; device->setType(QTouchDevice::TouchScreen); @@ -80,7 +81,7 @@ void tst_QQuickPinchArea::cleanupTestCase() void tst_QQuickPinchArea::pinchProperties() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml"))); + canvas->setSource(testFileUrl("pinchproperties.qml")); canvas->show(); canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); @@ -206,7 +207,7 @@ QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickIt void tst_QQuickPinchArea::scale() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml"))); + canvas->setSource(testFileUrl("pinchproperties.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -259,7 +260,7 @@ void tst_QQuickPinchArea::scale() void tst_QQuickPinchArea::pan() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml"))); + canvas->setSource(testFileUrl("pinchproperties.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); @@ -315,7 +316,7 @@ void tst_QQuickPinchArea::pan() void tst_QQuickPinchArea::retouch() { QQuickView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml"))); + canvas->setSource(testFileUrl("pinchproperties.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWaitForWindowShown(canvas); diff --git a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro b/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro index 5931b9ba3a..729b61e80b 100644 --- a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro +++ b/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro @@ -1,6 +1,9 @@ CONFIG += testcase TARGET = tst_qquickpositioners -SOURCES += tst_qquickpositioners.cpp +SOURCES += tst_qquickpositioners.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp index b6cc68f18e..2878240430 100644 --- a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp @@ -49,7 +49,7 @@ #include <qdeclarativeexpression.h> #include "../../shared/util.h" -class tst_qquickpositioners : public QObject +class tst_qquickpositioners : public QDeclarativeDataTest { Q_OBJECT public: @@ -99,7 +99,7 @@ tst_qquickpositioners::tst_qquickpositioners() void tst_qquickpositioners::test_horizontal() { - QQuickView *canvas = createView(TESTDATA("horizontal.qml")); + QQuickView *canvas = createView(testFile("horizontal.qml")); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -128,7 +128,7 @@ void tst_qquickpositioners::test_horizontal() void tst_qquickpositioners::test_horizontal_rtl() { - QQuickView *canvas = createView(TESTDATA("horizontal.qml")); + QQuickView *canvas = createView(testFile("horizontal.qml")); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -166,7 +166,7 @@ void tst_qquickpositioners::test_horizontal_rtl() void tst_qquickpositioners::test_horizontal_spacing() { - QQuickView *canvas = createView(TESTDATA("horizontal-spacing.qml")); + QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -195,7 +195,7 @@ void tst_qquickpositioners::test_horizontal_spacing() void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("horizontal-spacing.qml")); + QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -224,7 +224,7 @@ void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() void tst_qquickpositioners::test_horizontal_animated() { - QQuickView *canvas = createView(TESTDATA("horizontal-animated.qml"), false); + QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -278,7 +278,7 @@ void tst_qquickpositioners::test_horizontal_animated() void tst_qquickpositioners::test_horizontal_animated_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("horizontal-animated.qml"), false); + QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -334,7 +334,7 @@ void tst_qquickpositioners::test_horizontal_animated_rightToLeft() void tst_qquickpositioners::test_horizontal_animated_disabled() { - QQuickView *canvas = createView(TESTDATA("horizontal-animated-disabled.qml")); + QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -372,7 +372,7 @@ void tst_qquickpositioners::test_horizontal_animated_disabled() void tst_qquickpositioners::test_vertical() { - QQuickView *canvas = createView(TESTDATA("vertical.qml")); + QQuickView *canvas = createView(testFile("vertical.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -400,7 +400,7 @@ void tst_qquickpositioners::test_vertical() void tst_qquickpositioners::test_vertical_spacing() { - QQuickView *canvas = createView(TESTDATA("vertical-spacing.qml")); + QQuickView *canvas = createView(testFile("vertical-spacing.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -427,7 +427,7 @@ void tst_qquickpositioners::test_vertical_spacing() void tst_qquickpositioners::test_vertical_animated() { - QQuickView *canvas = createView(TESTDATA("vertical-animated.qml"), false); + QQuickView *canvas = createView(testFile("vertical-animated.qml"), false); //Note that they animate in QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); @@ -477,7 +477,7 @@ void tst_qquickpositioners::test_vertical_animated() void tst_qquickpositioners::test_grid() { - QQuickView *canvas = createView(TESTDATA("gridtest.qml")); + QQuickView *canvas = createView(testFile("gridtest.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -511,7 +511,7 @@ void tst_qquickpositioners::test_grid() void tst_qquickpositioners::test_grid_topToBottom() { - QQuickView *canvas = createView(TESTDATA("grid-toptobottom.qml")); + QQuickView *canvas = createView(testFile("grid-toptobottom.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -545,7 +545,7 @@ void tst_qquickpositioners::test_grid_topToBottom() void tst_qquickpositioners::test_grid_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("gridtest.qml")); + QQuickView *canvas = createView(testFile("gridtest.qml")); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -594,7 +594,7 @@ void tst_qquickpositioners::test_grid_rightToLeft() void tst_qquickpositioners::test_grid_spacing() { - QQuickView *canvas = createView(TESTDATA("grid-spacing.qml")); + QQuickView *canvas = createView(testFile("grid-spacing.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -627,7 +627,7 @@ void tst_qquickpositioners::test_grid_spacing() void tst_qquickpositioners::test_grid_row_column_spacing() { - QQuickView *canvas = createView(TESTDATA("grid-row-column-spacing.qml")); + QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -660,7 +660,7 @@ void tst_qquickpositioners::test_grid_row_column_spacing() void tst_qquickpositioners::test_grid_animated() { - QQuickView *canvas = createView(TESTDATA("grid-animated.qml"), false); + QQuickView *canvas = createView(testFile("grid-animated.qml"), false); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -745,7 +745,7 @@ void tst_qquickpositioners::test_grid_animated() void tst_qquickpositioners::test_grid_animated_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("grid-animated.qml"), false); + QQuickView *canvas = createView(testFile("grid-animated.qml"), false); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -830,7 +830,7 @@ void tst_qquickpositioners::test_grid_animated_rightToLeft() void tst_qquickpositioners::test_grid_zero_columns() { - QQuickView *canvas = createView(TESTDATA("gridzerocolumns.qml")); + QQuickView *canvas = createView(testFile("gridzerocolumns.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -863,7 +863,7 @@ void tst_qquickpositioners::test_grid_zero_columns() void tst_qquickpositioners::test_propertychanges() { - QQuickView *canvas = createView(TESTDATA("propertychangestest.qml")); + QQuickView *canvas = createView(testFile("propertychangestest.qml")); QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject()); QVERIFY(grid != 0); @@ -922,7 +922,7 @@ void tst_qquickpositioners::test_propertychanges() void tst_qquickpositioners::test_repeater() { - QQuickView *canvas = createView(TESTDATA("repeatertest.qml")); + QQuickView *canvas = createView(testFile("repeatertest.qml")); QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one"); QVERIFY(one != 0); @@ -945,7 +945,7 @@ void tst_qquickpositioners::test_repeater() void tst_qquickpositioners::test_flow() { - QQuickView *canvas = createView(TESTDATA("flowtest.qml")); + QQuickView *canvas = createView(testFile("flowtest.qml")); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -981,7 +981,7 @@ void tst_qquickpositioners::test_flow() void tst_qquickpositioners::test_flow_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("flowtest.qml")); + QQuickView *canvas = createView(testFile("flowtest.qml")); canvas->rootObject()->setProperty("testRightToLeft", true); @@ -1017,7 +1017,7 @@ void tst_qquickpositioners::test_flow_rightToLeft() void tst_qquickpositioners::test_flow_topToBottom() { - QQuickView *canvas = createView(TESTDATA("flowtest-toptobottom.qml")); + QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml")); canvas->rootObject()->setProperty("testRightToLeft", false); @@ -1070,7 +1070,7 @@ void tst_qquickpositioners::test_flow_topToBottom() void tst_qquickpositioners::test_flow_resize() { - QQuickView *canvas = createView(TESTDATA("flowtest.qml")); + QQuickView *canvas = createView(testFile("flowtest.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(root); @@ -1104,7 +1104,7 @@ void tst_qquickpositioners::test_flow_resize() void tst_qquickpositioners::test_flow_resize_rightToLeft() { - QQuickView *canvas = createView(TESTDATA("flowtest.qml")); + QQuickView *canvas = createView(testFile("flowtest.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(root); @@ -1138,7 +1138,7 @@ void tst_qquickpositioners::test_flow_resize_rightToLeft() void tst_qquickpositioners::test_flow_implicit_resize() { - QQuickView *canvas = createView(TESTDATA("flow-testimplicitsize.qml")); + QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml")); QVERIFY(canvas->rootObject() != 0); QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow"); @@ -1281,10 +1281,10 @@ void tst_qquickpositioners::test_mirroring() objectNames << "one" << "two" << "three" << "four" << "five"; foreach (const QString qmlFile, qmlFiles) { - QQuickView *canvasA = createView(TESTDATA(qmlFile)); + QQuickView *canvasA = createView(testFile(qmlFile)); QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject()); - QQuickView *canvasB = createView(TESTDATA(qmlFile)); + QQuickView *canvasB = createView(testFile(qmlFile)); QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject()); rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft @@ -1334,7 +1334,7 @@ void tst_qquickpositioners::test_mirroring() void tst_qquickpositioners::test_allInvisible() { //QTBUG-19361 - QQuickView *canvas = createView(TESTDATA("allInvisible.qml")); + QQuickView *canvas = createView(testFile("allInvisible.qml")); QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(root); @@ -1392,15 +1392,15 @@ void tst_qquickpositioners::test_attachedproperties_data() { QTest::addColumn<QString>("filename"); - QTest::newRow("column") << TESTDATA("attachedproperties-column.qml"); - QTest::newRow("row") << TESTDATA("attachedproperties-row.qml"); - QTest::newRow("grid") << TESTDATA("attachedproperties-grid.qml"); - QTest::newRow("flow") << TESTDATA("attachedproperties-flow.qml"); + QTest::newRow("column") << testFile("attachedproperties-column.qml"); + QTest::newRow("row") << testFile("attachedproperties-row.qml"); + QTest::newRow("grid") << testFile("attachedproperties-grid.qml"); + QTest::newRow("flow") << testFile("attachedproperties-flow.qml"); } void tst_qquickpositioners::test_attachedproperties_dynamic() { - QQuickView *canvas = createView(TESTDATA("attachedproperties-dynamic.qml")); + QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml")); QVERIFY(canvas->rootObject() != 0); QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos"); diff --git a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro b/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro index 7e740f98aa..efd7538099 100644 --- a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro +++ b/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickrepeater macx:CONFIG -= app_bundle -SOURCES += tst_qquickrepeater.cpp +SOURCES += tst_qquickrepeater.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testFiles.files = data testFiles.path = . diff --git a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp index 1d6af452e4..857b4a41f2 100644 --- a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp @@ -52,12 +52,7 @@ #include "../../shared/util.h" -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(TESTDATA(filename)); -} - -class tst_QQuickRepeater : public QObject +class tst_QQuickRepeater : public QDeclarativeDataTest { Q_OBJECT public: @@ -183,7 +178,7 @@ void tst_QQuickRepeater::numberModel() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(TEST_FILE("intmodel.qml")); + canvas->setSource(testFileUrl("intmodel.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -224,7 +219,7 @@ void tst_QQuickRepeater::objectList() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", QVariant::fromValue(data)); - canvas->setSource(TEST_FILE("objlist.qml")); + canvas->setSource(testFileUrl("objlist.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -265,7 +260,7 @@ void tst_QQuickRepeater::stringList() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", data); - canvas->setSource(TEST_FILE("repeater1.qml")); + canvas->setSource(testFileUrl("repeater1.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -313,7 +308,7 @@ void tst_QQuickRepeater::dataModel_adding() TestModel testModel; ctxt->setContextProperty("testData", &testModel); - canvas->setSource(TEST_FILE("repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -383,7 +378,7 @@ void tst_QQuickRepeater::dataModel_removing() testModel.addItem("five", "5"); ctxt->setContextProperty("testData", &testModel); - canvas->setSource(TEST_FILE("repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -449,7 +444,7 @@ void tst_QQuickRepeater::dataModel_changes() testModel.addItem("three", "3"); ctxt->setContextProperty("testData", &testModel); - canvas->setSource(TEST_FILE("repeater2.qml")); + canvas->setSource(testFileUrl("repeater2.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -483,7 +478,7 @@ void tst_QQuickRepeater::itemModel() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(TEST_FILE("itemlist.qml")); + canvas->setSource(testFileUrl("itemlist.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); @@ -527,7 +522,7 @@ void tst_QQuickRepeater::resetModel() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", dataA); - canvas->setSource(TEST_FILE("repeater1.qml")); + canvas->setSource(testFileUrl("repeater1.qml")); qApp->processEvents(); QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); @@ -589,7 +584,7 @@ void tst_QQuickRepeater::resetModel() void tst_QQuickRepeater::modelChanged() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("modelChanged.qml")); + QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create()); QVERIFY(rootObject); @@ -612,7 +607,7 @@ void tst_QQuickRepeater::modelChanged() void tst_QQuickRepeater::properties() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("properties.qml")); + QDeclarativeComponent component(&engine, testFileUrl("properties.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create()); QVERIFY(rootObject); @@ -646,7 +641,7 @@ void tst_QQuickRepeater::asynchronous() QDeclarativeIncubationController controller; canvas->engine()->setIncubationController(&controller); - canvas->setSource(TEST_FILE("asyncloader.qml")); + canvas->setSource(testFileUrl("asyncloader.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(rootObject); @@ -698,7 +693,7 @@ void tst_QQuickRepeater::asynchronous() void tst_QQuickRepeater::initParent() { QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("initparent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("initparent.qml")); QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create()); QVERIFY(rootObject); diff --git a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro b/tests/auto/qtquick2/qquickscreen/qquickscreen.pro index 05fa6b9936..8d6a32b7aa 100644 --- a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro +++ b/tests/auto/qtquick2/qquickscreen/qquickscreen.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qquickscreen -SOURCES += tst_qquickscreen.cpp +SOURCES += tst_qquickscreen.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h macx:CONFIG -= app_bundle diff --git a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp index f74f2845e0..89462230bf 100644 --- a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp +++ b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp @@ -46,35 +46,17 @@ #include <QtGui/QScreen> #include "../../shared/util.h" -class tst_qquickscreen : public QObject +class tst_qquickscreen : public QDeclarativeDataTest { Q_OBJECT -public: - tst_qquickscreen (); - private slots: - void initTestCase(); - void cleanupTestCase(); - void basicProperties(); }; -tst_qquickscreen::tst_qquickscreen() -{ -} - -void tst_qquickscreen::initTestCase() -{ -} - -void tst_qquickscreen::cleanupTestCase() -{ -} - void tst_qquickscreen::basicProperties() { QQuickView view; - view.setSource(TESTDATA("screen.qml")); + view.setSource(testFileUrl("screen.qml")); view.show(); QTest::qWaitForWindowShown(&view); diff --git a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro index fe788f5b7b..062a1b99cc 100644 --- a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro +++ b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro @@ -1,6 +1,9 @@ CONFIG += testcase TARGET = tst_qquickspriteimage -SOURCES += tst_qquickspriteimage.cpp +SOURCES += tst_qquickspriteimage.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h + macx:CONFIG -= app_bundle testDataFiles.files = data diff --git a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp index 5c09019b03..9d2c52ac54 100644 --- a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp +++ b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp @@ -43,7 +43,7 @@ #include <QtQuick/qquickview.h> #include <private/qquickspriteimage_p.h> -class tst_qquickspriteimage : public QObject +class tst_qquickspriteimage : public QDeclarativeDataTest { Q_OBJECT public: @@ -57,7 +57,7 @@ void tst_qquickspriteimage::test_properties() { QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("basic.qml"))); + canvas->setSource(testFileUrl("basic.qml")); canvas->show(); QTest::qWaitForWindowShown(canvas); diff --git a/tests/auto/qtquick2/qquicktext/qquicktext.pro b/tests/auto/qtquick2/qquicktext/qquicktext.pro index e5bd50afc6..5c55714605 100644 --- a/tests/auto/qtquick2/qquicktext/qquicktext.pro +++ b/tests/auto/qtquick2/qquicktext/qquicktext.pro @@ -5,8 +5,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_qquicktext.cpp INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h -SOURCES += ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h +SOURCES += ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 88a8b6d819..877fb311c5 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -57,15 +57,13 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) -class tst_qquicktext : public QObject +class tst_qquicktext : public QDeclarativeDataTest { Q_OBJECT public: tst_qquicktext(); private slots: - void initTestCase(); - void cleanupTestCase(); void text(); void width(); void wrap(); @@ -127,14 +125,7 @@ private: QQuickView *createView(const QString &filename); }; -void tst_qquicktext::initTestCase() -{ -} -void tst_qquicktext::cleanupTestCase() -{ - -} tst_qquicktext::tst_qquicktext() { standard << "the quick brown fox jumped over the lazy dog" @@ -451,7 +442,7 @@ void tst_qquicktext::elide() void tst_qquicktext::multilineElide() { - QQuickView *canvas = createView(TESTDATA("multilineelide.qml")); + QQuickView *canvas = createView(testFile("multilineelide.qml")); QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject()); QVERIFY(myText != 0); @@ -541,17 +532,17 @@ void tst_qquicktext::alignments_data() QTest::addColumn<int>("vAlign"); QTest::addColumn<QString>("expectfile"); - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << TESTDATA("alignments_lt.png"); - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << TESTDATA("alignments_rt.png"); - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << TESTDATA("alignments_ct.png"); + QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png"); + QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png"); + QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png"); - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << TESTDATA("alignments_lb.png"); - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << TESTDATA("alignments_rb.png"); - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << TESTDATA("alignments_cb.png"); + QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png"); + QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png"); + QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png"); - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << TESTDATA("alignments_lc.png"); - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << TESTDATA("alignments_rc.png"); - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << TESTDATA("alignments_cc.png"); + QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png"); + QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png"); + QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png"); } @@ -563,7 +554,7 @@ void tst_qquicktext::alignments() QFETCH(int, vAlign); QFETCH(QString, expectfile); - QQuickView *canvas = createView(TESTDATA("alignments.qml")); + QQuickView *canvas = createView(testFile("alignments.qml")); canvas->show(); canvas->requestActivateWindow(); QTest::qWait(50); @@ -626,7 +617,7 @@ void tst_qquicktext::horizontalAlignment() void tst_qquicktext::horizontalAlignment_RightToLeft() { - QQuickView *canvas = createView(TESTDATA("horizontalAlignment_RightToLeft.qml")); + QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml")); QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text"); QVERIFY(text != 0); canvas->show(); @@ -1298,12 +1289,12 @@ void tst_qquicktext::embeddedImages_data() { QTest::addColumn<QUrl>("qmlfile"); QTest::addColumn<QString>("error"); - QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocal.qml")) << ""; - QTest::newRow("local-error") << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocalError.qml")) - << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocalError.qml")).toString()+":3:1: QML Text: Cannot open: " + QUrl::fromLocalFile(TESTDATA("http/notexists.png")).toString(); - QTest::newRow("remote") << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemote.qml")) << ""; - QTest::newRow("remote-error") << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemoteError.qml")) - << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemoteError.qml")).toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; + QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; + QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") + << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString(); + QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; + QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") + << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; } void tst_qquicktext::embeddedImages() @@ -1314,7 +1305,7 @@ void tst_qquicktext::embeddedImages() QFETCH(QString, error); TestHTTPServer server(14453); - server.serveDirectory(TESTDATA("http")); + server.serveDirectory(testFile("http")); if (!error.isEmpty()) QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); @@ -1326,7 +1317,7 @@ void tst_qquicktext::embeddedImages() QTRY_COMPARE(textObject->resourcesLoading(), 0); - QPixmap pm(TESTDATA("http/exists.png")); + QPixmap pm(testFile("http/exists.png")); if (error.isEmpty()) { QCOMPARE(textObject->width(), double(pm.width())); QCOMPARE(textObject->height(), double(pm.height())); @@ -1341,7 +1332,7 @@ void tst_qquicktext::embeddedImages() void tst_qquicktext::lineCount() { - QQuickView *canvas = createView(TESTDATA("lineCount.qml")); + QQuickView *canvas = createView(testFile("lineCount.qml")); QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText"); QVERIFY(myText != 0); @@ -1370,7 +1361,7 @@ void tst_qquicktext::lineCount() void tst_qquicktext::lineHeight() { - QQuickView *canvas = createView(TESTDATA("lineHeight.qml")); + QQuickView *canvas = createView(testFile("lineHeight.qml")); QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText"); QVERIFY(myText != 0); @@ -1432,7 +1423,7 @@ void tst_qquicktext::implicitSize() void tst_qquicktext::lineLaidOut() { - QQuickView *canvas = createView(TESTDATA("lineLayout.qml")); + QQuickView *canvas = createView(testFile("lineLayout.qml")); QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText"); QVERIFY(myText != 0); diff --git a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro b/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro index 02a834beab..b647377482 100644 --- a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro +++ b/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro @@ -2,8 +2,12 @@ CONFIG += testcase TARGET = tst_qquicktextedit macx:CONFIG -= app_bundle -SOURCES += tst_qquicktextedit.cpp ../../shared/testhttpserver.cpp -HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquicktextedit.cpp \ + ../../shared/testhttpserver.cpp \ + ../../shared/util.cpp + +HEADERS += ../../shared/testhttpserver.h \ + ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index fc7b0329cb..075eacb211 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -74,7 +74,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = TESTDATA(""); + QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory(); QString arch = "unknown-architecture"; // QTest needs to help with this. QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; @@ -89,7 +89,7 @@ QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& typedef QPair<int, QChar> Key; -class tst_qquicktextedit : public QObject +class tst_qquicktextedit : public QDeclarativeDataTest { Q_OBJECT @@ -97,8 +97,6 @@ public: tst_qquicktextedit(); private slots: - void initTestCase(); - void cleanupTestCase(); void text(); void width(); void wrap(); @@ -253,15 +251,6 @@ QList<Key> &operator <<(QList<Key> &keys, Qt::Key key) return keys; } - -void tst_qquicktextedit::initTestCase() -{ -} - -void tst_qquicktextedit::cleanupTestCase() -{ - -} tst_qquicktextedit::tst_qquicktextedit() { standard << "the quick brown fox jumped over the lazy dog" @@ -568,7 +557,7 @@ void tst_qquicktextedit::alignments() QFETCH(int, vAlign); QFETCH(QString, expectfile); - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("alignments.qml"))); + QQuickView canvas(testFileUrl("alignments.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -627,7 +616,7 @@ void tst_qquicktextedit::hAlign() void tst_qquicktextedit::hAlign_RightToLeft() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment_RightToLeft.qml"))); + QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text"); QVERIFY(textEdit != 0); canvas.show(); @@ -1110,7 +1099,7 @@ void tst_qquicktextedit::isRightToLeft() void tst_qquicktextedit::keySelection() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml"))); + QQuickView canvas(testFileUrl("navigation.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -1500,19 +1489,19 @@ void tst_qquicktextedit::mouseSelection_data() QTest::addColumn<QString>("selectedText"); // import installed - QTest::newRow("on") << TESTDATA("mouseselection_true.qml") << 4 << 9 << "45678"; - QTest::newRow("off") << TESTDATA("mouseselection_false.qml") << 4 << 9 << QString(); - QTest::newRow("default") << TESTDATA("mouseselection_default.qml") << 4 << 9 << QString(); - QTest::newRow("off word selection") << TESTDATA("mouseselection_false_words.qml") << 4 << 9 << QString(); - QTest::newRow("on word selection (4,9)") << TESTDATA("mouseselection_true_words.qml") << 4 << 9 << "0123456789"; - QTest::newRow("on word selection (2,13)") << TESTDATA("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (2,30)") << TESTDATA("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,13)") << TESTDATA("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,30)") << TESTDATA("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (13,2)") << TESTDATA("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (20,2)") << TESTDATA("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (12,9)") << TESTDATA("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (30,9)") << TESTDATA("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678"; + QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString(); + QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString(); + QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString(); + QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789"; + QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } void tst_qquicktextedit::mouseSelection() @@ -1552,7 +1541,7 @@ void tst_qquicktextedit::mouseSelection() void tst_qquicktextedit::dragMouseSelection() { - QString qmlfile = TESTDATA("mouseselection_true.qml"); + QString qmlfile = testFile("mouseselection_true.qml"); QQuickView canvas(QUrl::fromLocalFile(qmlfile)); @@ -1595,9 +1584,9 @@ void tst_qquicktextedit::mouseSelectionMode_data() QTest::addColumn<bool>("selectWords"); // import installed - QTest::newRow("SelectWords") << TESTDATA("mouseselectionmode_words.qml") << true; - QTest::newRow("SelectCharacters") << TESTDATA("mouseselectionmode_characters.qml") << false; - QTest::newRow("default") << TESTDATA("mouseselectionmode_default.qml") << false; + QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; + QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; + QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; } void tst_qquicktextedit::mouseSelectionMode() @@ -1639,7 +1628,7 @@ void tst_qquicktextedit::mouseSelectionMode() void tst_qquicktextedit::inputMethodHints() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("inputmethodhints.qml"))); + QQuickView canvas(testFileUrl("inputmethodhints.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -1653,7 +1642,7 @@ void tst_qquicktextedit::inputMethodHints() void tst_qquicktextedit::positionAt() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("positionAt.qml"))); + QQuickView canvas(testFileUrl("positionAt.qml")); QVERIFY(canvas.rootObject() != 0); canvas.show(); canvas.requestActivateWindow(); @@ -1711,7 +1700,7 @@ void tst_qquicktextedit::positionAt() void tst_qquicktextedit::linkActivated() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("linkActivated.qml"))); + QQuickView canvas(testFileUrl("linkActivated.qml")); QVERIFY(canvas.rootObject() != 0); canvas.show(); canvas.requestActivateWindow(); @@ -1748,7 +1737,7 @@ void tst_qquicktextedit::linkActivated() void tst_qquicktextedit::cursorDelegate() { - QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorTest.qml"))); + QQuickView view(testFileUrl("cursorTest.qml")); view.show(); view.requestActivateWindow(); QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject"); @@ -1816,7 +1805,7 @@ void tst_qquicktextedit::cursorDelegate() void tst_qquicktextedit::cursorVisible() { - QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorVisible.qml"))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -1882,9 +1871,9 @@ void tst_qquicktextedit::delegateLoading() QFETCH(QString, error); TestHTTPServer server(42332); - server.serveDirectory(TESTDATA("httpfail"), TestHTTPServer::Disconnect); - server.serveDirectory(TESTDATA("httpslow"), TestHTTPServer::Delay); - server.serveDirectory(TESTDATA("http")); + server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect); + server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay); + server.serveDirectory(testFile("http")); QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile)); view.show(); @@ -1923,7 +1912,7 @@ the extent of the text, then they should ignore the keys. */ void tst_qquicktextedit::navigation() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml"))); + QQuickView canvas(testFileUrl("navigation.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -2043,7 +2032,7 @@ void tst_qquicktextedit::canPasteEmpty() { void tst_qquicktextedit::readOnly() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("readOnly.qml"))); + QQuickView canvas(testFileUrl("readOnly.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -2079,7 +2068,7 @@ void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModi void tst_qquicktextedit::textInput() { - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml"))); + QQuickView view(testFileUrl("inputMethodEvent.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2139,7 +2128,7 @@ void tst_qquicktextedit::openInputPanel() QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); inputPanelPrivate->testContext = &platformInputContext; - QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml"))); + QQuickView view(testFileUrl("openInputPanel.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2229,7 +2218,7 @@ void tst_qquicktextedit::openInputPanel() void tst_qquicktextedit::geometrySignals() { - QDeclarativeComponent component(&engine, TESTDATA("geometrySignals.qml")); + QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml")); QObject *o = component.create(); QVERIFY(o); QCOMPARE(o->property("bindingWidth").toInt(), 400); @@ -2340,7 +2329,7 @@ void tst_qquicktextedit::preeditCursorRectangle() { QString preeditText = "super"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml"))); + QQuickView view(testFileUrl("inputMethodEvent.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2401,7 +2390,7 @@ void tst_qquicktextedit::inputMethodComposing() { QString text = "supercalifragisiticexpialidocious!"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml"))); + QQuickView view(testFileUrl("inputContext.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2437,7 +2426,7 @@ void tst_qquicktextedit::inputMethodComposing() void tst_qquicktextedit::cursorRectangleSize() { - QQuickView *canvas = new QQuickView(QUrl::fromLocalFile(TESTDATA("positionAt.qml"))); + QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); QVERIFY(canvas->rootObject() != 0); QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject()); @@ -3634,7 +3623,7 @@ void tst_qquicktextedit::undo_keypressevents() void tst_qquicktextedit::emptytags_QTBUG_22058() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("qtbug-22058.qml"))); + QQuickView canvas(testFileUrl("qtbug-22058.qml")); QVERIFY(canvas.rootObject() != 0); canvas.show(); diff --git a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro b/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro index f81da61634..3c21307f02 100644 --- a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro +++ b/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquicktextinput macx:CONFIG -= app_bundle -SOURCES += tst_qquicktextinput.cpp +SOURCES += tst_qquicktextinput.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp index 266b0d4a33..f07e8fd8ee 100644 --- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp @@ -71,7 +71,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = TESTDATA(""); + QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory(); QString arch = "unknown-architecture"; // QTest needs to help with this. QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; @@ -95,7 +95,7 @@ template <typename T> static T evaluate(QObject *scope, const QString &expressio typedef QPair<int, QChar> Key; -class tst_qquicktextinput : public QObject +class tst_qquicktextinput : public QDeclarativeDataTest { Q_OBJECT @@ -103,8 +103,6 @@ public: tst_qquicktextinput(); private slots: - void initTestCase(); - void cleanupTestCase(); void cleanup(); void text(); void width(); @@ -244,14 +242,6 @@ QList<Key> &operator <<(QList<Key> &keys, Qt::Key key) return keys; } -void tst_qquicktextinput::initTestCase() -{ -} - -void tst_qquicktextinput::cleanupTestCase() -{ -} - void tst_qquicktextinput::cleanup() { // ensure not even skipped tests with custom input context leave it dangling @@ -1095,7 +1085,7 @@ void tst_qquicktextinput::moveCursorSelectionSequence() void tst_qquicktextinput::dragMouseSelection() { - QString qmlfile = TESTDATA("mouseselection_true.qml"); + QString qmlfile = testFile("mouseselection_true.qml"); QQuickView canvas(QUrl::fromLocalFile(qmlfile)); @@ -1140,9 +1130,9 @@ void tst_qquicktextinput::mouseSelectionMode_data() QTest::addColumn<bool>("selectWords"); // import installed - QTest::newRow("SelectWords") << TESTDATA("mouseselectionmode_words.qml") << true; - QTest::newRow("SelectCharacters") << TESTDATA("mouseselectionmode_characters.qml") << false; - QTest::newRow("default") << TESTDATA("mouseselectionmode_default.qml") << false; + QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; + QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; + QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; } void tst_qquicktextinput::mouseSelectionMode() @@ -1196,7 +1186,7 @@ void tst_qquicktextinput::horizontalAlignment() QFETCH(int, hAlign); QFETCH(QString, expectfile); - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment.qml"))); + QQuickView canvas(testFileUrl("horizontalAlignment.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -1216,7 +1206,7 @@ void tst_qquicktextinput::horizontalAlignment() void tst_qquicktextinput::horizontalAlignment_RightToLeft() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment_RightToLeft.qml"))); + QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text"); QVERIFY(textInput != 0); canvas.show(); @@ -1326,7 +1316,7 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft() void tst_qquicktextinput::verticalAlignment() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment.qml"))); + QQuickView canvas(testFileUrl("horizontalAlignment.qml")); QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text"); QVERIFY(textInput != 0); canvas.show(); @@ -1351,7 +1341,7 @@ void tst_qquicktextinput::verticalAlignment() void tst_qquicktextinput::positionAt() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("positionAt.qml"))); + QQuickView canvas(testFileUrl("positionAt.qml")); QVERIFY(canvas.rootObject() != 0); canvas.show(); canvas.requestActivateWindow(); @@ -1439,7 +1429,7 @@ void tst_qquicktextinput::positionAt() void tst_qquicktextinput::maxLength() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("maxLength.qml"))); + QQuickView canvas(testFileUrl("maxLength.qml")); QVERIFY(canvas.rootObject() != 0); canvas.show(); canvas.requestActivateWindow(); @@ -1470,7 +1460,7 @@ void tst_qquicktextinput::masks() { //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit) //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }"; - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("masks.qml"))); + QQuickView canvas(testFileUrl("masks.qml")); canvas.show(); canvas.requestActivateWindow(); QVERIFY(canvas.rootObject() != 0); @@ -1495,7 +1485,7 @@ void tst_qquicktextinput::validators() // so you may need to run their tests first. All validators are checked // here to ensure that their exposure to QML is working. - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("validators.qml"))); + QQuickView canvas(testFileUrl("validators.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -1599,7 +1589,7 @@ void tst_qquicktextinput::validators() void tst_qquicktextinput::inputMethods() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("inputmethods.qml"))); + QQuickView canvas(testFileUrl("inputmethods.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -1676,7 +1666,7 @@ the extent of the text, then they should ignore the keys. */ void tst_qquicktextinput::navigation() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml"))); + QQuickView canvas(testFileUrl("navigation.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -1715,7 +1705,7 @@ void tst_qquicktextinput::navigation() void tst_qquicktextinput::navigation_RTL() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml"))); + QQuickView canvas(testFileUrl("navigation.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -1962,7 +1952,7 @@ void tst_qquicktextinput::passwordCharacter() void tst_qquicktextinput::cursorDelegate() { - QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorTest.qml"))); + QQuickView view(testFileUrl("cursorTest.qml")); view.show(); view.requestActivateWindow(); QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject"); @@ -1989,7 +1979,7 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::cursorVisible() { - QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorVisible.qml"))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2142,7 +2132,7 @@ void tst_qquicktextinput::cursorRectangle() void tst_qquicktextinput::readOnly() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("readOnly.qml"))); + QQuickView canvas(testFileUrl("readOnly.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -2169,7 +2159,7 @@ void tst_qquicktextinput::readOnly() void tst_qquicktextinput::echoMode() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("echoMode.qml"))); + QQuickView canvas(testFileUrl("echoMode.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -2239,7 +2229,7 @@ void tst_qquicktextinput::echoMode() #ifdef QT_GUI_PASSWORD_ECHO_DELAY void tst_qquicktextinput::passwordEchoDelay() { - QQuickView canvas(QUrl::fromLocalFile(TESTDATA("echoMode.qml"))); + QQuickView canvas(testFileUrl("echoMode.qml")); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -2344,7 +2334,7 @@ void tst_qquicktextinput::openInputPanel() QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); inputPanelPrivate->testContext = &platformInputContext; - QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml"))); + QQuickView view(testFileUrl("openInputPanel.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2484,7 +2474,7 @@ void tst_qquicktextinput::focusOutClearSelection() void tst_qquicktextinput::geometrySignals() { - QDeclarativeComponent component(&engine, TESTDATA("geometrySignals.qml")); + QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml")); QObject *o = component.create(); QVERIFY(o); QCOMPARE(o->property("bindingWidth").toInt(), 400); @@ -2546,7 +2536,7 @@ void tst_qquicktextinput::preeditAutoScroll() { QString preeditText = "califragisiticexpialidocious!"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("preeditAutoScroll.qml"))); + QQuickView view(testFileUrl("preeditAutoScroll.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2633,7 +2623,7 @@ void tst_qquicktextinput::preeditCursorRectangle() { QString preeditText = "super"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml"))); + QQuickView view(testFileUrl("inputMethodEvent.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2688,7 +2678,7 @@ void tst_qquicktextinput::inputContextMouseHandler() inputPanelPrivate->testContext = &platformInputContext; QString text = "supercalifragisiticexpialidocious!"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml"))); + QQuickView view(testFileUrl("inputContext.qml")); QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject()); QVERIFY(input); @@ -2731,7 +2721,7 @@ void tst_qquicktextinput::inputMethodComposing() { QString text = "supercalifragisiticexpialidocious!"; - QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml"))); + QQuickView view(testFileUrl("inputContext.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); @@ -2764,7 +2754,7 @@ void tst_qquicktextinput::inputMethodComposing() void tst_qquicktextinput::cursorRectangleSize() { - QQuickView *canvas = new QQuickView(QUrl::fromLocalFile(TESTDATA("positionAt.qml"))); + QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); QVERIFY(canvas->rootObject() != 0); QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject()); @@ -2806,7 +2796,7 @@ void tst_qquicktextinput::cursorRectangleSize() void tst_qquicktextinput::tripleClickSelectsAll() { - QString qmlfile = TESTDATA("positionAt.qml"); + QString qmlfile = testFile("positionAt.qml"); QQuickView view(QUrl::fromLocalFile(qmlfile)); view.show(); view.requestActivateWindow(); @@ -3371,7 +3361,7 @@ void tst_qquicktextinput::QTBUG_19956() { QFETCH(QString, url); - QQuickView canvas(QUrl::fromLocalFile(TESTDATA(url))); + QQuickView canvas(testFileUrl(url)); canvas.show(); canvas.requestActivateWindow(); QTest::qWaitForWindowShown(&canvas); @@ -3405,7 +3395,7 @@ void tst_qquicktextinput::QTBUG_19956() void tst_qquicktextinput::QTBUG_19956_regexp() { - QUrl url = QUrl::fromLocalFile(TESTDATA("qtbug-19956regexp.qml")); + QUrl url = testFileUrl("qtbug-19956regexp.qml"); QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); diff --git a/tests/auto/qtquick2/qquickview/qquickview.pro b/tests/auto/qtquick2/qquickview/qquickview.pro index d4e7c064fa..90ad693eb0 100644 --- a/tests/auto/qtquick2/qquickview/qquickview.pro +++ b/tests/auto/qtquick2/qquickview/qquickview.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickview macx:CONFIG -= app_bundle -SOURCES += tst_qquickview.cpp +SOURCES += tst_qquickview.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp b/tests/auto/qtquick2/qquickview/tst_qquickview.cpp index 953374dcab..fff1cc9bed 100644 --- a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp +++ b/tests/auto/qtquick2/qquickview/tst_qquickview.cpp @@ -48,7 +48,7 @@ #include <QtGui/QWindow> #include <QtCore/QDebug> -class tst_QQuickView : public QObject +class tst_QQuickView : public QDeclarativeDataTest { Q_OBJECT public: @@ -73,7 +73,7 @@ void tst_QQuickView::resizemodeitem() QVERIFY(canvas); canvas->setResizeMode(QQuickView::SizeRootObjectToView); QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml"))); + canvas->setSource(testFileUrl("resizemodeitem.qml")); QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(item); window.show(); @@ -119,7 +119,7 @@ void tst_QQuickView::resizemodeitem() canvas = new QQuickView(&window); QVERIFY(canvas); canvas->setResizeMode(QQuickView::SizeViewToRootObject); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml"))); + canvas->setSource(testFileUrl("resizemodeitem.qml")); item = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(item); window.show(); @@ -166,7 +166,7 @@ void tst_QQuickView::resizemodeitem() canvas->resize(300, 300); canvas->setResizeMode(QQuickView::SizeRootObjectToView); QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml"))); + canvas->setSource(testFileUrl("resizemodeitem.qml")); canvas->resize(300, 300); item = qobject_cast<QQuickItem*>(canvas->rootObject()); QVERIFY(item); @@ -194,7 +194,7 @@ void tst_QQuickView::errors() QQuickView *canvas = new QQuickView; QVERIFY(canvas); QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); - canvas->setSource(QUrl::fromLocalFile(TESTDATA("error1.qml"))); + canvas->setSource(testFileUrl("error1.qml")); qInstallMsgHandler(old); QVERIFY(canvas->status() == QQuickView::Error); QVERIFY(canvas->errors().count() == 1); diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro index 8e87e10a97..3a194c54d6 100644 --- a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro +++ b/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickvisualdatamodel macx:CONFIG -= app_bundle -SOURCES += tst_qquickvisualdatamodel.cpp +SOURCES += tst_qquickvisualdatamodel.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index dfd8c753eb..a4db71a527 100644 --- a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -112,7 +112,7 @@ protected: }; -class tst_qquickvisualdatamodel : public QObject +class tst_qquickvisualdatamodel : public QDeclarativeDataTest { Q_OBJECT public: @@ -182,6 +182,7 @@ Q_DECLARE_METATYPE(QDeclarativeChangeSet) void tst_qquickvisualdatamodel::initTestCase() { + QDeclarativeDataTest::initTestCase(); qRegisterMetaType<QDeclarativeChangeSet>(); } @@ -251,7 +252,7 @@ tst_qquickvisualdatamodel::tst_qquickvisualdatamodel() void tst_qquickvisualdatamodel::rootIndex() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("visualdatamodel.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml")); QStandardItemModel model; initStandardTreeModel(&model); @@ -279,8 +280,8 @@ void tst_qquickvisualdatamodel::updateLayout_data() { QTest::addColumn<QUrl>("source"); - QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml")); - QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml")); + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); } void tst_qquickvisualdatamodel::updateLayout() @@ -329,8 +330,8 @@ void tst_qquickvisualdatamodel::childChanged_data() { QTest::addColumn<QUrl>("source"); - QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml")); - QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml")); + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); } void tst_qquickvisualdatamodel::childChanged() @@ -403,7 +404,7 @@ void tst_qquickvisualdatamodel::objectListModel() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - view.setSource(QUrl::fromLocalFile(TESTDATA("objectlist.qml"))); + view.setSource(testFileUrl("objectlist.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -431,7 +432,7 @@ void tst_qquickvisualdatamodel::singleRole() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole1.qml"))); + view.setSource(testFileUrl("singlerole1.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -453,7 +454,7 @@ void tst_qquickvisualdatamodel::singleRole() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole2.qml"))); + view.setSource(testFileUrl("singlerole2.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -475,7 +476,7 @@ void tst_qquickvisualdatamodel::singleRole() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole2.qml"))); + view.setSource(testFileUrl("singlerole2.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -501,7 +502,7 @@ void tst_qquickvisualdatamodel::modelProperties() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("modelproperties.qml"))); + view.setSource(testFileUrl("modelproperties.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -534,7 +535,7 @@ void tst_qquickvisualdatamodel::modelProperties() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - view.setSource(QUrl::fromLocalFile(TESTDATA("modelproperties.qml"))); + view.setSource(testFileUrl("modelproperties.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -563,7 +564,7 @@ void tst_qquickvisualdatamodel::modelProperties() view.rootContext()->setContextProperty("myModel", &model); - QUrl source(QUrl::fromLocalFile(TESTDATA("modelproperties2.qml"))); + QUrl source(testFileUrl("modelproperties2.qml")); //3 items, 3 i each QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); @@ -604,8 +605,8 @@ void tst_qquickvisualdatamodel::noDelegate_data() { QTest::addColumn<QUrl>("source"); - QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml")); - QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml")); + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); } void tst_qquickvisualdatamodel::noDelegate() @@ -636,10 +637,10 @@ void tst_qquickvisualdatamodel::itemsDestroyed_data() { QTest::addColumn<QUrl>("source"); - QTest::newRow("listView") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_listView.qml")); - QTest::newRow("package") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_package.qml")); - QTest::newRow("pathView") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_pathView.qml")); - QTest::newRow("repeater") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_repeater.qml")); + QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml"); + QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml"); + QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml"); + QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml"); } void tst_qquickvisualdatamodel::itemsDestroyed() @@ -674,7 +675,7 @@ void tst_qquickvisualdatamodel::packagesDestroyed() QQuickView view; view.rootContext()->setContextProperty("testModel", &model); - QString filename(TESTDATA("packageView.qml")); + QString filename(testFile("packageView.qml")); view.setSource(QUrl::fromLocalFile(filename)); qApp->processEvents(); @@ -746,7 +747,7 @@ void tst_qquickvisualdatamodel::qaimRowsMoved() QFETCH(int, expectCount); QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("visualdatamodel.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml")); SingleRoleModel model; model.list.clear(); @@ -811,10 +812,10 @@ void tst_qquickvisualdatamodel::remove_data() QTest::addColumn<QString>("package delegate"); QTest::newRow("item delegate") - << QUrl::fromLocalFile(TESTDATA("groups.qml")) + << testFileUrl("groups.qml") << QString(); QTest::newRow("package") - << QUrl::fromLocalFile(TESTDATA("groups-package.qml")) + << testFileUrl("groups-package.qml") << QString("package."); } @@ -840,7 +841,7 @@ void tst_qquickvisualdatamodel::remove() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml"))); + view.setSource(testFileUrl("groups.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -921,10 +922,10 @@ void tst_qquickvisualdatamodel::move_data() QTest::addColumn<QString>("package delegate"); QTest::newRow("item delegate") - << QUrl::fromLocalFile(TESTDATA("groups.qml")) + << testFileUrl("groups.qml") << QString(); QTest::newRow("package") - << QUrl::fromLocalFile(TESTDATA("groups-package.qml")) + << testFileUrl("groups-package.qml") << QString("package."); } @@ -950,7 +951,7 @@ void tst_qquickvisualdatamodel::move() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml"))); + view.setSource(testFileUrl("groups.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -1074,10 +1075,10 @@ void tst_qquickvisualdatamodel::groups_data() QTest::addColumn<QString>("part"); QTest::newRow("item delegate") - << QUrl::fromLocalFile(TESTDATA("groups.qml")) + << testFileUrl("groups.qml") << QString(); QTest::newRow("package") - << QUrl::fromLocalFile(TESTDATA("groups-package.qml")) + << testFileUrl("groups-package.qml") << QString("visualModel.parts.package."); } @@ -1461,7 +1462,7 @@ void tst_qquickvisualdatamodel::get() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml"))); + view.setSource(testFileUrl("groups.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -1592,7 +1593,7 @@ void tst_qquickvisualdatamodel::get() void tst_qquickvisualdatamodel::invalidGroups() { - QUrl source = QUrl::fromLocalFile(TESTDATA("groups-invalid.qml")); + QUrl source = testFileUrl("groups-invalid.qml"); QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); QDeclarativeComponent component(&engine, source); @@ -1714,7 +1715,7 @@ void tst_qquickvisualdatamodel::onChanged() QFETCH(QString, expression); QFETCH(QStringList, tests); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("onChanged.qml"))); + QDeclarativeComponent component(&engine, testFileUrl("onChanged.qml")); QScopedPointer<QObject> object(component.create()); QVERIFY(object); @@ -1758,7 +1759,7 @@ void tst_qquickvisualdatamodel::create() QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model); - view.setSource(QUrl::fromLocalFile(TESTDATA("create.qml"))); + view.setSource(testFileUrl("create.qml")); QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject()); QVERIFY(listview != 0); @@ -1876,7 +1877,7 @@ void tst_qquickvisualdatamodel::incompleteModel() // harmlessly ignored until then. QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\n VisualDataModel {}", QUrl::fromLocalFile(TESTDATA(""))); + component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl("")); QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); |