diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-11-01 13:28:30 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-07 14:26:15 +0000 |
commit | 3a36acc274ac55c8b036abf89757fed810efc61e (patch) | |
tree | b7f38769f6b3c136fcafc2fd5839116693782237 /tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp | |
parent | 484b29ed7bc630eefd3b7b3498d199ef438933cc (diff) |
Fix performance issue with drag retrigger events for qtquick items
The items that reject drag events (specifically onEntered in DropArea)
should not be retriggered with DragEnter event until entered once again.
Fixes: QTBUG-74496
Change-Id: I241a6004da6382685be89fe8a001b98dfde5c8a2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 0b7374fefa1abf08e956bc5d34008352144bd9ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp')
-rw-r--r-- | tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp index 6bbe0d522b..9c9d059a52 100644 --- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp @@ -67,6 +67,9 @@ public: private slots: void containsDrag_internal(); void containsDrag_external(); + + void ignoreRetriggerEvent(); + void keys_internal(); void keys_external(); void source_internal(); @@ -829,6 +832,32 @@ void tst_QQuickDropArea::competingDrags() QCOMPARE(evaluate<QString>(dropArea1, "statuslol"), QStringLiteral("parent")); } +void tst_QQuickDropArea::ignoreRetriggerEvent() +{ + QQuickView window; + QByteArray errorMessage; + QVERIFY2(QQuickTest::initView(window, testFileUrl("ignoreRetriggerEvent.qml"), true, &errorMessage), errorMessage.constData()); + + QQuickItem *dropArea = window.rootObject(); + QVERIFY(dropArea); + QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem"); + QVERIFY(dragItem); + + evaluate<void>(dragItem, "Drag.active = true"); + // Drag the item within the drop area + dragItem->setPosition(QPointF(25, 25)); + QCoreApplication::processEvents(); + dragItem->setPosition(QPointF(50, 50)); + QCoreApplication::processEvents(); + dragItem->setPosition(QPointF(75, 75)); + QCoreApplication::processEvents(); + + QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false); + QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0); +} + + void tst_QQuickDropArea::simultaneousDrags() { QQuickWindow window; |