aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@luxoft.com>2017-10-09 17:39:44 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-11-03 09:47:13 +0000
commit0821180dc833376a738742e33f728983b9ca6f84 (patch)
tree0f55d165cc3ef4e7811c0759625586a49a761108 /tests/auto/quick
parentc143c790b7a6fceaac16492023090940c81acc42 (diff)
Fix bug preventing ungrabMouse() on TouchCancel
The order matters. There won't be a mouseGrabberItem() after the cancelExclusiveGrabImpl() call. So ungrab the mouse before calling it, not after. Task-number: QTBUG-63680 Change-Id: I81e03e079362c865e13792feb8c3af8cb3abedc8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index c95d9b311e..f20a1a7e1a 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -144,7 +144,8 @@ public:
TestTouchItem(QQuickItem *parent = 0)
: QQuickRectangle(parent), acceptTouchEvents(true), acceptMouseEvents(true),
mousePressCount(0), mouseMoveCount(0),
- spinLoopWhenPressed(false), touchEventCount(0)
+ spinLoopWhenPressed(false), touchEventCount(0),
+ mouseUngrabEventCount(0)
{
border()->setWidth(1);
setAcceptedMouseButtons(Qt::LeftButton);
@@ -163,6 +164,7 @@ public:
lastMouseCapabilityFlags = 0;
touchEventCount = 0;
mouseMoveCount = 0;
+ mouseUngrabEventCount = 0;
}
static void clearMouseEventCounters()
@@ -182,6 +184,7 @@ public:
int mouseMoveCount;
bool spinLoopWhenPressed;
int touchEventCount;
+ int mouseUngrabEventCount;
QVector2D lastVelocity;
QVector2D lastVelocityFromMouseMove;
QPointF lastMousePos;
@@ -235,6 +238,10 @@ public:
lastMouseCapabilityFlags = QGuiApplicationPrivate::mouseEventCaps(e);
}
+ void mouseUngrabEvent() {
+ ++mouseUngrabEventCount;
+ }
+
bool childMouseEventFilter(QQuickItem *item, QEvent *e) {
qCDebug(lcTests) << objectName() << "filtering" << e << "ahead of delivery to" << item->metaObject()->className() << item->objectName();
switch (e->type()) {
@@ -315,6 +322,7 @@ private slots:
void touchEvent_propagation();
void touchEvent_propagation_data();
void touchEvent_cancel();
+ void touchEvent_cancelClearsMouseGrab();
void touchEvent_reentrant();
void touchEvent_velocity();
@@ -833,6 +841,38 @@ void tst_qquickwindow::touchEvent_cancel()
delete item;
}
+void tst_qquickwindow::touchEvent_cancelClearsMouseGrab()
+{
+ TestTouchItem::clearMouseEventCounters();
+
+ QQuickWindow *window = new QQuickWindow;
+ QScopedPointer<QQuickWindow> cleanup(window);
+
+ window->resize(250, 250);
+ window->setPosition(100, 100);
+ window->setTitle(QTest::currentTestFunction());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ TestTouchItem *item = new TestTouchItem(window->contentItem());
+ item->setPosition(QPointF(50, 50));
+ item->setSize(QSizeF(150, 150));
+ item->acceptMouseEvents = true;
+ item->acceptTouchEvents = false;
+
+ QPointF pos(50, 50);
+ QTest::touchEvent(window, touchDevice).press(0, item->mapToScene(pos).toPoint(), window);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(item->mousePressCount, 1);
+ QTRY_COMPARE(item->mouseUngrabEventCount, 0);
+
+ QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(item->mouseUngrabEventCount, 1);
+}
+
void tst_qquickwindow::touchEvent_reentrant()
{
TestTouchItem::clearMouseEventCounters();