[system/dolphin] src/tests: kitemlistcontrollertest: wait for item layout in the drag-hover tests
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 612804fe8756a6cacf36a262f4c40b9e172e4c79 by Méven Car.
Committed on 18/07/2026 at 13:48.
Pushed by meven into branch 'master'.
kitemlistcontrollertest: wait for item layout in the drag-hover tests
The drag-hover tests changed the item size and geometry and then read
itemContextRect() after a single processEvents(). itemContextRect() returns an
empty rectangle until the item's widget has been laid out, and the relayout
after an item-size change can take more than one event-loop iteration on slow
CI. When it was not ready the computed drag position was the (0, 0) corner, the
hit test missed the item, no itemHovered was emitted and the test failed
(observed on the FreeBSD CI).
Wait with QTRY_VERIFY until itemContextRect() is no longer empty before reading
the drag positions.
M +10 -2 src/tests/kitemlistcontrollertest.cpp
https://invent.kde.org/system/dolphin/-/commit/612804fe8756a6cacf36a262f4c40b9e172e4c79
diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp
index fad1e1c6c1..8047c238d6 100644
--- a/src/tests/kitemlistcontrollertest.cpp
+++ b/src/tests/kitemlistcontrollertest.cpp
@@ -1303,11 +1303,16 @@ void KItemListControllerTest::testDragMoveHoverIdempotency()
m_view->setItemSize(QSizeF(100, 100));
adjustGeometryForColumnCount(3);
m_view->setScrollOffset(0);
- QApplication::processEvents();
QMimeData mimeData;
mimeData.setUrls({QUrl("file:///external/dragged-file")});
+ // itemContextRect() is empty until the item's widget has been laid out, which can take
+ // more than one event-loop iteration after an item-size and geometry change on slow CI.
+ // Wait for it so the drag positions land on the items and not on the (0, 0) corner.
+ QTRY_VERIFY(!m_view->itemContextRect(0).isEmpty());
+ QTRY_VERIFY(!m_view->itemContextRect(1).isEmpty());
+
const QPointF pos0 = m_view->itemContextRect(0).center();
const QPointF pos1 = m_view->itemContextRect(1).center();
@@ -1351,11 +1356,14 @@ void KItemListControllerTest::testDragLeaveHoverCleanup()
m_view->setItemSize(QSizeF(100, 100));
adjustGeometryForColumnCount(3);
m_view->setScrollOffset(0);
- QApplication::processEvents();
QMimeData mimeData;
mimeData.setUrls({QUrl("file:///external/dragged-file")});
+ // itemContextRect() is empty until the item's widget has been laid out (see
+ // testDragMoveHoverIdempotency). Wait so the drag position lands on the item.
+ QTRY_VERIFY(!m_view->itemContextRect(0).isEmpty());
+
const QPointF pos0 = m_view->itemContextRect(0).center();
QSignalSpy hoveredSpy(m_controller, &KItemListController::itemHovered);