diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-01-08 08:18:11 +0200 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2019-01-08 08:18:11 +0200 |
commit | c2c012f79438d207cc95237c90b692121acc4876 (patch) | |
tree | 39064e5a58161a7edb4e0c63f2d43e386d1f4059 /tests/auto/quick/pointerhandlers | |
parent | 5208b2a671010b11b78312f9c4fe3c3098d253b4 (diff) | |
parent | 5ed082ea4ce3580134a9a0c83e6fdb81a6231c8e (diff) |
Merge 5.12 into 5.12.1
Change-Id: Ic746fbce93430867e2eda4bc7155d34e20a4aa2b
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml | 41 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp | 39 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml new file mode 100644 index 0000000000..aea01c154c --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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.12 + +Rectangle { + width: 320 + height: 240 + color: rightTap.pressed ? "tomato" : "beige" + TapHandler { + id: rightTap + objectName: "right button TapHandler" + longPressThreshold: 0.5 + acceptedButtons: Qt.RightButton + } +} diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index 187ade58d5..33cea69147 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -70,6 +70,7 @@ private slots: void mouseLongPress(); void buttonsMultiTouch(); void componentUserBehavioralOverride(); + void rightLongPressIgnoreWheel(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -676,6 +677,44 @@ void tst_TapHandler::componentUserBehavioralOverride() QCOMPARE(userGrabChangedSpy.count(), 2); } +void tst_TapHandler::rightLongPressIgnoreWheel() +{ + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "rightTapHandler.qml"); + QQuickView * window = windowPtr.data(); + + QQuickTapHandler *tap = window->rootObject()->findChild<QQuickTapHandler*>(); + QVERIFY(tap); + QSignalSpy tappedSpy(tap, SIGNAL(tapped(QQuickEventPoint *))); + QSignalSpy longPressedSpy(tap, SIGNAL(longPressed())); + QPoint p1(100, 100); + + // Mouse wheel with ScrollBegin phase (because as soon as two fingers are touching + // the trackpad, it will send such an event: QTBUG-71955) + { + QWheelEvent wheelEvent(p1, p1, QPoint(0, 0), QPoint(0, 0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin, false, Qt::MouseEventNotSynthesized); + QGuiApplication::sendEvent(window, &wheelEvent); + } + + // Press + QTest::mousePress(window, Qt::RightButton, Qt::NoModifier, p1); + QTRY_COMPARE(tap->isPressed(), true); + + // Mouse wheel ScrollEnd phase + QWheelEvent wheelEvent(p1, p1, QPoint(0, 0), QPoint(0, 0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd, false, Qt::MouseEventNotSynthesized); + QGuiApplication::sendEvent(window, &wheelEvent); + QTRY_COMPARE(longPressedSpy.count(), 1); + QCOMPARE(tap->isPressed(), true); + QCOMPARE(tappedSpy.count(), 0); + + // Release + QTest::mouseRelease(window, Qt::RightButton, Qt::NoModifier, p1, 500); + QTRY_COMPARE(tap->isPressed(), false); + QCOMPARE(tappedSpy.count(), 0); +} + QTEST_MAIN(tst_TapHandler) #include "tst_qquicktaphandler.moc" |