diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-02-07 09:37:10 -0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-15 22:25:46 +0000 |
commit | cffe6800d1db6ef810715d884ee20c07e388fef9 (patch) | |
tree | 0e719db27196167449a3be36dc1118010f685b38 /tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | |
parent | 8bb9290b72b379c9af6ae99b9f9b66235fd99675 (diff) | |
download | qtbase-cffe6800d1db6ef810715d884ee20c07e388fef9.tar.gz |
QFileSystemWatcher/Win: remove the pre-QFileInfo path normalization
It's completely unnecessary, since QFileInfo will query the file system
anyway and that has a much better view of what is normalized and what
isn't. More importantly, this fixes the mistake in failing to normalize
properly in removePaths(), which removed the ending slash of a root
directory such as "C:\\". That caused the path to become "C:", which
QFileInfo interprets as "current path on drive C:".
[ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that prevented
removePaths() from removing the root of a drive on Windows.
Fixes: QTBUG-110986
Change-Id: I9671dee8ceb64aa9b9cafffd17419b6d69670876
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 6d1769791348e9387e0c5f29d970131895888814)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp')
-rw-r--r-- | tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 5acab6e473..dfdf4e05c1 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -396,8 +396,14 @@ void tst_QFileSystemWatcher::addPaths() QFileSystemWatcher watcher; QStringList paths; paths << QDir::homePath() << QDir::tempPath(); +#ifndef Q_OS_QNX + // Adding this makes QNX fail and we haven't investigated why + for (const QFileInfo &fi : QDir::drives()) + paths << fi.absoluteFilePath(); // on Unix, this will be just "/" +#endif + QCOMPARE(watcher.addPaths(paths), QStringList()); - QCOMPARE(watcher.directories().size(), 2); + QCOMPARE(watcher.directories().size(), paths.size()); // With empty list paths.clear(); @@ -464,8 +470,14 @@ void tst_QFileSystemWatcher::removePaths() QFileSystemWatcher watcher; QStringList paths; paths << QDir::homePath() << QDir::tempPath(); +#ifndef Q_OS_QNX + // Adding this makes QNX fail and we haven't investigated why + for (const QFileInfo &fi : QDir::drives()) + paths << fi.absoluteFilePath(); // on Unix, this will be just "/" +#endif + QCOMPARE(watcher.addPaths(paths), QStringList()); - QCOMPARE(watcher.directories().size(), 2); + QCOMPARE(watcher.directories().size(), paths.size()); QCOMPARE(watcher.removePaths(paths), QStringList()); QCOMPARE(watcher.directories().size(), 0); @@ -613,9 +625,11 @@ void tst_QFileSystemWatcher::nonExistingFile() QStringList() << "../..//./does-not-exist"); // empty path is not actually a failure + QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::addPaths: list is empty"); QCOMPARE(watcher.addPaths(QStringList() << QString()), QStringList()); // empty path is not actually a failure + QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::removePaths: list is empty"); QCOMPARE(watcher.removePaths(QStringList() << QString()), QStringList()); } |