aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-11-18 16:32:25 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-11-23 15:41:18 +0100
commitfad8ef3e4133538e3785d7067c35c652bc894711 (patch)
treeca0d85658bbe52faf5460725e7698b58032b9461 /tests/auto/qmltest
parentacb6ed0815f92588c3ff875a568e9561fe61218c (diff)
mouseDrag(): ensure that intermediate moves are done for all drags
The code checking if the intermediate move distance was less than the drag threshold, but without accounting for negative distances. Since the negative distances were naturally less than the drag threshold, the intermediate distances were set to zero and the intermediate moves were never done. In practice, this means that mouseDrag() never did intermediate moves (i.e. what happens during a drag in real life) for drags that go from right to left or upwards. Task-number: QTBUG-80152 Change-Id: Ic27021f5ce5ba2937e95fb2dfb532bd2136f4205 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/qmltest')
-rw-r--r--tests/auto/qmltest/events/tst_drag.qml30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qmltest/events/tst_drag.qml b/tests/auto/qmltest/events/tst_drag.qml
index 2653848adc..5c5b885e6c 100644
--- a/tests/auto/qmltest/events/tst_drag.qml
+++ b/tests/auto/qmltest/events/tst_drag.qml
@@ -150,6 +150,15 @@ Rectangle{
SignalSpy {}
}
+ Component {
+ id: mouseAreaComponent
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+ }
+
TestCase {
name:"mouserelease"
when:windowShown
@@ -295,5 +304,26 @@ Rectangle{
else
verify(contentYSpy.count > 0)
}
+
+ function test_negativeDragDistance_data() {
+ return [
+ { tag: "horizontal", startX: 100, startY: 100, xDistance: -90, yDistance: 0 },
+ { tag: "vertical", startX: 100, startY: 100, xDistance: 0, yDistance: -90 }
+ ]
+ }
+
+ // Tests that dragging to the left or top actually results in intermediate mouse moves.
+ function test_negativeDragDistance(data) {
+ let mouseArea = createTemporaryObject(mouseAreaComponent, root)
+ verify(mouseArea)
+
+ let positionSpy = signalSpyComponent.createObject(mouseArea,
+ { target: mouseArea, signalName: "positionChanged" })
+ verify(positionSpy)
+ verify(positionSpy.valid)
+
+ mouseDrag(mouseArea, data.startX, data.startY, data.xDistance, data.yDistance)
+ verify(positionSpy.count > 2, "Expected more than 2 mouse position changes, but only got " + positionSpy.count)
+ }
}
}