┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-08-15 00:07:43 +0200
committerFrank Reininghaus <[email protected]>2013-08-15 00:07:43 +0200
commit7c99a9c2ad4455c65a218c53dfa7f6376f389b66 (patch)
tree0b2dcaf332ff5f507fc5ad94b41eb6c4e4764620 /src/tests
parent59723fca41a44e4d1ee753e93589027cbdf8d20d (diff)
Make sure that the sort order is correct after renaming
KFileItemModel::setData() should not only cause a resorting when the sort role is changed. The name is always used as a fallback if the sort role of multiple files is equal, therefore, renaming a file can change the correct order of the files even if the files are not sorted by "name". Unit test included. BUG: 323518 FIXED-IN: 4.11.1 REVIEW: 111721
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/kfileitemmodeltest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 513ecef5a..f8439789b 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -70,6 +70,7 @@ private slots:
void testSetDataWithModifiedSortRole_data();
void testSetDataWithModifiedSortRole();
void testChangeSortRole();
+ void testResortAfterChangingName();
void testModelConsistencyWhenInsertingItems();
void testItemRangeConsistencyWhenInsertingItems();
void testExpandItems();
@@ -368,6 +369,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);