From aced85db1f7c72268860f0368402cf97f34e55c2 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Thu, 29 Mar 2012 19:56:53 +0200 Subject: KItemListKeyboardSearchManager: make it possible to choose the timeout It's now possible to change the timeout, after which any call of KItemListKeyboardSearchManager::addKeys(const QString&) starts a new search, from the default value of 5000 milliseconds. This is not used in Dolphin at the moment, but it permits to reduce the timeout to a small value in the unit test. Before this change, the unit test took more than 5 seconds to complete. (cherry picked from commit 82fc1b54bd01768f50aba7d328cdcde7de1483d7) --- src/tests/kitemlistkeyboardsearchmanagertest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/tests') diff --git a/src/tests/kitemlistkeyboardsearchmanagertest.cpp b/src/tests/kitemlistkeyboardsearchmanagertest.cpp index 14a09a31c..aeca1f779 100644 --- a/src/tests/kitemlistkeyboardsearchmanagertest.cpp +++ b/src/tests/kitemlistkeyboardsearchmanagertest.cpp @@ -65,6 +65,10 @@ void KItemListKeyboardSearchManagerTest::testBasicKeyboardSearch() void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch() { + // Set the timeout to a small value (the default is 5000 milliseconds) + // to save time when running this test. + m_keyboardSearchManager.setTimeout(100); + QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool))); m_keyboardSearchManager.addKeys("f"); @@ -75,9 +79,9 @@ void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch() QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst(), QList() << "fi" << false); - // If the delay between two key presses is larger than 5000 milliseconds, + // If the delay between two key presses is larger than the chosen timeout, // a new search is started. We add a small safety margin to avoid race conditions. - QTest::qWait(5000 + 10); + QTest::qWait(m_keyboardSearchManager.timeout() + 10); m_keyboardSearchManager.addKeys("l"); QCOMPARE(spy.count(), 1); -- cgit v1.3