aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDamian Jansen <damian.jansen@nokia.com>2011-10-20 12:44:43 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-21 02:35:29 +0200
commit9167f5338ec978462d64f2f348144f674a2d599c (patch)
tree5bfa68b2c53b799412c326e65ebf4f38fd83e8a1 /tests
parent2dba656cb5b9d54db4f348bf6d0b3db7d950b392 (diff)
Unit test for QTBUG-21742
Test for crash when accessing a ListView in an odd way. Change-Id: I47dd8f4eaa2990c6842cf95a62ce925edac26f9a Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsglistview/data/qtbug-21742.qml36
-rw-r--r--tests/auto/declarative/qsglistview/tst_qsglistview.cpp18
2 files changed, 52 insertions, 2 deletions
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 0000000000..774f9041fb
--- /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 a23d3b592c..8e2375d6b5 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 <class T> void items();
template <class T> 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<QSGItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QCOMPARE(rootItem->property("count").toInt(), 1);
+}
+
QSGView *tst_QSGListView::createView()
{
QSGView *canvas = new QSGView(0);