┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-08-09 19:44:49 +0200
committerFrank Reininghaus <[email protected]>2011-08-09 19:44:49 +0200
commit84aa4e75b492c74ce29fcadd572bee338f009b0b (patch)
treed265cbe9803a2154ed8874c4643fb42d7011cce9 /src
parent3957884bf2e44619a4ed35ba0ffead519988885b (diff)
Test setting the current item and anchor item
Diffstat (limited to 'src')
-rw-r--r--src/tests/kitemlistselectionmanagertest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp
index 6fdf01b84..3d0c318ff 100644
--- a/src/tests/kitemlistselectionmanagertest.cpp
+++ b/src/tests/kitemlistselectionmanagertest.cpp
@@ -58,6 +58,7 @@ private slots:
void testConstructor();
+ void testCurrentItemAnchorItem();
void testSetSelected_data();
void testSetSelected();
void testItemsInserted();
@@ -88,6 +89,40 @@ void KItemListSelectionManagerTest::testConstructor()
QCOMPARE(m_selectionManager->anchorItem(), -1);
}
+void KItemListSelectionManagerTest::testCurrentItemAnchorItem()
+{
+ QSignalSpy spyCurrent(m_selectionManager, SIGNAL(currentChanged(int,int)));
+ QSignalSpy spyAnchor(m_selectionManager, SIGNAL(anchorChanged(int,int)));;
+
+ // Set current item and check that the selection manager emits the currentChanged(int,int) signal correctly.
+ m_selectionManager->setCurrentItem(4);
+ QCOMPARE(m_selectionManager->currentItem(), 4);
+ QCOMPARE(spyCurrent.count(), 1);
+ QCOMPARE(qvariant_cast<int>(spyCurrent.at(0).at(0)), 4);
+ spyCurrent.takeFirst();
+
+ m_selectionManager->setCurrentItem(2);
+ QCOMPARE(m_selectionManager->currentItem(), 2);
+ QCOMPARE(spyCurrent.count(), 1);
+ QCOMPARE(qvariant_cast<int>(spyCurrent.at(0).at(0)), 2);
+ QCOMPARE(qvariant_cast<int>(spyCurrent.at(0).at(1)), 4);
+ spyCurrent.takeFirst();
+
+ // Set anchor item and check that the selection manager emits the anchorChanged(int,int) signal correctly.
+ m_selectionManager->setAnchorItem(3);
+ QCOMPARE(m_selectionManager->anchorItem(), 3);
+ QCOMPARE(spyAnchor.count(), 1);
+ QCOMPARE(qvariant_cast<int>(spyAnchor.at(0).at(0)), 3);
+ spyAnchor.takeFirst();
+
+ m_selectionManager->setAnchorItem(5);
+ QCOMPARE(m_selectionManager->anchorItem(), 5);
+ QCOMPARE(spyAnchor.count(), 1);
+ QCOMPARE(qvariant_cast<int>(spyAnchor.at(0).at(0)), 5);
+ QCOMPARE(qvariant_cast<int>(spyAnchor.at(0).at(1)), 3);
+ spyAnchor.takeFirst();
+}
+
void KItemListSelectionManagerTest::testSetSelected_data()
{
QTest::addColumn<int>("index");