summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-07-13 17:26:43 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-14 08:56:21 +0000
commit6e1289638da9479b640734132e7b9a7b853a47bb (patch)
treeac3d8e08a4233aa1f9a6b4328e3abbb66982c62f /tests
parenta0ce6b44610ac61021c87761a9014ba650bfc04d (diff)
QCompleter: make filesystem test robust against slow I/O
Use a signal spy to watch for the relevant signal from the file system model and wait for that before checking whether the completer responded to that signal by showing (or not showing) the popup. If the file system model doesn't fire within the default timeout of 5 seconds, skip the rest of the test. Fixes: QTBUG-46113 Change-Id: I9becfe19a220bdb178ed8275c327d55ea19aa342 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit d609b20842c0493b13a24653ad0064d6f98d957b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 897608bca8..76b12d7aea 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1636,6 +1636,7 @@ void tst_QCompleter::QTBUG_14292_filesystem()
// to pop up the completion list due to file changed signals.
FileSystem fs;
QFileSystemModel model;
+ QSignalSpy filesAddedSpy(&model, &QAbstractItemModel::rowsInserted);
model.setRootPath(fs.path());
QVERIFY(fs.createDirectory(QLatin1String(testDir1)));
@@ -1672,13 +1673,16 @@ void tst_QCompleter::QTBUG_14292_filesystem()
QTest::keyClick(&edit, 'r');
QTRY_VERIFY(!comp.popup()->isVisible());
QVERIFY(fs.createDirectory(QStringLiteral("hero")));
+ if (!filesAddedSpy.wait())
+ QSKIP("File system model didn't notify about new directory, skipping tests");
QTRY_VERIFY(comp.popup()->isVisible());
QCOMPARE(comp.popup()->model()->rowCount(), 1);
QTest::keyClick(comp.popup(), Qt::Key_Escape);
QTRY_VERIFY(!comp.popup()->isVisible());
QVERIFY(fs.createDirectory(QStringLiteral("nothingThere")));
//there is no reason creating a file should open a popup, it did in Qt 4.7.0
- QTest::qWait(60);
+ if (!filesAddedSpy.wait())
+ QSKIP("File system model didn't notify about new file, skipping tests");
QVERIFY(!comp.popup()->isVisible());
QTest::keyClick(&edit, Qt::Key_Backspace);
@@ -1696,7 +1700,8 @@ void tst_QCompleter::QTBUG_14292_filesystem()
QVERIFY(fs.createDirectory(QStringLiteral("hemo")));
//there is no reason creating a file should open a popup, it did in Qt 4.7.0
- QTest::qWait(60);
+ if (!filesAddedSpy.wait())
+ QSKIP("File system model didn't notify about new file, skipping tests");
QVERIFY(!comp.popup()->isVisible());
}