From 9b856f28f2745a6d1f0425b8e7ac9c91119f3f36 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 1 Apr 2018 14:19:56 +0900 Subject: Pass actual changes with Connection::directChatsListChanged() Also: provide Connection::directChats() to get the whole direct chats map. --- examples/qmc-example.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'examples/qmc-example.cpp') diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index 23a1bff1..7226c060 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -25,9 +25,11 @@ class QMCTest : public QObject void doTests(); void addAndRemoveTag(); void sendAndRedact(); - void checkRedactionOutcome(QString evtIdToRedact, RoomEventsRange events); + void checkRedactionOutcome(QString evtIdToRedact, + RoomEventsRange events); void markDirectChat(); - void checkDirectChatOutcome(); + void checkDirectChatOutcome( + const Connection::DirectChatsMap& added); void finalize(); private: @@ -211,11 +213,11 @@ void QMCTest::checkRedactionOutcome(QString evtIdToRedact, void QMCTest::markDirectChat() { - if (c->isDirectChat(targetRoom->id())) + if (targetRoom->directChatUsers().contains(c->user())) { cout << "Warning: the room is already a direct chat," " only unmarking will be tested" << endl; - checkDirectChatOutcome(); + checkDirectChatOutcome({{ c->user(), targetRoom->id() }}); } // Connect first because the signal is emitted synchronously. connect(c.data(), &Connection::directChatsListChanged, @@ -224,11 +226,18 @@ void QMCTest::markDirectChat() c->addToDirectChats(targetRoom, c->user()); } -void QMCTest::checkDirectChatOutcome() +void QMCTest::checkDirectChatOutcome(const Connection::DirectChatsMap& added) { disconnect(c.data(), &Connection::directChatsListChanged, nullptr, nullptr); if (!c->isDirectChat(targetRoom->id())) { + cout << "The room has not been marked as a direct chat" << endl; + QMC_CHECK("Direct chat test", false); + return; + } + if (!added.contains(c->user(), targetRoom->id())) + { + cout << "The room has not been listed in new direct chats" << endl; QMC_CHECK("Direct chat test", false); return; } -- cgit v1.2.3 From cf5b5e74b20de2a0579de6a176d76f96bbe87603 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 5 Apr 2018 20:41:19 +0900 Subject: qmc-example: fix false negatives due to a missing return --- examples/qmc-example.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/qmc-example.cpp') diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index 7226c060..e2ec1d12 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -218,6 +218,7 @@ void QMCTest::markDirectChat() cout << "Warning: the room is already a direct chat," " only unmarking will be tested" << endl; checkDirectChatOutcome({{ c->user(), targetRoom->id() }}); + return; } // Connect first because the signal is emitted synchronously. connect(c.data(), &Connection::directChatsListChanged, -- cgit v1.2.3