diff options
| author | Frank Reininghaus <[email protected]> | 2013-03-10 18:31:23 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2013-03-10 18:31:23 +0100 |
| commit | f71e0881d2c0a52c5fa020e3fd2b44ca6ab7b2d4 (patch) | |
| tree | e711afe6b0e40c3efec8ff920af009c7c4e2155c /src/tests/kfileitemmodeltest.cpp | |
| parent | be8443bed87c1f27a9cd1f82d969cc06f91c2f62 (diff) | |
| parent | 9dd728cb98e0ea822248c641aef5d66f2476768e (diff) | |
Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts:
dolphin/src/kitemviews/kfileitemmodel.cpp
Diffstat (limited to 'src/tests/kfileitemmodeltest.cpp')
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 1145e1535..cd2e8d777 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -79,6 +79,7 @@ private slots: void testNameFilter(); void testEmptyPath(); void testRemoveHiddenItems(); + void collapseParentOfHiddenItems(); void removeParentOfHiddenItems(); private: @@ -905,6 +906,55 @@ void KFileItemModelTest::testRemoveHiddenItems() } /** + * Verify that filtered items are removed when their parent is collapsed. + */ +void KFileItemModelTest::collapseParentOfHiddenItems() +{ + QSet<QByteArray> modelRoles = m_model->roles(); + modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; + m_model->setRoles(modelRoles); + + QStringList files; + files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1"; + m_testDir->createFiles(files); + + m_model->loadDirectory(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(m_model->count(), 1); // Only "a/" + + // Expand "a/". + m_model->setExpanded(0, true); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1" + + // Expand "a/b/". + m_model->setExpanded(1, true); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1" + + // Expand "a/b/c/". + m_model->setExpanded(2, true); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1" + + // Set a name filter that matches nothing -> only the expanded folders remain. + m_model->setNameFilter("xyz"); + QCOMPARE(m_model->count(), 3); + QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c"); + + // Collapse the folder "a/". + QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); + m_model->setExpanded(0, false); + QCOMPARE(spyItemsRemoved.count(), 1); + QCOMPARE(m_model->count(), 1); + QCOMPARE(itemsInModel(), QStringList() << "a"); + + // Remove the filter -> no files should appear (and we should not get a crash). + m_model->setNameFilter(QString()); + QCOMPARE(m_model->count(), 1); +} + +/** * Verify that filtered items are removed when their parent is deleted. */ void KFileItemModelTest::removeParentOfHiddenItems() |
