diff options
| author | Frank Reininghaus <[email protected]> | 2013-12-22 13:08:38 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2013-12-22 13:12:51 +0100 |
| commit | c2108b122e2708245907d9f779f164721bcb3653 (patch) | |
| tree | a8b042095a9747062a5951ce5a73f824516d62e5 /src/tests | |
| parent | d5d1ae124a8d6e96656010179a624e1ce31a04b0 (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')
| -rw-r--r-- | src/tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9b152ed07..fca0819f8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -65,6 +65,7 @@ set(kfileitemmodeltest_SRCS testdir.cpp ../kitemviews/kfileitemmodel.cpp ../kitemviews/kitemmodelbase.cpp + ../kitemviews/kitemset.cpp ) kde4_add_unit_test(kfileitemmodeltest TEST ${kfileitemmodeltest_SRCS}) target_link_libraries(kfileitemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) 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; |
