summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@jollamobile.com>2014-01-08 17:04:35 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-09 00:54:55 +0100
commit8673ae8bb6d4bac01cc54638a7d617072299a808 (patch)
treed76fc05c7dfa0a9f041dd9d5afe45bf19e028c40 /tests
parent66e72c2cf08c2d2c381c6c22e4760d0df758af52 (diff)
Fix Flickable generated release event with pressDelay.
Map mouse position to grabber when forwarding release event due to release before pressDelay timeout. Task-number: QTBUG-34570 Change-Id: I7214077c9ac95f77407cf66f9dad52f577eccd79 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickflickable/data/pressDelay.qml14
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp23
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/pressDelay.qml b/tests/auto/quick/qquickflickable/data/pressDelay.qml
index 18a5840504..a69c4af6de 100644
--- a/tests/auto/quick/qquickflickable/data/pressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/pressDelay.qml
@@ -8,6 +8,11 @@ Flickable {
contentHeight: 400
pressDelay: 100
+ property real pressX
+ property real pressY
+ property real releaseX
+ property real releaseY
+
MouseArea {
id: ma
objectName: "mouseArea"
@@ -16,6 +21,15 @@ Flickable {
width: 240
height: 100
+ onPressed: {
+ pressX = mouse.x
+ pressY = mouse.y
+ }
+ onReleased: {
+ releaseX = mouse.x
+ releaseY = mouse.y
+ }
+
Rectangle {
anchors.fill: parent
color: parent.pressed ? 'blue' : 'green'
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 794f9a8af6..86321c775e 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -412,6 +412,29 @@ void tst_qquickflickable::pressDelay()
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
QCOMPARE(clickedSpy.count(),1);
+ // Press and release position should match
+ QCOMPARE(flickable->property("pressX").toReal(), flickable->property("releaseX").toReal());
+ QCOMPARE(flickable->property("pressY").toReal(), flickable->property("releaseY").toReal());
+
+
+ // Test a quick tap within the pressDelay timeout
+ clickedSpy.clear();
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(180, 180));
+
+ // The press should not occur immediately
+ QVERIFY(mouseArea->property("pressed").toBool() == false);
+
+ QCOMPARE(clickedSpy.count(),0);
+
+ // On release the press, release and clicked signal should be emitted
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(180, 180));
+ QCOMPARE(clickedSpy.count(),1);
+
+ // Press and release position should match
+ QCOMPARE(flickable->property("pressX").toReal(), flickable->property("releaseX").toReal());
+ QCOMPARE(flickable->property("pressY").toReal(), flickable->property("releaseY").toReal());
+
+
// QTBUG-31168
QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 110));