Improve QDirModel autotest
The unreadable() test function has been disabled since before the tests were imported into the Qt repository. The idea of the test seems valid (though the original implementation failed to correctly create an unreadable file), so it should be re-enabled. Change-Id: I94634bc5785dfbfbb42ca975badaead7fe812b29 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
65ece490a9
commit
edc77f5aa8
@ -63,10 +63,15 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
void init();
|
void init();
|
||||||
|
#endif
|
||||||
void cleanup();
|
void cleanup();
|
||||||
private slots:
|
private slots:
|
||||||
void getSetCheck();
|
void getSetCheck();
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
void unreadable();
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
void construct();
|
void construct();
|
||||||
void rowCount();
|
void rowCount();
|
||||||
@ -158,9 +163,20 @@ void tst_QDirModel::cleanupTestCase()
|
|||||||
current.rmdir(".qtest_hidden");
|
current.rmdir(".qtest_hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
void tst_QDirModel::init()
|
void tst_QDirModel::init()
|
||||||
{
|
{
|
||||||
|
if (QTest::currentTestFunction() == QLatin1String( "unreadable" )) {
|
||||||
|
// Make sure that the unreadable file created by the unreadable()
|
||||||
|
// test function doesn't already exist.
|
||||||
|
QFile unreadableFile(QDir::currentPath() + "qtest_unreadable");
|
||||||
|
if (unreadableFile.exists()) {
|
||||||
|
unreadableFile.remove();
|
||||||
|
QVERIFY(!unreadableFile.exists());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tst_QDirModel::cleanup()
|
void tst_QDirModel::cleanup()
|
||||||
{
|
{
|
||||||
@ -554,24 +570,28 @@ void tst_QDirModel::fileName()
|
|||||||
QCOMPARE(model.fileName(model.index(path)), result);
|
QCOMPARE(model.fileName(model.index(path)), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
void tst_QDirModel::unreadable()
|
void tst_QDirModel::unreadable()
|
||||||
{
|
{
|
||||||
//QFile current("qtest_unreadable");
|
// Create an empty file which has no read permissions (file will be removed by cleanup()).
|
||||||
//QVERIFY(current.setPermissions(QFile::WriteOwner));
|
QFile unreadableFile(QDir::currentPath() + "qtest_unreadable");
|
||||||
|
QVERIFY2(unreadableFile.open(QIODevice::WriteOnly | QIODevice::Text), qPrintable(unreadableFile.errorString()));
|
||||||
|
unreadableFile.close();
|
||||||
|
QVERIFY(unreadableFile.exists());
|
||||||
|
QVERIFY2(unreadableFile.setPermissions(QFile::WriteOwner), qPrintable(unreadableFile.errorString()));
|
||||||
|
|
||||||
|
// Check that we can't make a valid model index from an unreadable file.
|
||||||
QDirModel model;
|
QDirModel model;
|
||||||
QModelIndex index = model.index(QDir::currentPath() + "/qtest_unreadable");
|
QModelIndex index = model.index(QDir::currentPath() + "/qtest_unreadable");
|
||||||
QVERIFY(!index.isValid());
|
QVERIFY(!index.isValid());
|
||||||
|
|
||||||
|
// Check that unreadable files are not treated like hidden files.
|
||||||
QDirModel model2;
|
QDirModel model2;
|
||||||
model2.setFilter(model2.filter() | QDir::Hidden);
|
model2.setFilter(model2.filter() | QDir::Hidden);
|
||||||
index = model2.index(QDir::currentPath() + "/qtest_unreadable");
|
index = model2.index(QDir::currentPath() + "/qtest_unreadable");
|
||||||
QVERIFY(index.isValid());
|
QVERIFY(!index.isValid());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
void tst_QDirModel::filePath()
|
void tst_QDirModel::filePath()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user