aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-10 09:28:12 +0200
committerLars Knoll <lars.knoll@qt.io>2016-10-10 16:01:48 +0200
commit102fa9b6db82ecd2b95d168912fde0c8bc3798b3 (patch)
tree5bf934c323dcafb67cb508ace579110191ad782d /tests/auto/quick/qquickmousearea
parenta6be2d77aa6dc9f834b971eaff749a02cf982525 (diff)
parentfff4477661ae240c43088fa6d9069ccf969dbee8 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: examples/quick/quickwidgets/quickwidget/main.cpp src/qml/jsruntime/qv4jsonobject.cpp src/qml/jsruntime/qv4qobjectwrapper.cpp src/qml/jsruntime/qv4qobjectwrapper_p.h src/qml/qml/qqmlengine.cpp src/qml/qml/qqmlpropertycache.cpp src/qml/qml/qqmlpropertycache_p.h src/quick/items/qquickanimatedsprite.cpp src/quick/items/qquickitem.cpp src/quick/items/qquickitem.h src/quick/items/qquickitem_p.h src/quick/items/qquickview_p.h src/quick/scenegraph/qsgcontext.cpp src/quick/scenegraph/qsgdefaultrendercontext.cpp Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
Diffstat (limited to 'tests/auto/quick/qquickmousearea')
-rw-r--r--tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml44
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp93
2 files changed, 137 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml b/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml
new file mode 100644
index 0000000000..0d5b496766
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/nestedFlickableStopAtBounds.qml
@@ -0,0 +1,44 @@
+import QtQuick 2.5
+
+
+Rectangle {
+ width: 240
+ height: 320
+
+ MouseArea {
+ objectName: "mouseArea"
+ anchors.fill: parent
+
+ drag.target: moveable
+ drag.filterChildren: true
+
+ Rectangle {
+ id: moveable
+ objectName: "moveable"
+ color: "red"
+ x: 50
+ y: 80
+ width: 200
+ height: 200
+ }
+
+ Flickable {
+ objectName: "flickable"
+ anchors.fill: parent
+ contentHeight: 450
+
+ Rectangle {
+ x: 100
+ y: 50
+ width: 50
+ height: 350
+ color: "yellow"
+ }
+
+ MouseArea {
+ width: 240
+ height: 450
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index b69c6eedf8..f22528a8a0 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -122,6 +122,7 @@ private slots:
void moveAndReleaseWithoutPress();
void nestedStopAtBounds();
void nestedStopAtBounds_data();
+ void nestedFlickableStopAtBounds();
void containsPress_data();
void containsPress();
void ignoreBySource();
@@ -1814,6 +1815,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");