aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/touchmouse
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@canonical.com>2012-12-19 15:29:49 -0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-09 18:42:42 +0100
commit5644e4f46c39964c0541d29740a9f741a0830f66 (patch)
tree424aa875a1845ae516001707469694920ff9d807 /tests/auto/quick/touchmouse
parent54f9fe5d41bc4a66d03c9846c1990958518d8623 (diff)
Test case for tapping on stacked mouse areas
Shows bug where the bottom mouse area could get a double click event out of a single tap. Change-Id: I4907a1506db2b4ccc5299d698c6e05fd02db963c Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/quick/touchmouse')
-rw-r--r--tests/auto/quick/touchmouse/data/twoMouseAreas.qml33
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp49
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/quick/touchmouse/data/twoMouseAreas.qml b/tests/auto/quick/touchmouse/data/twoMouseAreas.qml
new file mode 100644
index 0000000000..a02a6a4444
--- /dev/null
+++ b/tests/auto/quick/touchmouse/data/twoMouseAreas.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 320
+ height: 480
+ color: "#0c6d49"
+ objectName: "top rect"
+
+ Rectangle {
+ id: greyRectangle
+ objectName: "grey rect"
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+ height: parent.height / 2
+ color: "grey"
+ }
+
+ MouseArea {
+ objectName: "rear mouseArea"
+ anchors.fill: parent
+ }
+
+ MouseArea {
+ objectName: "front mouseArea"
+ anchors.fill: greyRectangle
+ onPressed: {
+ mouse.accepted = false;
+ }
+ }
+}
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index 1af70e3464..fc4d0c4815 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -160,6 +160,8 @@ private slots:
void flickableOnPinch();
void mouseOnFlickableOnPinch();
+ void tapOnDismissiveTopMouseAreaClicksBottomOne();
+
private:
QQuickView *createView();
QTouchDevice *device;
@@ -918,6 +920,53 @@ void tst_TouchMouse::mouseOnFlickableOnPinch()
pinchSequence.release(0, p, window).commit();
}
+/*
+ Regression test for the following use case:
+ You have two mouse areas, on on top of the other.
+ 1 - You tap the top one.
+ 2 - That top mouse area receives a mouse press event but doesn't accept it
+ Expected outcome:
+ 3 - the bottom mouse area gets clicked (besides press and release mouse events)
+ Bogus outcome:
+ 3 - the bottom mouse area gets double clicked.
+ */
+void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne()
+{
+ QQuickView *window = createView();
+
+ window->setSource(testFileUrl("twoMouseAreas.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickMouseArea *bottomMouseArea =
+ window->rootObject()->findChild<QQuickMouseArea*>("rear mouseArea");
+
+ QSignalSpy bottomClickedSpy(bottomMouseArea, SIGNAL(clicked(QQuickMouseEvent*)));
+ QSignalSpy bottomDoubleClickedSpy(bottomMouseArea,
+ SIGNAL(doubleClicked(QQuickMouseEvent*)));
+
+ // tap the front mouse area (see qml file)
+ QPoint p1(20, 20);
+ QTest::touchEvent(window, device).press(0, p1, window);
+ QTest::qWait(1);
+ QTest::touchEvent(window, device).release(0, p1, window);
+
+ QCOMPARE(bottomClickedSpy.count(), 1);
+ QCOMPARE(bottomDoubleClickedSpy.count(), 0);
+ QTest::qWait(15);
+
+ QTest::touchEvent(window, device).press(0, p1, window);
+ QTest::qWait(1);
+ QTest::touchEvent(window, device).release(0, p1, window);
+
+ QCOMPARE(bottomClickedSpy.count(), 1);
+ QCOMPARE(bottomDoubleClickedSpy.count(), 1);
+
+ delete window;
+}
+
QTEST_MAIN(tst_TouchMouse)
#include "tst_touchmouse.moc"