1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2011 by Frank Reininghaus <frank78ac@googlemail.com> *
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. *
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. *
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 ***************************************************************************/
21 #include <qtest_kde.h>
24 #include "kitemviews/kfileitemmodel.h"
25 #include "kitemviews/private/kfileitemmodeldirlister.h"
28 void myMessageOutput(QtMsgType type
, const char* msg
)
36 fprintf(stderr
, "Critical: %s\n", msg
);
39 fprintf(stderr
, "Fatal: %s\n", msg
);
47 const int DefaultTimeout
= 5000;
50 Q_DECLARE_METATYPE(KItemRangeList
)
51 Q_DECLARE_METATYPE(QList
<int>)
53 class KFileItemModelTest
: public QObject
61 void testDefaultRoles();
62 void testDefaultSortRole();
63 void testDefaultGroupedSorting();
65 void testRemoveItems();
66 void testDirLoadingCompleted();
68 void testSetDataWithModifiedSortRole_data();
69 void testSetDataWithModifiedSortRole();
70 void testModelConsistencyWhenInsertingItems();
71 void testItemRangeConsistencyWhenInsertingItems();
72 void testExpandItems();
73 void testExpandParentItems();
75 void testIndexForKeyboardSearch();
76 void testNameFilter();
78 void testRemoveHiddenItems();
79 void collapseParentOfHiddenItems();
80 void removeParentOfHiddenItems();
83 bool isModelConsistent() const;
84 QStringList
itemsInModel() const;
87 KFileItemModel
* m_model
;
91 void KFileItemModelTest::init()
93 // The item-model tests result in a huge number of debugging
94 // output from kdelibs. Only show critical and fatal messages.
95 qInstallMsgHandler(myMessageOutput
);
97 qRegisterMetaType
<KItemRange
>("KItemRange");
98 qRegisterMetaType
<KItemRangeList
>("KItemRangeList");
99 qRegisterMetaType
<KFileItemList
>("KFileItemList");
101 m_testDir
= new TestDir();
102 m_model
= new KFileItemModel();
103 m_model
->m_dirLister
->setAutoUpdate(false);
106 void KFileItemModelTest::cleanup()
115 void KFileItemModelTest::testDefaultRoles()
117 const QSet
<QByteArray
> roles
= m_model
->roles();
118 QCOMPARE(roles
.count(), 3);
119 QVERIFY(roles
.contains("text"));
120 QVERIFY(roles
.contains("isDir"));
121 QVERIFY(roles
.contains("isLink"));
124 void KFileItemModelTest::testDefaultSortRole()
126 QCOMPARE(m_model
->sortRole(), QByteArray("text"));
129 files
<< "c.txt" << "a.txt" << "b.txt";
131 m_testDir
->createFiles(files
);
133 m_model
->loadDirectory(m_testDir
->url());
134 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
136 QCOMPARE(m_model
->count(), 3);
137 QCOMPARE(m_model
->data(0)["text"].toString(), QString("a.txt"));
138 QCOMPARE(m_model
->data(1)["text"].toString(), QString("b.txt"));
139 QCOMPARE(m_model
->data(2)["text"].toString(), QString("c.txt"));
142 void KFileItemModelTest::testDefaultGroupedSorting()
144 QCOMPARE(m_model
->groupedSorting(), false);
147 void KFileItemModelTest::testNewItems()
150 files
<< "a.txt" << "b.txt" << "c.txt";
151 m_testDir
->createFiles(files
);
153 m_model
->loadDirectory(m_testDir
->url());
154 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
156 QCOMPARE(m_model
->count(), 3);
158 QVERIFY(isModelConsistent());
161 void KFileItemModelTest::testRemoveItems()
163 m_testDir
->createFile("a.txt");
164 m_testDir
->createFile("b.txt");
165 m_model
->loadDirectory(m_testDir
->url());
166 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
167 QCOMPARE(m_model
->count(), 2);
168 QVERIFY(isModelConsistent());
170 m_testDir
->removeFile("a.txt");
171 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
172 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)), DefaultTimeout
));
173 QCOMPARE(m_model
->count(), 1);
174 QVERIFY(isModelConsistent());
177 void KFileItemModelTest::testDirLoadingCompleted()
179 QSignalSpy
loadingCompletedSpy(m_model
, SIGNAL(directoryLoadingCompleted()));
180 QSignalSpy
itemsInsertedSpy(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
181 QSignalSpy
itemsRemovedSpy(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)));
183 m_testDir
->createFiles(QStringList() << "a.txt" << "b.txt" << "c.txt");
185 m_model
->loadDirectory(m_testDir
->url());
186 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
187 QCOMPARE(loadingCompletedSpy
.count(), 1);
188 QCOMPARE(itemsInsertedSpy
.count(), 1);
189 QCOMPARE(itemsRemovedSpy
.count(), 0);
190 QCOMPARE(m_model
->count(), 3);
192 m_testDir
->createFiles(QStringList() << "d.txt" << "e.txt");
193 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
194 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
195 QCOMPARE(loadingCompletedSpy
.count(), 2);
196 QCOMPARE(itemsInsertedSpy
.count(), 2);
197 QCOMPARE(itemsRemovedSpy
.count(), 0);
198 QCOMPARE(m_model
->count(), 5);
200 m_testDir
->removeFile("a.txt");
201 m_testDir
->createFile("f.txt");
202 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
203 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
204 QCOMPARE(loadingCompletedSpy
.count(), 3);
205 QCOMPARE(itemsInsertedSpy
.count(), 3);
206 QCOMPARE(itemsRemovedSpy
.count(), 1);
207 QCOMPARE(m_model
->count(), 5);
209 m_testDir
->removeFile("b.txt");
210 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
211 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)), DefaultTimeout
));
212 QCOMPARE(loadingCompletedSpy
.count(), 4);
213 QCOMPARE(itemsInsertedSpy
.count(), 3);
214 QCOMPARE(itemsRemovedSpy
.count(), 2);
215 QCOMPARE(m_model
->count(), 4);
217 QVERIFY(isModelConsistent());
220 void KFileItemModelTest::testSetData()
222 m_testDir
->createFile("a.txt");
224 m_model
->loadDirectory(m_testDir
->url());
225 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
227 QHash
<QByteArray
, QVariant
> values
;
228 values
.insert("customRole1", "Test1");
229 values
.insert("customRole2", "Test2");
231 QSignalSpy
itemsChangedSpy(m_model
, SIGNAL(itemsChanged(KItemRangeList
,QSet
<QByteArray
>)));
232 m_model
->setData(0, values
);
233 QCOMPARE(itemsChangedSpy
.count(), 1);
235 values
= m_model
->data(0);
236 QCOMPARE(values
.value("customRole1").toString(), QString("Test1"));
237 QCOMPARE(values
.value("customRole2").toString(), QString("Test2"));
238 QVERIFY(isModelConsistent());
241 void KFileItemModelTest::testSetDataWithModifiedSortRole_data()
243 QTest::addColumn
<int>("changedIndex");
244 QTest::addColumn
<int>("changedRating");
245 QTest::addColumn
<bool>("expectMoveSignal");
246 QTest::addColumn
<int>("ratingIndex0");
247 QTest::addColumn
<int>("ratingIndex1");
248 QTest::addColumn
<int>("ratingIndex2");
251 // Index 0 = rating 2
252 // Index 1 = rating 4
253 // Index 2 = rating 6
255 QTest::newRow("Index 0: Rating 3") << 0 << 3 << false << 3 << 4 << 6;
256 QTest::newRow("Index 0: Rating 5") << 0 << 5 << true << 4 << 5 << 6;
257 QTest::newRow("Index 0: Rating 8") << 0 << 8 << true << 4 << 6 << 8;
259 QTest::newRow("Index 2: Rating 1") << 2 << 1 << true << 1 << 2 << 4;
260 QTest::newRow("Index 2: Rating 3") << 2 << 3 << true << 2 << 3 << 4;
261 QTest::newRow("Index 2: Rating 5") << 2 << 5 << false << 2 << 4 << 5;
264 void KFileItemModelTest::testSetDataWithModifiedSortRole()
266 QFETCH(int, changedIndex
);
267 QFETCH(int, changedRating
);
268 QFETCH(bool, expectMoveSignal
);
269 QFETCH(int, ratingIndex0
);
270 QFETCH(int, ratingIndex1
);
271 QFETCH(int, ratingIndex2
);
273 // Changing the value of a sort-role must result in
274 // a reordering of the items.
275 QCOMPARE(m_model
->sortRole(), QByteArray("text"));
278 files
<< "a.txt" << "b.txt" << "c.txt";
279 m_testDir
->createFiles(files
);
281 m_model
->loadDirectory(m_testDir
->url());
282 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
284 // Fill the "rating" role of each file:
289 QHash
<QByteArray
, QVariant
> ratingA
;
290 ratingA
.insert("rating", 2);
291 m_model
->setData(0, ratingA
);
293 QHash
<QByteArray
, QVariant
> ratingB
;
294 ratingB
.insert("rating", 4);
295 m_model
->setData(1, ratingB
);
297 QHash
<QByteArray
, QVariant
> ratingC
;
298 ratingC
.insert("rating", 6);
299 m_model
->setData(2, ratingC
);
301 m_model
->setSortRole("rating");
302 QCOMPARE(m_model
->data(0).value("rating").toInt(), 2);
303 QCOMPARE(m_model
->data(1).value("rating").toInt(), 4);
304 QCOMPARE(m_model
->data(2).value("rating").toInt(), 6);
306 // Now change the rating from a.txt. This usually results
307 // in reordering of the items.
308 QHash
<QByteArray
, QVariant
> rating
;
309 rating
.insert("rating", changedRating
);
310 m_model
->setData(changedIndex
, rating
);
312 if (expectMoveSignal
) {
313 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsMoved(KItemRange
,QList
<int>)), DefaultTimeout
));
316 QCOMPARE(m_model
->data(0).value("rating").toInt(), ratingIndex0
);
317 QCOMPARE(m_model
->data(1).value("rating").toInt(), ratingIndex1
);
318 QCOMPARE(m_model
->data(2).value("rating").toInt(), ratingIndex2
);
319 QVERIFY(isModelConsistent());
322 void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
324 //QSKIP("Temporary disabled", SkipSingle);
326 // KFileItemModel prevents that inserting a punch of items sequentially
327 // results in an itemsInserted()-signal for each item. Instead internally
328 // a timeout is given that collects such operations and results in only
329 // one itemsInserted()-signal. However in this test we want to stress
330 // KFileItemModel to do a lot of insert operation and hence decrease
331 // the timeout to 1 millisecond.
332 m_testDir
->createFile("1");
333 m_model
->loadDirectory(m_testDir
->url());
334 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
335 QCOMPARE(m_model
->count(), 1);
337 // Insert 10 items for 20 times. After each insert operation the model consistency
339 QSet
<int> insertedItems
;
340 for (int i
= 0; i
< 20; ++i
) {
341 QSignalSpy
spy(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
343 for (int j
= 0; j
< 10; ++j
) {
344 int itemName
= qrand();
345 while (insertedItems
.contains(itemName
)) {
348 insertedItems
.insert(itemName
);
350 m_testDir
->createFile(QString::number(itemName
));
353 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
354 if (spy
.count() == 0) {
355 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
358 QVERIFY(isModelConsistent());
361 QCOMPARE(m_model
->count(), 201);
364 void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems()
367 files
<< "B" << "E" << "G";
368 m_testDir
->createFiles(files
);
370 // Due to inserting the 3 items one item-range with index == 0 and
371 // count == 3 must be given
372 QSignalSpy
spy1(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
373 m_model
->loadDirectory(m_testDir
->url());
374 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
376 QCOMPARE(spy1
.count(), 1);
377 QList
<QVariant
> arguments
= spy1
.takeFirst();
378 KItemRangeList itemRangeList
= arguments
.at(0).value
<KItemRangeList
>();
379 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 3));
381 // The indexes of the item-ranges must always be related to the model before
382 // the items have been inserted. Having:
385 // and inserting A, C, D, F the resulting model will be:
388 // and the item-ranges must be:
389 // index: 0, count: 1 for A
390 // index: 1, count: 2 for B, C
391 // index: 2, count: 1 for G
394 files
<< "A" << "C" << "D" << "F";
395 m_testDir
->createFiles(files
);
397 QSignalSpy
spy2(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
398 m_model
->m_dirLister
->updateDirectory(m_testDir
->url());
399 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
401 QCOMPARE(spy2
.count(), 1);
402 arguments
= spy2
.takeFirst();
403 itemRangeList
= arguments
.at(0).value
<KItemRangeList
>();
404 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 1) << KItemRange(1, 2) << KItemRange(2, 1));
407 void KFileItemModelTest::testExpandItems()
409 // Test expanding subfolders in a folder with the items "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1".
410 // Besides testing the basic item expansion functionality, the test makes sure that
411 // KFileItemModel::expansionLevelsCompare(const KFileItem& a, const KFileItem& b)
412 // yields the correct result for "a/a/1" and "a/a-1/", whis is non-trivial because they share the
413 // first three characters.
414 QSet
<QByteArray
> modelRoles
= m_model
->roles();
415 modelRoles
<< "isExpanded" << "isExpandable" << "expandedParentsCount";
416 m_model
->setRoles(modelRoles
);
419 files
<< "a/a/1" << "a/a-1/1"; // missing folders are created automatically
420 m_testDir
->createFiles(files
);
422 // Store the URLs of all folders in a set.
423 QSet
<KUrl
> allFolders
;
424 allFolders
<< KUrl(m_testDir
->name() + 'a') << KUrl(m_testDir
->name() + "a/a") << KUrl(m_testDir
->name() + "a/a-1");
426 m_model
->loadDirectory(m_testDir
->url());
427 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
429 // So far, the model contains only "a/"
430 QCOMPARE(m_model
->count(), 1);
431 QVERIFY(m_model
->isExpandable(0));
432 QVERIFY(!m_model
->isExpanded(0));
433 QVERIFY(m_model
->expandedDirectories().empty());
435 QSignalSpy
spyInserted(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
437 // Expand the folder "a/" -> "a/a/" and "a/a-1/" become visible
438 m_model
->setExpanded(0, true);
439 QVERIFY(m_model
->isExpanded(0));
440 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
441 QCOMPARE(m_model
->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
442 QCOMPARE(m_model
->expandedDirectories(), QSet
<KUrl
>() << KUrl(m_testDir
->name() + 'a'));
444 QCOMPARE(spyInserted
.count(), 1);
445 KItemRangeList itemRangeList
= spyInserted
.takeFirst().at(0).value
<KItemRangeList
>();
446 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(1, 2)); // 2 new items "a/a/" and "a/a-1/" with indices 1 and 2
448 QVERIFY(m_model
->isExpandable(1));
449 QVERIFY(!m_model
->isExpanded(1));
450 QVERIFY(m_model
->isExpandable(2));
451 QVERIFY(!m_model
->isExpanded(2));
453 // Expand the folder "a/a/" -> "a/a/1" becomes visible
454 m_model
->setExpanded(1, true);
455 QVERIFY(m_model
->isExpanded(1));
456 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
457 QCOMPARE(m_model
->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
458 QCOMPARE(m_model
->expandedDirectories(), QSet
<KUrl
>() << KUrl(m_testDir
->name() + 'a') << KUrl(m_testDir
->name() + "a/a"));
460 QCOMPARE(spyInserted
.count(), 1);
461 itemRangeList
= spyInserted
.takeFirst().at(0).value
<KItemRangeList
>();
462 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(2, 1)); // 1 new item "a/a/1" with index 2
464 QVERIFY(!m_model
->isExpandable(2));
465 QVERIFY(!m_model
->isExpanded(2));
467 // Expand the folder "a/a-1/" -> "a/a-1/1" becomes visible
468 m_model
->setExpanded(3, true);
469 QVERIFY(m_model
->isExpanded(3));
470 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
471 QCOMPARE(m_model
->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
472 QCOMPARE(m_model
->expandedDirectories(), allFolders
);
474 QCOMPARE(spyInserted
.count(), 1);
475 itemRangeList
= spyInserted
.takeFirst().at(0).value
<KItemRangeList
>();
476 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(4, 1)); // 1 new item "a/a-1/1" with index 4
478 QVERIFY(!m_model
->isExpandable(4));
479 QVERIFY(!m_model
->isExpanded(4));
481 QSignalSpy
spyRemoved(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)));
483 // Collapse the top-level folder -> all other items should disappear
484 m_model
->setExpanded(0, false);
485 QVERIFY(!m_model
->isExpanded(0));
486 QCOMPARE(m_model
->count(), 1);
487 QVERIFY(!m_model
->expandedDirectories().contains(KUrl(m_testDir
->name() + 'a'))); // TODO: Make sure that child URLs are also removed
489 QCOMPARE(spyRemoved
.count(), 1);
490 itemRangeList
= spyRemoved
.takeFirst().at(0).value
<KItemRangeList
>();
491 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(1, 4)); // 4 items removed
493 // Clear the model, reload the folder and try to restore the expanded folders.
495 QCOMPARE(m_model
->count(), 0);
496 QVERIFY(m_model
->expandedDirectories().empty());
498 m_model
->loadDirectory(m_testDir
->url());
499 m_model
->restoreExpandedDirectories(allFolders
);
500 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
501 QCOMPARE(m_model
->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
502 QVERIFY(m_model
->isExpanded(0));
503 QVERIFY(m_model
->isExpanded(1));
504 QVERIFY(!m_model
->isExpanded(2));
505 QVERIFY(m_model
->isExpanded(3));
506 QVERIFY(!m_model
->isExpanded(4));
507 QCOMPARE(m_model
->expandedDirectories(), allFolders
);
509 // Move to a sub folder, then call restoreExpandedFolders() *before* going back.
510 // This is how DolphinView restores the expanded folders when navigating in history.
511 m_model
->loadDirectory(KUrl(m_testDir
->name() + "a/a/"));
512 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
513 QCOMPARE(m_model
->count(), 1); // 1 item: "1"
514 m_model
->restoreExpandedDirectories(allFolders
);
515 m_model
->loadDirectory(m_testDir
->url());
516 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
517 QCOMPARE(m_model
->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
518 QCOMPARE(m_model
->expandedDirectories(), allFolders
);
521 void KFileItemModelTest::testExpandParentItems()
523 // Create a tree structure of folders:
531 QSet
<QByteArray
> modelRoles
= m_model
->roles();
532 modelRoles
<< "isExpanded" << "isExpandable" << "expandedParentsCount";
533 m_model
->setRoles(modelRoles
);
536 files
<< "a 1/b1/c1/file.txt" << "a2/b2/c2/d2/file.txt"; // missing folders are created automatically
537 m_testDir
->createFiles(files
);
539 m_model
->loadDirectory(m_testDir
->url());
540 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
542 // So far, the model contains only "a 1/" and "a2/".
543 QCOMPARE(m_model
->count(), 2);
544 QVERIFY(m_model
->expandedDirectories().empty());
546 // Expand the parents of "a2/b2/c2".
547 m_model
->expandParentDirectories(KUrl(m_testDir
->name() + "a2/b2/c2"));
548 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
550 // The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/".
551 // It's important that only the parents of "a1/b1/c1" are expanded.
552 QCOMPARE(m_model
->count(), 4);
553 QVERIFY(!m_model
->isExpanded(0));
554 QVERIFY(m_model
->isExpanded(1));
555 QVERIFY(m_model
->isExpanded(2));
556 QVERIFY(!m_model
->isExpanded(3));
558 // Expand the parents of "a 1/b1".
559 m_model
->expandParentDirectories(KUrl(m_testDir
->name() + "a 1/b1"));
560 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(directoryLoadingCompleted()), DefaultTimeout
));
562 // The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/".
563 // It's important that only the parents of "a 1/b1/" and "a2/b2/c2/" are expanded.
564 QCOMPARE(m_model
->count(), 5);
565 QVERIFY(m_model
->isExpanded(0));
566 QVERIFY(!m_model
->isExpanded(1));
567 QVERIFY(m_model
->isExpanded(2));
568 QVERIFY(m_model
->isExpanded(3));
569 QVERIFY(!m_model
->isExpanded(4));
572 void KFileItemModelTest::testSorting()
574 // Create some files with different sizes and modification times to check the different sorting options
575 QDateTime now
= QDateTime::currentDateTime();
577 QSet
<QByteArray
> roles
;
578 roles
.insert("text");
579 roles
.insert("isExpanded");
580 roles
.insert("isExpandable");
581 roles
.insert("expandedParentsCount");
582 m_model
->setRoles(roles
);
584 m_testDir
->createDir("c/c-2");
585 m_testDir
->createFile("c/c-2/c-3");
586 m_testDir
->createFile("c/c-1");
588 m_testDir
->createFile("a", "A file", now
.addDays(-3));
589 m_testDir
->createFile("b", "A larger file", now
.addDays(0));
590 m_testDir
->createDir("c", now
.addDays(-2));
591 m_testDir
->createFile("d", "The largest file in this directory", now
.addDays(-1));
592 m_testDir
->createFile("e", "An even larger file", now
.addDays(-4));
593 m_testDir
->createFile(".f");
595 m_model
->loadDirectory(m_testDir
->url());
596 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
598 int index
= m_model
->index(KUrl(m_testDir
->url().url() + 'c'));
599 m_model
->setExpanded(index
, true);
600 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
602 index
= m_model
->index(KUrl(m_testDir
->url().url() + "c/c-2"));
603 m_model
->setExpanded(index
, true);
604 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
606 // Default: Sort by Name, ascending
607 QCOMPARE(m_model
->sortRole(), QByteArray("text"));
608 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
609 QVERIFY(m_model
->sortDirectoriesFirst());
610 QVERIFY(!m_model
->showHiddenFiles());
611 QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "d" << "e");
613 QSignalSpy
spyItemsMoved(m_model
, SIGNAL(itemsMoved(KItemRange
,QList
<int>)));
615 // Sort by Name, ascending, 'Sort Folders First' disabled
616 m_model
->setSortDirectoriesFirst(false);
617 QCOMPARE(m_model
->sortRole(), QByteArray("text"));
618 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
619 QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
620 QCOMPARE(spyItemsMoved
.count(), 1);
621 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7);
623 // Sort by Name, descending
624 m_model
->setSortDirectoriesFirst(true);
625 m_model
->setSortOrder(Qt::DescendingOrder
);
626 QCOMPARE(m_model
->sortRole(), QByteArray("text"));
627 QCOMPARE(m_model
->sortOrder(), Qt::DescendingOrder
);
628 QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a");
629 QCOMPARE(spyItemsMoved
.count(), 2);
630 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 6 << 7);
631 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4);
633 // Sort by Date, descending
634 m_model
->setSortDirectoriesFirst(true);
635 m_model
->setSortRole("date");
636 QCOMPARE(m_model
->sortRole(), QByteArray("date"));
637 QCOMPARE(m_model
->sortOrder(), Qt::DescendingOrder
);
638 QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "b" << "d" << "a" << "e");
639 QCOMPARE(spyItemsMoved
.count(), 1);
640 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 0 << 1 << 2 << 3 << 7 << 5 << 4 << 6);
642 // Sort by Date, ascending
643 m_model
->setSortOrder(Qt::AscendingOrder
);
644 QCOMPARE(m_model
->sortRole(), QByteArray("date"));
645 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
646 QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "a" << "d" << "b");
647 QCOMPARE(spyItemsMoved
.count(), 1);
648 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4);
650 // Sort by Date, ascending, 'Sort Folders First' disabled
651 m_model
->setSortDirectoriesFirst(false);
652 QCOMPARE(m_model
->sortRole(), QByteArray("date"));
653 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
654 QVERIFY(!m_model
->sortDirectoriesFirst());
655 QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "c-1" << "c-2" << "c-3" << "d" << "b");
656 QCOMPARE(spyItemsMoved
.count(), 1);
657 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7);
659 // Sort by Name, ascending, 'Sort Folders First' disabled
660 m_model
->setSortRole("text");
661 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
662 QVERIFY(!m_model
->sortDirectoriesFirst());
663 QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
664 QCOMPARE(spyItemsMoved
.count(), 1);
665 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1);
667 // Sort by Size, ascending, 'Sort Folders First' disabled
668 m_model
->setSortRole("size");
669 QCOMPARE(m_model
->sortRole(), QByteArray("size"));
670 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
671 QVERIFY(!m_model
->sortDirectoriesFirst());
672 QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d");
673 QCOMPARE(spyItemsMoved
.count(), 1);
674 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6);
676 QSKIP("2 tests of testSorting() are temporary deactivated as in KFileItemModel resortAllItems() "
677 "always emits a itemsMoved() signal. Before adjusting the tests think about probably introducing "
678 "another signal", SkipSingle
);
679 // Internal note: Check comment in KFileItemModel::resortAllItems() for details.
681 // In 'Sort by Size' mode, folders are always first -> changing 'Sort Folders First' does not resort the model
682 m_model
->setSortDirectoriesFirst(true);
683 QCOMPARE(m_model
->sortRole(), QByteArray("size"));
684 QCOMPARE(m_model
->sortOrder(), Qt::AscendingOrder
);
685 QVERIFY(m_model
->sortDirectoriesFirst());
686 QCOMPARE(itemsInModel(), QStringList() << "c" << "a" << "b" << "e" << "d");
687 QCOMPARE(spyItemsMoved
.count(), 0);
689 // Sort by Size, descending, 'Sort Folders First' enabled
690 m_model
->setSortOrder(Qt::DescendingOrder
);
691 QCOMPARE(m_model
->sortRole(), QByteArray("size"));
692 QCOMPARE(m_model
->sortOrder(), Qt::DescendingOrder
);
693 QVERIFY(m_model
->sortDirectoriesFirst());
694 QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "e" << "b" << "a");
695 QCOMPARE(spyItemsMoved
.count(), 1);
696 QCOMPARE(spyItemsMoved
.takeFirst().at(1).value
<QList
<int> >(), QList
<int>() << 0 << 4 << 3 << 2 << 1);
698 // TODO: Sort by other roles; show/hide hidden files
701 void KFileItemModelTest::testIndexForKeyboardSearch()
704 files
<< "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11";
705 m_testDir
->createFiles(files
);
707 m_model
->loadDirectory(m_testDir
->url());
708 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
710 // Search from index 0
711 QCOMPARE(m_model
->indexForKeyboardSearch("a", 0), 0);
712 QCOMPARE(m_model
->indexForKeyboardSearch("aa", 0), 1);
713 QCOMPARE(m_model
->indexForKeyboardSearch("i", 0), 2);
714 QCOMPARE(m_model
->indexForKeyboardSearch("image", 0), 2);
715 QCOMPARE(m_model
->indexForKeyboardSearch("image.jpg", 0), 2);
716 QCOMPARE(m_model
->indexForKeyboardSearch("image.png", 0), 3);
717 QCOMPARE(m_model
->indexForKeyboardSearch("t", 0), 4);
718 QCOMPARE(m_model
->indexForKeyboardSearch("text", 0), 4);
719 QCOMPARE(m_model
->indexForKeyboardSearch("text1", 0), 5);
720 QCOMPARE(m_model
->indexForKeyboardSearch("text2", 0), 6);
721 QCOMPARE(m_model
->indexForKeyboardSearch("text11", 0), 7);
723 // Start a search somewhere in the middle
724 QCOMPARE(m_model
->indexForKeyboardSearch("a", 1), 1);
725 QCOMPARE(m_model
->indexForKeyboardSearch("i", 3), 3);
726 QCOMPARE(m_model
->indexForKeyboardSearch("t", 5), 5);
727 QCOMPARE(m_model
->indexForKeyboardSearch("text1", 6), 7);
729 // Test searches that go past the last item back to index 0
730 QCOMPARE(m_model
->indexForKeyboardSearch("a", 2), 0);
731 QCOMPARE(m_model
->indexForKeyboardSearch("i", 7), 2);
732 QCOMPARE(m_model
->indexForKeyboardSearch("image.jpg", 3), 2);
733 QCOMPARE(m_model
->indexForKeyboardSearch("text2", 7), 6);
735 // Test searches that yield no result
736 QCOMPARE(m_model
->indexForKeyboardSearch("aaa", 0), -1);
737 QCOMPARE(m_model
->indexForKeyboardSearch("b", 0), -1);
738 QCOMPARE(m_model
->indexForKeyboardSearch("image.svg", 0), -1);
739 QCOMPARE(m_model
->indexForKeyboardSearch("text3", 0), -1);
740 QCOMPARE(m_model
->indexForKeyboardSearch("text3", 5), -1);
742 // Test upper case searches (note that search is case insensitive)
743 QCOMPARE(m_model
->indexForKeyboardSearch("A", 0), 0);
744 QCOMPARE(m_model
->indexForKeyboardSearch("aA", 0), 1);
745 QCOMPARE(m_model
->indexForKeyboardSearch("TexT", 5), 5);
746 QCOMPARE(m_model
->indexForKeyboardSearch("IMAGE", 4), 2);
748 // TODO: Maybe we should also test keyboard searches in directories which are not sorted by Name?
751 void KFileItemModelTest::testNameFilter()
754 files
<< "A1" << "A2" << "Abc" << "Bcd" << "Cde";
755 m_testDir
->createFiles(files
);
757 m_model
->loadDirectory(m_testDir
->url());
758 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
760 m_model
->setNameFilter("A"); // Shows A1, A2 and Abc
761 QCOMPARE(m_model
->count(), 3);
763 m_model
->setNameFilter("A2"); // Shows only A2
764 QCOMPARE(m_model
->count(), 1);
766 m_model
->setNameFilter("A2"); // Shows only A1
767 QCOMPARE(m_model
->count(), 1);
769 m_model
->setNameFilter("Bc"); // Shows "Abc" and "Bcd"
770 QCOMPARE(m_model
->count(), 2);
772 m_model
->setNameFilter("bC"); // Shows "Abc" and "Bcd"
773 QCOMPARE(m_model
->count(), 2);
775 m_model
->setNameFilter(QString()); // Shows again all items
776 QCOMPARE(m_model
->count(), 5);
780 * Verifies that we do not crash when adding a KFileItem with an empty path.
781 * Before this issue was fixed, KFileItemModel::expandedParentsCountCompare()
782 * tried to always read the first character of the path, even if the path is empty.
784 void KFileItemModelTest::testEmptyPath()
786 QSet
<QByteArray
> roles
;
787 roles
.insert("text");
788 roles
.insert("isExpanded");
789 roles
.insert("isExpandable");
790 roles
.insert("expandedParentsCount");
791 m_model
->setRoles(roles
);
794 QVERIFY(emptyUrl
.path().isEmpty());
796 const KUrl
url("file:///test/");
799 items
<< KFileItem(emptyUrl
, QString(), KFileItem::Unknown
) << KFileItem(url
, QString(), KFileItem::Unknown
);
800 m_model
->slotNewItems(items
);
801 m_model
->slotCompleted();
805 * Verify that removing hidden files and folders from the model does not
806 * result in a crash, see https://bugs.kde.org/show_bug.cgi?id=314046
808 void KFileItemModelTest::testRemoveHiddenItems()
810 m_testDir
->createDir(".a");
811 m_testDir
->createDir(".b");
812 m_testDir
->createDir("c");
813 m_testDir
->createDir("d");
814 m_testDir
->createFiles(QStringList() << ".f" << ".g" << "h" << "i");
816 QSignalSpy
spyItemsInserted(m_model
, SIGNAL(itemsInserted(KItemRangeList
)));
817 QSignalSpy
spyItemsRemoved(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)));
819 m_model
->setShowHiddenFiles(true);
820 m_model
->loadDirectory(m_testDir
->url());
821 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
822 QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
823 QCOMPARE(spyItemsInserted
.count(), 1);
824 QCOMPARE(spyItemsRemoved
.count(), 0);
825 KItemRangeList itemRangeList
= spyItemsInserted
.takeFirst().at(0).value
<KItemRangeList
>();
826 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 8));
828 m_model
->setShowHiddenFiles(false);
829 QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "h" << "i");
830 QCOMPARE(spyItemsInserted
.count(), 0);
831 QCOMPARE(spyItemsRemoved
.count(), 1);
832 itemRangeList
= spyItemsRemoved
.takeFirst().at(0).value
<KItemRangeList
>();
833 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 2) << KItemRange(4, 2));
835 m_model
->setShowHiddenFiles(true);
836 QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
837 QCOMPARE(spyItemsInserted
.count(), 1);
838 QCOMPARE(spyItemsRemoved
.count(), 0);
839 itemRangeList
= spyItemsInserted
.takeFirst().at(0).value
<KItemRangeList
>();
840 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 2) << KItemRange(2, 2));
843 QCOMPARE(itemsInModel(), QStringList());
844 QCOMPARE(spyItemsInserted
.count(), 0);
845 QCOMPARE(spyItemsRemoved
.count(), 1);
846 itemRangeList
= spyItemsRemoved
.takeFirst().at(0).value
<KItemRangeList
>();
847 QCOMPARE(itemRangeList
, KItemRangeList() << KItemRange(0, 8));
849 // Hiding hidden files makes the dir lister emit its itemsDeleted signal.
850 // Verify that this does not make the model crash.
851 m_model
->setShowHiddenFiles(false);
855 * Verify that filtered items are removed when their parent is collapsed.
857 void KFileItemModelTest::collapseParentOfHiddenItems()
859 QSet
<QByteArray
> modelRoles
= m_model
->roles();
860 modelRoles
<< "isExpanded" << "isExpandable" << "expandedParentsCount";
861 m_model
->setRoles(modelRoles
);
864 files
<< "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1";
865 m_testDir
->createFiles(files
);
867 m_model
->loadDirectory(m_testDir
->url());
868 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
869 QCOMPARE(m_model
->count(), 1); // Only "a/"
872 m_model
->setExpanded(0, true);
873 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
874 QCOMPARE(m_model
->count(), 3); // 3 items: "a/", "a/b/", "a/1"
877 m_model
->setExpanded(1, true);
878 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
879 QCOMPARE(m_model
->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1"
882 m_model
->setExpanded(2, true);
883 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
884 QCOMPARE(m_model
->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1"
886 // Set a name filter that matches nothing -> only the expanded folders remain.
887 m_model
->setNameFilter("xyz");
888 QCOMPARE(m_model
->count(), 3);
889 QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c");
891 // Collapse the folder "a/".
892 QSignalSpy
spyItemsRemoved(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)));
893 m_model
->setExpanded(0, false);
894 QCOMPARE(spyItemsRemoved
.count(), 1);
895 QCOMPARE(m_model
->count(), 1);
896 QCOMPARE(itemsInModel(), QStringList() << "a");
898 // Remove the filter -> no files should appear (and we should not get a crash).
899 m_model
->setNameFilter(QString());
900 QCOMPARE(m_model
->count(), 1);
904 * Verify that filtered items are removed when their parent is deleted.
906 void KFileItemModelTest::removeParentOfHiddenItems()
908 QSet
<QByteArray
> modelRoles
= m_model
->roles();
909 modelRoles
<< "isExpanded" << "isExpandable" << "expandedParentsCount";
910 m_model
->setRoles(modelRoles
);
913 files
<< "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1";
914 m_testDir
->createFiles(files
);
916 m_model
->loadDirectory(m_testDir
->url());
917 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
918 QCOMPARE(m_model
->count(), 1); // Only "a/"
921 m_model
->setExpanded(0, true);
922 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
923 QCOMPARE(m_model
->count(), 3); // 3 items: "a/", "a/b/", "a/1"
926 m_model
->setExpanded(1, true);
927 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
928 QCOMPARE(m_model
->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1"
931 m_model
->setExpanded(2, true);
932 QVERIFY(QTest::kWaitForSignal(m_model
, SIGNAL(itemsInserted(KItemRangeList
)), DefaultTimeout
));
933 QCOMPARE(m_model
->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1"
935 // Set a name filter that matches nothing -> only the expanded folders remain.
936 m_model
->setNameFilter("xyz");
937 QCOMPARE(m_model
->count(), 3);
938 QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c");
940 // Simulate the deletion of the directory "a/b/".
941 QSignalSpy
spyItemsRemoved(m_model
, SIGNAL(itemsRemoved(KItemRangeList
)));
942 m_model
->slotItemsDeleted(KFileItemList() << m_model
->fileItem(1));
943 QCOMPARE(spyItemsRemoved
.count(), 1);
944 QCOMPARE(m_model
->count(), 1);
945 QCOMPARE(itemsInModel(), QStringList() << "a");
947 // Remove the filter -> only the file "a/1" should appear.
948 m_model
->setNameFilter(QString());
949 QCOMPARE(m_model
->count(), 2);
950 QCOMPARE(itemsInModel(), QStringList() << "a" << "1");
953 bool KFileItemModelTest::isModelConsistent() const
955 if (m_model
->m_items
.count() != m_model
->m_itemData
.count()) {
959 for (int i
= 0; i
< m_model
->count(); ++i
) {
960 const KFileItem item
= m_model
->fileItem(i
);
962 qWarning() << "Item" << i
<< "is null";
966 const int itemIndex
= m_model
->index(item
);
967 if (itemIndex
!= i
) {
968 qWarning() << "Item" << i
<< "has a wrong index:" << itemIndex
;
976 QStringList
KFileItemModelTest::itemsInModel() const
979 for (int i
= 0; i
< m_model
->count(); i
++) {
980 items
<< m_model
->data(i
).value("text").toString();
985 QTEST_KDEMAIN(KFileItemModelTest
, NoGUI
)
987 #include "kfileitemmodeltest.moc"