diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-12-03 08:57:08 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-12-03 15:42:22 +0100 |
commit | 705e80b702d752633828be9ac9467090e6541c66 (patch) | |
tree | 9bee72a6eaddba29a39d25ddaf871e3b1e1ddbea /tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | |
parent | fb58b94c1c8f58a5da0066eb109f96820d05ca30 (diff) |
QQuickItemView: Set moveReason to other on model change
This implements Michael Brasser's suggestion in the bug report.
As there do not seem to be other bug reports related to the
fixupPosition change, this might already be enough.
Fixes: QTBUG-66163
Change-Id: Iee45621ff7081b280626f4a81dab9bd36a7ea6b7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicklistview/tst_qquicklistview.cpp')
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ca438a9cd5..f285d1967c 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -267,6 +267,7 @@ private slots: void QTBUG_61269_appendDuringScrollDown_data(); void QTBUG_50097_stickyHeader_positionViewAtIndex(); void QTBUG_63974_stickyHeader_positionViewAtIndex_Contain(); + void QTBUG_66163_setModelViewPortSizeChange(); void itemFiltered(); void releaseItems(); @@ -8843,6 +8844,62 @@ void tst_QQuickListView::QTBUG_63974_stickyHeader_positionViewAtIndex_Contain() QTRY_COMPARE(listview->contentY(), -headerSize); } +void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange() +{ + QScopedPointer<QQuickView> window(createView()); + QQmlComponent comp(window->engine()); + comp.setData(R"( + import QtQuick 2.0 + + Item { + id: root + width: 400 + height: 400 + + ListView { + id: view + objectName: "view" + anchors.fill: parent + + model: 4 + highlightRangeMode: ListView.StrictlyEnforceRange + + delegate: Rectangle { + color: index % 2 ? "green" : "orange" + width: parent.width + height: 50 + } + + populate: Transition { + SequentialAnimation { + NumberAnimation { property: "y"; from: 100; duration: 1000 } + } + } + } + } + )", QUrl("testData")); + auto root {qobject_cast<QQuickItem*>(comp.create())}; + QVERIFY(root); + window->setContent(QUrl(), &comp, root); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + auto view = root->findChild<QQuickListView *>("view"); + QVERIFY(view); + QVERIFY(QQuickTest::qWaitForItemPolished(view)); + QSignalSpy spy(view, &QQuickListView::contentYChanged); + auto transition = view->property("populate").value<QQuickTransition*>(); + QVERIFY(transition); + QQmlProperty model(view, "model"); + QVERIFY(model.isValid()); + model.write(5); + // Animations inside a Transition do not emit a finished signal + // so we cannot wait for them in that way + QTest::qWait(1100); // animation takes 1000ms, + 10% extra delay + /* the viewport should not have changed, thus there should not have + been any contentYChanged signal*/ + QCOMPARE(spy.count(), 0); +} + void tst_QQuickListView::itemFiltered() { QStringListModel model(QStringList() << "one" << "two" << "three" << "four" << "five" << "six"); |