summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtemporaryfile
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-05-25 11:26:23 (GMT)
committeraxis <qt-info@nokia.com>2009-05-25 11:26:23 (GMT)
commitde01a7e1e827ee7df035e0b32166db2263712e63 (patch)
tree3a5cda42d360c63c027afd80eb2e6715faa72aaa /tests/auto/qtemporaryfile
parent4c06cd950d27ba10d2288d508cbaef4e44abee91 (diff)
parent44d992ca150d9448cb7b9114b2bc489b441c7b76 (diff)
downloadQt-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/qtemporaryfile')
-rw-r--r--tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
index 8cae64e..543a116 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();
@@ -86,6 +87,8 @@ private slots:
void stressTest();
void rename();
void renameFdLeak();
+ void reOpenThroughQFile();
+
public:
};
@@ -189,6 +192,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 +382,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));
@@ -401,5 +426,18 @@ void tst_QTemporaryFile::renameFdLeak()
#endif
}
+void tst_QTemporaryFile::reOpenThroughQFile()
+{
+ QByteArray data("abcdefghij");
+
+ QTemporaryFile file;
+ QVERIFY(((QFile &)file).open(QIODevice::WriteOnly));
+ QCOMPARE(file.write(data), (qint64)data.size());
+
+ file.close();
+ QVERIFY(file.open());
+ QCOMPARE(file.readAll(), data);
+}
+
QTEST_MAIN(tst_QTemporaryFile)
#include "tst_qtemporaryfile.moc"