aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml44
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp68
2 files changed, 112 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml
new file mode 100644
index 0000000000..1fd39bb321
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml
@@ -0,0 +1,44 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ MouseArea {
+ id: outer
+ objectName: "outer"
+ x: 50
+ y: 50
+ width: 300
+ height: 300
+
+ drag.target: outer
+ drag.filterChildren: true
+
+ Rectangle {
+ anchors.fill: parent
+ color: "yellow"
+ }
+
+ MouseArea {
+ id: inner
+ objectName: "inner"
+
+ x: 0
+ y: 0
+ width: 200
+ height: 200
+
+ drag.target: inner
+ drag.minimumX: 0
+ drag.maximumX: 100
+ drag.minimumY: 0
+ drag.maximumY: 100
+
+ Rectangle {
+ anchors.fill: parent
+ color: "blue"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 37ce0fd394..ef7dc72345 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -89,6 +89,8 @@ private slots:
void cursorShape();
#endif
void moveAndReleaseWithoutPress();
+ void nestedStopAtBounds();
+ void nestedStopAtBounds_data();
private:
void acceptedButton_data();
@@ -1426,6 +1428,72 @@ void tst_QQuickMouseArea::moveAndReleaseWithoutPress()
delete window;
}
+void tst_QQuickMouseArea::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_QQuickMouseArea::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());
+
+ QQuickMouseArea *outer = view.rootObject()->findChild<QQuickMouseArea*>("outer");
+ QVERIFY(outer);
+
+ QQuickMouseArea *inner = outer->findChild<QQuickMouseArea*>("inner");
+ QVERIFY(inner);
+ inner->drag()->setAxis(transpose ? QQuickDrag::YAxis : QQuickDrag::XAxis);
+ inner->setX(invert ? 100 : 0);
+ inner->setY(invert ? 100 : 0);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ QPoint position(200, 200);
+ int &axis = transpose ? position.ry() : position.rx();
+
+ // drag toward the aligned boundary. Outer mouse area 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->drag()->active(), true);
+ QCOMPARE(inner->drag()->active(), false);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QVERIFY(!outer->drag()->active());
+
+ axis = 200;
+ outer->setX(50);
+ outer->setY(50);
+
+ // drag away from the aligned boundary. Inner mouse area 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->drag()->active(), false);
+ QCOMPARE(inner->drag()->active(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"