diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-12-24 18:23:00 +0100 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-12-24 18:23:00 +0100 |
commit | 424d5c33542c4c38baefb773163e9ebed1accfb6 (patch) | |
tree | 5156071d918e4f1f68a85b3230916d0b862f75d0 /tests | |
parent | 66972c81d018231f08f3767feda4b41ae5e1b8e0 (diff) | |
download | libquotient-424d5c33542c4c38baefb773163e9ebed1accfb6.tar.gz libquotient-424d5c33542c4c38baefb773163e9ebed1accfb6.zip |
quotest: wait until the final report is actually sent
Previously the code was waiting until an arbitrary event is sent.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/quotest.cpp | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/tests/quotest.cpp b/tests/quotest.cpp index 29b33edb..be95ee7d 100644 --- a/tests/quotest.cpp +++ b/tests/quotest.cpp @@ -808,34 +808,37 @@ void TestManager::conclude() auto txnId = room->postHtmlText(plainReport, htmlReport); // Now just wait until all the pending events reach the server - connectUntil(room, &Room::messageSent, this, [this, room, plainReport] { - const auto& pendingEvents = room->pendingEvents(); - if (auto c = std::count_if(pendingEvents.cbegin(), - pendingEvents.cend(), - [](const PendingEventItem& pe) { - return pe.deliveryStatus() - < EventStatus::ReachedServer; - }); - c > 0) { - clog << "Events to reach the server: " << c << ", not leaving yet" - << endl; - return false; - } + connectUntil(room, &Room::messageSent, this, + [this, txnId, room, plainReport] (const QString& sentTxnId) { + if (sentTxnId != txnId) + return false; + const auto& pendingEvents = room->pendingEvents(); + if (auto c = std::count_if(pendingEvents.cbegin(), + pendingEvents.cend(), + [](const PendingEventItem& pe) { + return pe.deliveryStatus() + < EventStatus::ReachedServer; + }); + c > 0) { + clog << "Events to reach the server: " << c + << ", not leaving yet" << endl; + return false; + } - clog << "Leaving the room" << endl; - // TODO: Waiting for proper futures to come so that it could be: - // room->leaveRoom() - // .then(this, &TestManager::finalize); // Qt-style or - // .then([this] { finalize(); }); // STL-style - auto* job = room->leaveRoom(); - connect(job, &BaseJob::finished, this, [this, job,plainReport] { - Q_ASSERT(job->status().good()); - finalize(); - // Still flying, as the exit() connection in finalize() is queued - clog << plainReport.toStdString() << endl; + clog << "Leaving the room" << endl; + // TODO: Waiting for proper futures to come so that it could be: +// room->leaveRoom() +// .then(this, &TestManager::finalize); // Qt-style or +// .then([this] { finalize(); }); // STL-style + auto* job = room->leaveRoom(); + connect(job, &BaseJob::finished, this, [this, job,plainReport] { + Q_ASSERT(job->status().good()); + finalize(); + // Still flying, as the exit() connection in finalize() is queued + clog << plainReport.toStdString() << endl; + }); + return true; }); - return true; - }); } void TestManager::finalize() |