Test QFileInfo::isWritable when it should return false
Extend existing tests to verify that QFileInfo::isWritable returns false when file is read-only or non-existent. Task-number: QTBUG-124011 Pick-to: 6.8 6.7 6.5 Change-Id: If41241b500aa76036b39a53590b5e0b6ab2f20ea Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2bc82f6a11
commit
42004d245e
@ -1905,9 +1905,24 @@ void tst_QFileInfo::isWritable()
|
||||
tempfile.write("This file is generated by the QFileInfo autotest.");
|
||||
tempfile.close();
|
||||
|
||||
// isWritable returns true when file is writable
|
||||
QVERIFY(QFileInfo("tempfile.txt").isWritable());
|
||||
|
||||
QFile::setPermissions("tempfile.txt",
|
||||
QFileDevice::ReadOwner | QFileDevice::ReadUser | QFileDevice::ReadGroup);
|
||||
|
||||
// isWritable returns false when read-only, unless root
|
||||
bool isRoot = false;
|
||||
#if defined (Q_OS_UNIX)
|
||||
isRoot = (geteuid() == 0);
|
||||
#endif
|
||||
QCOMPARE(QFileInfo("tempfile.txt").isWritable(), isRoot);
|
||||
|
||||
tempfile.remove();
|
||||
|
||||
// isWritable returns false when file does not exist
|
||||
QVERIFY(!QFileInfo("tempfile.txt").isWritable());
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
QFileInfo fi("c:\\pagefile.sys");
|
||||
QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
|
||||
|
Loading…
x
Reference in New Issue
Block a user