diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-24 07:48:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-24 07:48:20 (GMT) |
commit | d3a0bd57c7c3cecdeeb4ad9af3cf6bb4ee39964b (patch) | |
tree | ef5fd503f73819932ce1a240bd5ccfd287873edb /tests/auto | |
parent | 40256d682e1a552c9566a744a66cc6fe008b578b (diff) | |
download | Qt-d3a0bd57c7c3cecdeeb4ad9af3cf6bb4ee39964b.zip Qt-d3a0bd57c7c3cecdeeb4ad9af3cf6bb4ee39964b.tar.gz Qt-d3a0bd57c7c3cecdeeb4ad9af3cf6bb4ee39964b.tar.bz2 |
Don't crash if the currentIndex is set while creating a delegate.
Task-number: QTBUG-8456
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/data/setindex.qml | 33 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 15 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/setindex.qml b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml new file mode 100644 index 0000000..908b365 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml @@ -0,0 +1,33 @@ +import Qt 4.6 + +Rectangle { + width: 200 + height: 200 + Component { + id: appDelegate + + Item { + id : wrapper + Script { + function startupFunction() + { + if (index == 5) view.currentIndex = index; + + } + } + Component.onCompleted: startupFunction(); + width: 30; height: 30 + Text { text: index } + } + } + + GridView { + id: view + objectName: "grid" + anchors.fill: parent + cellWidth: 30; cellHeight: 30 + model: 35 + delegate: appDelegate + focus: true + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 9a7f517..9c7468d 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -66,6 +66,7 @@ private slots: void defaultValues(); void properties(); void positionViewAtIndex(); + void QTBUG_8456(); private: QDeclarativeView *createView(); @@ -657,6 +658,7 @@ void tst_QDeclarativeGridView::currentIndex() gridview->setFlow(QDeclarativeGridView::TopToBottom); + QEXPECT_FAIL("", "QTBUG-8475", Abort); QTest::keyClick(canvas, Qt::Key_Right); QCOMPARE(gridview->currentIndex(), 5); @@ -882,6 +884,19 @@ void tst_QDeclarativeGridView::positionViewAtIndex() delete canvas; } +void tst_QDeclarativeGridView::QTBUG_8456() +{ + QDeclarativeView *canvas = createView(); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + + QCOMPARE(gridview->currentIndex(), 0); +} + QDeclarativeView *tst_QDeclarativeGridView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); |