aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-09 19:00:34 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-10 15:06:47 +0200
commit3f58a12da394244137ba85249dd13d09cb07e927 (patch)
tree2f16a7003c08ef3d0042f9c8713670119ccf92a2
parent9e10771ed3195de3e23ef9e8bffc8eb0b734991f (diff)
downloadlibquotient-3f58a12da394244137ba85249dd13d09cb07e927.tar.gz
libquotient-3f58a12da394244137ba85249dd13d09cb07e927.zip
quotest: make sure to send all events before leaving
-rw-r--r--tests/quotest.cpp28
1 files changed, 17 insertions, 11 deletions
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()