aboutsummaryrefslogtreecommitdiff
path: root/examples/qmc-example.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-01 14:19:56 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-01 14:19:56 +0900
commit9b856f28f2745a6d1f0425b8e7ac9c91119f3f36 (patch)
tree45cd25d64509faa8184d717a24f2b0c4eb416d1e /examples/qmc-example.cpp
parent62dc885e46838368f5bba3f3e2fd0985dda36af1 (diff)
downloadlibquotient-9b856f28f2745a6d1f0425b8e7ac9c91119f3f36.tar.gz
libquotient-9b856f28f2745a6d1f0425b8e7ac9c91119f3f36.zip
Pass actual changes with Connection::directChatsListChanged()
Also: provide Connection::directChats() to get the whole direct chats map.
Diffstat (limited to 'examples/qmc-example.cpp')
-rw-r--r--examples/qmc-example.cpp19
1 files changed, 14 insertions, 5 deletions
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;
}