┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests/kitemlistkeyboardsearchmanagertest.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2012-03-29 19:56:53 +0200
committerFrank Reininghaus <[email protected]>2012-03-29 20:05:49 +0200
commitaced85db1f7c72268860f0368402cf97f34e55c2 (patch)
treef0b47ebdbc5e5f6549d76d3ec23c697a6e2c9e2d /src/tests/kitemlistkeyboardsearchmanagertest.cpp
parentbd26bf2a20fba80c33ad1e8438592bddc4bea4aa (diff)
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)
Diffstat (limited to 'src/tests/kitemlistkeyboardsearchmanagertest.cpp')
-rw-r--r--src/tests/kitemlistkeyboardsearchmanagertest.cpp8
1 files changed, 6 insertions, 2 deletions
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<QVariant>() << "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);