diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-10 16:04:58 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-10 16:04:58 (GMT) |
commit | d1bfdd4f7d4769786c4b9e385e77468d89a31d16 (patch) | |
tree | 5cbc1bc9928bed544f3daa8813e94c667d7809a2 /tests/auto/declarative/qdeclarativepathview | |
parent | 72e0778c9b5bdae58596090b114d5d0e7092f911 (diff) | |
parent | d446a0ec464556ede91225b14e75f2f8f5a748d5 (diff) | |
download | Qt-d1bfdd4f7d4769786c4b9e385e77468d89a31d16.zip Qt-d1bfdd4f7d4769786c4b9e385e77468d89a31d16.tar.gz Qt-d1bfdd4f7d4769786c4b9e385e77468d89a31d16.tar.bz2 |
Merge branch 4.7 into qt-master-from-4.7
Diffstat (limited to 'tests/auto/declarative/qdeclarativepathview')
-rw-r--r-- | tests/auto/declarative/qdeclarativepathview/data/treemodel.qml | 19 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp | 48 |
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepathview/data/treemodel.qml b/tests/auto/declarative/qdeclarativepathview/data/treemodel.qml new file mode 100644 index 0000000..56f7ae4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/treemodel.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 + +PathView { + width: 320 + height: 240 + function setRoot(index) { + vdm.rootIndex = vdm.modelIndex(index); + } + model: VisualDataModel { + id: vdm + model: myModel + delegate: Text { objectName: "wrapper"; text: display } + } + + path: Path { + startX: 0; startY: 120 + PathLine { x: 320; y: 120 } + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index f39e4b9..ebb5f98 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -53,6 +53,7 @@ #include <QtDeclarative/private/qdeclarativevaluetype_p.h> #include <QAbstractListModel> #include <QStringListModel> +#include <QStandardItemModel> #include <QFile> #include "../../../shared/util.h" @@ -62,6 +63,25 @@ #define SRCDIR "." #endif +static void initStandardTreeModel(QStandardItemModel *model) +{ + QStandardItem *item; + item = new QStandardItem(QLatin1String("Row 1 Item")); + model->insertRow(0, item); + + item = new QStandardItem(QLatin1String("Row 2 Item")); + item->setCheckable(true); + model->insertRow(1, item); + + QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); + item->setChild(0, childItem); + + item = new QStandardItem(QLatin1String("Row 3 Item")); + item->setIcon(QIcon()); + model->insertRow(2, item); +} + + class tst_QDeclarativePathView : public QObject { Q_OBJECT @@ -90,6 +110,7 @@ private slots: void visualDataModel(); void undefinedPath(); void mouseDrag(); + void treeModel(); private: QDeclarativeView *createView(); @@ -900,6 +921,33 @@ void tst_QDeclarativePathView::mouseDrag() delete canvas; } +void tst_QDeclarativePathView::treeModel() +{ + QDeclarativeView *canvas = createView(); + + QStandardItemModel model; + initStandardTreeModel(&model); + canvas->engine()->rootContext()->setContextProperty("myModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/treemodel.qml")); + + QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject()); + QVERIFY(pathview != 0); + QCOMPARE(pathview->count(), 3); + + QDeclarativeText *item = findItem<QDeclarativeText>(pathview, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->text(), QLatin1String("Row 1 Item")); + + QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1))); + QCOMPARE(pathview->count(), 1); + + QTRY_VERIFY(item = findItem<QDeclarativeText>(pathview, "wrapper", 0)); + QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); |