aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-30 00:16:40 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-30 00:16:40 +0200
commit0bf14044178d7aa212ac7e28530f9077790a3df4 (patch)
tree4c403571abbc5e18c6962ba67d9cb584d8e121c4 /tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
parent0aea009425242417bffdb171c8eca02ff52f4a7b (diff)
parent79cfc8788d6267eeb263983466ba21758f618dcd (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I241cd418bb7e7b95e0a0a2ee4c465d48be2a5582
Diffstat (limited to 'tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp')
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 89d48c4f09..5891e67df6 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -120,6 +120,7 @@ private slots:
void moveAndReleaseWithoutPress();
void nestedStopAtBounds();
void nestedStopAtBounds_data();
+ void nestedFlickableStopAtBounds();
void containsPress_data();
void containsPress();
void ignoreBySource();
@@ -1751,6 +1752,98 @@ void tst_QQuickMouseArea::nestedStopAtBounds()
QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
}
+void tst_QQuickMouseArea::nestedFlickableStopAtBounds()
+{
+ QQuickView view;
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("nestedFlickableStopAtBounds.qml"), false, &errorMessage), errorMessage.constData());
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QQuickMouseArea *mouseArea = view.rootObject()->findChild<QQuickMouseArea*>("mouseArea");
+ QVERIFY(mouseArea);
+
+ QQuickFlickable *flickable = mouseArea->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flickable);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ QPoint position(200, 280);
+ int &pos = position.ry();
+
+ // Drag up - should move the Flickable to end
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 150;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYEnd(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ pos = 280;
+
+ // Drag up again - should activate MouseArea drag
+ QVERIFY(!mouseArea->drag()->active());
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ pos -= threshold * 2;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 20;
+ QTest::mouseMove(&view, position);
+ QVERIFY(mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYEnd(), true);
+ QVERIFY(!flickable->isDragging());
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ // Drag to the top and verify that the MouseArea doesn't steal the grab when we drag back (QTBUG-56036)
+ pos = 50;
+
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos += threshold;
+ QTest::mouseMove(&view, position);
+ pos += threshold;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos += 150;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QCOMPARE(flickable->isAtYBeginning(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ pos = 280;
+
+ // Drag up again - should not activate MouseArea drag
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ pos -= threshold;
+ QTest::mouseMove(&view, position);
+ pos -= threshold;
+ QTest::mouseMove(&view, position);
+ QTest::qWait(10);
+ pos -= 100;
+ QTest::mouseMove(&view, position);
+ QVERIFY(flickable->isDragging());
+ QVERIFY(!mouseArea->drag()->active());
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+}
+
void tst_QQuickMouseArea::containsPress_data()
{
QTest::addColumn<bool>("hoverEnabled");