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/testhelpers.h | |
| 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/testhelpers.h')
| -rw-r--r-- | src/tests/testhelpers.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tests/testhelpers.h b/src/tests/testhelpers.h new file mode 100644 index 000000000..e73f5449f --- /dev/null +++ b/src/tests/testhelpers.h @@ -0,0 +1,26 @@ +/* + * SPDX-FileCopyrightText: 2026 Sebastian Englbrecht + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#pragma once + +#include <QApplication> +#include <QTest> + +namespace TestHelpers +{ + +/** + * Disables all Qt UI animations. + * Call once in initTestCase(). + * Eliminates the need for qWait(N) hacks that wait for animations to finish. + */ +inline void disableAnimations() +{ + QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); + QApplication::setEffectEnabled(Qt::UI_AnimateTooltip, false); + QApplication::setEffectEnabled(Qt::UI_AnimateToolBox, false); +} + +} // namespace TestHelpers |
