diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 6171800ade..dae2f90389 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -54,7 +54,7 @@ #include <QSignalSpy> #include "../../shared/util.h" -class tst_qdeclarativeqt : public QObject +class tst_qdeclarativeqt : public QDeclarativeDataTest { Q_OBJECT public: @@ -95,14 +95,9 @@ private: QDeclarativeEngine engine; }; -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(TESTDATA(filename)); -} - void tst_qdeclarativeqt::enums() { - QDeclarativeComponent component(&engine, TEST_FILE("enums.qml")); + QDeclarativeComponent component(&engine, testFileUrl("enums.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -116,7 +111,7 @@ void tst_qdeclarativeqt::enums() void tst_qdeclarativeqt::rgba() { - QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rgba.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments"; @@ -139,7 +134,7 @@ void tst_qdeclarativeqt::rgba() void tst_qdeclarativeqt::hsla() { - QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml")); + QDeclarativeComponent component(&engine, testFileUrl("hsla.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments"; @@ -161,7 +156,7 @@ void tst_qdeclarativeqt::hsla() void tst_qdeclarativeqt::rect() { - QDeclarativeComponent component(&engine, TEST_FILE("rect.qml")); + QDeclarativeComponent component(&engine, testFileUrl("rect.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments"; @@ -182,7 +177,7 @@ void tst_qdeclarativeqt::rect() void tst_qdeclarativeqt::point() { - QDeclarativeComponent component(&engine, TEST_FILE("point.qml")); + QDeclarativeComponent component(&engine, testFileUrl("point.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments"; @@ -202,7 +197,7 @@ void tst_qdeclarativeqt::point() void tst_qdeclarativeqt::size() { - QDeclarativeComponent component(&engine, TEST_FILE("size.qml")); + QDeclarativeComponent component(&engine, testFileUrl("size.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments"; QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments"; @@ -223,7 +218,7 @@ void tst_qdeclarativeqt::size() void tst_qdeclarativeqt::vector() { - QDeclarativeComponent component(&engine, TEST_FILE("vector.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments"; @@ -243,7 +238,7 @@ void tst_qdeclarativeqt::vector() void tst_qdeclarativeqt::vector4d() { - QDeclarativeComponent component(&engine, TEST_FILE("vector4.qml")); + QDeclarativeComponent component(&engine, testFileUrl("vector4.qml")); QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments"; QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments"; @@ -263,7 +258,7 @@ void tst_qdeclarativeqt::vector4d() void tst_qdeclarativeqt::lighter() { - QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); + QDeclarativeComponent component(&engine, testFileUrl("lighter.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments"; @@ -285,7 +280,7 @@ void tst_qdeclarativeqt::lighter() void tst_qdeclarativeqt::darker() { - QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); + QDeclarativeComponent component(&engine, testFileUrl("darker.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments"; @@ -307,7 +302,7 @@ void tst_qdeclarativeqt::darker() void tst_qdeclarativeqt::tint() { - QDeclarativeComponent component(&engine, TEST_FILE("tint.qml")); + QDeclarativeComponent component(&engine, testFileUrl("tint.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments"; QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments"; @@ -347,7 +342,7 @@ void tst_qdeclarativeqt::openUrlExternally() QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler("file", &handler, "noteCall"); - QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally.qml")); + QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(handler.called,1); @@ -356,7 +351,7 @@ void tst_qdeclarativeqt::openUrlExternally() object->setProperty("testFile", true); QCOMPARE(handler.called,2); - QCOMPARE(handler.last, TEST_FILE("test.html")); + QCOMPARE(handler.last, testFileUrl("test.html")); QDesktopServices::unsetUrlHandler("test"); QDesktopServices::unsetUrlHandler("file"); @@ -369,7 +364,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler("file", &handler, "noteCall"); - QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally_lib.qml")); + QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(handler.called,1); @@ -378,7 +373,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() object->setProperty("testFile", true); QCOMPARE(handler.called,2); - QCOMPARE(handler.last, TEST_FILE("test.html")); + QCOMPARE(handler.last, testFileUrl("test.html")); QDesktopServices::unsetUrlHandler("test"); QDesktopServices::unsetUrlHandler("file"); @@ -386,7 +381,7 @@ void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary() void tst_qdeclarativeqt::md5() { - QDeclarativeComponent component(&engine, TEST_FILE("md5.qml")); + QDeclarativeComponent component(&engine, testFileUrl("md5.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -401,7 +396,7 @@ void tst_qdeclarativeqt::md5() void tst_qdeclarativeqt::createComponent() { - QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createComponent.qml")); QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments"; QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments"; @@ -412,7 +407,7 @@ void tst_qdeclarativeqt::createComponent() QVERIFY(object != 0); QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); - QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString()); + QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString()); delete object; } @@ -420,7 +415,7 @@ void tst_qdeclarativeqt::createComponent() void tst_qdeclarativeqt::createComponent_pragmaLibrary() { // Currently, just loading createComponent_lib.qml causes crash on some platforms - QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createComponent_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); @@ -430,14 +425,14 @@ void tst_qdeclarativeqt::createComponent_pragmaLibrary() void tst_qdeclarativeqt::createQmlObject() { - QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("createQmlObject.qml")); QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments"; - QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type"; - QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name"; + QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type"; + QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:1: Duplicate property name"; QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object"; QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments"; - QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method"; + QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); @@ -460,9 +455,9 @@ void tst_qdeclarativeqt::createQmlObject() void tst_qdeclarativeqt::console() { - QUrl testFileUrl = TEST_FILE("console.qml"); - QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testFileUrl.toString()).arg(34); - QString testTrace = QString(QLatin1String("onCompleted (%1:%2:%3)\n")).arg(testFileUrl.toString()).arg(31).arg(17); + QUrl testUrl = testFileUrl("console.qml"); + QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testUrl.toString()).arg(34); + QString testTrace = QString(QLatin1String("onCompleted (%1:%2:%3)\n")).arg(testUrl.toString()).arg(31).arg(17); QTest::ignoreMessage(QtDebugMsg, qPrintable(testTrace)); QTest::ignoreMessage(QtDebugMsg, "Profiling started."); QTest::ignoreMessage(QtDebugMsg, "Profiling ended."); @@ -487,7 +482,7 @@ void tst_qdeclarativeqt::console() QTest::ignoreMessage(QtWarningMsg, qPrintable(testException)); - QDeclarativeComponent component(&engine, testFileUrl); + QDeclarativeComponent component(&engine, testUrl); QObject *object = component.create(); QVERIFY(object != 0); delete object; @@ -507,7 +502,7 @@ void tst_qdeclarativeqt::dateTimeConversion() QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200)); QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, TEST_FILE("dateTimeConversion.qml")); + QDeclarativeComponent component(&eng, testFileUrl("dateTimeConversion.qml")); QObject *obj = component.create(); QCOMPARE(obj->property("qdate").toDate(), date); @@ -536,7 +531,7 @@ void tst_qdeclarativeqt::dateTimeFormatting() eng.rootContext()->setContextProperty("qtime", time); eng.rootContext()->setContextProperty("qdatetime", dateTime); - QDeclarativeComponent component(&eng, TEST_FILE("formatting.qml")); + QDeclarativeComponent component(&eng, testFileUrl("formatting.qml")); QStringList warnings; warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format" @@ -609,7 +604,7 @@ void tst_qdeclarativeqt::dateTimeFormattingVariants() QDeclarativeEngine eng; eng.rootContext()->setContextProperty("qvariant", variant); - QDeclarativeComponent component(&eng, TEST_FILE("formatting.qml")); + QDeclarativeComponent component(&eng, testFileUrl("formatting.qml")); QStringList warnings; warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format" @@ -683,7 +678,7 @@ void tst_qdeclarativeqt::dateTimeFormattingVariants_data() void tst_qdeclarativeqt::isQtObject() { - QDeclarativeComponent component(&engine, TEST_FILE("isQtObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("isQtObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -698,7 +693,7 @@ void tst_qdeclarativeqt::isQtObject() void tst_qdeclarativeqt::btoa() { - QDeclarativeComponent component(&engine, TEST_FILE("btoa.qml")); + QDeclarativeComponent component(&engine, testFileUrl("btoa.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -713,7 +708,7 @@ void tst_qdeclarativeqt::btoa() void tst_qdeclarativeqt::atob() { - QDeclarativeComponent component(&engine, TEST_FILE("atob.qml")); + QDeclarativeComponent component(&engine, testFileUrl("atob.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -728,7 +723,7 @@ void tst_qdeclarativeqt::atob() void tst_qdeclarativeqt::fontFamilies() { - QDeclarativeComponent component(&engine, TEST_FILE("fontFamilies.qml")); + QDeclarativeComponent component(&engine, testFileUrl("fontFamilies.qml")); QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -744,7 +739,7 @@ void tst_qdeclarativeqt::fontFamilies() void tst_qdeclarativeqt::quit() { - QDeclarativeComponent component(&engine, TEST_FILE("quit.qml")); + QDeclarativeComponent component(&engine, testFileUrl("quit.qml")); QSignalSpy spy(&engine, SIGNAL(quit())); QObject *object = component.create(); @@ -756,7 +751,7 @@ void tst_qdeclarativeqt::quit() void tst_qdeclarativeqt::resolvedUrl() { - QDeclarativeComponent component(&engine, TEST_FILE("resolvedUrl.qml")); + QDeclarativeComponent component(&engine, testFileUrl("resolvedUrl.qml")); QObject *object = component.create(); QVERIFY(object != 0); |