summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 << ")";