diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-10-12 13:46:02 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-14 02:39:59 +0200 |
commit | 6b497734df0c4f13f6b7185801fc69ce680c698c (patch) | |
tree | 66b0b8cd32a91f8c7e753a3ef124050188035c3c /tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | |
parent | 5f7c22001163eb4bce25be1cfee4e84c5a25ff09 (diff) |
Use TESTDATA macro in declarative tests.
Includes a few other minor cleanups as well.
Task-number: QTBUG-21721
Change-Id: I5b1c2c116e63748c6b4199183212de8a00037af1
Reviewed-on: http://codereview.qt-project.org/6473
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 04eb7c6b47..3328232236 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -52,6 +52,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qfile.h> #include <QtCore/qtemporaryfile.h> +#include "../shared/util.h" #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> @@ -187,7 +188,7 @@ QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent void tst_qdeclarativexmllistmodel::buildModel() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -210,7 +211,7 @@ void tst_qdeclarativexmllistmodel::testTypes() QFETCH(QString, roleName); QFETCH(QVariant, expectedValue); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/testtypes.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("testtypes.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); model->setXml(xml.toUtf8()); @@ -270,7 +271,7 @@ void tst_qdeclarativexmllistmodel::testTypes_data() void tst_qdeclarativexmllistmodel::cdata() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 5); @@ -286,7 +287,7 @@ void tst_qdeclarativexmllistmodel::cdata() void tst_qdeclarativexmllistmodel::attributes() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 5); @@ -301,7 +302,7 @@ void tst_qdeclarativexmllistmodel::attributes() void tst_qdeclarativexmllistmodel::roles() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -318,9 +319,9 @@ void tst_qdeclarativexmllistmodel::roles() void tst_qdeclarativexmllistmodel::roleErrors() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml")); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleErrors.qml"))); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); //### make sure we receive all expected warning messages. QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); @@ -345,8 +346,8 @@ void tst_qdeclarativexmllistmodel::roleErrors() void tst_qdeclarativexmllistmodel::uniqueRoleNames() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml")); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("unique.qml"))); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("unique.qml")).toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 9); @@ -363,7 +364,7 @@ void tst_qdeclarativexmllistmodel::xml() QFETCH(QString, xml); QFETCH(int, count); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); @@ -412,7 +413,7 @@ void tst_qdeclarativexmllistmodel::headers() CustomNetworkAccessManagerFactory factory; qmlEng.setNetworkAccessManagerFactory(&factory); - QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->status(), QDeclarativeXmlListModel::Ready); @@ -435,7 +436,7 @@ void tst_qdeclarativexmllistmodel::source() QFETCH(int, count); QFETCH(QDeclarativeXmlListModel::Status, status); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); @@ -487,7 +488,7 @@ void tst_qdeclarativexmllistmodel::source_data() QTest::addColumn<int>("count"); QTest::addColumn<QDeclarativeXmlListModel::Status>("status"); - QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarativeXmlListModel::Ready; + QTest::newRow("valid") << QUrl::fromLocalFile(TESTDATA("model2.xml")) << 2 << QDeclarativeXmlListModel::Ready; QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error; // empty file @@ -499,7 +500,7 @@ void tst_qdeclarativexmllistmodel::source_data() void tst_qdeclarativexmllistmodel::data() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); @@ -519,7 +520,7 @@ void tst_qdeclarativexmllistmodel::data() void tst_qdeclarativexmllistmodel::get() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("get.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); @@ -540,7 +541,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(SRCDIR "/data/model.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(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(SRCDIR "/data/roleKeys.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(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(SRCDIR "/data/roleKeys.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(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(SRCDIR "/data/roleKeys.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); @@ -806,7 +807,7 @@ void tst_qdeclarativexmllistmodel::threading() { QFETCH(int, xmlDataCount); - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml"))); QDeclarativeXmlListModel *m1 = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(m1 != 0); @@ -879,7 +880,7 @@ void tst_qdeclarativexmllistmodel::threading_data() void tst_qdeclarativexmllistmodel::propertyChanges() { - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("propertychanges.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(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(SRCDIR "/data/roleCrash.qml")); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleCrash.qml"))); QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QVERIFY(model != 0); delete model; |