]> cloud.milkyroute.net Git - dolphin.git/blob - src/tests/kfileitemmodeltest.cpp
Implement 'Sort By Size'
[dolphin.git] / src / tests / kfileitemmodeltest.cpp
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2011 by Frank Reininghaus <frank78ac@googlemail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include <qtest_kde.h>
22
23 #include <KDirLister>
24 #include "kitemviews/kfileitemmodel.h"
25 #include "testdir.h"
26
27 namespace {
28 const int DefaultTimeout = 5000;
29 };
30
31 Q_DECLARE_METATYPE(KItemRangeList)
32
33 class KFileItemModelTest : public QObject
34 {
35 Q_OBJECT
36
37 private slots:
38 void init();
39 void cleanup();
40
41 void testDefaultRoles();
42 void testDefaultSortRole();
43 void testDefaultGroupRole();
44 void testNewItems();
45 void testRemoveItems();
46 void testModelConsistencyWhenInsertingItems();
47 void testItemRangeConsistencyWhenInsertingItems();
48 void testExpandItems();
49 void testSorting();
50
51 void testExpansionLevelsCompare_data();
52 void testExpansionLevelsCompare();
53
54 void testIndexForKeyboardSearch();
55
56 private:
57 bool isModelConsistent() const;
58 QStringList itemsInModel() const;
59
60 private:
61 KFileItemModel* m_model;
62 KDirLister* m_dirLister;
63 TestDir* m_testDir;
64 };
65
66 void KFileItemModelTest::init()
67 {
68 qRegisterMetaType<KItemRangeList>("KItemRangeList");
69 qRegisterMetaType<KFileItemList>("KFileItemList");
70
71 m_testDir = new TestDir();
72 m_dirLister = new KDirLister();
73 m_model = new KFileItemModel(m_dirLister);
74 }
75
76 void KFileItemModelTest::cleanup()
77 {
78 delete m_model;
79 m_model = 0;
80
81 delete m_dirLister;
82 m_dirLister = 0;
83
84 delete m_testDir;
85 m_testDir = 0;
86 }
87
88 void KFileItemModelTest::testDefaultRoles()
89 {
90 const QSet<QByteArray> roles = m_model->roles();
91 QCOMPARE(roles.count(), 2);
92 QVERIFY(roles.contains("name"));
93 QVERIFY(roles.contains("isDir"));
94 }
95
96 void KFileItemModelTest::testDefaultSortRole()
97 {
98 QCOMPARE(m_model->sortRole(), QByteArray("name"));
99
100 QStringList files;
101 files << "c.txt" << "a.txt" << "b.txt";
102
103 m_testDir->createFiles(files);
104
105 m_dirLister->openUrl(m_testDir->url());
106 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
107
108 QCOMPARE(m_model->count(), 3);
109 QCOMPARE(m_model->data(0)["name"].toString(), QString("a.txt"));
110 QCOMPARE(m_model->data(1)["name"].toString(), QString("b.txt"));
111 QCOMPARE(m_model->data(2)["name"].toString(), QString("c.txt"));
112 }
113
114 void KFileItemModelTest::testDefaultGroupRole()
115 {
116 QVERIFY(m_model->groupRole().isEmpty());
117 }
118
119 void KFileItemModelTest::testNewItems()
120 {
121 QStringList files;
122 files << "a.txt" << "b.txt" << "c.txt";
123 m_testDir->createFiles(files);
124
125 m_dirLister->openUrl(m_testDir->url());
126 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
127
128 QCOMPARE(m_model->count(), 3);
129
130 QVERIFY(isModelConsistent());
131 }
132
133 void KFileItemModelTest::testRemoveItems()
134 {
135 m_testDir->createFile("a.txt");
136 m_dirLister->openUrl(m_testDir->url());
137 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
138 QCOMPARE(m_model->count(), 1);
139
140 m_testDir->removeFile("a.txt");
141 m_dirLister->updateDirectory(m_testDir->url());
142 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
143 QCOMPARE(m_model->count(), 0);
144 }
145
146 void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
147 {
148 QSKIP("Temporary disabled", SkipSingle);
149
150 // KFileItemModel prevents that inserting a punch of items sequentially
151 // results in an itemsInserted()-signal for each item. Instead internally
152 // a timeout is given that collects such operations and results in only
153 // one itemsInserted()-signal. However in this test we want to stress
154 // KFileItemModel to do a lot of insert operation and hence decrease
155 // the timeout to 1 millisecond.
156 m_model->m_minimumUpdateIntervalTimer->setInterval(1);
157
158 m_testDir->createFile("1");
159 m_dirLister->openUrl(m_testDir->url());
160 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
161 QCOMPARE(m_model->count(), 1);
162
163 // Insert 10 items for 20 times. After each insert operation the model consistency
164 // is checked.
165 QSet<int> insertedItems;
166 for (int i = 0; i < 20; ++i) {
167 QSignalSpy spy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
168
169 for (int j = 0; j < 10; ++j) {
170 int itemName = qrand();
171 while (insertedItems.contains(itemName)) {
172 itemName = qrand();
173 }
174 insertedItems.insert(itemName);
175
176 m_testDir->createFile(QString::number(itemName));
177 }
178
179 m_dirLister->updateDirectory(m_testDir->url());
180 if (spy.count() == 0) {
181 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
182 }
183
184 QVERIFY(isModelConsistent());
185 }
186
187 QCOMPARE(m_model->count(), 201);
188 }
189
190 void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems()
191 {
192 QStringList files;
193 files << "B" << "E" << "G";
194 m_testDir->createFiles(files);
195
196 // Due to inserting the 3 items one item-range with index == 0 and
197 // count == 3 must be given
198 QSignalSpy spy1(m_model, SIGNAL(itemsInserted(KItemRangeList)));
199 m_dirLister->openUrl(m_testDir->url());
200 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
201
202 QCOMPARE(spy1.count(), 1);
203 QList<QVariant> arguments = spy1.takeFirst();
204 KItemRangeList itemRangeList = arguments.at(0).value<KItemRangeList>();
205 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 3));
206
207 // The indexes of the item-ranges must always be related to the model before
208 // the items have been inserted. Having:
209 // 0 1 2
210 // B E G
211 // and inserting A, C, D, F the resulting model will be:
212 // 0 1 2 3 4 5 6
213 // A B C D E F G
214 // and the item-ranges must be:
215 // index: 0, count: 1 for A
216 // index: 1, count: 2 for B, C
217 // index: 2, count: 1 for G
218
219 files.clear();
220 files << "A" << "C" << "D" << "F";
221 m_testDir->createFiles(files);
222
223 QSignalSpy spy2(m_model, SIGNAL(itemsInserted(KItemRangeList)));
224 m_dirLister->updateDirectory(m_testDir->url());
225 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
226
227 QCOMPARE(spy2.count(), 1);
228 arguments = spy2.takeFirst();
229 itemRangeList = arguments.at(0).value<KItemRangeList>();
230 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 1) << KItemRange(1, 2) << KItemRange(2, 1));
231 }
232
233 void KFileItemModelTest::testExpandItems()
234 {
235 // Test expanding subfolders in a folder with the items "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1".
236 // Besides testing the basic item expansion functionality, the test makes sure that
237 // KFileItemModel::expansionLevelsCompare(const KFileItem& a, const KFileItem& b)
238 // yields the correct result for "a/a/1" and "a/a-1/", whis is non-trivial because they share the
239 // first three characters.
240 QSet<QByteArray> modelRoles = m_model->roles();
241 modelRoles << "isExpanded" << "expansionLevel";
242 m_model->setRoles(modelRoles);
243
244 QStringList files;
245 files << "a/a/1" << "a/a-1/1"; // missing folders are created automatically
246 m_testDir->createFiles(files);
247
248 // Store the URLs of all folders in a set.
249 QSet<KUrl> allFolders;
250 allFolders << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1");
251
252 m_dirLister->openUrl(m_testDir->url());
253 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
254
255 // So far, the model contains only "a/"
256 QCOMPARE(m_model->count(), 1);
257 QVERIFY(m_model->isExpandable(0));
258 QVERIFY(!m_model->isExpanded(0));
259 QVERIFY(m_model->expandedUrls().empty());
260
261 QSignalSpy spyInserted(m_model, SIGNAL(itemsInserted(KItemRangeList)));
262
263 // Expand the folder "a/" -> "a/a/" and "a/a-1/" become visible
264 m_model->setExpanded(0, true);
265 QVERIFY(m_model->isExpanded(0));
266 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
267 QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
268 QCOMPARE(m_model->expandedUrls(), QSet<KUrl>() << KUrl(m_testDir->name() + "a"));
269
270 QCOMPARE(spyInserted.count(), 1);
271 KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
272 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 2)); // 2 new items "a/a/" and "a/a-1/" with indices 1 and 2
273
274 QVERIFY(m_model->isExpandable(1));
275 QVERIFY(!m_model->isExpanded(1));
276 QVERIFY(m_model->isExpandable(2));
277 QVERIFY(!m_model->isExpanded(2));
278
279 // Expand the folder "a/a/" -> "a/a/1" becomes visible
280 m_model->setExpanded(1, true);
281 QVERIFY(m_model->isExpanded(1));
282 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
283 QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
284 QCOMPARE(m_model->expandedUrls(), QSet<KUrl>() << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a"));
285
286 QCOMPARE(spyInserted.count(), 1);
287 itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
288 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(2, 1)); // 1 new item "a/a/1" with index 2
289
290 QVERIFY(!m_model->isExpandable(2));
291 QVERIFY(!m_model->isExpanded(2));
292
293 // Expand the folder "a/a-1/" -> "a/a-1/1" becomes visible
294 m_model->setExpanded(3, true);
295 QVERIFY(m_model->isExpanded(3));
296 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
297 QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
298 QCOMPARE(m_model->expandedUrls(), allFolders);
299
300 QCOMPARE(spyInserted.count(), 1);
301 itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
302 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(4, 1)); // 1 new item "a/a-1/1" with index 4
303
304 QVERIFY(!m_model->isExpandable(4));
305 QVERIFY(!m_model->isExpanded(4));
306
307 QSignalSpy spyRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
308
309 // Collapse the top-level folder -> all other items should disappear
310 m_model->setExpanded(0, false);
311 QVERIFY(!m_model->isExpanded(0));
312 QCOMPARE(m_model->count(), 1);
313 QVERIFY(!m_model->expandedUrls().contains(KUrl(m_testDir->name() + "a"))); // TODO: Make sure that child URLs are also removed
314
315 QCOMPARE(spyRemoved.count(), 1);
316 itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
317 QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 4)); // 4 items removed
318
319 // Clear the model, reload the folder and try to restore the expanded folders.
320 m_model->clear();
321 QCOMPARE(m_model->count(), 0);
322 QVERIFY(m_model->expandedUrls().empty());
323
324 m_dirLister->openUrl(m_testDir->url());
325 m_model->restoreExpandedUrls(allFolders);
326 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(loadingCompleted()), DefaultTimeout));
327 QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
328 QVERIFY(m_model->isExpanded(0));
329 QVERIFY(m_model->isExpanded(1));
330 QVERIFY(!m_model->isExpanded(2));
331 QVERIFY(m_model->isExpanded(3));
332 QVERIFY(!m_model->isExpanded(4));
333 QCOMPARE(m_model->expandedUrls(), allFolders);
334 }
335
336 void KFileItemModelTest::testSorting()
337 {
338 // Create some files with different sizes and modification times to check the different sorting options
339 QDateTime now = QDateTime::currentDateTime();
340
341 m_testDir->createFile("a", "A file", now.addDays(-3));
342 m_testDir->createFile("b", "A larger file", now.addDays(0));
343 m_testDir->createDir("c", now.addDays(-2));
344 m_testDir->createFile("d", "The largest file in this directory", now.addDays(-1));
345 m_testDir->createFile("e", "An even larger file", now.addDays(-4));
346 m_testDir->createFile(".f");
347
348 m_dirLister->openUrl(m_testDir->url());
349 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
350
351 // Default: Sort by Name, ascending
352 QCOMPARE(m_model->sortRole(), QByteArray("name"));
353 QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
354 QVERIFY(m_model->sortFoldersFirst());
355 //QVERIFY(!m_model->showHiddenFiles());
356 QCOMPARE(itemsInModel(), QStringList() << "c" << "a" << "b" << "d" << "e");
357
358 // Sort by Name, descending
359 m_model->setSortOrder(Qt::DescendingOrder);
360 QCOMPARE(m_model->sortRole(), QByteArray("name"));
361 QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
362 QCOMPARE(itemsInModel(), QStringList() << "c" << "e" << "d" << "b" << "a");
363
364 // Sort by Date, decending
365 m_model->setSortRole("date");
366 QCOMPARE(m_model->sortRole(), QByteArray("date"));
367 QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
368 QCOMPARE(itemsInModel(), QStringList() << "c" << "b" << "d" << "a" << "e");
369
370 // Sort by Date, ascending
371 m_model->setSortOrder(Qt::AscendingOrder);
372 QCOMPARE(m_model->sortRole(), QByteArray("date"));
373 QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
374 QCOMPARE(itemsInModel(), QStringList() << "c" << "e" << "a" << "d" << "b");
375
376 // Sort by Date, ascending, 'Sort Folders First' disabled
377 m_model->setSortFoldersFirst(false);
378 QCOMPARE(m_model->sortRole(), QByteArray("date"));
379 QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
380 QVERIFY(!m_model->sortFoldersFirst());
381 QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "d" << "b");
382
383 // Default: Sort by Name, ascending, 'Sort Folders First' disabled
384 m_model->setSortRole("name");
385 QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
386 QVERIFY(!m_model->sortFoldersFirst());
387 QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "d" << "e");
388
389 // Sort by Size, ascending, 'Sort Folders First' enabled
390 m_model->setSortRole("size");
391 m_model->setSortFoldersFirst(true);
392 QCOMPARE(m_model->sortRole(), QByteArray("size"));
393 QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
394 QVERIFY(m_model->sortFoldersFirst());
395 QCOMPARE(itemsInModel(), QStringList() << "c" << "a" << "b" << "e" << "d");
396
397 // Sort by Size, descending, 'Sort Folders First' enabled
398 m_model->setSortOrder(Qt::DescendingOrder);
399 QCOMPARE(m_model->sortRole(), QByteArray("size"));
400 QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
401 QVERIFY(m_model->sortFoldersFirst());
402 QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "e" << "b" << "a");
403
404 // TODO: How shall the sorting by size be done if 'Sort Folders First' is disabled?
405
406 // TODO: Sort by other roles; show/hide hidden files
407 }
408
409 void KFileItemModelTest::testExpansionLevelsCompare_data()
410 {
411 QTest::addColumn<QString>("urlA");
412 QTest::addColumn<QString>("urlB");
413 QTest::addColumn<int>("result");
414
415 QTest::newRow("Equal") << "/a/b" << "/a/b" << 0;
416 QTest::newRow("Sub path: A < B") << "/a/b" << "/a/b/c" << -1;
417 QTest::newRow("Sub path: A > B") << "/a/b/c" << "/a/b" << +1;
418 QTest::newRow("Same level: /a/1 < /a-1/1") << "/a/1" << "/a-1/1" << -1;
419 QTest::newRow("Same level: /a-/1 > /a/1") << "/a-1/1" << "/a/1" << +1;
420 QTest::newRow("Different levels: /a/a/1 < /a/a-1") << "/a/a/1" << "/a/a-1" << -1;
421 QTest::newRow("Different levels: /a/a-1 > /a/a/1") << "/a/a-1" << "/a/a/1" << +1;
422 }
423
424 void KFileItemModelTest::testExpansionLevelsCompare()
425 {
426 QFETCH(QString, urlA);
427 QFETCH(QString, urlB);
428 QFETCH(int, result);
429
430 const KFileItem a(KUrl(urlA), QString(), mode_t(-1));
431 const KFileItem b(KUrl(urlB), QString(), mode_t(-1));
432 QCOMPARE(m_model->expansionLevelsCompare(a, b), result);
433 }
434
435 void KFileItemModelTest::testIndexForKeyboardSearch()
436 {
437 QStringList files;
438 files << "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11";
439 m_testDir->createFiles(files);
440
441 m_dirLister->openUrl(m_testDir->url());
442 QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
443
444 // Search from index 0
445 QCOMPARE(m_model->indexForKeyboardSearch("a", 0), 0);
446 QCOMPARE(m_model->indexForKeyboardSearch("aa", 0), 1);
447 QCOMPARE(m_model->indexForKeyboardSearch("i", 0), 2);
448 QCOMPARE(m_model->indexForKeyboardSearch("image", 0), 2);
449 QCOMPARE(m_model->indexForKeyboardSearch("image.jpg", 0), 2);
450 QCOMPARE(m_model->indexForKeyboardSearch("image.png", 0), 3);
451 QCOMPARE(m_model->indexForKeyboardSearch("t", 0), 4);
452 QCOMPARE(m_model->indexForKeyboardSearch("text", 0), 4);
453 QCOMPARE(m_model->indexForKeyboardSearch("text1", 0), 5);
454 QCOMPARE(m_model->indexForKeyboardSearch("text2", 0), 6);
455 QCOMPARE(m_model->indexForKeyboardSearch("text11", 0), 7);
456
457 // Start a search somewhere in the middle
458 QCOMPARE(m_model->indexForKeyboardSearch("a", 1), 1);
459 QCOMPARE(m_model->indexForKeyboardSearch("i", 3), 3);
460 QCOMPARE(m_model->indexForKeyboardSearch("t", 5), 5);
461 QCOMPARE(m_model->indexForKeyboardSearch("text1", 6), 7);
462
463 // Test searches that go past the last item back to index 0
464 QCOMPARE(m_model->indexForKeyboardSearch("a", 2), 0);
465 QCOMPARE(m_model->indexForKeyboardSearch("i", 7), 2);
466 QCOMPARE(m_model->indexForKeyboardSearch("image.jpg", 3), 2);
467 QCOMPARE(m_model->indexForKeyboardSearch("text2", 7), 6);
468
469 // Test searches that yield no result
470 QCOMPARE(m_model->indexForKeyboardSearch("aaa", 0), -1);
471 QCOMPARE(m_model->indexForKeyboardSearch("b", 0), -1);
472 QCOMPARE(m_model->indexForKeyboardSearch("image.svg", 0), -1);
473 QCOMPARE(m_model->indexForKeyboardSearch("text3", 0), -1);
474 QCOMPARE(m_model->indexForKeyboardSearch("text3", 5), -1);
475
476 // Test upper case searches (note that search is case insensitive)
477 QCOMPARE(m_model->indexForKeyboardSearch("A", 0), 0);
478 QCOMPARE(m_model->indexForKeyboardSearch("aA", 0), 1);
479 QCOMPARE(m_model->indexForKeyboardSearch("TexT", 5), 5);
480 QCOMPARE(m_model->indexForKeyboardSearch("IMAGE", 4), 2);
481
482 // TODO: Maybe we should also test keyboard searches in directories which are not sorted by Name?
483 }
484
485 bool KFileItemModelTest::isModelConsistent() const
486 {
487 for (int i = 0; i < m_model->count(); ++i) {
488 const KFileItem item = m_model->fileItem(i);
489 if (item.isNull()) {
490 qWarning() << "Item" << i << "is null";
491 return false;
492 }
493
494 const int itemIndex = m_model->index(item);
495 if (itemIndex != i) {
496 qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
497 return false;
498 }
499 }
500
501 return true;
502 }
503
504 QStringList KFileItemModelTest::itemsInModel() const
505 {
506 QStringList items;
507
508 for (int i = 0; i < m_model->count(); i++) {
509 items << m_model->data(i).value("name").toString();
510 }
511
512 return items;
513 }
514
515 QTEST_KDEMAIN(KFileItemModelTest, NoGUI)
516
517 #include "kfileitemmodeltest.moc"