summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Avatars')
-rw-r--r--Swiften/Avatars/AvatarManager.cpp11
-rw-r--r--Swiften/Avatars/AvatarManager.h11
-rw-r--r--Swiften/Avatars/UnitTest/MockAvatarManager.cpp26
-rw-r--r--Swiften/Avatars/UnitTest/MockAvatarManager.h17
4 files changed, 62 insertions, 3 deletions
diff --git a/Swiften/Avatars/AvatarManager.cpp b/Swiften/Avatars/AvatarManager.cpp
index 599d1d4..7abbb8b 100644
--- a/Swiften/Avatars/AvatarManager.cpp
+++ b/Swiften/Avatars/AvatarManager.cpp
@@ -16,6 +16,17 @@ AvatarManager::AvatarManager(StanzaChannel* stanzaChannel, IQRouter* iqRouter, A
stanzaChannel->onPresenceReceived.connect(boost::bind(&AvatarManager::handlePresenceReceived, this, _1));
}
+AvatarManager::AvatarManager() {
+ stanzaChannel_ = NULL;
+ iqRouter_ = NULL;
+ avatarStorage_ = NULL;
+ mucRegistry_ = NULL;
+}
+
+AvatarManager::~AvatarManager() {
+
+}
+
void AvatarManager::handlePresenceReceived(boost::shared_ptr<Presence> presence) {
boost::shared_ptr<VCardUpdate> update = presence->getPayload<VCardUpdate>();
if (!update) {
diff --git a/Swiften/Avatars/AvatarManager.h b/Swiften/Avatars/AvatarManager.h
index 65ec372..448526e 100644
--- a/Swiften/Avatars/AvatarManager.h
+++ b/Swiften/Avatars/AvatarManager.h
@@ -20,14 +20,19 @@ namespace Swift {
class AvatarManager {
public:
AvatarManager(StanzaChannel*, IQRouter*, AvatarStorage*, MUCRegistry*);
+ virtual ~AvatarManager();
- String getAvatarHash(const JID&) const;
- boost::filesystem::path getAvatarPath(const JID&) const;
- void setAvatar(const JID&, const ByteArray& avatar);
+ virtual String getAvatarHash(const JID&) const;
+ virtual boost::filesystem::path getAvatarPath(const JID&) const;
+ virtual void setAvatar(const JID&, const ByteArray& avatar);
public:
boost::signal<void (const JID&, const String&)> onAvatarChanged;
+ protected:
+ /** Used only for testing. Leads to a non-functional object. */
+ AvatarManager();
+
private:
void handlePresenceReceived(boost::shared_ptr<Presence>);
void handleVCardReceived(const JID& from, const String& hash, boost::shared_ptr<VCard>, const boost::optional<ErrorPayload>&);
diff --git a/Swiften/Avatars/UnitTest/MockAvatarManager.cpp b/Swiften/Avatars/UnitTest/MockAvatarManager.cpp
new file mode 100644
index 0000000..2d3d48a
--- /dev/null
+++ b/Swiften/Avatars/UnitTest/MockAvatarManager.cpp
@@ -0,0 +1,26 @@
+#include "Swiften/Avatars/UnitTest/MockAvatarManager.h"
+
+namespace Swift {
+
+MockAvatarManager::MockAvatarManager() {
+
+}
+
+MockAvatarManager::~MockAvatarManager() {
+
+}
+
+String MockAvatarManager::getAvatarHash(const JID& jid) const {
+ return jid.toBare();
+}
+
+boost::filesystem::path MockAvatarManager::getAvatarPath(const JID& jid) const {
+ return jid.getResource().getUTF8String();
+}
+
+void MockAvatarManager::setAvatar(const JID&, const ByteArray&) {
+
+}
+
+}
+
diff --git a/Swiften/Avatars/UnitTest/MockAvatarManager.h b/Swiften/Avatars/UnitTest/MockAvatarManager.h
new file mode 100644
index 0000000..416d921
--- /dev/null
+++ b/Swiften/Avatars/UnitTest/MockAvatarManager.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "Swiften/Avatars/AvatarManager.h"
+#include "Swiften/Client/DummyStanzaChannel.h"
+
+namespace Swift {
+ class MockAvatarManager : public AvatarManager {
+ public:
+ MockAvatarManager();
+ virtual ~MockAvatarManager();
+ virtual String getAvatarHash(const JID&) const;
+ virtual boost::filesystem::path getAvatarPath(const JID&) const;
+ virtual void setAvatar(const JID&, const ByteArray& avatar);
+ private:
+ DummyStanzaChannel channel_;
+ };
+}