aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-02-16 17:21:28 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-22 10:03:20 +0100
commit6ad4a61d482d895d135a7a281115bf104e0b9a90 (patch)
tree29bc2ffc39092105efde3c21c3fa45f9187301ed /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
parent7a1282a9edd8afa4645d7d449ca2ed3746fb8d71 (diff)
Flickable shouldn't grab the mouse until it starts an effective move.
If the boundBehavior prevents the flickable from moving its content item in response to a drag it shouldn't grab the mouse as that will prevent a parent MouseArea or Flickable from handling the drag. Task-number: QTBUG-29718 Change-Id: I3a1be4ed0132b91dca2fb0387ecefd39275a52da Reviewed-by: Alan Alpert <aalpert@rim.com>
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 784988b913..57c4c12264 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -91,6 +91,8 @@ private slots:
void cancelOnMouseGrab();
void clickAndDragWhenTransformed();
void flickTwiceUsingTouches();
+ void nestedStopAtBounds();
+ void nestedStopAtBounds_data();
private:
void flickWithTouch(QWindow *window, QTouchDevice *touchDevice);
@@ -1311,6 +1313,75 @@ void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDev
QTest::qWait(1);
}
+void tst_qquickflickable::nestedStopAtBounds_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;
+}
+
+void tst_qquickflickable::nestedStopAtBounds()
+{
+ QFETCH(bool, transpose);
+ QFETCH(bool, invert);
+
+ QQuickView view;
+ view.setSource(testFileUrl("nestedStopAtBounds.qml"));
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(view.rootObject());
+ QVERIFY(outer);
+
+ QQuickFlickable *inner = outer->findChild<QQuickFlickable*>("innerFlickable");
+ QVERIFY(inner);
+ inner->setFlickableDirection(transpose ? QQuickFlickable::VerticalFlick : QQuickFlickable::HorizontalFlick);
+ inner->setContentX(invert ? 0 : 100);
+ inner->setContentY(invert ? 0 : 100);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ QPoint position(200, 200);
+ int &axis = transpose ? position.ry() : position.rx();
+
+ // drag toward the aligned boundary. Outer flickable dragged.
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ axis += invert ? threshold * 2 : -threshold * 2;
+ QTest::mouseMove(&view, position);
+ axis += invert ? threshold : -threshold;
+ QTest::mouseMove(&view, position);
+ QCOMPARE(outer->isDragging(), true);
+ QCOMPARE(inner->isDragging(), false);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QVERIFY(!outer->isDragging());
+ QTRY_VERIFY(!outer->isMoving());
+
+ axis = 200;
+ outer->setContentX(50);
+ outer->setContentY(50);
+
+ // drag away from the aligned boundary. Inner flickable dragged.
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ axis += invert ? -threshold * 2 : threshold * 2;
+ QTest::mouseMove(&view, position);
+ axis += invert ? -threshold : threshold;
+ QTest::mouseMove(&view, position);
+ QCOMPARE(outer->isDragging(), false);
+ QCOMPARE(inner->isDragging(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!outer->isMoving());
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"