QTemporaryFile: Test what happens if current dir isn't writable.
No surprises, QTemporaryFile("tempXXXXXX") fails. But that is consistent with QFile::open, and it's documented, so ok. Change-Id: I04c805a242aeda8327d25be238da6120b3c90f5a Merge-request: 57 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Reviewed-on: http://codereview.qt-project.org/5714 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
This commit is contained in:
parent
c7a0fd0950
commit
e316deffef
@ -87,6 +87,7 @@ private slots:
|
||||
void fileName();
|
||||
void fileNameIsEmpty();
|
||||
void autoRemove();
|
||||
void nonWritableCurrentDir();
|
||||
void write();
|
||||
void openCloseOpenClose();
|
||||
void size();
|
||||
@ -290,6 +291,22 @@ void tst_QTemporaryFile::autoRemove()
|
||||
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::nonWritableCurrentDir()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
QString cwd = QDir::currentPath();
|
||||
QDir::setCurrent("/");
|
||||
// QTemporaryFile("tempXXXXXX") is probably a bad idea in any app
|
||||
// where the current dir could anything...
|
||||
QString fileName;
|
||||
QTemporaryFile file("tempXXXXXX");
|
||||
file.setAutoRemove(true);
|
||||
QVERIFY(!file.open());
|
||||
fileName = file.fileName();
|
||||
QDir::setCurrent(cwd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::write()
|
||||
{
|
||||
QByteArray data("OLE\nOLE\nOLE");
|
||||
|
Loading…
Reference in New Issue
Block a user