diff options
| author | Frank Reininghaus <[email protected]> | 2013-08-15 00:15:51 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2013-08-15 00:15:51 +0200 |
| commit | 6bfa0ccfc701df5af5f043fce3168b3840858212 (patch) | |
| tree | a978d69d1afbd237cf5a3f8e8e117fbbab71adb2 /src/tests/kfileitemmodeltest.cpp | |
| parent | 68520f55f0b6b2fc450f646477bf3c535324aa2b (diff) | |
| parent | 7c99a9c2ad4455c65a218c53dfa7f6376f389b66 (diff) | |
Merge remote-tracking branch 'origin/KDE/4.11'
Diffstat (limited to 'src/tests/kfileitemmodeltest.cpp')
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 6d5d4b77c..e55e3eb33 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -71,6 +71,7 @@ private slots: void testSetDataWithModifiedSortRole_data(); void testSetDataWithModifiedSortRole(); void testChangeSortRole(); + void testResortAfterChangingName(); void testModelConsistencyWhenInsertingItems(); void testItemRangeConsistencyWhenInsertingItems(); void testExpandItems(); @@ -369,6 +370,30 @@ void KFileItemModelTest::testChangeSortRole() QVERIFY(ok1 || ok2); } +void KFileItemModelTest::testResortAfterChangingName() +{ + // We sort by size in a directory where all files have the same size. + // Therefore, the files are sorted by their names. + m_model->setSortRole("size"); + + QStringList files; + files << "a.txt" << "b.txt" << "c.txt"; + m_testDir->createFiles(files); + + m_model->loadDirectory(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt"); + + // We rename a.txt to d.txt. Even though the size has not changed at all, + // the model must re-sort the items. + QHash<QByteArray, QVariant> data; + data.insert("text", "d.txt"); + m_model->setData(0, data); + + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout)); + QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt"); +} + void KFileItemModelTest::testModelConsistencyWhenInsertingItems() { //QSKIP("Temporary disabled", SkipSingle); |
