aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml10
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml45
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp36
3 files changed, 86 insertions, 5 deletions
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
index eebeb22201..084cc25414 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
@@ -90,6 +90,11 @@ Rectangle {
// In order to get the touchpoints first, it has to be on top of the Z order: i.e. come last in paintOrderChildItems().
// This is the opposite situation as with filtersChildMouseEvents: e.g. PinchArea would have wanted to be the parent,
// if it even knew that trick (which it doesn't).
+ DragHandler {
+ id: dragHandler
+ objectName: "DragHandler"
+ target: container
+ }
PinchHandler {
id: pinch3
objectName: "3-finger pinch"
@@ -98,11 +103,6 @@ Rectangle {
minimumScale: 0.1
maximumScale: 10
}
- DragHandler {
- id: dragHandler
- objectName: "DragHandler"
- target: container
- }
}
}
}
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml
new file mode 100644
index 0000000000..14a8d67300
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Qt.labs.handlers 1.0
+
+Item {
+ width: 320
+ height: 240
+ Button {
+ id: button
+ objectName: "Overridden"
+ label: "Overridden"
+ x: 10; y: 10; width: parent.width - 20; height: 40
+ TapHandler {
+ objectName: "override"
+ onTapped: button.tapped()
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index d7eda5e19c..9e3261f7b2 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -68,6 +68,7 @@ private slots:
void touchLongPress();
void mouseLongPress();
void buttonsMultiTouch();
+ void componentUserBehavioralOverride();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
@@ -585,6 +586,41 @@ void tst_TapHandler::buttonsMultiTouch()
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
}
+void tst_TapHandler::componentUserBehavioralOverride()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "buttonOverrideHandler.qml");
+ QQuickView * window = windowPtr.data();
+
+ QQuickItem *button = window->rootObject()->findChild<QQuickItem*>("Overridden");
+ QVERIFY(button);
+ QQuickTapHandler *innerTapHandler = button->findChild<QQuickTapHandler*>("Overridden");
+ QVERIFY(innerTapHandler);
+ QQuickTapHandler *userTapHandler = button->findChild<QQuickTapHandler*>("override");
+ QVERIFY(userTapHandler);
+ QSignalSpy tappedSpy(button, SIGNAL(tapped()));
+ QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint *)));
+ QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint *)));
+ QSignalSpy innerPressedChangedSpy(innerTapHandler, SIGNAL(pressedChanged()));
+ QSignalSpy userPressedChangedSpy(userTapHandler, SIGNAL(pressedChanged()));
+
+ // Press
+ QPoint p1 = button->mapToScene(button->clipRect().center()).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_COMPARE(userPressedChangedSpy.count(), 1);
+ QCOMPARE(innerPressedChangedSpy.count(), 0);
+ QCOMPARE(innerGrabChangedSpy.count(), 0);
+ QCOMPARE(userGrabChangedSpy.count(), 1);
+
+ // Release
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_COMPARE(userPressedChangedSpy.count(), 2);
+ QCOMPARE(innerPressedChangedSpy.count(), 0);
+ QCOMPARE(tappedSpy.count(), 1); // only because the override handler makes that happen
+ QCOMPARE(innerGrabChangedSpy.count(), 0);
+ QCOMPARE(userGrabChangedSpy.count(), 2);
+}
+
QTEST_MAIN(tst_TapHandler)
#include "tst_qquicktaphandler.moc"