diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-05-22 16:50:30 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-05-22 16:50:30 (GMT) |
commit | d9ab330f613bd2c921ba00ed36b6eea8927aec80 (patch) | |
tree | 8a5337dac7617fe8e654fd4ffd1302c587967c76 /tests/auto/qfile/tst_qfile.cpp | |
parent | dacc8cb0b2abd5ec3e9603c9bcf5b8f489639404 (diff) | |
parent | 701bdcbc8b7751834f6d24844bcb91a23cbdc409 (diff) | |
download | Qt-d9ab330f613bd2c921ba00ed36b6eea8927aec80.zip Qt-d9ab330f613bd2c921ba00ed36b6eea8927aec80.tar.gz Qt-d9ab330f613bd2c921ba00ed36b6eea8927aec80.tar.bz2 |
Merge branch '4.5'
Conflicts:
src/corelib/kernel/qsharedmemory_unix.cpp
Diffstat (limited to 'tests/auto/qfile/tst_qfile.cpp')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index cb8091b..d650b0d 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -126,6 +126,7 @@ private slots: void copyAfterFail(); void copyRemovesTemporaryFile() const; void copyShouldntOverwrite(); + void copyFallback(); void link(); void linkToDir(); void absolutePathLinkToRelativePath(); @@ -214,6 +215,13 @@ void tst_QFile::cleanup() // TODO: Add cleanup code here. // This will be executed immediately after each test is run. + // for copyFallback() + if (QFile::exists("file-copy-destination.txt")) { + QFile::setPermissions("file-copy-destination.txt", + QFile::ReadOwner | QFile::WriteOwner); + QFile::remove("file-copy-destination.txt"); + } + // for renameFallback() QFile::remove("file-rename-destination.txt"); @@ -948,6 +956,34 @@ void tst_QFile::copyShouldntOverwrite() QFile::remove("tst_qfile.cpy"); } +void tst_QFile::copyFallback() +{ + // Using a resource file to trigger QFile::copy's fallback handling + QFile file(":/copy-fallback.qrc"); + QFile::remove("file-copy-destination.txt"); + + QVERIFY2(file.exists(), "test precondition"); + QVERIFY2(!QFile::exists("file-copy-destination.txt"), "test precondition"); + + // Fallback copy of closed file. + QVERIFY(file.copy("file-copy-destination.txt")); + QVERIFY(QFile::exists("file-copy-destination.txt")); + QVERIFY(!file.isOpen()); + + // Need to reset permissions on Windows to be able to delete + QVERIFY(QFile::setPermissions("file-copy-destination.txt", + QFile::ReadOwner | QFile::WriteOwner)); + QVERIFY(QFile::remove("file-copy-destination.txt")); + + // Fallback copy of open file. + QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(file.copy("file-copy-destination.txt")); + QVERIFY(QFile::exists("file-copy-destination.txt")); + QVERIFY(!file.isOpen()); + + QFile::remove("file-copy-destination.txt"); +} + #ifdef Q_OS_WIN #include <objbase.h> #include <shlobj.h> @@ -2122,6 +2158,7 @@ void tst_QFile::renameFallback() QVERIFY(!file.rename("file-rename-destination.txt")); QVERIFY(!QFile::exists("file-rename-destination.txt")); + QVERIFY(!file.isOpen()); } void tst_QFile::renameMultiple() |