summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-11-28 21:44:26 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-12-24 13:43:44 (GMT)
commitf08d7dc30a1242ea5a148377c5593188a8fb1317 (patch)
treef55fd5175d21c804528c5f531c08880621274e71 /Swift/Controllers/UnitTest/ChatsManagerTest.cpp
parent39209e6b419af417d3db011d7fd29433e88c8b3a (diff)
downloadswift-f08d7dc30a1242ea5a148377c5593188a8fb1317.zip
swift-f08d7dc30a1242ea5a148377c5593188a8fb1317.tar.bz2
Extract the Chat dialog management from MainController into ChatsManager.
There is a single unit test so far - but that's more than was there before, so I'm pushing. Expect more unit tests shortly. Resolves: #139
Diffstat (limited to 'Swift/Controllers/UnitTest/ChatsManagerTest.cpp')
-rw-r--r--Swift/Controllers/UnitTest/ChatsManagerTest.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/Swift/Controllers/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/UnitTest/ChatsManagerTest.cpp
new file mode 100644
index 0000000..6f6958e
--- /dev/null
+++ b/Swift/Controllers/UnitTest/ChatsManagerTest.cpp
@@ -0,0 +1,99 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include "3rdParty/hippomocks.h"
+
+#include "Swift/Controllers/ChatsManager.h"
+
+#include "Swift/Controllers/ChatWindow.h"
+#include "Swift/Controllers/ChatWindowFactory.h"
+#include "Swiften/Roster/TreeWidgetFactory.h"
+#include "Swiften/Client/Client.h"
+#include "Swift/Controllers/ChatController.h"
+#include "Swift/Controllers/EventController.h"
+#include "Swift/Controllers/MUCController.h"
+#include "Swiften/Presence/PresenceSender.h"
+#include "Swiften/Avatars/UnitTest/MockAvatarManager.h"
+#include "Swift/Controllers/NickResolver.h"
+#include "Swiften/Roster/XMPPRoster.h"
+#include "Swift/Controllers/UnitTest/MockChatWindow.h"
+#include "Swiften/Client/DummyStanzaChannel.h"
+#include "Swiften/Queries/DummyIQChannel.h"
+#include "Swiften/Presence/PresenceOracle.h"
+
+
+using namespace Swift;
+
+class ChatsManagerTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(ChatsManagerTest);
+ CPPUNIT_TEST(testFirstOpenWindow);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ ChatsManagerTest() {};
+
+ void setUp() {
+ mocks_ = new MockRepository();
+ jid_ = JID("test@test.com/resource");
+ stanzaChannel_ = new DummyStanzaChannel();
+ iqChannel_ = new DummyIQChannel();
+ iqRouter_ = new IQRouter(iqChannel_);
+ eventController_ = new EventController();
+ chatWindowFactory_ = mocks_->InterfaceMock<ChatWindowFactory>();
+ treeWidgetFactory_ = NULL;
+ xmppRoster_ = boost::shared_ptr<XMPPRoster>(new XMPPRoster());
+ nickResolver_ = new NickResolver(xmppRoster_);
+ presenceOracle_ = new PresenceOracle(stanzaChannel_);
+ serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ presenceSender_ = NULL;
+ manager_ = new ChatsManager(jid_, stanzaChannel_, iqRouter_, eventController_, chatWindowFactory_, treeWidgetFactory_, nickResolver_, presenceOracle_, serverDiscoInfo_, presenceSender_);
+ avatarManager_ = new MockAvatarManager();
+ manager_->setAvatarManager(avatarManager_);
+ };
+
+ void tearDown() {
+ delete manager_;
+ delete presenceSender_;
+ delete avatarManager_;
+ delete presenceOracle_;
+ delete nickResolver_;
+ delete treeWidgetFactory_;
+ //delete chatWindowFactory_;
+ delete stanzaChannel_;
+ delete iqChannel_;
+ delete iqRouter_;
+ delete mocks_;
+ }
+
+ void testFirstOpenWindow() {
+ JID messageJID("testling@test.com/resource1");
+
+ ChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(messageJID).Return(window);
+
+ boost::shared_ptr<Message> message(new Message());
+ message->setFrom(messageJID);
+ message->setBody("This is a legible message.");
+ manager_->handleIncomingMessage(message);
+ }
+
+private:
+ JID jid_;
+ ChatsManager* manager_;
+ StanzaChannel* stanzaChannel_;
+ IQChannel* iqChannel_;
+ IQRouter* iqRouter_;
+ EventController* eventController_;
+ ChatWindowFactory* chatWindowFactory_;
+ TreeWidgetFactory* treeWidgetFactory_;
+ NickResolver* nickResolver_;
+ PresenceOracle* presenceOracle_;
+ AvatarManager* avatarManager_;
+ boost::shared_ptr<DiscoInfo> serverDiscoInfo_;
+ boost::shared_ptr<XMPPRoster> xmppRoster_;
+ PresenceSender* presenceSender_;
+ MockRepository* mocks_;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ChatsManagerTest);
+