From 79d0a9696af910a446cd535148880a9fb6cdf90f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 13 Apr 2010 14:45:19 +1000 Subject: Network-related test fails on the rare occasion --- .../tst_qdeclarativexmllistmodel.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 7edf7e9..cf7e357 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -320,7 +320,21 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->progress(), qreal(0.0)); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); + + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)), &loop, SLOT(quit())); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(20000); + loop.exec(); + + if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) { + qWarning("QDeclarativeXmlListModel invalid source test timed out"); + } else { + QCOMPARE(spy.count(), 1); spy.clear(); + } + QCOMPARE(model->status(), status); QCOMPARE(model->count(), count); if (status == QDeclarativeXmlListModel::Ready) @@ -336,9 +350,7 @@ void tst_qdeclarativexmllistmodel::source_data() QTest::addColumn("status"); QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarativeXmlListModel::Ready; - - // XXX This test fails on the rare occasion due to networking, fix the test for Error status signal (323) - //QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error; + QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error; // empty file QTemporaryFile *temp = new QTemporaryFile(this); -- cgit v0.12