X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7f381a34cb37ff4aeb215a8fe91448e5ea27aca0..5100c20c0df8ead9a7a97fa0ebb63f6fc8927dcb:/src/tests/kfileitemmodelbenchmark.cpp diff --git a/src/tests/kfileitemmodelbenchmark.cpp b/src/tests/kfileitemmodelbenchmark.cpp index f72e43ede..c970a7198 100644 --- a/src/tests/kfileitemmodelbenchmark.cpp +++ b/src/tests/kfileitemmodelbenchmark.cpp @@ -18,15 +18,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include +#include +#include + +#include +#include #include "kitemviews/kfileitemmodel.h" #include "kitemviews/private/kfileitemmodelsortalgorithm.h" #include "testdir.h" -#include - void myMessageOutput(QtMsgType type, const char* msg) { switch (type) { @@ -45,10 +47,6 @@ void myMessageOutput(QtMsgType type, const char* msg) } } -namespace { - const int DefaultTimeout = 5000; -}; - Q_DECLARE_METATYPE(KFileItemList) Q_DECLARE_METATYPE(KItemRangeList) @@ -167,7 +165,7 @@ void KFileItemModelBenchmark::insertAndRemoveManyItems() // Avoid overhead caused by natural sorting // and determining the isDir/isLink roles. model.m_naturalSorting = false; - model.setRoles(QSet() << "text"); + model.setRoles({"text"}); QSignalSpy spyItemsInserted(&model, SIGNAL(itemsInserted(KItemRangeList))); QSignalSpy spyItemsRemoved(&model, SIGNAL(itemsRemoved(KItemRangeList))); @@ -185,7 +183,7 @@ void KFileItemModelBenchmark::insertAndRemoveManyItems() QCOMPARE(model.count(), initialItems.count() + newItems.count()); if (!removedItems.isEmpty()) { - model.removeItems(removedItems, KFileItemModel::DeleteItemData); + model.slotItemsDeleted(removedItems); } QCOMPARE(model.count(), initialItems.count() + newItems.count() - removedItems.count()); } @@ -294,8 +292,9 @@ void KFileItemModelBenchmark::insertManyChildItems() } // Bring the items into random order. - KRandomSequence randomSequence(0); - randomSequence.randomize(newItems); + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(newItems.begin(), newItems.end(), g); // Measure how long it takes to insert and then remove all files. QBENCHMARK { @@ -322,13 +321,12 @@ KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fil KFileItemList result; foreach (const QString& name, fileNames) { - const KUrl url(prefix + name); - const KFileItem item(url, QString(), KFileItem::Unknown); + const KFileItem item(QUrl::fromLocalFile(prefix + name), QString(), KFileItem::Unknown); result << item; } return result; } -QTEST_KDEMAIN(KFileItemModelBenchmark, NoGUI) +QTEST_MAIN(KFileItemModelBenchmark) #include "kfileitemmodelbenchmark.moc"