diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-13 03:09:40 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-13 03:16:46 (GMT) |
commit | f21957b3bb12a16a905f79f3a791931eb77663d9 (patch) | |
tree | fa95f3708fb27f954f7fc44821449106b1f0e15f /tests/auto/declarative | |
parent | db3ae6188c8f88f25b4f8e2645e76a7c6fffef18 (diff) | |
download | Qt-f21957b3bb12a16a905f79f3a791931eb77663d9.zip Qt-f21957b3bb12a16a905f79f3a791931eb77663d9.tar.gz Qt-f21957b3bb12a16a905f79f3a791931eb77663d9.tar.bz2 |
Enforce unique role names for XmlListModel.
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qmlxmllistmodel/data/unique.qml | 8 | ||||
-rw-r--r-- | tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp | 15 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/unique.qml b/tests/auto/declarative/qmlxmllistmodel/data/unique.qml new file mode 100644 index 0000000..ed0f293 --- /dev/null +++ b/tests/auto/declarative/qmlxmllistmodel/data/unique.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "name"; query: "type/string()" } +} diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp index 71bc4f9..a68006d 100644 --- a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp +++ b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp @@ -58,6 +58,7 @@ private slots: void attributes(); void roles(); void roleErrors(); + void uniqueRoleNames(); private: QmlEngine engine; @@ -175,6 +176,20 @@ void tst_qmlxmllistmodel::roleErrors() delete listModel; } +void tst_qmlxmllistmodel::uniqueRoleNames() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/data/unique.qml")); + QTest::ignoreMessage(QtWarningMsg, "QML QmlXmlListModelRole (file://" SRCDIR "/data/unique.qml:7:5) \"name\" duplicates a previous role name and will be disabled."); + QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create()); + QVERIFY(listModel != 0); + QTRY_COMPARE(listModel->count(), 9); + + QList<int> roles = listModel->roles(); + QCOMPARE(roles.count(), 1); + + delete listModel; +} + QTEST_MAIN(tst_qmlxmllistmodel) #include "tst_qmlxmllistmodel.moc" |