diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-10-29 18:21:23 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-10-29 19:47:08 +0100 |
commit | cbb49ad30b5b5c1cc30531c6bd6c9fbcc4142da0 (patch) | |
tree | bd1e16e3b432b8b105f5de936199dec99acafb28 | |
parent | 5bbfd850d77c05e2d1ccf4d052e70240d5aae342 (diff) |
Fix tst_qquickitem::touchEventAcceptIgnore
This test (like many) is older than the setAcceptTouchEvents() function
added in 1457df74f4c1d770e1e820de8cd082be1bd2489e. Now there are 3 cases:
if we don't setAcceptTouchEvents(true), the item doesn't get any touch
events; but if it does, it can accept or reject the individual events.
For some reason the touch events were tediously created and sent before,
but using QTest::touchEvent() simplifies it a lot.
Task-number: QTBUG-86729
Change-Id: I2dd12af8c356c5455bd37d691fc24f3e1d9c107b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | tests/auto/quick/qquickitem/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquickitem/tst_qquickitem.cpp | 92 |
2 files changed, 24 insertions, 70 deletions
diff --git a/tests/auto/quick/qquickitem/BLACKLIST b/tests/auto/quick/qquickitem/BLACKLIST index 6563bc8743..af5b63e1bc 100644 --- a/tests/auto/quick/qquickitem/BLACKLIST +++ b/tests/auto/quick/qquickitem/BLACKLIST @@ -2,5 +2,3 @@ xcb [qtBug60123] * # QTBUG-86729 -[touchEventAcceptIgnore] -* # QTBUG-86729 diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index a187a536ab..0c92d0454e 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -1344,15 +1344,18 @@ void tst_qquickitem::mousePropagationToParent() void tst_qquickitem::touchEventAcceptIgnore_data() { - QTest::addColumn<bool>("itemSupportsTouch"); + QTest::addColumn<bool>("itemAcceptsTouch"); + QTest::addColumn<bool>("itemAcceptsTouchEvents"); - QTest::newRow("with touch") << true; - QTest::newRow("without touch") << false; + QTest::newRow("accepts touch, accepts events") << true << true; + QTest::newRow("accepts touch, ignores events") << true << false; + QTest::newRow("doesn't accept touch, gets no events") << false << false; } void tst_qquickitem::touchEventAcceptIgnore() { - QFETCH(bool, itemSupportsTouch); + QFETCH(bool, itemAcceptsTouch); + QFETCH(bool, itemAcceptsTouchEvents); TestWindow window; window.resize(100, 100); @@ -1362,74 +1365,27 @@ void tst_qquickitem::touchEventAcceptIgnore() QScopedPointer<TestItem> item(new TestItem); item->setSize(QSizeF(100, 100)); item->setParentItem(window.contentItem()); - item->acceptIncomingTouchEvents = itemSupportsTouch; + if (itemAcceptsTouch) + item->setAcceptTouchEvents(itemAcceptsTouch); // it's false by default in Qt 6 + item->acceptIncomingTouchEvents = itemAcceptsTouchEvents; static QPointingDevice* device = QTest::createTouchDevice(); // Send Begin, Update & End touch sequence - { - QMutableEventPoint point(1, QEventPoint::State::Pressed); - point.setPosition(QPointF(50, 50)); - point.setGlobalPosition(point.position()); - - QTouchEvent event(QEvent::TouchBegin, device, - Qt::NoModifier, - QList<QEventPoint>() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = window.event(&event); - QQuickTouchUtils::flush(&window); - - QVERIFY(item->touchEventReached); - - // always true because QtQuick always eats touch events so as to not - // allow QtGui to synthesise them for us. - QCOMPARE(accepted && event.isAccepted(), true); - } - { - QMutableEventPoint point(1, QEventPoint::State::Updated); - point.setPosition(QPointF(60, 60)); - point.setGlobalPosition(point.position()); - - QTouchEvent event(QEvent::TouchUpdate, device, - Qt::NoModifier, - QList<QEventPoint>() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = window.event(&event); - QQuickTouchUtils::flush(&window); - - QCOMPARE(item->touchEventReached, itemSupportsTouch); - - // always true because QtQuick always eats touch events so as to not - // allow QtGui to synthesise them for us. - QCOMPARE(accepted && event.isAccepted(), true); - } - { - QMutableEventPoint point(1, QEventPoint::State::Released); - point.setPosition(QPointF(60, 60)); - point.setGlobalPosition(point.position()); - - QTouchEvent event(QEvent::TouchEnd, device, - Qt::NoModifier, - QList<QEventPoint>() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = window.event(&event); - QQuickTouchUtils::flush(&window); - - QCOMPARE(item->touchEventReached, itemSupportsTouch); - - // always true because QtQuick always eats touch events so as to not - // allow QtGui to synthesise them for us. - QCOMPARE(accepted && event.isAccepted(), true); - } + item->touchEventReached = false; + QTest::touchEvent(&window, device).press(1, QPoint(50, 50), &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(item->touchEventReached, itemAcceptsTouch); + + item->touchEventReached = false; + QTest::touchEvent(&window, device).move(1, QPoint(60, 60), &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(item->touchEventReached, itemAcceptsTouchEvents); + + item->touchEventReached = false; + QTest::touchEvent(&window, device).release(1, QPoint(60, 60), &window); + QQuickTouchUtils::flush(&window); + QTRY_COMPARE(item->touchEventReached, itemAcceptsTouchEvents); } void tst_qquickitem::polishOutsideAnimation() |