summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-05-08 21:10:06 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-05-13 11:14:51 -0700
commite27798da447279683afb8e97dcf713c904785672 (patch)
tree2db50c2fec2ebedd8b7c625b0df510321733ffdb /tests
parentedb4d8110091bd9bd7b131ea8adbd766396516e0 (diff)
tst_QOAuthHttpServerReplyHandler: fix infinite wait on fail
Just add a timeout and use QTestEventLoop. Change-Id: Ie30a3caf09ef4176bb36fffd17cdb69a30b6b1ee Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp
index a5def79..6c5d0c6 100644
--- a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp
+++ b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp
@@ -9,6 +9,8 @@
typedef QSharedPointer<QNetworkReply> QNetworkReplyPtr;
+static constexpr std::chrono::seconds Timeout(20);
+
class tst_QOAuthHttpServerReplyHandler : public QObject
{
Q_OBJECT
@@ -26,7 +28,7 @@ void tst_QOAuthHttpServerReplyHandler::callback()
QUrl callback(replyHandler.callback());
QVERIFY(!callback.isEmpty());
callback.setQuery(query);
- QEventLoop eventLoop;
+
connect(&replyHandler, &QOAuthHttpServerReplyHandler::callbackReceived, this, [&](
const QVariantMap &parameters) {
for (auto item : query.queryItems()) {
@@ -34,7 +36,7 @@ void tst_QOAuthHttpServerReplyHandler::callback()
QCOMPARE(parameters[item.first].toString(), item.second);
}
count = parameters.size();
- eventLoop.quit();
+ QTestEventLoop::instance().exitLoop();
});
QNetworkAccessManager networkAccessManager;
@@ -42,8 +44,11 @@ void tst_QOAuthHttpServerReplyHandler::callback()
request.setUrl(callback);
QNetworkReplyPtr reply;
reply.reset(networkAccessManager.get(request));
- eventLoop.exec();
+ connect(reply.get(), &QNetworkReply::finished, &QTestEventLoop::instance(),
+ &QTestEventLoop::exitLoop);
+ QTestEventLoop::instance().enterLoop(Timeout);
QCOMPARE(count, query.queryItems().size());
+ QVERIFY(!QTestEventLoop::instance().timeout());
}
QTEST_MAIN(tst_QOAuthHttpServerReplyHandler)