From bf19d3294f83fc061eddc719bc608bb19e500a5a Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 24 Jan 2017 16:39:28 -0800 Subject: MouseArea: fix bug preventing dragging from start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp') 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("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; -- cgit v1.2.3