From 22d65e047ac75fc3527ddac2401e90a2805a6f04 Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Sat, 23 May 2026 13:27:36 +0200 Subject: tests: replace QTest::qWait(N) with signal-based waits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/tests/kitemlistcontrollerexpandtest.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/tests/kitemlistcontrollerexpandtest.cpp') 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); -- cgit v1.3.1