summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-08-27 20:19:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-08-27 21:52:18 (GMT)
commit7f1bcf974efac0ed87b6f8f639e1fdc16a89eb09 (patch)
tree7fa948375b6cc56f37bd2be400d6d8be9ca97837 /Swift/Controllers/UnitTest
parentba774f85e77531c7971804cb738c6b434a197258 (diff)
downloadswift-7f1bcf974efac0ed87b6f8f639e1fdc16a89eb09.zip
swift-7f1bcf974efac0ed87b6f8f639e1fdc16a89eb09.tar.bz2
Separate MUCRegistry from ChatsManager.
Diffstat (limited to 'Swift/Controllers/UnitTest')
-rw-r--r--Swift/Controllers/UnitTest/MockMUCRegistry.h24
-rw-r--r--Swift/Controllers/UnitTest/NickResolverTest.cpp42
-rw-r--r--Swift/Controllers/UnitTest/RosterControllerTest.cpp6
3 files changed, 25 insertions, 47 deletions
diff --git a/Swift/Controllers/UnitTest/MockMUCRegistry.h b/Swift/Controllers/UnitTest/MockMUCRegistry.h
deleted file mode 100644
index fdda8e1..0000000
--- a/Swift/Controllers/UnitTest/MockMUCRegistry.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/MUC/MUCRegistry.h"
-
-namespace Swift {
- class JID;
-
- class MockMUCRegistry : public MUCRegistry {
- public:
- virtual ~MockMUCRegistry() {};
-
- void setNext(bool next) {next_ = next;}
- virtual bool isMUC(const JID&) const {return next_;}
-
- private:
- bool next_;
- };
-}
diff --git a/Swift/Controllers/UnitTest/NickResolverTest.cpp b/Swift/Controllers/UnitTest/NickResolverTest.cpp
index 67b42ac..dfb459f 100644
--- a/Swift/Controllers/UnitTest/NickResolverTest.cpp
+++ b/Swift/Controllers/UnitTest/NickResolverTest.cpp
@@ -8,7 +8,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include "Swift/Controllers/NickResolver.h"
-#include "Swift/Controllers/UnitTest/MockMUCRegistry.h"
+#include "Swiften/MUC/MUCRegistry.h"
#include "Swiften/Roster/XMPPRoster.h"
#include "Swiften/VCards/VCardManager.h"
#include "Swiften/VCards/VCardMemoryStorage.h"
@@ -17,8 +17,7 @@
using namespace Swift;
-class NickResolverTest : public CppUnit::TestFixture
-{
+class NickResolverTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(NickResolverTest);
CPPUNIT_TEST(testNoMatch);
CPPUNIT_TEST(testZeroLengthMatch);
@@ -33,18 +32,7 @@ class NickResolverTest : public CppUnit::TestFixture
CPPUNIT_TEST(testOwnNickNickEtAl);
CPPUNIT_TEST_SUITE_END();
- std::vector<String> groups_;
- boost::shared_ptr<XMPPRoster> xmppRoster_;
- VCardStorage* vCardStorage_;
- IQRouter* iqRouter_;
- DummyStanzaChannel* stanzaChannel_;
- VCardManager* vCardManager_;
- NickResolver* resolver_;
- JID ownJID_;
-
public:
- NickResolverTest() {}
-
void setUp() {
ownJID_ = JID("kev@wonderland.lit");
xmppRoster_ = boost::shared_ptr<XMPPRoster>(new XMPPRoster());
@@ -52,30 +40,28 @@ class NickResolverTest : public CppUnit::TestFixture
iqRouter_ = new IQRouter(stanzaChannel_);
vCardStorage_ = new VCardMemoryStorage();
vCardManager_ = new VCardManager(ownJID_, iqRouter_, vCardStorage_);
- resolver_ = new NickResolver(ownJID_, xmppRoster_, vCardManager_);
+ registry_ = new MUCRegistry();
+ resolver_ = new NickResolver(ownJID_, xmppRoster_, vCardManager_, registry_);
}
void tearDown() {
+ delete resolver_;
+ delete registry_;
delete vCardManager_;
delete stanzaChannel_;
delete iqRouter_;
delete vCardStorage_;
- delete resolver_;
}
void testMUCNick() {
- MockMUCRegistry registry;
- resolver_->setMUCRegistry(&registry);
- registry.setNext(true);
+ registry_->addMUC(JID("foo@bar"));
JID testJID("foo@bar/baz");
CPPUNIT_ASSERT_EQUAL(String("baz"), resolver_->jidToNick(testJID));
}
void testMUCNoNick() {
- MockMUCRegistry registry;
- resolver_->setMUCRegistry(&registry);
- registry.setNext(true);
+ registry_->addMUC(JID("foo@bar"));
JID testJID("foo@bar");
CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID));
@@ -146,6 +132,18 @@ class NickResolverTest : public CppUnit::TestFixture
IQ::ref result(IQ::createResult(JID(), stanzaChannel_->sentStanzas[0]->getID(), vcard));
stanzaChannel_->onIQReceived(result);
}
+
+ private:
+ std::vector<String> groups_;
+ boost::shared_ptr<XMPPRoster> xmppRoster_;
+ VCardStorage* vCardStorage_;
+ IQRouter* iqRouter_;
+ DummyStanzaChannel* stanzaChannel_;
+ VCardManager* vCardManager_;
+ MUCRegistry* registry_;
+ NickResolver* resolver_;
+ JID ownJID_;
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(NickResolverTest);
diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
index f57240f..23fca2c 100644
--- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
@@ -24,6 +24,7 @@
#include "Swiften/Presence/PresenceOracle.h"
#include "Swift/Controllers/NickResolver.h"
#include "Swift/Controllers/UIEvents/UIEventStream.h"
+#include "Swiften/MUC/MUCRegistry.h"
using namespace Swift;
@@ -44,7 +45,8 @@ class RosterControllerTest : public CppUnit::TestFixture
xmppRoster_ = boost::shared_ptr<XMPPRoster>(new XMPPRoster());
avatarManager_ = NULL;//new AvatarManager();
mainWindowFactory_ = new MockMainWindowFactory();
- nickResolver_ = new NickResolver(jid_.toBare(), xmppRoster_, NULL);
+ mucRegistry_ = new MUCRegistry();
+ nickResolver_ = new NickResolver(jid_.toBare(), xmppRoster_, NULL, mucRegistry_);
channel_ = new DummyIQChannel();
router_ = new IQRouter(channel_);
stanzaChannel_ = new DummyStanzaChannel();
@@ -58,6 +60,7 @@ class RosterControllerTest : public CppUnit::TestFixture
void tearDown() {
delete rosterController_;
delete nickResolver_;
+ delete mucRegistry_;
delete mainWindowFactory_;
delete avatarManager_;
delete channel_;
@@ -116,6 +119,7 @@ class RosterControllerTest : public CppUnit::TestFixture
private:
JID jid_;
boost::shared_ptr<XMPPRoster> xmppRoster_;
+ MUCRegistry* mucRegistry_;
AvatarManager* avatarManager_;
MockMainWindowFactory* mainWindowFactory_;
NickResolver* nickResolver_;