diff options
author | axis <qt-info@nokia.com> | 2009-05-25 11:26:23 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-05-25 11:26:23 (GMT) |
commit | de01a7e1e827ee7df035e0b32166db2263712e63 (patch) | |
tree | 3a5cda42d360c63c027afd80eb2e6715faa72aaa /tests/auto/qfile | |
parent | 4c06cd950d27ba10d2288d508cbaef4e44abee91 (diff) | |
parent | 44d992ca150d9448cb7b9114b2bc489b441c7b76 (diff) | |
download | Qt-de01a7e1e827ee7df035e0b32166db2263712e63.zip Qt-de01a7e1e827ee7df035e0b32166db2263712e63.tar.gz Qt-de01a7e1e827ee7df035e0b32166db2263712e63.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
src/corelib/io/qfile.cpp
src/corelib/kernel/qsharedmemory_unix.cpp
src/network/socket/qnativesocketengine_p.h
src/network/socket/qnativesocketengine_unix.cpp
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r-- | tests/auto/qfile/copy-fallback.qrc | 5 | ||||
-rw-r--r-- | tests/auto/qfile/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 37 |
3 files changed, 43 insertions, 1 deletions
diff --git a/tests/auto/qfile/copy-fallback.qrc b/tests/auto/qfile/copy-fallback.qrc new file mode 100644 index 0000000..864491f --- /dev/null +++ b/tests/auto/qfile/copy-fallback.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>copy-fallback.qrc</file> +</qresource> +</RCC> diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index b51eff6..80102f0 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -23,7 +23,7 @@ wince*:{ DEFINES += SRCDIR=\\\"$$PWD/../\\\" } -RESOURCES += ../qfile.qrc ../rename-fallback.qrc +RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc TARGET = ../tst_qfile diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 483e978..597343f 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -128,6 +128,7 @@ private slots: void copy(); void copyRemovesTemporaryFile() const; void copyShouldntOverwrite(); + void copyFallback(); void link(); void linkToDir(); void absolutePathLinkToRelativePath(); @@ -216,6 +217,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"); @@ -921,6 +929,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> @@ -2109,6 +2145,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() |