diff options
author | João Abecasis <joao@abecasis.name> | 2009-05-18 10:40:01 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-05-22 12:33:42 (GMT) |
commit | cfa01206e38d120c0ddb17aec7358aadff30b6f5 (patch) | |
tree | 44c1b74bccb3b7be4e5aa78ce99de070642e4e64 /tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | |
parent | 662e8997e9777c6661dde2134e43e35963a12cb6 (diff) | |
download | Qt-cfa01206e38d120c0ddb17aec7358aadff30b6f5.zip Qt-cfa01206e38d120c0ddb17aec7358aadff30b6f5.tar.gz Qt-cfa01206e38d120c0ddb17aec7358aadff30b6f5.tar.bz2 |
QTemporaryFile would forget fileName while file was "closed"
Note: this showed even if the file descriptor was kept open.
Reviewed-by: Peter Hartmann
Reviewed-by: Thiago
Diffstat (limited to 'tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp')
-rw-r--r-- | tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index 2daa0f6..c6a43ff 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -77,6 +77,7 @@ private slots: void fileTemplate_data(); void getSetCheck(); void fileName(); + void fileNameIsEmpty(); void autoRemove(); void write(); void openCloseOpenClose(); @@ -189,6 +190,27 @@ void tst_QTemporaryFile::fileName() QCOMPARE(absoluteFilePath, absoluteTempPath); } +void tst_QTemporaryFile::fileNameIsEmpty() +{ + QString filename; + { + QTemporaryFile file; + QVERIFY(file.fileName().isEmpty()); + + QVERIFY(file.open()); + QVERIFY(!file.fileName().isEmpty()); + + filename = file.fileName(); + QVERIFY(QFile::exists(filename)); + + file.close(); + QVERIFY(!file.isOpen()); + QVERIFY(QFile::exists(filename)); + QVERIFY(!file.fileName().isEmpty()); + } + QVERIFY(!QFile::exists(filename)); +} + void tst_QTemporaryFile::autoRemove() { // Test auto remove @@ -358,6 +380,7 @@ void tst_QTemporaryFile::rename() QVERIFY(file.rename("temporary-file.txt")); QVERIFY(!dir.exists(tempname)); QVERIFY(dir.exists("temporary-file.txt")); + QCOMPARE(file.fileName(), QString("temporary-file.txt")); } QVERIFY(!dir.exists(tempname)); |