aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-08-02 18:23:34 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-08-02 18:23:34 +0200
commit6d40d7b8cc40259e451636e3a372de08d075553b (patch)
treeea5ee44f93e1e3b09d616858d9fd3769c546aff1
parent5010a78505a1a89b60cd5d3102e78717567354dd (diff)
downloadlibquotient-6d40d7b8cc40259e451636e3a372de08d075553b.tar.gz
libquotient-6d40d7b8cc40259e451636e3a372de08d075553b.zip
quotest: add changeName test
-rw-r--r--tests/quotest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/quotest.cpp b/tests/quotest.cpp
index ae272622..ce714a84 100644
--- a/tests/quotest.cpp
+++ b/tests/quotest.cpp
@@ -96,6 +96,7 @@ private slots:
TEST_DECL(sendReaction)
TEST_DECL(sendFile)
TEST_DECL(setTopic)
+ TEST_DECL(changeName)
TEST_DECL(sendAndRedact)
TEST_DECL(addAndRemoveTag)
TEST_DECL(markDirectChat)
@@ -488,6 +489,31 @@ TEST_IMPL(setTopic)
return false;
}
+TEST_IMPL(changeName)
+{
+ auto* const localUser = connection()->user();
+ const auto& newName = connection()->generateTxnId(); // See setTopic()
+ localUser->rename(newName);
+ connectUntil(targetRoom, &Room::memberRenamed, this,
+ [this, thisTest, newName, localUser](const User* arrivedUser) {
+ if (localUser != arrivedUser)
+ return false;
+
+ localUser->rename({});
+ const auto& arrivedNewName = arrivedUser->name(targetRoom);
+ // Old names may diverge e.g. because the original name
+ // hasn't been known to Quotient
+ if (newName == arrivedNewName)
+ FINISH_TEST(true);
+
+ clog << "Names mismatch: found" << newName.toStdString()
+ << "instead of" << arrivedNewName.toStdString()
+ << endl;
+ FAIL_TEST();
+ });
+ return false;
+}
+
TEST_IMPL(sendAndRedact)
{
clog << "Sending a message to redact" << endl;