diff options
| author | Frank Reininghaus <[email protected]> | 2012-02-03 19:09:42 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-02-05 15:59:59 +0100 |
| commit | d0933155e2dc179cde49b4306ff7feee9ca47697 (patch) | |
| tree | 80ec968e4538193d751b28f44d796db6d4f462fc /src/tests | |
| parent | 72af3125a824722d9875d202dd156cd3f7d8fc46 (diff) | |
Replace setExpanded(const QSet<KUrl>&) by expandParentItems(const KUrl&)
The use case of this function (Folders Panel) requires the expansion of
the parent items of a single URL, so it's not needed to handle a full
set of URLs in this function. Moreover, the issue that not only the
parents, but also the URLs themselves were expanded is fixed by this
commit.
(cherry picked from commit 89082ca391807abdc26d8985efe6b4c27183a9b1)
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index c3611ef73..d0accd68a 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -68,6 +68,7 @@ private slots: void testModelConsistencyWhenInsertingItems(); void testItemRangeConsistencyWhenInsertingItems(); void testExpandItems(); + void testExpandParentItems(); void testSorting(); void testExpansionLevelsCompare_data(); @@ -478,6 +479,57 @@ void KFileItemModelTest::testExpandItems() QCOMPARE(m_model->expandedUrls(), allFolders); } +void KFileItemModelTest::testExpandParentItems() +{ + // Create a tree structure of folders: + // a 1/ + // a 1/b1/ + // a 1/b1/c1/ + // a2/ + // a2/b2/ + // a2/b2/c2/ + // a2/b2/c2/d2/ + QSet<QByteArray> modelRoles = m_model->roles(); + modelRoles << "isExpanded" << "isExpandable" << "expansionLevel"; + m_model->setRoles(modelRoles); + + QStringList files; + files << "a 1/b1/c1/file.txt" << "a2/b2/c2/d2/file.txt"; // missing folders are created automatically + m_testDir->createFiles(files); + + m_dirLister->openUrl(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + + // So far, the model contains only "a 1/" and "a2/". + QCOMPARE(m_model->count(), 2); + QVERIFY(m_model->expandedUrls().empty()); + + // Expand the parents of "a2/b2/c2". + m_model->expandParentItems(KUrl(m_testDir->name() + "a2/b2/c2")); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + + // The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/". + // It's important that only the parents of "a1/b1/c1" are expanded. + QCOMPARE(m_model->count(), 4); + QVERIFY(!m_model->isExpanded(0)); + QVERIFY(m_model->isExpanded(1)); + QVERIFY(m_model->isExpanded(2)); + QVERIFY(!m_model->isExpanded(3)); + + // Expand the parents of "a 1/b1". + m_model->expandParentItems(KUrl(m_testDir->name() + "a 1/b1")); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout)); + + // The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/". + // It's important that only the parents of "a 1/b1/" and "a2/b2/c2/" are expanded. + QCOMPARE(m_model->count(), 5); + QVERIFY(m_model->isExpanded(0)); + QVERIFY(!m_model->isExpanded(1)); + QVERIFY(m_model->isExpanded(2)); + QVERIFY(m_model->isExpanded(3)); + QVERIFY(!m_model->isExpanded(4)); +} + void KFileItemModelTest::testSorting() { // Create some files with different sizes and modification times to check the different sorting options |
