Ensure Flickable bounds detection is executed at the end of animation.
authorMartin Jones <martin.jones@jollamobile.com>
Tue, 21 Jan 2014 06:12:48 +0000 (16:12 +1000)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 21 Jan 2014 22:28:20 +0000 (23:28 +0100)
In pixelAligned mode the content position when animating is rounded to
a whole pixel, so the contentItem may reach the bound before the
animation completes.

Ensure bounds detection is run on animation completion.

Task-number: QTBUG-36300
Change-Id: I083ff6a03a5d1b9ca9e2201487b602f1588002be
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Joona Petrell <joona.petrell@jollamobile.com>
src/quick/items/qquickflickable.cpp
tests/auto/quick/qquickflickable/tst_qquickflickable.cpp

index 7cc37e0..333c11c 100644 (file)
@@ -2309,6 +2309,7 @@ void QQuickFlickable::timelineCompleted()
         return;
     }
     movementEnding();
+    d->updateBeginningEnd();
 }
 
 void QQuickFlickable::movementStarting()
index 86321c7..59b54e7 100644 (file)
@@ -1440,17 +1440,23 @@ void tst_qquickflickable::stopAtBounds_data()
 {
     QTest::addColumn<bool>("transpose");
     QTest::addColumn<bool>("invert");
-
-    QTest::newRow("left") << false << false;
-    QTest::newRow("right") << false << true;
-    QTest::newRow("top") << true << false;
-    QTest::newRow("bottom") << true << true;
+    QTest::addColumn<bool>("pixelAligned");
+
+    QTest::newRow("left") << false << false << false;
+    QTest::newRow("right") << false << true << false;
+    QTest::newRow("top") << true << false << false;
+    QTest::newRow("bottom") << true << true << false;
+    QTest::newRow("left,pixelAligned") << false << false << true;
+    QTest::newRow("right,pixelAligned") << false << true << true;
+    QTest::newRow("top,pixelAligned") << true << false << true;
+    QTest::newRow("bottom,pixelAligned") << true << true << true;
 }
 
 void tst_qquickflickable::stopAtBounds()
 {
     QFETCH(bool, transpose);
     QFETCH(bool, invert);
+    QFETCH(bool, pixelAligned);
 
     QQuickView view;
     view.setSource(testFileUrl("stopAtBounds.qml"));
@@ -1469,6 +1475,7 @@ void tst_qquickflickable::stopAtBounds()
         flickable->setContentY(invert ? 100 : 0);
     else
         flickable->setContentX(invert ? 100 : 0);
+    flickable->setPixelAligned(pixelAligned);
 
     const int threshold = qApp->styleHints()->startDragDistance();
 
@@ -1518,6 +1525,29 @@ void tst_qquickflickable::stopAtBounds()
     }
 
     QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+    if (transpose) {
+        flickable->setContentY(invert ? 100 : 0);
+    } else {
+        flickable->setContentX(invert ? 100 : 0);
+    }
+    if (invert)
+        flick(&view, QPoint(20,20), QPoint(100,100), 100);
+    else
+        flick(&view, QPoint(100,100), QPoint(20,20), 100);
+
+    QVERIFY(flickable->isFlicking());
+    if (transpose) {
+        if (invert)
+            QTRY_COMPARE(flickable->isAtYBeginning(), true);
+        else
+            QTRY_COMPARE(flickable->isAtYEnd(), true);
+    } else {
+        if (invert)
+            QTRY_COMPARE(flickable->isAtXBeginning(), true);
+        else
+            QTRY_COMPARE(flickable->isAtXEnd(), true);
+    }
 }
 
 void tst_qquickflickable::nestedMouseAreaUsingTouch()