diff options
| author | Sebastian Englbrecht <[email protected]> | 2026-05-23 13:27:36 +0200 |
|---|---|---|
| committer | Sebastian Englbrecht <[email protected]> | 2026-05-25 13:05:50 +0200 |
| commit | 22d65e047ac75fc3527ddac2401e90a2805a6f04 (patch) | |
| tree | 20fe87e98add69c53a2b7fff636f05baf13c8dfb /src/tests/kitemlistcontrollerexpandtest.cpp | |
| parent | 9ed55e4d5e66f509a12a01f3f4f684bec37fbb58 (diff) | |
tests: replace QTest::qWait(N) with signal-based waits
Fixed-time sleeps are a source of intermittent failures on slow CI
machines — if the delay is too short, the test races ahead of the
code under test.
Replacements made:
- dolphinmainwindowtest: qWait() calls replaced with QTRY_COMPARE,
QTRY_VERIFY, qWaitFor lambdas and processEvents() where animations
are disabled; one genuinely unavoidable timer wait marked
// UNAVOIDABLE:
- kitemlistcontrollerexpandtest: qWaitFor(..., 100ms) / qWaitFor(...,
300ms) replaced with spy->wait() loops that block until all
expected directoryLoadingCompleted signals have arrived
- kitemlistkeyboardsearchmanagertest: timer-driven wait marked
// UNAVOIDABLE: (must wait for keyboard search timeout to expire)
Add testhelpers.h providing TestHelpers::disableAnimations(), which
eliminates the need for delays that previously waited for Qt UI
animations to settle.
Diffstat (limited to 'src/tests/kitemlistcontrollerexpandtest.cpp')
| -rw-r--r-- | src/tests/kitemlistcontrollerexpandtest.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/tests/kitemlistcontrollerexpandtest.cpp b/src/tests/kitemlistcontrollerexpandtest.cpp index 8f16251b4..cb84fb693 100644 --- a/src/tests/kitemlistcontrollerexpandtest.cpp +++ b/src/tests/kitemlistcontrollerexpandtest.cpp @@ -152,11 +152,8 @@ void KItemListControllerExpandTest::testDirExpand() // expand selected folders QTest::keyClick(m_container, Qt::Key_Right); - QVERIFY(QTest::qWaitFor( - [this]() { - return m_spyDirectoryLoadingCompleted->count() == 3; - }, - 100)); + QVERIFY(m_spyDirectoryLoadingCompleted->wait()); + QCOMPARE(m_spyDirectoryLoadingCompleted->count(), 3); QCOMPARE(m_model->count(), 8); QCOMPARE(m_selectionManager->currentItem(), 6); QCOMPARE(m_selectionManager->selectedItems().count(), 2); @@ -179,11 +176,11 @@ void KItemListControllerExpandTest::testDirExpand() // expand the three folders QTest::keyClick(m_container, Qt::Key_Right); - QVERIFY(QTest::qWaitFor( - [this]() { - return m_spyDirectoryLoadingCompleted->count() == 6; - }, - 300)); + // Key_Right expands all 3 selected folders, each triggering one directoryLoadingCompleted. + // spy->wait() unblocks on a single emission, so loop until all 3 have arrived. + while (m_spyDirectoryLoadingCompleted->count() < 6) { + QVERIFY(m_spyDirectoryLoadingCompleted->wait()); + } QCOMPARE(m_model->count(), 18); QCOMPARE(m_selectionManager->currentItem(), 12); @@ -216,11 +213,10 @@ void KItemListControllerExpandTest::testDirExpand() // expand the three folders with shift modifier QTest::keyClick(m_container, Qt::Key_Right, Qt::ShiftModifier); - QVERIFY(QTest::qWaitFor( - [this]() { - return m_spyDirectoryLoadingCompleted->count() == 9; - }, - 100)); + // Same as above: 3 folders expand in parallel, one signal each — loop until all 3 arrive. + while (m_spyDirectoryLoadingCompleted->count() < 9) { + QVERIFY(m_spyDirectoryLoadingCompleted->wait()); + } QCOMPARE(m_model->count(), 18); QCOMPARE(m_selectionManager->currentItem(), 12); |
