diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-12-17 08:07:07 +0100 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2021-12-17 08:07:07 +0100 |
commit | e5256e0b1e4c43ce96d99d1b82ca5d98a1baded6 (patch) | |
tree | 3e25f47d794dbb7444ca50ff1f70283012f669e9 /quotest | |
parent | 90b4ac346ac253345aca2b9a3c98df75d9c058d3 (diff) | |
download | libquotient-e5256e0b1e4c43ce96d99d1b82ca5d98a1baded6.tar.gz libquotient-e5256e0b1e4c43ce96d99d1b82ca5d98a1baded6.zip |
RoomMemberEvent: fix an off-by-one error
Also: extended quotest to cover member renames, not just user profile renames.
Diffstat (limited to 'quotest')
-rw-r--r-- | quotest/quotest.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index 764d5dfd..8703efb2 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -214,6 +214,7 @@ TestManager::TestManager(int& argc, char** argv) // Big countdown watchdog QTimer::singleShot(180000, this, [this] { + clog << "Time is up, stopping the session"; if (testSuite) conclude(); else @@ -537,14 +538,32 @@ TEST_IMPL(setTopic) TEST_IMPL(changeName) { - auto* const localUser = connection()->user(); - const auto& newName = connection()->generateTxnId(); // See setTopic() - clog << "Renaming the user to " << newName.toStdString() << endl; - localUser->rename(newName); - connectUntil(localUser, &User::defaultNameChanged, this, - [this, thisTest, localUser, newName] { - FINISH_TEST(localUser->name() == newName); - }); + connectSingleShot(targetRoom, &Room::allMembersLoaded, this, [this, thisTest] { + auto* const localUser = connection()->user(); + const auto& newName = connection()->generateTxnId(); // See setTopic() + clog << "Renaming the user to " << newName.toStdString() + << " in the target room" << endl; + localUser->rename(newName, targetRoom); + connectUntil(targetRoom, &Room::memberRenamed, this, + [this, thisTest, localUser, newName](const User* u) { + if (localUser != u) + return false; + if (localUser->name(targetRoom) != newName) + FAIL_TEST(); + + clog + << "Member rename successful, renaming the account" + << endl; + const auto newN = newName.mid(0, 5); + localUser->rename(newN); + connectUntil(localUser, &User::defaultNameChanged, + this, [this, thisTest, localUser, newN] { + targetRoom->localUser()->rename({}); + FINISH_TEST(localUser->name() == newN); + }); + return true; + }); + }); return false; } |