summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-01-09 09:11:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-15 16:36:20 +0100
commitd3dc0f21225845f404262ea563870044cbbbe53f (patch)
tree595c5553aa6abd5fba4c6c22bb8762c812dafc11 /tests/auto
parentcd7ba89a07f794b17fc66ba29515b104c4d21f27 (diff)
Fix renaming of files that differ only in case.
This currently fails on case-insensitive file systems since the check for existence then triggered and indicated "file already exists". Check on the file id (inode or file id) whether the target file is really a different file for a case-changing rename. Task-number: QTBUG-3570 Change-Id: I1b2d40850692e02142ee23d2c753428de00aedc6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 61a1fea343..f523225ef1 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -51,6 +51,7 @@
#include <private/qabstractfileengine_p.h>
#include <private/qfsfileengine_p.h>
+#include <private/qfilesystemengine_p.h>
#ifdef Q_OS_WIN
QT_BEGIN_NAMESPACE
@@ -2418,6 +2419,7 @@ void tst_QFile::rename_data()
#endif
QTest::newRow("renamefile -> renamedfile") << QString::fromLatin1(renameSourceFile) << QString("renamedfile") << true;
QTest::newRow("renamefile -> ..") << QString::fromLatin1(renameSourceFile) << QString("..") << false;
+ QTest::newRow("renamefile -> rEnAmEfIlE") << QString::fromLatin1(renameSourceFile) << QStringLiteral("rEnAmEfIlE") << true;
}
void tst_QFile::rename()
@@ -2435,7 +2437,8 @@ void tst_QFile::rename()
}
#endif
- QFile sourceFile(QString::fromLatin1(renameSourceFile));
+ const QString sourceFileName = QString::fromLatin1(renameSourceFile);
+ QFile sourceFile(sourceFileName);
QVERIFY2(sourceFile.open(QFile::WriteOnly | QFile::Text), qPrintable(sourceFile.errorString()));
QVERIFY2(sourceFile.write(content), qPrintable(sourceFile.errorString()));
sourceFile.close();
@@ -2445,7 +2448,10 @@ void tst_QFile::rename()
if (result) {
QVERIFY2(success, qPrintable(file.errorString()));
QCOMPARE(file.error(), QFile::NoError);
- QVERIFY(!sourceFile.exists());
+ // This will report the source file still existing for a rename changing the case
+ // on Windows, Mac.
+ if (sourceFileName.compare(destination, Qt::CaseInsensitive))
+ QVERIFY(!sourceFile.exists());
QFile destinationFile(destination);
QVERIFY2(destinationFile.open(QFile::ReadOnly | QFile::Text), qPrintable(destinationFile.errorString()));
QCOMPARE(destinationFile.readAll(), content);