aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@qinetic.com.au>2015-03-10 11:59:23 +1000
committerAndrew den Exter <andrew.den.exter@qinetic.com.au>2015-03-19 05:40:37 +0000
commit4c22c0cec688655e77ecbf8829b1477d12a3c10b (patch)
treeb1dfaa7c0722c9a51b7197de38c2fc105ad688d0 /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
parent6293efb101263473709f4e887aead798e247b95f (diff)
Allow Flickable's grab to be stolen if dragging over bounds.
This allows a parent item to intercept a drag gesture in one direction when the flickable has reached it's limit in that direction without disabling the drag over bounds for drag gestures in the opposite direction. Change-Id: I6ac60113f150dbb8da42d9b5593325b04be166f5 Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp51
1 files changed, 38 insertions, 13 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 5c96cc151e..7d08c3c81e 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -1427,17 +1427,30 @@ 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;
+ QTest::addColumn<int>("boundsBehavior");
+ QTest::addColumn<qreal>("margin");
+
+ QTest::newRow("left,stop") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0);
+ QTest::newRow("right,stop") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(0);
+ QTest::newRow("top,stop") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(0);
+ QTest::newRow("bottom,stop") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(0);
+ QTest::newRow("left,over") << false << false << int(QQuickFlickable::DragOverBounds) << qreal(0);
+ QTest::newRow("right,over") << false << true << int(QQuickFlickable::DragOverBounds) << qreal(0);
+ QTest::newRow("top,over") << true << false << int(QQuickFlickable::DragOverBounds) << qreal(0);
+ QTest::newRow("bottom,over") << true << true << int(QQuickFlickable::DragOverBounds) << qreal(0);
+
+ QTest::newRow("left,stop,margin") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(20);
+ QTest::newRow("right,stop,margin") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(20);
+ QTest::newRow("top,stop,margin") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(20);
+ QTest::newRow("bottom,stop,margin") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(20);
}
void tst_qquickflickable::nestedStopAtBounds()
{
QFETCH(bool, transpose);
QFETCH(bool, invert);
+ QFETCH(int, boundsBehavior);
+ QFETCH(qreal, margin);
QQuickView view;
view.setSource(testFileUrl("nestedStopAtBounds.qml"));
@@ -1455,8 +1468,20 @@ void tst_qquickflickable::nestedStopAtBounds()
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);
+ inner->setBoundsBehavior(QQuickFlickable::BoundsBehavior(boundsBehavior));
+
+ invert ? inner->setRightMargin(margin) : inner->setLeftMargin(margin);
+ invert ? inner->setBottomMargin(margin) : inner->setTopMargin(margin);
+
+ inner->setContentX(invert ? -margin : 100 - margin);
+ inner->setContentY(invert ? -margin : 100 - margin);
+ inner->setContentWidth(400 - margin);
+ inner->setContentHeight(400 - margin);
+
+ QCOMPARE(inner->isAtXBeginning(), invert);
+ QCOMPARE(inner->isAtXEnd(), !invert);
+ QCOMPARE(inner->isAtYBeginning(), invert);
+ QCOMPARE(inner->isAtYEnd(), !invert);
const int threshold = qApp->styleHints()->startDragDistance();
@@ -1495,10 +1520,10 @@ void tst_qquickflickable::nestedStopAtBounds()
QTRY_VERIFY(!outer->isMoving());
axis = 200;
- inner->setContentX(0);
- inner->setContentY(0);
- inner->setContentWidth(inner->width());
- inner->setContentHeight(inner->height());
+ inner->setContentX(-margin);
+ inner->setContentY(-margin);
+ inner->setContentWidth(inner->width() - margin);
+ inner->setContentHeight(inner->height() - margin);
// Drag inner with equal size and contentSize
QTest::mousePress(&view, Qt::LeftButton, 0, position);
@@ -1512,8 +1537,8 @@ void tst_qquickflickable::nestedStopAtBounds()
QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
axis = 200;
- inner->setContentX(0);
- inner->setContentY(0);
+ inner->setContentX(-margin);
+ inner->setContentY(-margin);
inner->setContentWidth(inner->width() - 100);
inner->setContentHeight(inner->height() - 100);