┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests/kfileitemmodeltest.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-12-22 13:08:38 +0100
committerFrank Reininghaus <[email protected]>2013-12-22 13:12:51 +0100
commitc2108b122e2708245907d9f779f164721bcb3653 (patch)
treea8b042095a9747062a5951ce5a73f824516d62e5 /src/tests/kfileitemmodeltest.cpp
parentd5d1ae124a8d6e96656010179a624e1ce31a04b0 (diff)
Add unit test for KFileItemModel::createMimeData().
The test verifies that creating the mime data for a child of an expanced folder does not cause a crash. The regression happenened in the master branch, but it doesn't hurt to have the test also in KDE/4.12. CCBUG: 329119
Diffstat (limited to 'src/tests/kfileitemmodeltest.cpp')
-rw-r--r--src/tests/kfileitemmodeltest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 9079e584e..99ee3368e 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -93,6 +93,7 @@ private slots:
void testChangeRolesForFilteredItems();
void testChangeSortRoleWhileFiltering();
void testRefreshFilteredItems();
+ void testCreateMimeData();
private:
QStringList itemsInModel() const;
@@ -1591,6 +1592,33 @@ void KFileItemModelTest::testRefreshFilteredItems()
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "d.jpg" << "e.jpg");
}
+void KFileItemModelTest::testCreateMimeData()
+{
+ QSet<QByteArray> modelRoles = m_model->roles();
+ modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
+ m_model->setRoles(modelRoles);
+
+ QStringList files;
+ files << "a/1";
+ m_testDir->createFiles(files);
+
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(itemsInModel(), QStringList() << "a");
+
+ // Expand "a/".
+ m_model->setExpanded(0, true);
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(itemsInModel(), QStringList() << "a" << "1");
+
+ // Verify that creating the MIME data for a child of an expanded folder does
+ // not cause a crash, see https://bugs.kde.org/show_bug.cgi?id=329119
+ KItemSet selection;
+ selection.insert(1);
+ QMimeData* mimeData = m_model->createMimeData(selection);
+ delete mimeData;
+}
+
QStringList KFileItemModelTest::itemsInModel() const
{
QStringList items;