From: Damian Jansen Date: Thu, 20 Oct 2011 02:44:43 +0000 (+1000) Subject: Unit test for QTBUG-21742 X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9167f5338ec978462d64f2f348144f674a2d599c;p=konrad%2Fqtdeclarative.git Unit test for QTBUG-21742 Test for crash when accessing a ListView in an odd way. Change-Id: I47dd8f4eaa2990c6842cf95a62ce925edac26f9a Reviewed-by: Glenn Watson --- diff --git a/tests/auto/declarative/qsglistview/data/qtbug-21742.qml b/tests/auto/declarative/qsglistview/data/qtbug-21742.qml new file mode 100644 index 0000000..774f904 --- /dev/null +++ b/tests/auto/declarative/qsglistview/data/qtbug-21742.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 + +Rectangle { + height: 200 + width: 200 + property int count: menuView.count + + Component.onCompleted: { setModel(); } + + function setModel() + { + menuModel.append({"enabledItem" : true}); + menuView.currentIndex = 0; + } + + ListModel { + id: menuModel + } + + ListView { + id: menuView + anchors.fill: parent + model: menuModel + delegate: mything + } + + Component { + id: mything + Rectangle { + height: 50 + width: 200 + color: index == menuView.currentIndex ? "green" : "blue" + } + } + +} \ No newline at end of file diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index a23d3b5..8e2375d 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -114,9 +114,7 @@ private slots: void propertyChanges(); void componentChanges(); void modelChanges(); - void QTBUG_9791(); void manualHighlight(); - void QTBUG_11105(); void header(); void header_data(); void header_delayItemCreation(); @@ -143,6 +141,10 @@ private slots: void snapToItem_data(); void snapToItem(); + void QTBUG_9791(); + void QTBUG_11105(); + void QTBUG_21742(); + private: template void items(); template void changed(); @@ -4045,6 +4047,18 @@ void tst_QSGListView::creationContext() QCOMPARE(item->property("text").toString(), QString("Hello!")); } +void tst_QSGListView::QTBUG_21742() +{ + QSGView canvas; + canvas.setGeometry(0,0,200,200); + canvas.setSource(QUrl::fromLocalFile(TESTDATA("qtbug-21742.qml"))); + qApp->processEvents(); + + QSGItem *rootItem = qobject_cast(canvas.rootObject()); + QVERIFY(rootItem); + QCOMPARE(rootItem->property("count").toInt(), 1); +} + QSGView *tst_QSGListView::createView() { QSGView *canvas = new QSGView(0);