summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp')
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp231
1 files changed, 158 insertions, 73 deletions
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index a096fcd324..e721c8d434 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1,37 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <emulationdetector.h>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+
#include <QTest>
#include <QSignalSpy>
#include <QTemporaryFile>
#include <QLoggingCategory>
+#include <QtTest/private/qemulationdetector_p.h>
#ifdef QT_BUILD_INTERNAL
#include <private/qfilesystemmodel_p.h>
@@ -45,6 +20,7 @@
#include <QStyle>
#include <QtGlobal>
#include <QTemporaryDir>
+#include <QAbstractItemModelTester>
#if defined(Q_OS_WIN)
# include <qt_windows.h> // for SetFileAttributes
#endif
@@ -52,6 +28,9 @@
#include <algorithm>
+using namespace Qt::StringLiterals;
+using namespace std::chrono;
+
#define WAITTIME 1000
// Will try to wait for the condition while allowing event processing
@@ -86,6 +65,7 @@ private slots:
void rootPath();
void readOnly();
void iconProvider();
+ void nullIconProvider();
void rowCount();
@@ -101,6 +81,8 @@ private slots:
void filters_data();
void filters();
+ void showFilesOnly();
+
void nameFilters();
void setData_data();
@@ -172,6 +154,8 @@ void tst_QFileSystemModel::indexPath()
{
#if !defined(Q_OS_WIN)
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
int depth = QDir::currentPath().count('/');
model->setRootPath(QDir::currentPath());
QString backPath;
@@ -186,12 +170,14 @@ void tst_QFileSystemModel::indexPath()
void tst_QFileSystemModel::rootPath()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QCOMPARE(model->rootPath(), QString(QDir().path()));
QSignalSpy rootChanged(model.data(), &QFileSystemModel::rootPathChanged);
QModelIndex root = model->setRootPath(model->rootPath());
root = model->setRootPath("this directory shouldn't exist");
- QCOMPARE(rootChanged.count(), 0);
+ QCOMPARE(rootChanged.size(), 0);
QString oldRootPath = model->rootPath();
const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
@@ -208,33 +194,50 @@ void tst_QFileSystemModel::rootPath()
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), QString(documentPath));
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? 0 : 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
model->setRootPath(QDir::rootPath());
- int oldCount = rootChanged.count();
+ int oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), documentPath);
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
QDir newdir = documentPath;
if (newdir.cdUp()) {
- oldCount = rootChanged.count();
+ oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/.."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), newdir.path());
- QCOMPARE(rootChanged.count(), oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
+
+#ifdef Q_OS_WIN
+ // check case insensitive root node on windows, tests QTBUG-71701
+ QModelIndex index = model->setRootPath(uR"(\\localhost\c$)"_s);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//localhost/c$"_s);
+
+ index = model->setRootPath(uR"(\\localhost\C$)"_s);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//localhost/C$"_s);
+
+ index = model->setRootPath(uR"(\\LOCALHOST\C$)"_s);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//LOCALHOST/C$"_s);
+#endif
}
void tst_QFileSystemModel::readOnly()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QCOMPARE(model->isReadOnly(), true);
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
QVERIFY2(file.open(), qPrintable(file.errorString()));
@@ -246,10 +249,14 @@ void tst_QFileSystemModel::readOnly()
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
+
+ // ItemIsEditable should change, ItemNeverHasChildren should not change
QVERIFY(!(model->flags(model->index(fileName)) & Qt::ItemIsEditable));
+ QVERIFY(model->flags(model->index(fileName)) & Qt::ItemNeverHasChildren);
model->setReadOnly(false);
QCOMPARE(model->isReadOnly(), false);
QVERIFY(model->flags(model->index(fileName)) & Qt::ItemIsEditable);
+ QVERIFY(model->flags(model->index(fileName)) & Qt::ItemNeverHasChildren);
}
class CustomFileIconProvider : public QFileIconProvider
@@ -284,6 +291,8 @@ private:
void tst_QFileSystemModel::iconProvider()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(model->iconProvider());
QScopedPointer<QFileIconProvider> provider(new QFileIconProvider);
model->setIconProvider(provider.data());
@@ -303,6 +312,19 @@ void tst_QFileSystemModel::iconProvider()
QCOMPARE(myModel->fileIcon(myModel->index(QDir::homePath())).pixmap(50, 50), mb);
}
+void tst_QFileSystemModel::nullIconProvider()
+{
+ QFileSystemModel model;
+ QAbstractItemModelTester tester(&model);
+ tester.setUseFetchMore(false);
+ QVERIFY(model.iconProvider());
+ // No crash when setIconProvider(nullptr) is used
+ model.setIconProvider(nullptr);
+ const auto documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
+ QVERIFY(!documentPaths.isEmpty());
+ model.setRootPath(documentPaths.constFirst());
+}
+
bool tst_QFileSystemModel::createFiles(QFileSystemModel *model, const QString &test_path,
const QStringList &initial_files, int existingFileCount,
const QStringList &initial_dirs)
@@ -393,11 +415,13 @@ void tst_QFileSystemModel::rowCount()
QSignalSpy *spy2 = nullptr;
QSignalSpy *spy3 = nullptr;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
QVERIFY(root.isValid());
- QVERIFY(spy2 && spy2->count() > 0);
- QVERIFY(spy3 && spy3->count() > 0);
+ QVERIFY(spy2 && spy2->size() > 0);
+ QVERIFY(spy3 && spy3->size() > 0);
}
void tst_QFileSystemModel::rowsInserted_data()
@@ -421,6 +445,8 @@ void tst_QFileSystemModel::rowsInserted()
{
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -437,7 +463,7 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(model.data(), tmp, files, 5));
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
- for (int i = 0; i < spy0.count(); ++i) {
+ for (int i = 0; i < spy0.size(); ++i) {
int start = spy0[i].value(1).toInt();
int end = spy0[i].value(2).toInt();
totalRowsInserted += end - start + 1;
@@ -446,24 +472,24 @@ void tst_QFileSystemModel::rowsInserted()
const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
QTRY_COMPARE(lastEntry(root), expected);
- if (spy0.count() > 0) {
+ if (spy0.size() > 0) {
if (count == 0)
- QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy0.size(), 0);
else
- QVERIFY(spy0.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
}
- if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
+ if (count == 0) QCOMPARE(spy1.size(), 0); else QVERIFY(spy1.size() >= 1);
QVERIFY(createFiles(model.data(), tmp, QStringList(".hidden_file"), 5 + count));
if (count != 0)
- QTRY_VERIFY(spy0.count() >= 1);
+ QTRY_VERIFY(spy0.size() >= 1);
else
- QTRY_COMPARE(spy0.count(), 0);
+ QTRY_COMPARE(spy0.size(), 0);
if (count != 0)
- QTRY_VERIFY(spy1.count() >= 1);
+ QTRY_VERIFY(spy1.size() >= 1);
else
- QTRY_COMPARE(spy1.count(), 0);
+ QTRY_COMPARE(spy1.size(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -475,6 +501,8 @@ void tst_QFileSystemModel::rowsRemoved()
{
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -492,14 +520,14 @@ void tst_QFileSystemModel::rowsRemoved()
}
for (int i = 0 ; i < 10; ++i) {
if (count != 0) {
- if (i == 10 || spy0.count() != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ if (i == 10 || spy0.size() != 0) {
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
}
} else {
- if (i == 10 || spy0.count() == 0) {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ if (i == 10 || spy0.size() == 0) {
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
QStringList lst;
@@ -518,11 +546,11 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + QLatin1String("/.c")));
if (count != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
} else {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
@@ -537,6 +565,8 @@ void tst_QFileSystemModel::dataChanged()
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -552,7 +582,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
+ if (count != 0) QVERIFY(spy.size() >= 1); else QCOMPARE(spy.size(), 0);
}
void tst_QFileSystemModel::filters_data()
@@ -597,6 +627,8 @@ void tst_QFileSystemModel::filters()
{
QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, QStringList()));
QModelIndex root = model->setRootPath(tmp);
QFETCH(QStringList, files);
@@ -605,7 +637,7 @@ void tst_QFileSystemModel::filters()
QFETCH(QStringList, nameFilters);
QFETCH(int, rowCount);
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
model->setNameFilters(nameFilters);
model->setNameFilterDisables(false);
model->setFilter(dirFilters);
@@ -617,12 +649,12 @@ void tst_QFileSystemModel::filters()
QDir xFactor(tmp);
QStringList dirEntries;
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
dirEntries = xFactor.entryList(nameFilters, dirFilters);
else
dirEntries = xFactor.entryList(dirFilters);
- QCOMPARE(dirEntries.count(), rowCount);
+ QCOMPARE(dirEntries.size(), rowCount);
QStringList modelEntries;
@@ -634,7 +666,7 @@ void tst_QFileSystemModel::filters()
QCOMPARE(dirEntries, modelEntries);
#ifdef Q_OS_LINUX
- if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
+ if (files.size() >= 3 && rowCount >= 3 && rowCount != 5) {
QString fileName1 = (tmp + '/' + files.at(0));
QString fileName2 = (tmp + '/' + files.at(1));
QString fileName3 = (tmp + '/' + files.at(2));
@@ -660,11 +692,46 @@ void tst_QFileSystemModel::filters()
#endif
}
+void tst_QFileSystemModel::showFilesOnly()
+{
+ QString tmp = flatDirTestPath;
+ QFileSystemModel model;
+ QAbstractItemModelTester tester(&model);
+ tester.setUseFetchMore(false);
+ QVERIFY(createFiles(&model, tmp, QStringList()));
+ const QStringList files{u"a"_s, u"b"_s, u"c"_s};
+ const auto subdir = u"sub_directory"_s;
+ QVERIFY(createFiles(&model, tmp, files, 0, {subdir}));
+
+ // The model changes asynchronously when we run the event loop in the QTRY_...
+ // macros, so the root index returned by an earlier call to setRootPath might
+ // become invalid. Make sure we use a fresh one for each iteration.
+
+ // QTBUG-74471
+ // WHAT: setting the root path of the model to a dir with some files and a subdir
+ QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size() + 1);
+
+ // Change the model to only show files
+ model.setFilter(QDir::Files);
+ QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size());
+
+ // WHEN: setting the root path to a subdir
+ QModelIndex subIndex = model.setRootPath(tmp + u'/' + subdir);
+ QTRY_COMPARE(model.rowCount(subIndex), 0);
+
+ // THEN: setting the root path to the previous (parent) dir, the model should
+ // still only show files.
+ // Doubling the default timeout (5s) as this test to fails on macos on the CI
+ QTRY_COMPARE_WITH_TIMEOUT(model.rowCount(model.setRootPath(tmp)), files.size(), 10s);
+}
+
void tst_QFileSystemModel::nameFilters()
{
QStringList list;
list << "a" << "b" << "c";
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
model->setNameFilters(list);
model->setNameFilterDisables(false);
QCOMPARE(model->nameFilters(), list);
@@ -710,6 +777,8 @@ void tst_QFileSystemModel::setData_data()
void tst_QFileSystemModel::setData()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QSignalSpy spy(model.data(), &QFileSystemModel::fileRenamed);
QFETCH(QString, subdirName);
QFETCH(QStringList, files);
@@ -729,7 +798,7 @@ void tst_QFileSystemModel::setData()
tmpIdx = model->index(tmp);
model->fetchMore(tmpIdx);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
QModelIndex idx = model->index(tmp + '/' + oldFileName);
QCOMPARE(idx.isValid(), true);
@@ -739,7 +808,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(model->setData(idx, newFileName), success);
model->setReadOnly(true);
if (success) {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
@@ -748,7 +817,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(arguments.at(2).toString(), newFileName);
QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
// cleanup
if (!subdirName.isEmpty())
QVERIFY(QDir(tmp).removeRecursively());
@@ -762,6 +831,8 @@ void tst_QFileSystemModel::sortPersistentIndex()
file.close();
QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
@@ -792,7 +863,7 @@ void tst_QFileSystemModel::sort()
QTreeView tree;
tree.setWindowTitle(QTest::currentTestFunction());
- if (fileDialogMode && EmulationDetector::isRunningArmOnX86())
+ if (fileDialogMode && QTestPrivate::isRunningArmOnX86())
QSKIP("Crashes in QEMU. QTBUG-70572");
#ifdef QT_BUILD_INTERNAL
@@ -806,13 +877,13 @@ void tst_QFileSystemModel::sort()
//Create a file that will be at the end when sorting by name (For Mac, the default)
//but if we sort by size descending it will be the first
QFile tempFile(dirPath + "/plop2.txt");
- tempFile.open(QIODevice::WriteOnly | QIODevice::Text);
+ QVERIFY(tempFile.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&tempFile);
out << "The magic number is: " << 49 << "\n";
tempFile.close();
QFile tempFile2(dirPath + "/plop.txt");
- tempFile2.open(QIODevice::WriteOnly | QIODevice::Text);
+ QVERIFY(tempFile2.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out2(&tempFile2);
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
tempFile2.close();
@@ -841,7 +912,7 @@ void tst_QFileSystemModel::sort()
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) {
- QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
+ QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.size());
// File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list
@@ -868,6 +939,8 @@ void tst_QFileSystemModel::mkdir()
QString tmp = flatDirTestPath;
QString newFolderPath = QDir::toNativeSeparators(tmp + '/' + "NewFoldermkdirtest4");
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex tmpDir = model->index(tmp);
QVERIFY(tmpDir.isValid());
QDir bestatic(newFolderPath);
@@ -903,6 +976,8 @@ void tst_QFileSystemModel::deleteFile()
}
newFile.close();
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex idx = model->index(newFilePath);
QVERIFY(idx.isValid());
QVERIFY(model->remove(idx));
@@ -965,12 +1040,14 @@ void tst_QFileSystemModel::caseSensitivity()
QStringList files;
files << "a" << "c" << "C";
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, files));
QModelIndex root = model->index(tmp);
QStringList paths;
QModelIndexList indexes;
QCOMPARE(model->rowCount(root), 0);
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
const QString path = tmp + '/' + files.at(i);
const QModelIndex index = model->index(path);
QVERIFY(index.isValid());
@@ -980,7 +1057,7 @@ void tst_QFileSystemModel::caseSensitivity()
if (!QFileSystemEngine::isCaseSensitive()) {
// QTBUG-31103, QTBUG-64147: Verify that files can be accessed by paths with fLipPeD case.
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < paths.size(); ++i) {
const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i)));
QCOMPARE(indexes.at(i), flippedCaseIndex);
}
@@ -1001,11 +1078,12 @@ void tst_QFileSystemModel::drives()
QFileSystemModel model;
model.setRootPath(path);
model.fetchMore(QModelIndex());
- QFileInfoList drives = QDir::drives();
+ const QFileInfoList drives = QDir::drives();
int driveCount = 0;
- foreach(const QFileInfo& driveRoot, drives)
+ for (const QFileInfo& driveRoot : drives) {
if (driveRoot.exists())
driveCount++;
+ }
QTRY_COMPARE(model.rowCount(), driveCount);
}
@@ -1030,6 +1108,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
}
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = model->setRootPath(dir.absolutePath());
// Wait for model to be notified by the file system watcher
QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
@@ -1104,6 +1184,8 @@ void tst_QFileSystemModel::permissions() // checks QTBUG-20503
const QString tmp = flatDirTestPath;
const QString file = tmp + QLatin1String("/f");
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, QStringList{QLatin1String("f")}));
QVERIFY(QFile::setPermissions(file, permissions));
@@ -1168,6 +1250,9 @@ void tst_QFileSystemModel::specialFiles()
#ifndef Q_OS_UNIX
QSKIP("Not implemented");
#endif
+#ifdef Q_OS_ANDROID
+ QSKIP("Android does not allow access to root filesystem");
+#endif
QFileSystemModel model;