summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-11-20 16:16:55 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-11-30 10:16:48 +0000
commit58b70c2f1acedad0df6b4de1acf3dea2011e369c (patch)
treedae1e0e2719540f017f96c453824300c7b4f9848 /tests/auto/widgets
parent6508fdca1dcc7105947befadba272d0fd4bbc27f (diff)
tst_QFileSystemModel: Stabilize readOnly(), sortPersistentIndex()
The tests start to show flakyness on Linux in 5.10 (rowCount() check failing). This seems to point to a race condition between the files showing up and the file system watchers of QFileSystemModel starting. To fix this, close the file and wait until it shows up in the directory before pointing the QFileSystemModel to it. The tests then no longer rely on the file system watchers. Change-Id: I39cffb4cacf6843e8e4180efb405345307c78dd8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 31df66e312..979d5c632e 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -239,13 +239,18 @@ void tst_QFileSystemModel::readOnly()
QCOMPARE(model->isReadOnly(), true);
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
QVERIFY2(file.open(), qPrintable(file.errorString()));
+ const QString fileName = file.fileName();
+ file.close();
+
+ const QFileInfo fileInfo(fileName);
+ QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
- QVERIFY(!(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable));
+ QVERIFY(!(model->flags(model->index(fileName)) & Qt::ItemIsEditable));
model->setReadOnly(false);
QCOMPARE(model->isReadOnly(), false);
- QVERIFY(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable);
+ QVERIFY(model->flags(model->index(fileName)) & Qt::ItemIsEditable);
}
class CustomFileIconProvider : public QFileIconProvider
@@ -729,6 +734,9 @@ void tst_QFileSystemModel::sortPersistentIndex()
{
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
QVERIFY2(file.open(), qPrintable(file.errorString()));
+ const QFileInfo fileInfo(file.fileName());
+ file.close();
+ QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);