aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-08-24 12:40:23 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2016-08-24 13:52:08 +0000
commit651ecf9ae413478af622761e89347bb4e6243e0c (patch)
tree931200743f2f60619d10fe11b4ed34ba84a69396 /tests/auto/quick/qquickmousearea
parent4e9fc0129d6b4326c2159e4fafa42a3df9d35e0a (diff)
Fix mouse area pressed after removal of pre-grab
Qt Quick used to actively "grab" the mouse before delivering events, making the code more complex than necessary. Some items came to rely on the behavior and now lack the ungrab event. This is triggered when inside the delivery of a mouse event, some other item grabs the mouse. If the mouse grab changed to an item that was not the target of the original delivery, the grab must have been stolen, so call mouseUngrabEvent in this case. Test case by J-P Nurmi. Task-number: QTBUG-55325 Change-Id: I2f0ac9d8aed1415662196070fb763f2752004d22 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickmousearea')
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 7baff93574..b69c6eedf8 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -125,6 +125,7 @@ private slots:
void containsPress_data();
void containsPress();
void ignoreBySource();
+ void notPressedAfterStolenGrab();
private:
int startDragDistance() const {
@@ -1987,6 +1988,23 @@ void tst_QQuickMouseArea::ignoreBySource()
QCOMPARE(flickable->contentY(), 0.);
}
+void tst_QQuickMouseArea::notPressedAfterStolenGrab()
+{
+ QQuickWindow window;
+ window.resize(200, 200);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+
+ QQuickMouseArea *ma = new QQuickMouseArea(window.contentItem());
+ ma->setSize(window.size());
+ QObject::connect(ma,
+ static_cast<void (QQuickMouseArea::*)(QQuickMouseEvent*)>(&QQuickMouseArea::pressed),
+ [&]() { window.contentItem()->grabMouse(); });
+
+ QTest::mouseClick(&window, Qt::LeftButton);
+ QVERIFY(!ma->pressed());
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"