aboutsummaryrefslogtreecommitdiff
path: root/tests/quotest.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-24 18:23:00 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-24 22:32:14 +0100
commit34660bed9e90374a1ace0913331ca2965513d19b (patch)
tree670d7e609f0dc28549ae928e55726120926a97fa /tests/quotest.cpp
parentecaf0093e5857074b51607924035555a4442d4d1 (diff)
downloadlibquotient-34660bed9e90374a1ace0913331ca2965513d19b.tar.gz
libquotient-34660bed9e90374a1ace0913331ca2965513d19b.zip
quotest: wait until the final report is actually sent
Previously the code was waiting until an arbitrary event is sent. (cherry picked from commit 424d5c33542c4c38baefb773163e9ebed1accfb6)
Diffstat (limited to 'tests/quotest.cpp')
-rw-r--r--tests/quotest.cpp55
1 files changed, 29 insertions, 26 deletions
diff --git a/tests/quotest.cpp b/tests/quotest.cpp
index d4bfa786..2b1f0229 100644
--- a/tests/quotest.cpp
+++ b/tests/quotest.cpp
@@ -803,36 +803,39 @@ void TestManager::conclude()
htmlReport += "<br><strong>Did not finish:</strong>" + dnfList;
}
- // TODO: Waiting for proper futures to come so that it could be:
- // targetRoom->postHtmlText(...)
- // .then(this, &TestManager::finalize); // Qt-style or
- // .then([this] { finalize(); }); // STL-style
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;
- 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()