summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-22 17:38:29 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-22 17:39:06 (GMT)
commite8360f0dd62ea651e94f681499faef58747f2ece (patch)
tree5eeb231a12a44c65baf648b0350387a6f25986af /Swiften/Avatars/UnitTest
parent86e892137d512a11edde0aa7760fc1c15e598dad (diff)
downloadswift-e8360f0dd62ea651e94f681499faef58747f2ece.zip
swift-e8360f0dd62ea651e94f681499faef58747f2ece.tar.bz2
Support vCard-based avatars in MUCs.
Diffstat (limited to 'Swiften/Avatars/UnitTest')
-rw-r--r--Swiften/Avatars/UnitTest/AvatarManagerTest.cpp101
-rw-r--r--Swiften/Avatars/UnitTest/Makefile.inc2
2 files changed, 103 insertions, 0 deletions
diff --git a/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp
new file mode 100644
index 0000000..b8a6246
--- /dev/null
+++ b/Swiften/Avatars/UnitTest/AvatarManagerTest.cpp
@@ -0,0 +1,101 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Avatars/AvatarManager.h"
+#include "Swiften/Avatars/AvatarStorage.h"
+#include "Swiften/MUC/MUCRegistry.h"
+#include "Swiften/Queries/IQRouter.h"
+#include "Swiften/Client/DummyStanzaChannel.h"
+
+using namespace Swift;
+
+class AvatarManagerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(AvatarManagerTest);
+ CPPUNIT_TEST(testUpdate_UpdateNewHash);
+ CPPUNIT_TEST(testUpdate_UpdateNewHashAlreadyHaveAvatar);
+ CPPUNIT_TEST(testUpdate_UpdateNewHashFromMUC);
+ CPPUNIT_TEST(testUpdate_UpdateSameHash);
+ CPPUNIT_TEST(testUpdate_UpdateNewHashSameThanOtherUser);
+ CPPUNIT_TEST(testReceiveVCard);
+ CPPUNIT_TEST(testGetAvatarPath);
+ CPPUNIT_TEST(testGetAvatarPathFromMUC);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ AvatarManagerTest() {}
+
+ void setUp() {
+ stanzaChannel_ = new DummyStanzaChannel();
+ iqRouter_ = new IQRouter(stanzaChannel_);
+ mucRegistry_ = new DummyMUCRegistry();
+ avatarStorage_ = new DummyAvatarStorage();
+ }
+
+ void tearDown() {
+ delete avatarStorage_;
+ delete mucRegistry_;
+ delete iqRouter_;
+ delete stanzaChannel_;
+ }
+
+ void testUpdateNewHash() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testUpdate_UpdateNewHash() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testUpdate_UpdateNewHashAlreadyHaveAvatar() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testUpdate_UpdateNewHashFromMUC() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testUpdate_UpdateSameHash() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testUpdate_UpdateNewHashSameThanOtherUser() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testReceiveVCard() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testGetAvatarPath() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ void testGetAvatarPathFromMUC() {
+ std::auto_ptr<AvatarManager> testling = createManager();
+ }
+
+ private:
+ std::auto_ptr<AvatarManager> createManager() {
+ return std::auto_ptr<AvatarManager>(new AvatarManager(stanzaChannel_, iqRouter_, avatarStorage_, mucRegistry_));
+ }
+
+ private:
+ struct DummyMUCRegistry : public MUCRegistry {
+ bool isMUC(const JID& jid) const { return std::find(mucs_.begin(), mucs_.end(), jid) != mucs_.end(); }
+ std::vector<JID> mucs_;
+ };
+ struct DummyAvatarStorage : public AvatarStorage {
+ virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); }
+ virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; }
+ virtual boost::filesystem::path getAvatarPath(const String& hash) const {
+ return boost::filesystem::path("/avatars") / hash.getUTF8String();
+ }
+ std::map<String, ByteArray> avatars;
+ };
+ DummyStanzaChannel* stanzaChannel_;
+ IQRouter* iqRouter_;
+ DummyMUCRegistry* mucRegistry_;
+ DummyAvatarStorage* avatarStorage_;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AvatarManagerTest);
diff --git a/Swiften/Avatars/UnitTest/Makefile.inc b/Swiften/Avatars/UnitTest/Makefile.inc
index e69de29..c089c02 100644
--- a/Swiften/Avatars/UnitTest/Makefile.inc
+++ b/Swiften/Avatars/UnitTest/Makefile.inc
@@ -0,0 +1,2 @@
+UNITTEST_SOURCES += \
+ Swiften/Avatars/UnitTest/AvatarManagerTest.cpp