diff options
author | Tobias Markmann <tm@ayena.de> | 2013-04-30 20:10:12 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-10-01 14:48:44 (GMT) |
commit | fd47dd7d5cec5155b9985959d2f0e0f3b386cd98 (patch) | |
tree | d4da57ce3f1c90f56701cab8757d75e089473c9e /Swiften/Avatars/UnitTest | |
parent | a3781c5b770c03ff32c5cf8f1280b21c2a8e2626 (diff) | |
download | swift-fd47dd7d5cec5155b9985959d2f0e0f3b386cd98.zip swift-fd47dd7d5cec5155b9985959d2f0e0f3b386cd98.tar.bz2 |
Adding support for impromptu MUCs.
Change-Id: I363e9d740bbec311454827645f4ea6df8bb60bed
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swiften/Avatars/UnitTest')
-rw-r--r-- | Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp index dd76fb6..97edc73 100644 --- a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp @@ -13,15 +13,15 @@ #include <Swiften/Elements/VCard.h> #include <Swiften/Avatars/VCardAvatarManager.h> +#include <Swiften/VCards/VCardMemoryStorage.h> #include <Swiften/Avatars/AvatarMemoryStorage.h> #include <Swiften/VCards/VCardManager.h> -#include <Swiften/VCards/VCardStorage.h> #include <Swiften/MUC/MUCRegistry.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Client/DummyStanzaChannel.h> -#include <Swiften/StringCodecs/Hexify.h> #include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/Crypto/PlatformCryptoProvider.h> +#include <Swiften/StringCodecs/Hexify.h> using namespace Swift; @@ -36,45 +36,6 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE_END(); public: - class TestVCardStorage : public VCardStorage { - public: - TestVCardStorage(CryptoProvider* crypto) : VCardStorage(crypto), crypto(crypto) {} - - virtual VCard::ref getVCard(const JID& jid) const { - VCardMap::const_iterator i = vcards.find(jid); - if (i != vcards.end()) { - return i->second; - } - else { - return VCard::ref(); - } - } - - virtual void setVCard(const JID& jid, VCard::ref v) { - vcards[jid] = v; - } - - std::string getPhotoHash(const JID& jid) const { - if (photoHashes.find(jid) != photoHashes.end()) { - return photoHashes.find(jid)->second; - } - VCard::ref vCard = getVCard(jid); - if (vCard && !vCard->getPhoto().empty()) { - return Hexify::hexify(crypto->getSHA1Hash(vCard->getPhoto())); - } - else { - return ""; - } - } - - std::map<JID, std::string> photoHashes; - - private: - typedef std::map<JID, VCard::ref> VCardMap; - VCardMap vcards; - CryptoProvider* crypto; - }; - void setUp() { crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); ownJID = JID("foo@fum.com/bum"); @@ -83,7 +44,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { iqRouter = new IQRouter(stanzaChannel); mucRegistry = new DummyMUCRegistry(); avatarStorage = new AvatarMemoryStorage(); - vcardStorage = new TestVCardStorage(crypto.get()); + vcardStorage = new VCardMemoryStorage(crypto.get()); vcardManager = new VCardManager(ownJID, iqRouter, vcardStorage); avatar1 = createByteArray("abcdefg"); avatar1Hash = Hexify::hexify(crypto->getSHA1Hash(avatar1)); @@ -140,8 +101,9 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { void testGetAvatarHashKnownAvatarUnknownVCard() { boost::shared_ptr<VCardAvatarManager> testling = createManager(); - vcardStorage->photoHashes[user1.toBare()] = avatar1Hash; + avatarStorage->setAvatarForJID(user1, avatar1Hash); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(std::string(), result); @@ -196,7 +158,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { DummyMUCRegistry* mucRegistry; AvatarMemoryStorage* avatarStorage; VCardManager* vcardManager; - TestVCardStorage* vcardStorage; + VCardMemoryStorage* vcardStorage; ByteArray avatar1; std::string avatar1Hash; std::vector<JID> changes; |