diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2025-02-24 18:51:44 +0100 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2025-02-24 21:51:13 +0100 |
| commit | 8623d14876245c2f5bc6af23ceeb1755e51a0dd1 (patch) | |
| tree | c26fe6592c1d535b85d04dc2e1f96724949762c2 /tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp | |
| parent | 17a777a5dfa72e47d02c3e6b4c3a137d923d50bc (diff) | |
tst_qquickpointerhandler: fix warning about mismatched enums; ctor casts
The GrabTransition enum has no "none" value: there's no reason we need
one for public API. But this test records events and transitions, and
needs a way to record that no grab transition happened. It's just an int
anyway, so QCOMPARE_EVENT simply casts it before comparison; and in any
ternary-if expression using NoGrab, we cast both arms to int.
The warning was
warning: enumerated mismatch in conditional expression: ‘<unnamed enum>’ vs
‘QPointingDevice::GrabTransition’ [-Wenum-compare]
549 | QEventPoint::State::Pressed, itemIgnoreMouse ? NoGrab : QPointingDevice::GrabExclusive);
| ^
Next, there is -Wint-in-bool-context: fixed by surrounding the ternary
if's with parentheses.
Replace C-style with constructor-style casts while we're at it.
Change-Id: I0796abc8e19c1842a6b2f4e343d566ff0cc226e6
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp')
| -rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index b5751f7f7e..1db6b0ac3b 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -78,7 +78,7 @@ public: {} inline int grabTransition(bool accept, QEventPoint::State state) { - return (accept && (state != QEventPoint::State::Released)) ? (int)QPointingDevice::GrabExclusive : (int)NoGrab; + return (accept && (state != QEventPoint::State::Released)) ? int(QPointingDevice::GrabExclusive) : int(NoGrab); } void touchEvent(QTouchEvent *event) override @@ -177,7 +177,7 @@ public: QCOMPARE(event.destination, d);\ QCOMPARE(event.type, t);\ QCOMPARE(event.state, s);\ - QCOMPARE(event.grabTransition, g);\ + QCOMPARE(int(event.grabTransition), int(g));\ }\ class EventHandler : public QQuickPointerHandler @@ -220,7 +220,7 @@ public: // target item holds the eventList, which records all events to the item and handler in order item->eventList.append(Event(Event::HandlerDestination, QEvent::Pointer, static_cast<QEventPoint::State>(point.state()), - grabPoint ? (int)QPointingDevice::GrabExclusive : (int)NoGrab, + grabPoint ? int(QPointingDevice::GrabExclusive) : int(NoGrab), eventPos(point), point.scenePosition())); } } @@ -546,8 +546,8 @@ void tst_PointerHandlers::mouseEventDelivery() QCOMPARE(eventItem1->eventList.at(eventCheckIndex).posWrtItem, localPos); QCOMPARE(eventItem1->eventList.at(eventCheckIndex).posWrtScene, scenePos); QCOMPARE_EVENT(eventCheckIndex++, Event::ItemMouseDestination, QEvent::MouseButtonPress, - QEventPoint::State::Pressed, itemIgnoreMouse ? NoGrab : QPointingDevice::GrabExclusive); - QCOMPARE(window->mouseGrabberItem(), itemIgnoreMouse ? nullptr: eventItem1); + QEventPoint::State::Pressed, (itemIgnoreMouse ? int(NoGrab) : int(QPointingDevice::GrabExclusive))); + QCOMPARE(window->mouseGrabberItem(), (itemIgnoreMouse ? nullptr : eventItem1)); p1 += QPoint(10, 0); QTest::mouseMove(window, p1); @@ -587,14 +587,14 @@ void tst_PointerHandlers::touchReleaseOutside_data() QTest::addColumn<int>("endState"); // QEventPoint::State QTest::addColumn<int>("endGrabState"); // QEventPoint::State - QTest::newRow("reject and ignore") << false << false << 6 << 5 << (int)Event::ItemTouchDestination - << (int)QEvent::TouchEnd << (int)QEventPoint::State::Released << (int)NoGrab; - QTest::newRow("reject and grab") << false << true << 5 << 4 << (int)Event::HandlerDestination - << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QPointingDevice::UngrabExclusive; - QTest::newRow("accept and ignore") << true << false << 1 << 0 << (int)Event::HandlerDestination - << (int)QEvent::Pointer << (int)QEventPoint::State::Pressed << (int)NoGrab; - QTest::newRow("accept and grab") << true << true << 5 << 4 << (int)Event::HandlerDestination - << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QPointingDevice::UngrabExclusive; + QTest::newRow("reject and ignore") << false << false << 6 << 5 << int(Event::ItemTouchDestination) + << int(QEvent::TouchEnd) << int(QEventPoint::State::Released) << int(NoGrab); + QTest::newRow("reject and grab") << false << true << 5 << 4 << int(Event::HandlerDestination) + << int(QEvent::None) << int(QEventPoint::State::Released) << int(QPointingDevice::UngrabExclusive); + QTest::newRow("accept and ignore") << true << false << 1 << 0 << int(Event::HandlerDestination) + << int(QEvent::Pointer) << int(QEventPoint::State::Pressed) << int(NoGrab); + QTest::newRow("accept and grab") << true << true << 5 << 4 << int(Event::HandlerDestination) + << int(QEvent::None) << int(QEventPoint::State::Released) << int(QPointingDevice::UngrabExclusive); } void tst_PointerHandlers::touchReleaseOutside() |
