From 3f58a12da394244137ba85249dd13d09cb07e927 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 9 Jun 2020 19:00:34 +0200 Subject: quotest: make sure to send all events before leaving --- tests/quotest.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'tests/quotest.cpp') diff --git a/tests/quotest.cpp b/tests/quotest.cpp index ae5ece30..fefd0182 100644 --- a/tests/quotest.cpp +++ b/tests/quotest.cpp @@ -639,18 +639,24 @@ void TestManager::conclude() // .then([this] { finalize(); }); // STL-style auto* room = testSuite->room(); auto txnId = room->postHtmlText(plainReport, htmlReport); - connect(room, &Room::messageSent, this, - [this, room, txnId](const QString& serverTxnId) { - if (txnId != serverTxnId) - return; + // Now just wait until all the pending events reach the server + connectUntil(room, &Room::messageSent, this, [this, room] { + const auto& pendingEvents = room->pendingEvents(); + if (std::any_of(pendingEvents.begin(), pendingEvents.end(), + [](const PendingEventItem& pe) { + return pe.deliveryStatus() + < EventStatus::ReachedServer; + })) + return false; - clog << "Leaving the room" << endl; - auto* job = room->leaveRoom(); - connect(job, &BaseJob::finished, this, [this, job] { - Q_ASSERT(job->status().good()); - finalize(); - }); - }); + clog << "Leaving the room" << endl; + auto* job = room->leaveRoom(); + connect(job, &BaseJob::finished, this, [this, job] { + Q_ASSERT(job->status().good()); + finalize(); + }); + return true; + }); } void TestManager::finalize() -- cgit v1.2.3