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>
This commit is contained in:
parent
a0ce6b4461
commit
6e1289638d
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user