summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-02-26 14:35:24 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2021-03-01 09:30:33 +0100
commit35cb65b657890717e33430cb3c12c6138c669fb2 (patch)
tree3e22b5c557725a144e40060514c2bcbf336888ea
parent2309c0815824757f47e5389136a8030f60ffe07b (diff)
Try to stabilize flaky tests
Increase waiting timeouts and use QTRY_COMPARE instead of wait/QVERIFY combination. Task-number: QTBUG-82284 Pick-to: 5.15 dev Change-Id: I223bf50b0482949529f19e74f312dc3be79f0f0c Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--tests/auto/modelview/tst_modelview.cpp2
-rw-r--r--tests/auto/proxy/tst_proxy.cpp9
-rw-r--r--tests/auto/shared/model_utilities.h2
3 files changed, 5 insertions, 8 deletions
diff --git a/tests/auto/modelview/tst_modelview.cpp b/tests/auto/modelview/tst_modelview.cpp
index 44d3593..1793476 100644
--- a/tests/auto/modelview/tst_modelview.cpp
+++ b/tests/auto/modelview/tst_modelview.cpp
@@ -383,7 +383,7 @@ public:
}
}
- bool fetchAndWait(int timeout = 3000)
+ bool fetchAndWait(int timeout = 5000)
{
QEventLoop l;
QTimer::singleShot(timeout, &l, &QEventLoop::quit);
diff --git a/tests/auto/proxy/tst_proxy.cpp b/tests/auto/proxy/tst_proxy.cpp
index 8022063..3fc49d9 100644
--- a/tests/auto/proxy/tst_proxy.cpp
+++ b/tests/auto/proxy/tst_proxy.cpp
@@ -226,8 +226,7 @@ void ProxyTest::testProxy()
}
QSignalSpy dataSpy(rep->tracks(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
QVector<QModelIndex> pending;
- QTest::qWait(100);
- QCOMPARE(rep->tracks()->rowCount(), model.rowCount());
+ QTRY_COMPARE(rep->tracks()->rowCount(), model.rowCount());
for (int i = 0; i < rep->tracks()->rowCount(); i++)
{
// We haven't received any data yet
@@ -296,8 +295,7 @@ void ProxyTest::testProxy()
QTRY_COMPARE(tracksReplica->isInitialized(), true);
QSignalSpy dataSpy(tracksReplica, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
QVector<QModelIndex> pending;
- QTest::qWait(100);
- QCOMPARE(tracksReplica->rowCount(), model.rowCount());
+ QTRY_COMPARE(tracksReplica->rowCount(), model.rowCount());
for (int i = 0; i < tracksReplica->rowCount(); i++)
{
// We haven't received any data yet
@@ -360,8 +358,7 @@ void ProxyTest::testTopLevelModel()
QAbstractItemModelReplica *replica = client.acquireModel("trackList");
QSignalSpy tracksSpy(replica, &QAbstractItemModelReplica::initialized);
QVERIFY(tracksSpy.wait());
- QTest::qWait(100);
- QCOMPARE(replica->rowCount(), model.rowCount());
+ QTRY_COMPARE(replica->rowCount(), model.rowCount());
}
QTEST_MAIN(ProxyTest)
diff --git a/tests/auto/shared/model_utilities.h b/tests/auto/shared/model_utilities.h
index 0d77499..7e30382 100644
--- a/tests/auto/shared/model_utilities.h
+++ b/tests/auto/shared/model_utilities.h
@@ -68,7 +68,7 @@ struct WaitForDataChanged
cancel = m_pending.isEmpty();
}
if (!cancel)
- m_spy->wait(50);
+ m_spy->wait();
++runs;
if (runs >= maxRuns)
cancel = true;