┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-08-04 21:28:04 +0200
committerFrank Reininghaus <[email protected]>2013-08-04 21:28:04 +0200
commit6467358eeffca2e5888e83c4fbeb995e60c53ada (patch)
tree5fb63fbea26ed24ce13ec543e591127bc876960d /src
parentc03e7a3272772fb10204e338124bc918742653ac (diff)
parent8bf4aab73e1e8584a06a9c954853369c08f41d8a (diff)
Merge remote-tracking branch 'origin/KDE/4.11'
Diffstat (limited to 'src')
-rw-r--r--src/tests/kfileitemmodeltest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 0ad7a378d..513ecef5a 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -84,6 +84,7 @@ private slots:
void collapseParentOfHiddenItems();
void removeParentOfHiddenItems();
void testGeneralParentChildRelationships();
+ void testNameRoleGroups();
private:
QStringList itemsInModel() const;
@@ -106,6 +107,9 @@ void KFileItemModelTest::init()
m_testDir = new TestDir();
m_model = new KFileItemModel();
m_model->m_dirLister->setAutoUpdate(false);
+
+ // Reduce the timer interval to make the test run faster.
+ m_model->m_resortAllItemsTimer->setInterval(0);
}
void KFileItemModelTest::cleanup()
@@ -1172,6 +1176,53 @@ void KFileItemModelTest::testGeneralParentChildRelationships()
QCOMPARE(itemsInModel(), QStringList() << "parent1");
}
+void KFileItemModelTest::testNameRoleGroups()
+{
+ QStringList files;
+ files << "b.txt" << "c.txt" << "d.txt" << "e.txt";
+
+ m_testDir->createFiles(files);
+
+ m_model->setGroupedSorting(true);
+ m_model->loadDirectory(m_testDir->url());
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt" << "e.txt");
+
+ QList<QPair<int, QVariant> > expectedGroups;
+ expectedGroups << QPair<int, QVariant>(0, QLatin1String("B"));
+ expectedGroups << QPair<int, QVariant>(1, QLatin1String("C"));
+ expectedGroups << QPair<int, QVariant>(2, QLatin1String("D"));
+ expectedGroups << QPair<int, QVariant>(3, QLatin1String("E"));
+ QCOMPARE(m_model->groups(), expectedGroups);
+
+ // Rename d.txt to a.txt.
+ QHash<QByteArray, QVariant> data;
+ data.insert("text", "a.txt");
+ m_model->setData(2, data);
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt");
+
+ expectedGroups.clear();
+ expectedGroups << QPair<int, QVariant>(0, QLatin1String("A"));
+ expectedGroups << QPair<int, QVariant>(1, QLatin1String("B"));
+ expectedGroups << QPair<int, QVariant>(2, QLatin1String("C"));
+ expectedGroups << QPair<int, QVariant>(3, QLatin1String("E"));
+ QCOMPARE(m_model->groups(), expectedGroups);
+
+ // Rename c.txt to d.txt.
+ data.insert("text", "d.txt");
+ m_model->setData(2, data);
+ QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "d.txt" << "e.txt");
+
+ expectedGroups.clear();
+ expectedGroups << QPair<int, QVariant>(0, QLatin1String("A"));
+ expectedGroups << QPair<int, QVariant>(1, QLatin1String("B"));
+ expectedGroups << QPair<int, QVariant>(2, QLatin1String("D"));
+ expectedGroups << QPair<int, QVariant>(3, QLatin1String("E"));
+ QCOMPARE(m_model->groups(), expectedGroups);
+}
+
QStringList KFileItemModelTest::itemsInModel() const
{
QStringList items;