diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2013-12-16 09:45:40 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2013-12-18 14:48:12 (GMT) |
commit | 26994474c1ebfe874c2cd62ededf9a82b0496136 (patch) | |
tree | 20feb19c35f438b7789fe0c5113412c87b27b235 /Swiften/MUC/UnitTest/MockMUC.cpp | |
parent | 503a8077c8811c2e9f65a619c33690a36eb5c153 (diff) | |
download | swift-26994474c1ebfe874c2cd62ededf9a82b0496136.zip swift-26994474c1ebfe874c2cd62ededf9a82b0496136.tar.bz2 |
Add affiliations to tooltips for MUC occupant lists.
Also extracts MUC into an interface and MUCImpl the existing implementation, adds a MockMUC for using in unit tests, and adds unit tests for the MUCController changes.
Change-Id: I25034384f59d3c274c46ffc37b2d1ae60ec660f4
Diffstat (limited to 'Swiften/MUC/UnitTest/MockMUC.cpp')
-rw-r--r-- | Swiften/MUC/UnitTest/MockMUC.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Swiften/MUC/UnitTest/MockMUC.cpp b/Swiften/MUC/UnitTest/MockMUC.cpp new file mode 100644 index 0000000..9ca35ec --- /dev/null +++ b/Swiften/MUC/UnitTest/MockMUC.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/MUC/UnitTest/MockMUC.h> + +namespace Swift { + +MockMUC::MockMUC(const JID &muc) +: ownMUCJID(muc) +{ +} + +MockMUC::~MockMUC() { +} + +void MockMUC::insertOccupant(const MUCOccupant& occupant) +{ + occupants_.insert(std::make_pair(occupant.getNick(), occupant)); + onOccupantJoined(occupant); +} + +const MUCOccupant& MockMUC::getOccupant(const std::string& nick) { + return occupants_.find(nick)->second; +} + +bool MockMUC::hasOccupant(const std::string& nick) { + return occupants_.find(nick) != occupants_.end(); +} + +void MockMUC::changeAffiliation(const JID &jid, MUCOccupant::Affiliation newAffilation) { + std::map<std::string, MUCOccupant>::iterator i = occupants_.find(jid.getResource()); + if (i != occupants_.end()) { + const MUCOccupant old = i->second; + i->second = MUCOccupant(old.getNick(), old.getRole(), newAffilation); + onOccupantAffiliationChanged(i->first, newAffilation, old.getAffiliation()); + } +} + +void MockMUC::changeOccupantRole(const JID &jid, MUCOccupant::Role newRole) { + std::map<std::string, MUCOccupant>::iterator i = occupants_.find(jid.getResource()); + if (i != occupants_.end()) { + const MUCOccupant old = i->second; + i->second = MUCOccupant(old.getNick(), newRole, old.getAffiliation()); + onOccupantRoleChanged(i->first, i->second, old.getRole()); + } +} + +} |