diff options
author | João Abecasis <joao@abecasis.name> | 2009-04-02 15:17:16 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-04-02 17:13:35 (GMT) |
commit | b2b11265d9cf20706eadca61c37d931886eb35cf (patch) | |
tree | 759504fdafd6462a6e9febadaa9626942f54978c /tests/auto/qfile/tst_qfile.cpp | |
parent | fb5790e1b1d4ddeac19a2996c806744509de4ac8 (diff) | |
download | Qt-b2b11265d9cf20706eadca61c37d931886eb35cf.zip Qt-b2b11265d9cf20706eadca61c37d931886eb35cf.tar.gz Qt-b2b11265d9cf20706eadca61c37d931886eb35cf.tar.bz2 |
Adding auto-tests for commits a2fcc4a5 and 8d500381
Task-number: 244500
Task-number: 244485
Reviewed-by: ossi
Reviewed-by: thiago
Diffstat (limited to 'tests/auto/qfile/tst_qfile.cpp')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 48902c7..829e0b3 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -169,6 +169,8 @@ private slots: void rename_data(); void rename(); void renameWithAtEndSpecialFile() const; + void renameFallback(); + void renameMultiple(); void appendAndRead(); void miscWithUncPathAsCurrentDir(); void standarderror(); @@ -214,6 +216,14 @@ void tst_QFile::cleanup() { // TODO: Add cleanup code here. // This will be executed immediately after each test is run. + + // for renameFallback() + QFile::remove("file-rename-destination.txt"); + + // for renameMultiple() + QFile::remove("file-to-be-renamed.txt"); + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); } void tst_QFile::initTestCase() @@ -2091,6 +2101,42 @@ void tst_QFile::renameWithAtEndSpecialFile() const QVERIFY(QFile::rename(newName, originalName)); } +void tst_QFile::renameFallback() +{ + // Using a resource file both to trigger QFile::rename's fallback handling + // and as a *read-only* source whose move should fail. + QFile file(":/rename-fallback.qrc"); + QVERIFY(file.exists() && "(test-precondition)"); + QFile::remove("file-rename-destination.txt"); + + QVERIFY(!file.rename("file-rename-destination.txt")); + QVERIFY(!QFile::exists("file-rename-destination.txt")); +} + +void tst_QFile::renameMultiple() +{ + // create the file if it doesn't exist + QFile file("file-to-be-renamed.txt"); + QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)"); + + // any stale files from previous test failures? + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); + + // begin testing + QVERIFY(file.rename("file-renamed-once.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-once.txt")); + QVERIFY(file.rename("file-renamed-twice.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-twice.txt")); + + QVERIFY(!QFile::exists("file-to-be-renamed.txt")); + QVERIFY(!QFile::exists("file-renamed-once.txt")); + QVERIFY(QFile::exists("file-renamed-twice.txt")); + + file.remove(); + QVERIFY(!QFile::exists("file-renamed-twice.txt")); +} + void tst_QFile::appendAndRead() { QFile writeFile(QLatin1String("appendfile.txt")); |