diff options
| author | Emmanuel Pescosta <[email protected]> | 2015-02-27 11:30:27 +0100 |
|---|---|---|
| committer | Emmanuel Pescosta <[email protected]> | 2015-02-27 11:30:27 +0100 |
| commit | 9aee5d22513f0367febab54b38b3a7dc58d120bb (patch) | |
| tree | 99cf391070ac5d4650a3f1b309c3ec2e814f1ac6 /src/tests/kfileitemmodelbenchmark.cpp | |
| parent | f025aeb63aa2a38e91c43d99ba9955793d3adf1e (diff) | |
| parent | b701b7e4edefb628d6f8b14146b2e299bd0ce5fc (diff) | |
Merge branch 'frameworks'
Diffstat (limited to 'src/tests/kfileitemmodelbenchmark.cpp')
| -rw-r--r-- | src/tests/kfileitemmodelbenchmark.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/tests/kfileitemmodelbenchmark.cpp b/src/tests/kfileitemmodelbenchmark.cpp index 66918b6ee..b73485efb 100644 --- a/src/tests/kfileitemmodelbenchmark.cpp +++ b/src/tests/kfileitemmodelbenchmark.cpp @@ -18,37 +18,37 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include <qtest_kde.h> +#include <QTest> +#include <QSignalSpy> + +#include <algorithm> +#include <random> #include "kitemviews/kfileitemmodel.h" #include "kitemviews/private/kfileitemmodelsortalgorithm.h" #include "testdir.h" -#include <KRandomSequence> - -void myMessageOutput(QtMsgType type, const char* msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg) { + Q_UNUSED(context); + switch (type) { case QtDebugMsg: break; case QtWarningMsg: break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); + fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data()); break; case QtFatalMsg: - fprintf(stderr, "Fatal: %s\n", msg); + fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data()); abort(); default: break; } } -namespace { - const int DefaultTimeout = 5000; -}; - Q_DECLARE_METATYPE(KFileItemList) Q_DECLARE_METATYPE(KItemRangeList) @@ -167,7 +167,7 @@ void KFileItemModelBenchmark::insertAndRemoveManyItems() // Avoid overhead caused by natural sorting // and determining the isDir/isLink roles. model.m_naturalSorting = false; - model.setRoles(QSet<QByteArray>() << "text"); + model.setRoles({"text"}); QSignalSpy spyItemsInserted(&model, SIGNAL(itemsInserted(KItemRangeList))); QSignalSpy spyItemsRemoved(&model, SIGNAL(itemsRemoved(KItemRangeList))); @@ -294,8 +294,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 { @@ -318,17 +319,16 @@ void KFileItemModelBenchmark::insertManyChildItems() KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fileNames, const QString& prefix) { // Suppress 'file does not exist anymore' messages from KFileItemPrivate::init(). - qInstallMsgHandler(myMessageOutput); + qInstallMessageHandler(myMessageOutput); 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" |
