summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-28 07:33:43 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-28 07:33:43 (GMT)
commitb0b175c73f8ce9f693adeb1137a6a50a9ec3e101 (patch)
tree370033076c0509e360d259ab87969f174d596e63 /Swift/Controllers/UnitTest
parent6ff7ff9f1f028ce21b58e19367b4710ba155d6bd (diff)
downloadswift-contrib-b0b175c73f8ce9f693adeb1137a6a50a9ec3e101.zip
swift-contrib-b0b175c73f8ce9f693adeb1137a6a50a9ec3e101.tar.bz2
Correctly mark roster items with the highest priority status.
Resolves: #668
Diffstat (limited to 'Swift/Controllers/UnitTest')
-rw-r--r--Swift/Controllers/UnitTest/RosterControllerTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
index 4dd7b57..c0c0319 100644
--- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
@@ -46,6 +46,7 @@ class RosterControllerTest : public CppUnit::TestFixture
CPPUNIT_TEST(testPresence);
CPPUNIT_TEST(testHighestPresence);
CPPUNIT_TEST(testNotHighestPresence);
+ CPPUNIT_TEST(testUnavailablePresence);
CPPUNIT_TEST_SUITE_END();
public:
@@ -151,6 +152,46 @@ class RosterControllerTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(highPresence->getStatus(), item->getStatusText());
};
+ void testUnavailablePresence() {
+ std::vector<String> groups;
+ 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->setStatus("Not here");
+ Presence::ref highPresence(new Presence());
+ highPresence->setFrom(withResource(from, "bert"));
+ highPresence->setPriority(10);
+ highPresence->setStatus("So totally here");
+ 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);
+ stanzaChannel_->onPresenceReceived(highPresence);
+ stanzaChannel_->onPresenceReceived(highPresenceOffline);
+ ContactRosterItem* item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
+ /* 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());
+ CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), item->getStatusText());
+ stanzaChannel_->onPresenceReceived(lowPresenceOffline);
+ item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
+ /* 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());
+ CPPUNIT_ASSERT_EQUAL(StatusShow::None, item->getStatusShow());
+ CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), item->getStatusText());
+ };
+
void testAdd() {
std::vector<String> groups;
groups.push_back("testGroup1");