aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2017-01-24 16:39:28 -0800
committerOleg Yadrov <oleg.yadrov@qt.io>2017-02-03 02:32:16 +0000
commitbf19d3294f83fc061eddc719bc608bb19e500a5a (patch)
tree0fe9facb85bca2974cc208480e934bdce17f60a8 /tests/auto/quick/qquickmousearea
parent22b03fd6d3efdfa0385ced2450c6c7dfcf555d6e (diff)
MouseArea: fix bug preventing dragging from start
The same bounded dragPos values were used for - moving the target item to new position; and - if dragging didn’t start yet, determining whether cursor moved over the threshold distance. It is right for moving the target item, but in the second case it led to that dragging did not start if the distance between item's left border and minimumX (right border and maximumX, top border and minimumY, bottom border and maximumY accordingly) was less than drag.threshold. Task-number: QTBUG-58347 Change-Id: If61a98bf734739323ef19dee6709560b754b2456 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Diffstat (limited to 'tests/auto/quick/qquickmousearea')
-rw-r--r--tests/auto/quick/qquickmousearea/data/availableDistanceLessThanDragThreshold.qml24
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp30
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/data/availableDistanceLessThanDragThreshold.qml b/tests/auto/quick/qquickmousearea/data/availableDistanceLessThanDragThreshold.qml
new file mode 100644
index 0000000000..2b45a19340
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/availableDistanceLessThanDragThreshold.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 200
+
+ MouseArea {
+ id: mouseArea
+ objectName: "mouseArea"
+ width: 200
+ height: 200
+
+ drag.target: mouseArea
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: 200
+ drag.threshold: 200
+
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index e1f903123b..c2a2118598 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -88,6 +88,7 @@ private slots:
void invalidDrag_data() { rejectedButton_data(); }
void invalidDrag();
void cancelDragging();
+ void availableDistanceLessThanDragThreshold();
void setDragOnPressed();
void updateMouseAreaPosOnClick();
void updateMouseAreaPosOnResize();
@@ -583,6 +584,35 @@ void tst_QQuickMouseArea::cancelDragging()
QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(122,122));
}
+// QTBUG-58347
+void tst_QQuickMouseArea::availableDistanceLessThanDragThreshold()
+{
+ QQuickView view;
+ QByteArray errorMessage;
+ QVERIFY2(initView(view, testFileUrl("availableDistanceLessThanDragThreshold.qml"), true, &errorMessage),
+ errorMessage.constData());
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QQuickMouseArea *mouseArea = view.rootObject()->findChild<QQuickMouseArea*>("mouseArea");
+ QVERIFY(mouseArea);
+
+ QPoint position(100, 100);
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ position.setX(301);
+ QTest::mouseMove(&view, position);
+ position.setX(501);
+ QTest::mouseMove(&view, position);
+ QVERIFY(mouseArea->drag()->active());
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QVERIFY(!mouseArea->drag()->active());
+ QCOMPARE(mouseArea->x(), 200.0);
+}
+
void tst_QQuickMouseArea::setDragOnPressed()
{
QQuickView window;