summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-16 09:47:40 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-10-19 19:28:47 (GMT)
commita0199d151c8c0286caa5185988b5604d7e1e2d52 (patch)
treebaff226cd1043bc375d9c5062a197602cdc372c7 /Swift
parent08a340dbfc9208d1c0e6d574fed244a98e104f01 (diff)
downloadswift-a0199d151c8c0286caa5185988b5604d7e1e2d52.zip
swift-a0199d151c8c0286caa5185988b5604d7e1e2d52.tar.bz2
Fix presence handling of own contact in roster
Previously, presence from your own full JID was not applied to your own roster entry. With this commit all presence changes are applied. Test-Information: Added unit test verifying new behavior. All unit tests pass on OS X 10.11.6. Change-Id: Ib93f487329aa1eec0e876857541780ff44b8cac9
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Roster/RosterController.cpp4
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp24
2 files changed, 22 insertions, 6 deletions
diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp
index 1c750a3..116ef2e 100644
--- a/Swift/Controllers/Roster/RosterController.cpp
+++ b/Swift/Controllers/Roster/RosterController.cpp
@@ -384,9 +384,7 @@ void RosterController::handlePresenceChanged(Presence::ref presence) {
ownContact_->applyPresence(presence);
mainWindow_->setMyContactRosterItem(ownContact_);
}
- else {
- handleIncomingPresence(presence);
- }
+ handleIncomingPresence(presence);
}
boost::optional<XMPPRosterItem> RosterController::getItem(const JID& jid) const {
diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
index e01f78a..0cd4080 100644
--- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
@@ -9,7 +9,6 @@
#include <Swiften/Avatars/NullAvatarManager.h>
#include <Swiften/Base/Algorithm.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Client/ClientBlockListManager.h>
#include <Swiften/Client/DummyNickManager.h>
#include <Swiften/Client/DummyStanzaChannel.h>
@@ -61,6 +60,7 @@ class RosterControllerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testNotHighestPresence);
CPPUNIT_TEST(testUnavailablePresence);
CPPUNIT_TEST(testRemoveResultsInUnavailablePresence);
+ CPPUNIT_TEST(testOwnContactInRosterPresence);
CPPUNIT_TEST_SUITE_END();
public:
@@ -146,7 +146,6 @@ class RosterControllerTest : public CppUnit::TestFixture {
ContactRosterItem* item2 = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[1])->getChildren()[0]);
CPPUNIT_ASSERT(item2);
CPPUNIT_ASSERT_EQUAL(presence->getStatus(), item2->getStatusText());
-
}
void testHighestPresence() {
@@ -354,8 +353,27 @@ class RosterControllerTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, presenceOracle_->getAllPresence("test@testdomain.com")[0]->getType());
}
+ void testOwnContactInRosterPresence() {
+ std::vector<std::string> groups;
+ groups.push_back("testGroup1");
+ groups.push_back("testGroup2");
+ JID from = jid_;
+ xmppRoster_->addContact(from.toBare(), "name", groups, RosterItemPayload::Both);
+ Presence::ref presence(new Presence());
+ presence->setFrom(from);
+ presence->setPriority(2);
+ presence->setStatus("So totally here");
+ stanzaChannel_->onPresenceReceived(presence);
+ ContactRosterItem* item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
+ CPPUNIT_ASSERT(item);
+ CPPUNIT_ASSERT_EQUAL(presence->getStatus(), item->getStatusText());
+ ContactRosterItem* item2 = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[1])->getChildren()[0]);
+ CPPUNIT_ASSERT(item2);
+ CPPUNIT_ASSERT_EQUAL(presence->getStatus(), item2->getStatusText());
+ }
+
void assertVectorsEqual(const std::vector<std::string>& v1, const std::vector<std::string>& v2, int line) {
- foreach (const std::string& entry, v1) {
+ for (const auto& entry : v1) {
if (std::find(v2.begin(), v2.end(), entry) == v2.end()) {
std::stringstream stream;
stream << "Couldn't find " << entry << " in v2 (line " << line << ")";