aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/mousearea_interop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/pointerhandlers/mousearea_interop')
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/BLACKLIST7
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/CMakeLists.txt24
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/data/dragHandlerInMouseAreaGrandparent.qml20
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml29
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/data/hoverHandlerInGrandparentOfHoverableItem.qml33
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp103
6 files changed, 142 insertions, 74 deletions
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/BLACKLIST b/tests/auto/quick/pointerhandlers/mousearea_interop/BLACKLIST
new file mode 100644
index 0000000000..74d29b4ac3
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/BLACKLIST
@@ -0,0 +1,7 @@
+# QTBUG-95938
+[dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch]
+opensuse-leap
+
+# QTBUG-95938
+[dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse]
+opensuse-leap
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/CMakeLists.txt b/tests/auto/quick/pointerhandlers/mousearea_interop/CMakeLists.txt
index f799de97b8..22123e6385 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/CMakeLists.txt
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/CMakeLists.txt
@@ -1,9 +1,18 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
# Generated from mousearea_interop.pro.
#####################################################################
## tst_mousearea_interop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_mousearea_interop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -12,21 +21,14 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_mousearea_interop
SOURCES
- ../../../shared/util.cpp ../../../shared/util.h
- ../../shared/geometrytestutil.cpp ../../shared/geometrytestutil.h
- ../../shared/viewtestutil.cpp ../../shared/viewtestutil.h
- ../../shared/visualtestutil.cpp ../../shared/visualtestutil.h
tst_mousearea_interop.cpp
- DEFINES
- QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
- INCLUDE_DIRECTORIES
- ../../../shared
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
Qt::QmlPrivate
Qt::QuickPrivate
+ Qt::QuickTestUtilsPrivate
TESTDATA ${test_data}
)
@@ -38,10 +40,10 @@ qt_internal_add_test(tst_mousearea_interop
qt_internal_extend_target(tst_mousearea_interop CONDITION ANDROID OR IOS
DEFINES
- QT_QMLTEST_DATADIR=\\\":/data\\\"
+ QT_QMLTEST_DATADIR=":/data"
)
qt_internal_extend_target(tst_mousearea_interop CONDITION NOT ANDROID AND NOT IOS
DEFINES
- QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+ QT_QMLTEST_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data"
)
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragHandlerInMouseAreaGrandparent.qml b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragHandlerInMouseAreaGrandparent.qml
new file mode 100644
index 0000000000..7adb205a1f
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragHandlerInMouseAreaGrandparent.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.12
+
+Rectangle {
+ width: 200; height: 200
+
+ DragHandler { }
+
+ Rectangle {
+ objectName: "button"
+ width: 100; height: 40; x: 10; y: 10
+ border.color: "orange"
+ color: ma.pressed ? "lightsteelblue" : "beige"
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ onDoubleClicked: console.log("__")
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml
index 48b1dc86f0..1bde433dba 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.12
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/data/hoverHandlerInGrandparentOfHoverableItem.qml b/tests/auto/quick/pointerhandlers/mousearea_interop/data/hoverHandlerInGrandparentOfHoverableItem.qml
new file mode 100644
index 0000000000..a3b957a1f7
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/data/hoverHandlerInGrandparentOfHoverableItem.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.12
+
+Item {
+ width: 320
+ height: 240
+
+ Rectangle {
+ color: hh.hovered ? "orange" : "gray"
+ anchors.fill: container
+ }
+
+ Item {
+ id: container
+ anchors.fill: parent
+ anchors.margins: 40
+
+ Rectangle {
+ width: parent.width
+ height: 40
+ color: ma.pressed ? "blue" : ma.containsMouse ? "aquamarine" : "beige"
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+ }
+
+ HoverHandler {
+ id: hh
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
index 4709622245..b1a480b9cf 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
@@ -1,43 +1,22 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module 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$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
+#include <QtGui/qstylehints.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlproperty.h>
#include <QtQuick/private/qquickdraghandler_p.h>
+#include <QtQuick/private/qquickhoverhandler_p.h>
#include <QtQuick/private/qquickmousearea_p.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QtGui/private/qpointingdevice_p.h>
-#include "../../../shared/util.h"
-#include "../../shared/viewtestutil.h"
+#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
+
+#include <QtCore/qpointer.h>
Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests")
@@ -46,12 +25,15 @@ class tst_MouseAreaInterop : public QQmlDataTest
Q_OBJECT
public:
tst_MouseAreaInterop()
+ : QQmlDataTest(QT_QMLTEST_DATADIR)
{}
private slots:
void dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse();
void dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch_data();
void dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch();
+ void hoverHandlerDoesntHoverOnPress();
+ void doubleClickInMouseAreaWithDragHandlerInGrandparent();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
@@ -63,8 +45,8 @@ void tst_MouseAreaInterop::createView(QScopedPointer<QQuickView> &window, const
window.reset(new QQuickView);
window->setSource(testFileUrl(fileName));
QTRY_COMPARE(window->status(), QQuickView::Ready);
- QQuickViewTestUtil::centerOnScreen(window.data());
- QQuickViewTestUtil::moveMouseAway(window.data());
+ QQuickViewTestUtils::centerOnScreen(window.data());
+ QQuickViewTestUtils::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
@@ -86,7 +68,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse
QPoint p1(150, 150);
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(window->mouseGrabberItem(), ma);
- QCOMPARE(ma->pressed(), true);
+ QCOMPARE(ma->isPressed(), true);
// Start dragging
// DragHandler keeps monitoring, due to its passive grab,
@@ -104,7 +86,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse
qCDebug(lcPointerTests, "DragHandler stole the grab after %d events", dragStoleGrab);
QVERIFY(dragStoleGrab > 1);
QCOMPARE(handler->active(), true);
- QCOMPARE(ma->pressed(), false);
+ QCOMPARE(ma->isPressed(), false);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(handler->active(), false);
@@ -145,7 +127,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
QVERIFY(epd);
QVERIFY(epd->passiveGrabbers.contains(handler.data()));
QCOMPARE(epd->exclusiveGrabber, ma);
- QCOMPARE(ma->pressed(), true);
+ QCOMPARE(ma->isPressed(), true);
// Start dragging
// DragHandler keeps monitoring, due to its passive grab,
@@ -163,11 +145,11 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
if (preventStealing) {
QCOMPARE(dragStoleGrab, 0);
QCOMPARE(handler->active(), false);
- QCOMPARE(ma->pressed(), true);
+ QCOMPARE(ma->isPressed(), true);
} else {
QVERIFY(dragStoleGrab > 1);
QCOMPARE(handler->active(), true);
- QCOMPARE(ma->pressed(), false);
+ QCOMPARE(ma->isPressed(), false);
}
touch.release(1, p1).commit();
@@ -175,6 +157,55 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
QCOMPARE(handler->active(), false);
}
+void tst_MouseAreaInterop::hoverHandlerDoesntHoverOnPress() // QTBUG-72843
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("hoverHandlerInGrandparentOfHoverableItem.qml")));
+
+ QPointer<QQuickHoverHandler> handler = window.rootObject()->findChild<QQuickHoverHandler*>();
+ QVERIFY(handler);
+ QQuickMouseArea *ma = window.rootObject()->findChild<QQuickMouseArea*>();
+ QVERIFY(ma);
+ QPoint p = ma->mapToScene(ma->boundingRect().center()).toPoint();
+
+ // move the mouse below the "button" but within HoverHandler's region of interest
+ QTest::mouseMove(&window, p + QPoint(0, 50));
+ QTRY_COMPARE(handler->isHovered(), true);
+ // move the mouse into the "button"
+ QTest::mouseMove(&window, p);
+ // both the hoverhandler and the mouse area should now be hovered!
+ QTRY_COMPARE(handler->isHovered(), true);
+ QCOMPARE(ma->hovered(), true);
+
+ QSignalSpy hoveredChangedSpy(handler, SIGNAL(hoveredChanged()));
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p);
+ QTRY_COMPARE(ma->isPressed(), true);
+ QCOMPARE(handler->isHovered(), true);
+ QCOMPARE(hoveredChangedSpy.size(), 0);
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p);
+ QTRY_COMPARE(ma->isPressed(), false);
+ QCOMPARE(handler->isHovered(), true);
+ QCOMPARE(hoveredChangedSpy.size(), 0);
+}
+
+void tst_MouseAreaInterop::doubleClickInMouseAreaWithDragHandlerInGrandparent()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("dragHandlerInMouseAreaGrandparent.qml")));
+
+ QQuickDragHandler *handler = window.rootObject()->findChild<QQuickDragHandler*>();
+ QVERIFY(handler);
+ QSignalSpy dragActiveSpy(handler, &QQuickDragHandler::activeChanged);
+ QQuickMouseArea *ma = window.rootObject()->findChild<QQuickMouseArea*>();
+ QVERIFY(ma);
+ QSignalSpy dClickSpy(ma, &QQuickMouseArea::doubleClicked);
+ QPoint p = ma->mapToScene(ma->boundingRect().center()).toPoint();
+
+ QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p);
+ QCOMPARE(dClickSpy.size(), 1);
+ QCOMPARE(dragActiveSpy.size(), 0);
+}
+
QTEST_MAIN(tst_MouseAreaInterop)
#include "tst_mousearea_interop.moc"