diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-03-17 17:41:59 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-07-01 15:22:17 +0000 |
commit | 18ca2d72e498a54bffe5a4f099a0320a348c5558 (patch) | |
tree | c46e28a0e5ad4719c0be74a83fbb33198565c8bf /tests | |
parent | da278e05766da8620a5ff577c0c5e58f988433eb (diff) |
Fix and un-blacklist tst_qquickwidget::synthMouseFromTouch
In Qt 6, any QQuickItem that wants to handle touch events needs to
explicitly enable them by calling setAcceptTouchEvents(true).
This was anticipated in 1457df74f4c1d770e1e820de8cd082be1bd2489e
and ab91e7fa02a562d80fd0747f28a60e00c3b45a01
If an Item calls setAcceptTouchEvents(true), it will not receive
synth-mouse events, even if it calls ignore() on a particular
touch press event. So now in this test, when we want to test
synth-mouse events, we call setAcceptTouchEvents(false).
Task-number: QTBUG-86729
Task-number: QTBUG-101736
Change-Id: I71d2f213bc62206c190c94de5e4d39ce17504a0d
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit 18954828363a6e14b969c7ba43784d48a157da06)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quickwidgets/qquickwidget/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp | 15 |
2 files changed, 8 insertions, 9 deletions
diff --git a/tests/auto/quickwidgets/qquickwidget/BLACKLIST b/tests/auto/quickwidgets/qquickwidget/BLACKLIST index 44ab3e9397..095e9ee484 100644 --- a/tests/auto/quickwidgets/qquickwidget/BLACKLIST +++ b/tests/auto/quickwidgets/qquickwidget/BLACKLIST @@ -3,5 +3,3 @@ opensuse-42.3 opensuse-leap [enterLeave] macos -[synthMouseFromTouch] # QTBUG-86729 -* diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 35187feaf8..1ef70e6515 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -86,17 +86,18 @@ public: class MouseRecordingItem : public QQuickItem { public: - MouseRecordingItem(bool acceptTouch, QQuickItem *parent = nullptr) + MouseRecordingItem(bool acceptTouch, bool acceptTouchPress, QQuickItem *parent = nullptr) : QQuickItem(parent) - , m_acceptTouch(acceptTouch) + , m_acceptTouchPress(acceptTouchPress) { setSize(QSizeF(300, 300)); setAcceptedMouseButtons(Qt::LeftButton); + setAcceptTouchEvents(acceptTouch); } protected: void touchEvent(QTouchEvent* event) override { - event->setAccepted(m_acceptTouch); + event->setAccepted(m_acceptTouchPress); m_touchEvents << event->type(); qCDebug(lcTests) << "accepted?" << event->isAccepted() << event; } @@ -118,7 +119,7 @@ public: QList<QEvent::Type> m_touchEvents; private: - bool m_acceptTouch; + bool m_acceptTouchPress; }; class tst_qquickwidget : public QQmlDataTest @@ -625,7 +626,7 @@ void tst_qquickwidget::synthMouseFromTouch() QWidget window; window.setAttribute(Qt::WA_AcceptTouchEvents); QScopedPointer<MouseRecordingQQWidget> childView(new MouseRecordingQQWidget(&window)); - MouseRecordingItem *item = new MouseRecordingItem(acceptTouch, nullptr); + MouseRecordingItem *item = new MouseRecordingItem(!synthMouse, acceptTouch, nullptr); childView->setContent(QUrl(), nullptr, item); window.resize(300, 300); childView->resize(300, 300); @@ -640,8 +641,8 @@ void tst_qquickwidget::synthMouseFromTouch() QTest::touchEvent(&window, device).move(0, p2, &window); QTest::touchEvent(&window, device).release(0, p2, &window); - QCOMPARE(item->m_touchEvents.count(), !synthMouse && !acceptTouch ? 1 : 3); - QCOMPARE(item->m_mouseEvents.count(), (acceptTouch || !synthMouse) ? 0 : 3); + QCOMPARE(item->m_touchEvents.count(), synthMouse ? 0 : (acceptTouch ? 3 : 1)); + QCOMPARE(item->m_mouseEvents.count(), synthMouse ? 3 : 0); QCOMPARE(childView->m_mouseEvents.count(), 0); for (const auto &ev : item->m_mouseEvents) QCOMPARE(ev, Qt::MouseEventSynthesizedByQt); |