┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-02-13 17:56:03 +0100
committerFrank Reininghaus <[email protected]>2013-02-13 17:56:03 +0100
commitd82d92d7dd71c1ef155b0dd5dea34c257fdad65c (patch)
treed564ae15f1a7ecfb91e6819d8823438252f6a5e1 /src/tests
parent66af7c390ccf015400f80ee0a1a5f14dc1bf18d9 (diff)
Improve the recently added test testMouseClickActivation
The method to make sure that the first item is visible turned out to be less reliable than I thought. This could make the test hang forever. Moreover, this commit removes some trailing whitespace that had been added accidentally.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/kitemlistcontrollertest.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp
index 8044f9ac9..279096655 100644
--- a/src/tests/kitemlistcontrollertest.cpp
+++ b/src/tests/kitemlistcontrollertest.cpp
@@ -521,12 +521,9 @@ void KItemListControllerTest::testMouseClickActivation()
adjustGeometryForColumnCount(5);
// Make sure that the first item is visible in the view.
- QTest::keyClick(m_container, Qt::Key_End, Qt::NoModifier);
- QTest::keyClick(m_container, Qt::Key_Home, Qt::NoModifier);
- while (m_view->firstVisibleIndex() > 0) {
- QTest::qWait(50);
- }
-
+ m_view->setScrollOffset(0);
+ QCOMPARE(m_view->firstVisibleIndex(), 0);
+
const QPointF pos = m_view->itemContextRect(0).center();
// Save the "single click" setting.
@@ -544,9 +541,9 @@ void KItemListControllerTest::testMouseClickActivation()
mouseReleaseEvent.setPos(pos);
mouseReleaseEvent.setButton(Qt::LeftButton);
mouseReleaseEvent.setButtons(Qt::NoButton);
-
+
QSignalSpy spyItemActivated(m_controller, SIGNAL(itemActivated(int)));
-
+
// Default setting: single click activation.
group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
config.sync();
@@ -558,7 +555,7 @@ void KItemListControllerTest::testMouseClickActivation()
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 1);
spyItemActivated.clear();
-
+
// Set the global setting to "double click activation".
group.writeEntry("SingleClick", false, KConfig::Persistent|KConfig::Global);
config.sync();
@@ -570,7 +567,7 @@ void KItemListControllerTest::testMouseClickActivation()
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 0);
spyItemActivated.clear();
-
+
// Enforce single click activation in the controller.
m_controller->setSingleClickActivationEnforced(true);
m_view->event(&mousePressEvent);
@@ -584,7 +581,7 @@ void KItemListControllerTest::testMouseClickActivation()
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 0);
spyItemActivated.clear();
-
+
// Set the global setting back to "single click activation".
group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
config.sync();
@@ -596,7 +593,7 @@ void KItemListControllerTest::testMouseClickActivation()
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 1);
spyItemActivated.clear();
-
+
// Enforce single click activation in the controller.
m_controller->setSingleClickActivationEnforced(true);
m_view->event(&mousePressEvent);