Skip to content

Commit

Permalink
Fix flakiness in qquicklistmodel autotest
Browse files Browse the repository at this point in the history
The worker_remove_element test calls processEvents() before
calling waitForWorker(). It's possible that the worker actually
finishes during the processEvents() call. In such a situation,
waitForWorker() should return right away; otherwise it would
wait for 10000ms for a signal that had already emitted, and the
test would fail.

Change-Id: I8e98a3297cf5f360c1c405b1baa7524cc6593d81
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
  • Loading branch information
Kent Hansen authored and Qt by Nokia committed Mar 12, 2012
1 parent c787809 commit 2553575
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp
Expand Up @@ -216,17 +216,21 @@ QQuickItem *tst_qquicklistmodel::createWorkerTest(QQmlEngine *eng, QQmlComponent

void tst_qquicklistmodel::waitForWorker(QQuickItem *item)
{
QQmlProperty prop(item, "done");
QVERIFY(prop.isValid());
if (prop.read().toBool())
return; // already finished

QEventLoop loop;
QTimer timer;
timer.setSingleShot(true);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));

QQmlProperty prop(item, "done");
QVERIFY(prop.isValid());
QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
timer.start(10000);
loop.exec();
QVERIFY(timer.isActive());
QVERIFY(prop.read().toBool());
}

void tst_qquicklistmodel::static_types_data()
Expand Down

0 comments on commit 2553575

Please sign in to comment.