diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-10-31 18:51:01 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-03 12:17:40 (GMT) |
commit | d509598b0f0edf5e103caedbab8662edc834445e (patch) | |
tree | 9365ef58175eee453f999c1c5b8515cb50cf90e0 /Swiften/Presence/UnitTest | |
parent | badcdcb7456d38016ea1746d6754a40dd9646813 (diff) | |
download | swift-contrib-d509598b0f0edf5e103caedbab8662edc834445e.zip swift-contrib-d509598b0f0edf5e103caedbab8662edc834445e.tar.bz2 |
Refactoring Presence & MUC handling.
Diffstat (limited to 'Swiften/Presence/UnitTest')
-rw-r--r-- | Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp (renamed from Swiften/Presence/UnitTest/PresenceSenderTest.cpp) | 28 | ||||
-rw-r--r-- | Swiften/Presence/UnitTest/PresenceOracleTest.cpp | 6 |
2 files changed, 21 insertions, 13 deletions
diff --git a/Swiften/Presence/UnitTest/PresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp index 737f317..a60c429 100644 --- a/Swiften/Presence/UnitTest/PresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp @@ -8,12 +8,13 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include "Swiften/Client/DummyStanzaChannel.h" -#include "Swiften/Presence/PresenceSender.h" +#include "Swiften/Presence/DirectedPresenceSender.h" +#include "Swiften/Presence/StanzaChannelPresenceSender.h" using namespace Swift; -class PresenceSenderTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(PresenceSenderTest); +class DirectedPresenceSenderTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(DirectedPresenceSenderTest); CPPUNIT_TEST(testSendPresence); CPPUNIT_TEST(testSendPresence_UndirectedPresenceWithDirectedPresenceReceivers); CPPUNIT_TEST(testSendPresence_DirectedPresenceWithDirectedPresenceReceivers); @@ -29,14 +30,16 @@ class PresenceSenderTest : public CppUnit::TestFixture { testPresence->setStatus("Foo"); secondTestPresence = boost::shared_ptr<Presence>(new Presence()); secondTestPresence->setStatus("Bar"); + stanzaChannelPresenceSender = new StanzaChannelPresenceSender(channel); } void tearDown() { + delete stanzaChannelPresenceSender; delete channel; } void testSendPresence() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->sentStanzas.size())); @@ -45,7 +48,7 @@ class PresenceSenderTest : public CppUnit::TestFixture { } void testSendPresence_UndirectedPresenceWithDirectedPresenceReceivers() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty")); testling->sendPresence(testPresence); @@ -59,7 +62,7 @@ class PresenceSenderTest : public CppUnit::TestFixture { } void testSendPresence_DirectedPresenceWithDirectedPresenceReceivers() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty")); channel->sentStanzas.clear(); @@ -72,7 +75,7 @@ class PresenceSenderTest : public CppUnit::TestFixture { } void testAddDirectedPresenceReceiver() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); channel->sentStanzas.clear(); @@ -85,7 +88,7 @@ class PresenceSenderTest : public CppUnit::TestFixture { } void testAddDirectedPresenceReceiver_AfterSendingDirectedPresence() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); secondTestPresence->setTo(JID("foo@bar.com")); testling->sendPresence(secondTestPresence); @@ -100,7 +103,7 @@ class PresenceSenderTest : public CppUnit::TestFixture { } void testRemoveDirectedPresenceReceiver() { - std::auto_ptr<PresenceSender> testling(createPresenceSender()); + std::auto_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty")); channel->sentStanzas.clear(); @@ -113,14 +116,15 @@ class PresenceSenderTest : public CppUnit::TestFixture { } private: - PresenceSender* createPresenceSender() { - return new PresenceSender(channel); + DirectedPresenceSender* createPresenceSender() { + return new DirectedPresenceSender(stanzaChannelPresenceSender); } private: DummyStanzaChannel* channel; + StanzaChannelPresenceSender* stanzaChannelPresenceSender; boost::shared_ptr<Presence> testPresence; boost::shared_ptr<Presence> secondTestPresence; }; -CPPUNIT_TEST_SUITE_REGISTRATION(PresenceSenderTest); +CPPUNIT_TEST_SUITE_REGISTRATION(DirectedPresenceSenderTest); diff --git a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp index d3b4b20..aa450a2 100644 --- a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp +++ b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp @@ -11,6 +11,7 @@ #include "Swiften/Presence/PresenceOracle.h" #include "Swiften/Client/DummyStanzaChannel.h" +#include "Swiften/Presence/SubscriptionManager.h" using namespace Swift; @@ -31,13 +32,15 @@ class PresenceOracleTest : public CppUnit::TestFixture { stanzaChannel_ = new DummyStanzaChannel(); oracle_ = new PresenceOracle(stanzaChannel_); oracle_->onPresenceChange.connect(boost::bind(&PresenceOracleTest::handlePresenceChange, this, _1)); - oracle_->onPresenceSubscriptionRequest.connect(boost::bind(&PresenceOracleTest::handlePresenceSubscriptionRequest, this, _1, _2)); + subscriptionManager_ = new SubscriptionManager(stanzaChannel_); + subscriptionManager_->onPresenceSubscriptionRequest.connect(boost::bind(&PresenceOracleTest::handlePresenceSubscriptionRequest, this, _1, _2)); user1 = JID("user1@foo.com/Foo"); user1alt = JID("user1@foo.com/Bar"); user2 = JID("user2@bar.com/Bar"); } void tearDown() { + delete subscriptionManager_; delete oracle_; delete stanzaChannel_; } @@ -181,6 +184,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { String reason; }; PresenceOracle* oracle_; + SubscriptionManager* subscriptionManager_; DummyStanzaChannel* stanzaChannel_; std::vector<Presence::ref> changes; std::vector<SubscriptionRequestInfo> subscriptionRequests; |