diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-23 16:55:03 +0100 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-25 22:35:23 +0100 |
commit | 4c59f10262b3de2e8b808b0839d772b0d70d2057 (patch) | |
tree | fe70d60381072c4cc4d0e2704aeeeea9ced7afbd /examples | |
parent | f7442619401fa789647101f56fdfbddaf4fc6796 (diff) | |
download | libquotient-4c59f10262b3de2e8b808b0839d772b0d70d2057.tar.gz libquotient-4c59f10262b3de2e8b808b0839d772b0d70d2057.zip |
qmc-example: make tests work again
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qmc-example.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index bd9190b9..2aaaf147 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -183,7 +183,7 @@ void QMCTest::loadMembers() // The dedicated qmc-test room is too small to test // lazy-loading-then-full-loading; use #qmatrixclient:matrix.org instead. // TODO: #264 - auto* r = c->room(QStringLiteral("!PCzUtxtOjUySxSelof:matrix.org")); + auto* r = c->roomByAlias(QStringLiteral("#qmatrixclient:matrix.org")); if (!r) { cout << "#test:matrix.org is not found in the test user's rooms" << endl; @@ -344,8 +344,9 @@ void QMCTest::setTopic() const auto newTopic = c->generateTxnId(); targetRoom->setTopic(newTopic); // Sets the state by proper means const auto fakeTopic = c->generateTxnId(); - targetRoom->postJson(RoomTopicEvent::matrixTypeId(), // Fake state event - RoomTopicEvent(fakeTopic).contentJson()); + auto fakeTxnId = + targetRoom->postJson(RoomTopicEvent::matrixTypeId(), // Fake state event + RoomTopicEvent(fakeTopic).contentJson()); connectUntil(targetRoom, &Room::topicChanged, this, [this,newTopic,fakeTopic,initialTopic] { @@ -353,22 +354,25 @@ void QMCTest::setTopic() { QMC_CHECK(stateTestName, true); // Don't reset the topic yet if the negative test still runs - if (!running.contains(fakeStateTestName)) - targetRoom->setTopic(initialTopic); + targetRoom->setTopic(initialTopic); return true; } return false; }); - connectUntil(targetRoom, &Room::pendingEventAboutToMerge, this, - [this,fakeTopic,initialTopic] (const RoomEvent* e, int) { - if (e->contentJson().value("topic").toString() != fakeTopic) - return false; // Wait on for the right event + connectUntil(targetRoom, &Room::pendingEventChanged, this, + [this, fakeTxnId](int pendingIdx) { + const auto& pendingEvents = targetRoom->pendingEvents(); + Q_ASSERT(pendingIdx >= 0 && pendingIdx < int(pendingEvents.size())); - QMC_CHECK(fakeStateTestName, !e->isStateEvent()); - if (!running.contains(fakeStateTestName)) - targetRoom->setTopic(initialTopic); + const auto& pendingItem = pendingEvents[pendingIdx]; + if (pendingItem->transactionId() != fakeTxnId + || pendingItem.deliveryStatus() <= EventStatus::Departed) + return false; + + QMC_CHECK(fakeStateTestName, pendingItem.deliveryStatus() + == EventStatus::SendingFailed); return true; }); } |