]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tests/kfileitemmodeltest.cpp
Merge branch 'release/20.08' into master
[dolphin.git] / src / tests / kfileitemmodeltest.cpp
index 2f258d17d94310405f9419d4900aeda350146a2b..8fd1883ac665d79e268165e4325d53007c925f9d 100644 (file)
@@ -1,23 +1,11 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *   Copyright (C) 2011 by Frank Reininghaus <frank78ac@googlemail.com>    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2011 Frank Reininghaus <frank78ac@googlemail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
+#include <QRandomGenerator>
 #include <QTest>
 #include <QSignalSpy>
 #include <QTimer>
@@ -31,7 +19,7 @@
 
 void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
 {
-    Q_UNUSED(context);
+    Q_UNUSED(context)
 
     switch (type) {
     case QtDebugMsg:
@@ -450,9 +438,9 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
         itemsInsertedSpy.clear();
 
         for (int j = 0; j < 10; ++j) {
-            int itemName = qrand();
+            int itemName = QRandomGenerator::global()->generate();
             while (insertedItems.contains(itemName)) {
-                itemName = qrand();
+                itemName = QRandomGenerator::global()->generate();
             }
             insertedItems.insert(itemName);
 
@@ -460,7 +448,7 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
         }
 
         m_model->m_dirLister->updateDirectory(m_testDir->url());
-        if (itemsInsertedSpy.count() == 0) {
+        if (itemsInsertedSpy.isEmpty()) {
             QVERIFY(itemsInsertedSpy.wait());
         }
 
@@ -1553,22 +1541,22 @@ void KFileItemModelTest::testChangeSortRoleWhileFiltering()
 
     KIO::UDSEntry entry[3];
 
-    entry[0].insert(KIO::UDSEntry::UDS_NAME, "a.txt");
-    entry[0].insert(KIO::UDSEntry::UDS_USER, "user-b");
+    entry[0].fastInsert(KIO::UDSEntry::UDS_NAME, "a.txt");
+    entry[0].fastInsert(KIO::UDSEntry::UDS_USER, "user-b");
 
-    entry[1].insert(KIO::UDSEntry::UDS_NAME, "b.txt");
-    entry[1].insert(KIO::UDSEntry::UDS_USER, "user-c");
+    entry[1].fastInsert(KIO::UDSEntry::UDS_NAME, "b.txt");
+    entry[1].fastInsert(KIO::UDSEntry::UDS_USER, "user-c");
 
-    entry[2].insert(KIO::UDSEntry::UDS_NAME, "c.txt");
-    entry[2].insert(KIO::UDSEntry::UDS_USER, "user-a");
+    entry[2].fastInsert(KIO::UDSEntry::UDS_NAME, "c.txt");
+    entry[2].fastInsert(KIO::UDSEntry::UDS_USER, "user-a");
 
     for (int i = 0; i < 3; ++i) {
-        entry[i].insert(KIO::UDSEntry::UDS_FILE_TYPE, 0100000);    // S_IFREG might not be defined on non-Unix platforms.
-        entry[i].insert(KIO::UDSEntry::UDS_ACCESS, 07777);
-        entry[i].insert(KIO::UDSEntry::UDS_SIZE, 0);
-        entry[i].insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, 0);
-        entry[i].insert(KIO::UDSEntry::UDS_GROUP, "group");
-        entry[i].insert(KIO::UDSEntry::UDS_ACCESS_TIME, 0);
+        entry[i].fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, 0100000);    // S_IFREG might not be defined on non-Unix platforms.
+        entry[i].fastInsert(KIO::UDSEntry::UDS_ACCESS, 07777);
+        entry[i].fastInsert(KIO::UDSEntry::UDS_SIZE, 0);
+        entry[i].fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, 0);
+        entry[i].fastInsert(KIO::UDSEntry::UDS_GROUP, "group");
+        entry[i].fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, 0);
         items.append(KFileItem(entry[i], m_testDir->url(), false, true));
     }