summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-12-10 14:58:12 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-12-10 17:07:48 +0000
commit0d54b0f4ddb3ec3e14f39d954eb43b10100bbce9 (patch)
treeb2fa4acc13a4b6bbf7d7811694e84d6b7d30d65a /tests/auto/widgets
parentf0c75bb050badf69e5e24bc44a2b2de601b11069 (diff)
QFileSystemModel: do not unwatch directories if removal fails
... otherwise we would not detect subsequent file/directories added into the non-removed one. Change-Id: I43018dfb9a9c6c0399190800da3f0d572ec5d8d8 Task-number: QTBUG-49307 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 3252650d12..996d919591 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -123,6 +123,8 @@ private slots:
void permissions_data();
void permissions();
+ void doNotUnwatchOnFailedRmdir();
+
protected:
bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList());
@@ -1043,6 +1045,35 @@ void tst_QFileSystemModel::permissions() // checks QTBUG-20503
QCOMPARE(fileInfoPermissions, modelPermissions);
}
+void tst_QFileSystemModel::doNotUnwatchOnFailedRmdir()
+{
+ const QString tmp = flatDirTestPath;
+
+ QFileSystemModel model;
+
+ const QTemporaryDir tempDir(tmp + '/' + QStringLiteral("doNotUnwatchOnFailedRmdir-XXXXXX"));
+ QVERIFY(tempDir.isValid());
+
+ const QModelIndex rootIndex = model.setRootPath(tempDir.path());
+
+ // create a file in the directory so to prevent it from deletion
+ {
+ QFile file(tempDir.path() + '/' + QStringLiteral("file1"));
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ }
+
+ QCOMPARE(model.rmdir(rootIndex), false);
+
+ // create another file
+ {
+ QFile file(tempDir.path() + '/' + QStringLiteral("file2"));
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ }
+
+ // the model must now detect this second file
+ QTRY_COMPARE(model.rowCount(rootIndex), 2);
+}
+
QTEST_MAIN(tst_QFileSystemModel)
#include "tst_qfilesystemmodel.moc"