aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickgridview
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-12-20 08:32:22 +0100
committerLiang Qi <liang.qi@qt.io>2017-12-20 08:50:58 +0100
commit9a38fdcf8f9b734808bb54422e306872f3bfa944 (patch)
tree20fd361db6c505d99a40ab7a695511b97dcdcbd3 /tests/auto/quick/qquickgridview
parent1db9405128972d5ba77e33181bee40356f718cea (diff)
parent4fff2bb14e55484eacec0a1b49a2b02958f75eca (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: tests/auto/quick/pointerhandlers/flickableinterop/data/FlashAnimation.qml tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml tests/auto/quick/pointerhandlers/qquickdraghandler/data/FlashAnimation.qml tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml tests/auto/quick/pointerhandlers/qquicktaphandler/data/FlashAnimation.qml tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml tests/manual/pointer/content/FakeFlickable.qml tests/manual/pointer/content/FlashAnimation.qml tests/manual/pointer/content/MomentumAnimation.qml tests/manual/pointer/content/MouseAreaButton.qml tests/manual/pointer/content/MouseAreaSlider.qml tests/manual/pointer/content/MptaButton.qml tests/manual/pointer/content/MultiButton.qml tests/manual/pointer/content/ScrollBar.qml tests/manual/pointer/content/Slider.qml tests/manual/pointer/content/TapHandlerButton.qml tests/manual/pointer/fakeFlickable.qml tests/manual/pointer/flickableWithHandlers.qml tests/manual/pointer/flingAnimation.qml tests/manual/pointer/joystick.qml tests/manual/pointer/main.cpp tests/manual/pointer/main.qml tests/manual/pointer/map.qml tests/manual/pointer/map2.qml tests/manual/pointer/mixer.qml tests/manual/pointer/multibuttons.qml tests/manual/pointer/photosurface.qml tests/manual/pointer/pinchDragFlingMPTA.qml tests/manual/pointer/pinchHandler.qml tests/manual/pointer/singlePointHandlerProperties.qml tests/manual/pointer/tapHandler.qml tests/manual/pointer/tapWithModifiers.qml tests/manual/shapestest/main.cpp Change-Id: I4f233a521305fab1ebfecbac801da192434ed524
Diffstat (limited to 'tests/auto/quick/qquickgridview')
-rw-r--r--tests/auto/quick/qquickgridview/data/qtbug57225.qml95
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp61
2 files changed, 156 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickgridview/data/qtbug57225.qml b/tests/auto/quick/qquickgridview/data/qtbug57225.qml
new file mode 100644
index 0000000000..3871e5d273
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/qtbug57225.qml
@@ -0,0 +1,95 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 200
+ height: 200
+
+ property int duration: 100
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+ property bool removalStarted: false
+ property real minX: 0
+ property real minY: 0
+
+ onXChanged: if (removalStarted) grid.recordPosition(x, y)
+ onYChanged: if (removalStarted) grid.recordPosition(x, y)
+
+ objectName: "wrapper"
+ width: 80
+ height: 80
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper; property: "removalStarted"; value: true }
+ PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0.5; duration: root.duration; easing.type: Easing.InOutQuad }
+ PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false }
+ PropertyAction { target: grid; property: "animationDone"; value: true }
+ }
+
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int displaceTransitionsDone: 0
+ property bool animationDone: false
+ property point minimumPosition: Qt.point(0, 0)
+
+ signal delegateMoved(real x, real y)
+
+ objectName: "grid"
+ focus: true
+ anchors.fill: parent
+ cacheBuffer: 0
+ cellWidth: 80
+ cellHeight: 80
+ model: testModel
+ delegate: myDelegate
+
+ displaced: Transition {
+ id: transition
+ SequentialAnimation {
+ NumberAnimation {
+ properties: "x,y"
+ duration: root.duration
+ easing.type: Easing.OutBounce
+ }
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+ }
+
+ function recordPosition(index, x, y) {
+ if (x < minimumPosition.x || y < minimumPosition.y) {
+ minimumPosition = Qt.point(x, y)
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 9bba6c9291..dddda7e2bf 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -153,6 +153,8 @@ private slots:
void multipleTransitions();
void multipleTransitions_data();
void multipleDisplaced();
+ void regression_QTBUG_57225();
+ void regression_QTBUG_57225_data();
void inserted_leftToRight_RtL_TtB();
void inserted_leftToRight_RtL_TtB_data();
@@ -5798,6 +5800,65 @@ void tst_QQuickGridView::multipleDisplaced()
delete window;
}
+void tst_QQuickGridView::regression_QTBUG_57225()
+{
+ QFETCH(int, initialCount);
+ QFETCH(int, removeIndex);
+ QFETCH(int, removeCount);
+ QFETCH(int, expectedDisplaceTransitions);
+
+ // deleting all visible items should not cause a repositioning of said items.
+
+ QaimModel model;
+ for (int i = 0; i < initialCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ QQuickView *window = createView();
+ QQmlContext *ctxt = window->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ window->setSource(testFileUrl("qtbug57225.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.removeItems(removeIndex, removeCount);
+ QTRY_VERIFY(gridview->property("animationDone").toBool());
+
+ // verify that none of the removed items has moved to a negative position
+ QPoint minimumPosition = gridview->property("minimumPosition").toPoint();
+ QVERIFY(minimumPosition.x() >= 0);
+ QVERIFY(minimumPosition.y() >= 0);
+
+ // wait some more time to let the displaced transition happen
+ QTest::qWait(window->rootObject()->property("duration").toInt());
+ QTRY_VERIFY2(gridview->property("displaceTransitionsDone").toInt() >= expectedDisplaceTransitions,
+ QByteArray::number(gridview->property("displaceTransitionsDone").toInt()).constData());
+
+ delete window;
+}
+
+void tst_QQuickGridView::regression_QTBUG_57225_data()
+{
+ QTest::addColumn<int>("initialCount");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("removeCount");
+ QTest::addColumn<int>("expectedDisplaceTransitions");
+
+ // no displace transitions should happen
+ QTest::newRow("remove all visible items") <<
+ 20 << 0 << 8 << 0;
+
+ // check that the removal animation is performed
+ QTest::newRow("remove items in between") <<
+ 20 << 1 << 2 << 3;
+
+ QTest::newRow("remove items in between - 2") <<
+ 20 << 2 << 3 << 1;
+}
+
void tst_QQuickGridView::cacheBuffer()
{
QQuickView *window = createView();