- QCOMPARE(m_selectionManager->selectedItems(), QSet<int>());
- QVERIFY(!m_selectionManager->hasSelection());
- if (finalSelection.isEmpty()) {
- // Selection has been empty already
- QCOMPARE(spySelectionChanged.count(), 0);
+
+ verifySelectionChange(spySelectionChanged, QSet<int>(), finalSelection);
+}
+
+void KItemListSelectionManagerTest::verifySelectionChange(QSignalSpy& spy,
+ const QSet<int>& currentSelection,
+ const QSet<int>& previousSelection) const
+{
+ QCOMPARE(m_selectionManager->selectedItems(), currentSelection);
+ QCOMPARE(m_selectionManager->hasSelection(), !currentSelection.isEmpty());
+ for (int index = 0; index < m_selectionManager->model()->count(); ++index) {
+ if (currentSelection.contains(index)) {
+ QVERIFY(m_selectionManager->isSelected(index));
+ }
+ else {
+ QVERIFY(!m_selectionManager->isSelected(index));
+ }
+ }
+
+ if (currentSelection == previousSelection) {
+ QCOMPARE(spy.count(), 0);