Stabilize tst_QFileSystemModel::showFilesOnly test case
Amends 83e5d74864a8780445db4b34e406afc53b331039. A model index returned by QFileSystemModel might become invalid when events get processed, so don't store the result of setRootPath to re-use it in a QTRY_COMPARE function. Instead, always ask for a fresh model index. Also, use std::chrono::duration::count correctly; it returns the "tick", not the corresponding milliseconds, so (10s).count() returns 10 instead of 10000. Explicitly use 10000ms here. Un-blacklist the test on macOS again. Task-number: QTBUG-74471 Pick-to: 6.6 6.5 Change-Id: Ic98bb53c696441131bbc1055b64822faf2aec96f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 72f5b35b3d7704db6ef16e4c60751ed8444363be) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
108990dc13
commit
e20f2a6c8b
@ -3,5 +3,3 @@ ubuntu
|
||||
b2qt
|
||||
[specialFiles]
|
||||
b2qt
|
||||
[showFilesOnly]
|
||||
macos
|
||||
|
@ -689,14 +689,17 @@ void tst_QFileSystemModel::showFilesOnly()
|
||||
const auto subdir = u"sub_directory"_s;
|
||||
QVERIFY(createFiles(&model, tmp, files, 0, {subdir}));
|
||||
|
||||
// The model changes asynchronously when we run the event loop in the QTRY_...
|
||||
// macros, so the root index returned by an earlier call to setRootPath might
|
||||
// become invalid. Make sure we use a fresh one for each iteration.
|
||||
|
||||
// QTBUG-74471
|
||||
// WHAT: setting the root path of the model to a dir with some files and a subdir
|
||||
QModelIndex root = model.setRootPath(tmp);
|
||||
QTRY_COMPARE(model.rowCount(root), files.size() + 1);
|
||||
QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size() + 1);
|
||||
|
||||
// Change the model to only show files
|
||||
model.setFilter(QDir::Files);
|
||||
QTRY_COMPARE(model.rowCount(root), files.size());
|
||||
QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size());
|
||||
|
||||
// WHEN: setting the root path to a subdir
|
||||
QModelIndex subIndex = model.setRootPath(tmp + u'/' + subdir);
|
||||
@ -704,9 +707,9 @@ void tst_QFileSystemModel::showFilesOnly()
|
||||
|
||||
// THEN: setting the root path to the previous (parent) dir, the model should
|
||||
// still only show files.
|
||||
root = model.setRootPath(tmp);
|
||||
// Doubling the default timeout (5s) as this test to fails on macos on the CI
|
||||
QTRY_COMPARE_WITH_TIMEOUT(model.rowCount(root), files.size(), (10s).count());
|
||||
QTRY_COMPARE_WITH_TIMEOUT(model.rowCount(model.setRootPath(tmp)), files.size(),
|
||||
(10000ms).count());
|
||||
}
|
||||
|
||||
void tst_QFileSystemModel::nameFilters()
|
||||
|
Loading…
x
Reference in New Issue
Block a user