#include "input/KeyRepeater.h" #include #include class TestKeyRepeater : public QObject { Q_OBJECT private Q_SLOTS: void repeatsThenSwitchesToWords() { KeyRepeater repeater({.initialDelayMs = 50, .intervalMs = 10, .wordModeAfterMs = 150, .wordIntervalMs = 20}); QSignalSpy spy(&repeater, &KeyRepeater::repeat); repeater.start(); QTest::qWait(40); QCOMPARE(spy.count(), 0); // still in the initial delay QTRY_VERIFY(spy.count() >= 3); QCOMPARE(spy.first().first().toBool(), false); QTRY_VERIFY(spy.last().first().toBool()); // word mode eventually repeater.stop(); const auto count = spy.count(); QTest::qWait(60); QCOMPARE(spy.count(), count); } }; QTEST_GUILESS_MAIN(TestKeyRepeater) #include "tst_keyrepeater.moc"