diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2014-09-30 13:23:56 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2014-10-10 11:30:06 +0200 |
commit | 2b5e9534450404fba3bdf89f304d0504ae8587dd (patch) | |
tree | 93e869bf0e2e70fdf96c325c45bc5d859a520a2d /tests/auto/quick/qquickpathview | |
parent | 9e71faae038de4c41c206f1321da1b37ab6ca8b1 (diff) |
PathView: Fix QML engine thinking currentItem is null when it's not
QML didn't re-evaluate any bindings using currentItem because a
notification was missing.
Change-Id: Icdaa3022e0b01644a060e577d87f011b4ea9fabb
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquickpathview')
-rw-r--r-- | tests/auto/quick/qquickpathview/data/pathview4.qml | 20 | ||||
-rw-r--r-- | tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 22 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/data/pathview4.qml b/tests/auto/quick/qquickpathview/data/pathview4.qml new file mode 100644 index 0000000000..c42986d5a3 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview4.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property bool currentItemIsNull: view.currentItem === null + + PathView { + id: view + objectName: "view" + model: testModel + delegate: Item {} + + path: Path { + PathLine { + y: 0 + x: 0 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index fd6dc4da60..0e9994899f 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -90,6 +90,7 @@ private slots: void pathview2(); void pathview3(); void initialCurrentIndex(); + void initialCurrentItem(); void insertModel_data(); void insertModel(); void removeModel_data(); @@ -237,6 +238,27 @@ void tst_QQuickPathView::items() QCOMPARE(pathview->highlightItem()->position() + offset, start); } +void tst_QQuickPathView::initialCurrentItem() +{ + QScopedPointer<QQuickView> window(createView()); + + QaimModel model; + model.addItem("Jules", "12345"); + model.addItem("Vicent", "2345"); + model.addItem("Marvin", "54321"); + + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(testFileUrl("pathview4.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem<QQuickPathView>(window->rootObject(), "view"); + QVERIFY(pathview != 0); + QVERIFY(pathview->currentIndex() != -1); + QVERIFY(!window->rootObject()->property("currentItemIsNull").toBool()); +} + void tst_QQuickPathView::pathview2() { QQmlEngine engine; |