aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2016-07-25 12:26:54 +0200
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2016-08-04 08:10:44 +0000
commit5e60d281f1c84c76b80d001ddb3ac00c213de15f (patch)
tree2c7e0a57bdd025b3041c55cc23ef3fe8bd0f0a2c /tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
parent0a4cebe6d35abe1019c0d86cf933af972dc8bc6c (diff)
Test that we don't crash when items are sorted and filtered at the same time
This is a test for commit 49c892328223dfa2502b462d8e5e8e181f4f6cd5 in qtbase Change-Id: Id7be42ddd9136b73af08093117316fe2e86a000a Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 08c0887fcf..a3b3a1d309 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -254,6 +254,7 @@ private slots:
void QTBUG_50105();
void QTBUG_50097_stickyHeader_positionViewAtIndex();
+ void itemFiltered();
private:
template <class T> void items(const QUrl &source);
@@ -8281,6 +8282,37 @@ void tst_QQuickListView::QTBUG_50097_stickyHeader_positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), -100.0); // back to the same position: header visible, items not under the header.
}
+void tst_QQuickListView::itemFiltered()
+{
+ QStringListModel model(QStringList() << "one" << "two" << "three" << "four" << "five" << "six");
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ proxy1.setSortRole(Qt::DisplayRole);
+ proxy1.setDynamicSortFilter(true);
+ proxy1.sort(0);
+
+ QSortFilterProxyModel proxy2;
+ proxy2.setSourceModel(&proxy1);
+ proxy2.setFilterRole(Qt::DisplayRole);
+ proxy2.setFilterRegExp("^[^ ]*$");
+ proxy2.setDynamicSortFilter(true);
+
+ QScopedPointer<QQuickView> window(createView());
+ window->engine()->rootContext()->setContextProperty("_model", &proxy2);
+ QQmlComponent component(window->engine());
+ component.setData("import QtQuick 2.4; ListView { "
+ "anchors.fill: parent; model: _model; delegate: Text { width: parent.width;"
+ "text: model.display; } }",
+ QUrl());
+ window->setContent(QUrl(), &component, component.create());
+
+ window->show();
+ QTest::qWaitForWindowExposed(window.data());
+
+ // this should not crash
+ model.setData(model.index(2), QStringLiteral("modified three"), Qt::DisplayRole);
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"