11#include < QtTest>
22
3+ #include < QMouseEvent>
34#include < QToolButton>
45
56#include < widgets/tableinsertpopup.h>
@@ -18,6 +19,8 @@ private slots:
1819 void testDialogFallbackEmitsRequest ();
1920
2021private:
22+ void movePointer (const QPoint &p_pos);
23+
2124 QToolButton m_button;
2225 TableInsertPopup *m_popup = nullptr ;
2326 QWidget *m_grid = nullptr ;
@@ -38,11 +41,18 @@ void TestTableInsertPopup::cleanup() {
3841 m_grid = nullptr ;
3942}
4043
44+ void TestTableInsertPopup::movePointer (const QPoint &p_pos) {
45+ // Test Qt input handling without relying on native cursor warping on CI desktops.
46+ QMouseEvent move (QEvent::MouseMove, p_pos, m_grid->mapToGlobal (p_pos), Qt::NoButton, Qt::NoButton,
47+ Qt::NoModifier);
48+ QCoreApplication::sendEvent (m_grid, &move);
49+ }
50+
4151void TestTableInsertPopup::testHoverAndClickEmitsBodyRowsAndColumns () {
4252 QSignalSpy selected (m_popup, &TableInsertPopup::tableSelected);
4353 const QPoint cell (m_grid->width () * 7 / 14 , m_grid->height () * 5 / 14 );
44- QTest::mouseMove (m_grid, cell);
45- QTRY_COMPARE (m_popup->getHoveredBodyRows (), 3 );
54+ movePointer ( cell);
55+ QCOMPARE (m_popup->getHoveredBodyRows (), 3 );
4656 QCOMPARE (m_popup->getHoveredColumns (), 4 );
4757
4858 QTest::mouseClick (m_grid, Qt::LeftButton, Qt::NoModifier, cell);
@@ -54,13 +64,14 @@ void TestTableInsertPopup::testHoverAndClickEmitsBodyRowsAndColumns() {
5464
5565void TestTableInsertPopup::testOutsideGridClickIgnored () {
5666 QSignalSpy selected (m_popup, &TableInsertPopup::tableSelected);
57- QTest::mouseMove (m_grid, QPoint (m_grid->width () * 13 / 14 , m_grid->height () * 13 / 14 ));
58- QTRY_COMPARE (m_popup->getHoveredBodyRows (), 7 );
67+ movePointer ( QPoint (m_grid->width () * 13 / 14 , m_grid->height () * 13 / 14 ));
68+ QCOMPARE (m_popup->getHoveredBodyRows (), 7 );
5969 QCOMPARE (m_popup->getHoveredColumns (), 7 );
6070
6171 const QPoint outside (m_grid->width () + 1 , m_grid->height () / 2 );
62- QTest::mouseMove (m_grid, outside);
63- QTRY_COMPARE (m_popup->getHoveredBodyRows (), 0 );
72+ QEvent leave (QEvent::Leave);
73+ QCoreApplication::sendEvent (m_grid, &leave);
74+ QCOMPARE (m_popup->getHoveredBodyRows (), 0 );
6475 QCOMPARE (m_popup->getHoveredColumns (), 0 );
6576 QTest::mouseClick (m_grid, Qt::LeftButton, Qt::NoModifier, outside);
6677 QCOMPARE (selected.count (), 0 );
0 commit comments