diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-07-22 13:43:43 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-07-22 13:43:43 +0200 |
commit | 3a6f5735ee723ff998114314c5ccdf6609667f6f (patch) | |
tree | 9c877dd1e35972fa336cea8a61986594f168b49c /tests/auto/quick/qquickxmllistmodel | |
parent | 000b6330d4ca7165ff241b21ee728ed28d82fba1 (diff) | |
parent | 17ded06804576dfde1b19f82f168f7ceb09ec92c (diff) |
Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into wip/v4
Conflicts:
src/quick/items/context2d/qquickcontext2d.cpp
tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
Change-Id: I36a4fd28b3156839aecd70039a3ba566bf19a0bc
Diffstat (limited to 'tests/auto/quick/qquickxmllistmodel')
4 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.qml b/tests/auto/quick/qquickxmllistmodel/data/groups.qml new file mode 100644 index 0000000000..c1b574a822 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/groups.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "groups.xml" + query: "//animal[@name='Garfield']/parent::group" + + XmlRole { name: "id"; query: "@id/string()" } + XmlRole { name: "name"; query: "@name/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.xml b/tests/auto/quick/qquickxmllistmodel/data/groups.xml new file mode 100644 index 0000000000..5de4d2ec71 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/groups.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<groups version="2.0"> + <group id="1" name="Animals" type="root"> + <group id="11" name="dogs"> + <animal id="111" name="Lassie"/> + <animal id="112" name="Laika"/> + <animal id="113" name="Wile E. Coyote" type="fictional"/> + </group> + <group id="12" name="cats"> + <animal id="121" name="Garfield" type="fictional"/> + <animal id="122" name="Sylvester" type="fictional"/> + </group> + <group id="13" name="birds"> + <animal id="131" name="Donald Duck" type="fictional"/> + <animal id="132" name="Phoenix" type="fictional"/> + </group> + </group> +</groups> diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro index da899a12ec..574481c456 100644 --- a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro +++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro @@ -12,3 +12,6 @@ CONFIG += parallel_test QT += core-private gui-private qml-private network testlib xmlpatterns DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +OTHER_FILES += \ + data/groups.qml diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp index 847cc5078d..1f7a8029dc 100644 --- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp +++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -101,6 +101,7 @@ private slots: void threading(); void threading_data(); void propertyChanges(); + void selectAncestor(); void roleCrash(); @@ -964,6 +965,18 @@ void tst_qquickxmllistmodel::propertyChanges() delete model; } +void tst_qquickxmllistmodel::selectAncestor() +{ + QQmlComponent component(&engine, testFileUrl("groups.qml")); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->rowCount(), 1); + + QModelIndex index = model->index(0, 0); + QCOMPARE(model->data(index, Qt::UserRole).toInt(), 12); + QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("cats")); +} + void tst_qquickxmllistmodel::roleCrash() { // don't crash |