diff options
author | Joanna Hulboj <joanna.hulboj@isode.com> | 2017-02-09 11:55:31 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2017-02-22 16:24:03 (GMT) |
commit | 773c181d57085905d8a989f2f1cb644c747e63ab (patch) | |
tree | 7ccccc13f7aeda67b182ea441b1489dadf35f0c1 /Swift/Controllers/Chat/UnitTest | |
parent | ce307c6531053fc7edb966ba9bc2149f73cd18c2 (diff) | |
download | swift-773c181d57085905d8a989f2f1cb644c747e63ab.zip swift-773c181d57085905d8a989f2f1cb644c747e63ab.tar.bz2 |
Fix double entries in MUC participant lists after merging nicks
Test-Information:
Tested using Psi and Swift.
Log in to Psi and Swift as UserOne. Enter Room (e.g. testRoom) using Swift and join the same room from Psi using drop down menu Join Groupchat.
Splitting: change nick from UserOne to UserTwo. Swift correctly
displays: UserOne, UserTwo.
Merging: change nick back from UserTwo to UsetOne. Swift correctly
displays: UserOne.
Change-Id: I291eddd5aed154fb0babe1b0ada0a15a317eacdb
Diffstat (limited to 'Swift/Controllers/Chat/UnitTest')
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 32639f6..59dcd77 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -62,6 +62,8 @@ class MUCControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testSubjectChangeIncorrectA); CPPUNIT_TEST(testSubjectChangeIncorrectB); CPPUNIT_TEST(testSubjectChangeIncorrectC); + CPPUNIT_TEST(testHandleOccupantNicknameChanged); + CPPUNIT_TEST(testHandleOccupantNicknameChangedRoster); CPPUNIT_TEST_SUITE_END(); public: @@ -501,6 +503,61 @@ public: } } + void testHandleOccupantNicknameChanged() { + const auto occupantCount = [&](const std::string & nick) { + auto roster = window_->getRosterModel(); + CPPUNIT_ASSERT(roster != nullptr); + const auto currentOccupantsJIDs = roster->getJIDs(); + int count = 0; + for (auto & p : currentOccupantsJIDs) { + if (p.getResource() == nick) { + ++count; + } + } + return count; + }; + + muc_->insertOccupant(MUCOccupant("TestUserOne", MUCOccupant::Participant, MUCOccupant::Owner)); + muc_->insertOccupant(MUCOccupant("TestUserTwo", MUCOccupant::Participant, MUCOccupant::Owner)); + muc_->insertOccupant(MUCOccupant("TestUserThree", MUCOccupant::Participant, MUCOccupant::Owner)); + + muc_->onOccupantNicknameChanged("TestUserOne", "TestUserTwo"); + + CPPUNIT_ASSERT_EQUAL(0, occupantCount("TestUserOne")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserTwo")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserThree")); + } + + void testHandleOccupantNicknameChangedRoster() { + const auto occupantCount = [&](const std::string & nick) { + auto roster = window_->getRosterModel(); + CPPUNIT_ASSERT(roster != nullptr); + const auto participants = roster->getGroup("Participants"); + CPPUNIT_ASSERT(participants != nullptr); + const auto displayedParticipants = participants->getDisplayedChildren(); + int count = 0; + for (auto & p : displayedParticipants) { + if (p->getDisplayName() == nick) { + ++count; + } + } + return count; + }; + + muc_->insertOccupant(MUCOccupant("TestUserOne", MUCOccupant::Participant, MUCOccupant::Owner)); + muc_->insertOccupant(MUCOccupant("TestUserTwo", MUCOccupant::Participant, MUCOccupant::Owner)); + muc_->insertOccupant(MUCOccupant("TestUserThree", MUCOccupant::Participant, MUCOccupant::Owner)); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserOne")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserTwo")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserThree")); + + muc_->onOccupantNicknameChanged("TestUserOne", "TestUserTwo"); + + CPPUNIT_ASSERT_EQUAL(0, occupantCount("TestUserOne")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserTwo")); + CPPUNIT_ASSERT_EQUAL(1, occupantCount("TestUserThree")); + } + void testRoleAffiliationStatesVerify(const std::map<std::string, MUCOccupant> &occupants) { /* verify that the roster is in sync */ GroupRosterItem* group = window_->getRosterModel()->getRoot(); |