From fcbaa8ec385e796c18cf317e8f364bd8e3c2538b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 20 Nov 2017 15:30:20 +0100 Subject: QFileSystemModel/Windows: Make file name checking case-insensitive Introduce a special hash modeled on the one used for QFileSystemWatcher on Windows. Task-number: QTBUG-31103 Task-number: QTBUG-64147 Change-Id: I69ebabe841716e4957ae3fb04fa5c43d233a3552 Reviewed-by: Oliver Wolff Reviewed-by: Richard Moe Gustavsen --- .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 979d5c632e..71efe1d59a 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -43,6 +43,7 @@ #if defined(Q_OS_WIN) # include // for SetFileAttributes #endif +#include #include @@ -883,6 +884,18 @@ void tst_QFileSystemModel::deleteFile() QVERIFY(!newFile.exists()); } +static QString flipCase(QString s) +{ + for (int i = 0, size = s.size(); i < size; ++i) { + const QChar c = s.at(i); + if (c.isUpper()) + s[i] = c.toLower(); + else if (c.isLower()) + s[i] = c.toUpper(); + } + return s; +} + void tst_QFileSystemModel::caseSensitivity() { QString tmp = flatDirTestPath; @@ -890,9 +903,23 @@ void tst_QFileSystemModel::caseSensitivity() files << "a" << "c" << "C"; QVERIFY(createFiles(tmp, files)); QModelIndex root = model->index(tmp); + QStringList paths; + QModelIndexList indexes; QCOMPARE(model->rowCount(root), 0); for (int i = 0; i < files.count(); ++i) { - QVERIFY(model->index(tmp + '/' + files.at(i)).isValid()); + const QString path = tmp + '/' + files.at(i); + const QModelIndex index = model->index(path); + QVERIFY(index.isValid()); + paths.append(path); + indexes.append(index); + } + + 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) { + const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i))); + QCOMPARE(indexes.at(i), flippedCaseIndex); + } } } -- cgit v1.2.3