summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-10-27 16:20:09 (GMT)
committerTobias Markmann <tm@ayena.de>2015-10-30 12:34:52 (GMT)
commit0f5ef716a50c8d9761cafda12aacf818cdfd6353 (patch)
tree4ed80dedc2fa8b04036eb7567282094ea8fe07f1 /Swift/Controllers/Roster/UnitTest
parent4320235bef1b601856b295a8d6411d1898048802 (diff)
downloadswift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.zip
swift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.tar.bz2
Change bare JID presence lookup code to ignore priorities
Before presence handling code was handled by both, the ContactRosterItem in Swift and the PresenceOracle in Swiften. The ContactRosterItem also considered the presence priority for deciding what presence to show for a bare JID. With this code all full or bare JID presence requests are finally handled by the PresenceOracle. For bare JIDs it is looked up to a presence of one of the available resources of that JID regardless of the priorities. Test-Information: Adjusted tests according to above description and documentation in PresenceOracle. Change-Id: I972a4574f476cdf4d4b5593a035eb1c25ef2f8ba
Diffstat (limited to 'Swift/Controllers/Roster/UnitTest')
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
index 9320af1..d774e6d 100644
--- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp
@@ -194,10 +194,17 @@ class RosterControllerTest : public CppUnit::TestFixture {
groups.push_back("testGroup1");
JID from("test@testdomain.com");
xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both);
+
Presence::ref lowPresence(new Presence());
lowPresence->setFrom(withResource(from, "bob"));
lowPresence->setPriority(2);
+ lowPresence->setShow(StatusShow::Away);
lowPresence->setStatus("Not here");
+ Presence::ref lowPresenceOffline(new Presence());
+ lowPresenceOffline->setFrom(withResource(from, "bob"));
+ lowPresenceOffline->setStatus("Signing out");
+ lowPresenceOffline->setType(Presence::Unavailable);
+
Presence::ref highPresence(new Presence());
highPresence->setFrom(withResource(from, "bert"));
highPresence->setPriority(10);
@@ -205,28 +212,34 @@ class RosterControllerTest : public CppUnit::TestFixture {
Presence::ref highPresenceOffline(new Presence());
highPresenceOffline->setFrom(withResource(from, "bert"));
highPresenceOffline->setType(Presence::Unavailable);
- Presence::ref lowPresenceOffline(new Presence());
- lowPresenceOffline->setFrom(withResource(from, "bob"));
- lowPresenceOffline->setStatus("Signing out");
- lowPresenceOffline->setType(Presence::Unavailable);
+
stanzaChannel_->onPresenceReceived(lowPresence);
+ Presence::ref accountPresence = presenceOracle_->getAccountPresence(from);
+ CPPUNIT_ASSERT_EQUAL(StatusShow::Away, accountPresence->getShow());
+
stanzaChannel_->onPresenceReceived(highPresence);
+ accountPresence = presenceOracle_->getAccountPresence(from);
+ CPPUNIT_ASSERT_EQUAL(StatusShow::Online, accountPresence->getShow());
+
stanzaChannel_->onPresenceReceived(highPresenceOffline);
+
+ // After this, the roster should show the low presence.
ContactRosterItem* item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
CPPUNIT_ASSERT(item);
- /* A verification that if the test fails, it's the RosterController, not the PresenceOracle. */
- Presence::ref high = presenceOracle_->getHighestPriorityPresence(from);
- CPPUNIT_ASSERT_EQUAL(Presence::Available, high->getType());
- CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), high->getStatus());
- CPPUNIT_ASSERT_EQUAL(StatusShow::Online, item->getStatusShow());
+
+ Presence::ref low = presenceOracle_->getAccountPresence(from);
+
+ CPPUNIT_ASSERT_EQUAL(Presence::Available, low->getType());
+ CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), low->getStatus());
+ CPPUNIT_ASSERT_EQUAL(lowPresence->getShow(), item->getStatusShow());
CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), item->getStatusText());
stanzaChannel_->onPresenceReceived(lowPresenceOffline);
item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
CPPUNIT_ASSERT(item);
/* A verification that if the test fails, it's the RosterController, not the PresenceOracle. */
- high = presenceOracle_->getHighestPriorityPresence(from);
- CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, high->getType());
- CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), high->getStatus());
+ low = presenceOracle_->getHighestPriorityPresence(from);
+ CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, low->getType());
+ CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), low->getStatus());
CPPUNIT_ASSERT_EQUAL(StatusShow::None, item->getStatusShow());
CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), item->getStatusText());
}