diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-10-27 20:17:02 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-10-27 20:19:35 (GMT) |
commit | 78f702aba1b1a0978c152536053233e6f9aedb91 (patch) | |
tree | a5f24dcc9f6b86b45e4c46cfb7cbd8750e718bdb /Swiften/Presence | |
parent | 5f6543647862b5ae1d5abdddd0612e6cf9f23c8f (diff) | |
download | swift-contrib-78f702aba1b1a0978c152536053233e6f9aedb91.zip swift-contrib-78f702aba1b1a0978c152536053233e6f9aedb91.tar.bz2 |
Starting to test getHighestPriorityPresence
Diffstat (limited to 'Swiften/Presence')
-rw-r--r-- | Swiften/Presence/UnitTest/PresenceOracleTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp index e96d8a4..645f917 100644 --- a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp +++ b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp @@ -20,6 +20,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { CPPUNIT_TEST(testReceivePresenceFromDifferentResources); CPPUNIT_TEST(testSubscriptionRequest); CPPUNIT_TEST(testReconnectResetsPresences); + CPPUNIT_TEST(testHighestPresence); CPPUNIT_TEST_SUITE_END(); public: @@ -38,6 +39,19 @@ class PresenceOracleTest : public CppUnit::TestFixture { delete stanzaChannel_; } + void testHighestPresence() { + JID bareJID("alice@wonderland.lit"); + Presence::ref fiveOn = makeOnline("blah", 5); + Presence::ref fiveOff = makeOffline("/blah"); + Presence::ref tenOn = makeOnline("bert", 10); + Presence::ref allOff = makeOffline(""); + CPPUNIT_ASSERT_EQUAL(Presence::ref(), oracle_->getHighestPriorityPresence(bareJID)); + stanzaChannel_->onPresenceReceived(fiveOn); + CPPUNIT_ASSERT_EQUAL(fiveOn, oracle_->getHighestPriorityPresence(bareJID)); + stanzaChannel_->onPresenceReceived(fiveOff); + CPPUNIT_ASSERT_EQUAL(fiveOff, oracle_->getHighestPriorityPresence(bareJID)); + } + void testReceivePresence() { boost::shared_ptr<Presence> sentPresence(createPresence(user1)); stanzaChannel_->onPresenceReceived(sentPresence); @@ -84,6 +98,20 @@ class PresenceOracleTest : public CppUnit::TestFixture { } private: + Presence::ref makeOnline(const String& resource, int priority) { + Presence::ref presence(new Presence()); + presence->setPriority(priority); + presence->setFrom(JID("alice@wonderland.lit/" + resource)); + return presence; + } + + Presence::ref makeOffline(const String& resource) { + Presence::ref presence(new Presence()); + presence->setFrom(JID("alice@wonderland.lit" + resource)); + presence->setType(Presence::Unavailable); + return presence; + } + void handlePresenceChange(boost::shared_ptr<Presence> newPresence) { changes.push_back(newPresence); } |