aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp51
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 658ffa1f57..b0d903908f 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -250,6 +250,7 @@ private slots:
void QTBUG_50105();
void keyNavigationEnabled();
void QTBUG_50097_stickyHeader_positionViewAtIndex();
+ void itemFiltered();
private:
template <class T> void items(const QUrl &source);
@@ -629,6 +630,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
}
listview->setContentY(contentY);
+ QQuickItemViewPrivate::get(listview)->layout();
+
QList<QPair<QString, QString> > newData;
for (int i=0; i<insertCount; i++)
newData << qMakePair(QString("value %1").arg(i), QString::number(i));
@@ -650,6 +653,14 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QCOMPARE(item0->y(), itemsOffsetAfterMove);
#endif
+ QList<FxViewItem *> visibleItems = QQuickItemViewPrivate::get(listview)->visibleItems;
+ for (QList<FxViewItem *>::const_iterator itemIt = visibleItems.begin(); itemIt != visibleItems.end(); ++itemIt) {
+ FxViewItem *item = *itemIt;
+ if (item->item->position().y() >= 0 && item->item->position().y() < listview->height()) {
+ QVERIFY(!QQuickItemPrivate::get(item->item)->culled);
+ }
+ }
+
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
for (int i=0; i<items.count(); i++) {
@@ -735,7 +746,7 @@ void tst_QQuickListView::inserted_more_data()
<< 15 << 1
<< 0.0;
- QTest::newRow("add 1, at end of visible, content at start")
+ QTest::newRow("add multiple, at end of visible, content at start")
<< 0.0
<< 15 << 3
<< 0.0;
@@ -756,7 +767,7 @@ void tst_QQuickListView::inserted_more_data()
<< 16 << 1
<< 0.0;
- QTest::newRow("add 1, after visible, content at start")
+ QTest::newRow("add multiple, after visible, content at start")
<< 0.0
<< 16 << 3
<< 0.0;
@@ -770,6 +781,11 @@ void tst_QQuickListView::inserted_more_data()
<< 80.0 // show 4-19
<< 20 << 3
<< 0.0;
+
+ QTest::newRow("add multiple, within visible, content at start")
+ << 0.0
+ << 2 << 50
+ << 0.0;
}
void tst_QQuickListView::insertBeforeVisible()
@@ -8328,6 +8344,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"