aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFilippo Cucchetto <f.cucchetto@asem.it>2016-04-14 10:48:25 +0200
committerFilippo Cucchetto <filippocucchetto@gmail.com>2016-04-19 16:12:17 +0000
commite1400b5b4d8311769ad3b9f631479ee2b0271197 (patch)
tree7ec3196d596f72c81aa48110d7977df83dfa3016 /tests
parentfc22938dfc7b4c09f76913ac62e1f8ba345eccaf (diff)
Fixed MouseArea threshold with preventStealing
When preventStealing is true both keepMouseGrab() and d->stealMouse are true. This in turn enable the dragging immediately since the condition "keepMouseGrab() && d->stealMouse && !d->drag->active()" is true. Conversely when preventStealing is false the dragging is enabled in the next move event since keepMouseGrab() and d->stealMouse are set true inside the last "if" "!keepMouseGrab() && ...check threshold..". This patch adds a new boolean flag for storing if we detected a drag motion (so we exceeded the threshold) and enable the dragging iff this flag is true. With this change: - if preventStealing is true (and so keepMouseGrab() and d->stealMouse) the additional d->overThresHold prevent the start of dragging. At the same time the last if (!keepMouseGrab()) cannot be executed since keepMouseGrab is true and we still check for the threshold being exceeded. - if preventStealing is false, we still check for exceeding the threshold and if this happen we enter in the last "if" since !keepMousegrab() && d->overThreshold is true taking the mouseGrab as without this patch Task-number: QTBUG-52534 Change-Id: I2b14d3048b6f8223c90ce5e2fd26e7ca706cb56a Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 82c053d76a..9cdfd21f9c 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -79,6 +79,7 @@ private slots:
void dragging_data() { acceptedButton_data(); }
void dragging();
void dragSmoothed();
+ void dragThreshold_data();
void dragThreshold();
void invalidDrag_data() { rejectedButton_data(); }
void invalidDrag();
@@ -375,8 +376,17 @@ void tst_QQuickMouseArea::dragSmoothed()
QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(100, 122));
}
+void tst_QQuickMouseArea::dragThreshold_data()
+{
+ QTest::addColumn<bool>("preventStealing");
+ QTest::newRow("without preventStealing") << false;
+ QTest::newRow("with preventStealing") << true;
+}
+
void tst_QQuickMouseArea::dragThreshold()
{
+ QFETCH(bool, preventStealing);
+
QQuickView window;
QByteArray errorMessage;
QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData());
@@ -386,6 +396,7 @@ void tst_QQuickMouseArea::dragThreshold()
QVERIFY(window.rootObject() != 0);
QQuickMouseArea *mouseRegion = window.rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ mouseRegion->setPreventStealing(preventStealing);
QQuickDrag *drag = mouseRegion->drag();
drag->setThreshold(5);