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 Pick-to: 6.4 6.3 6.2 Change-Id: I9becfe19a220bdb178ed8275c327d55ea19aa342 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
826a98cff1
commit
d609b20842
@ -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