summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Avatars/UnitTest')
-rw-r--r--Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp32
-rw-r--r--Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp39
-rw-r--r--Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp45
3 files changed, 59 insertions, 57 deletions
diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
index 4894e14..50b0adb 100644
--- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
+++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
@@ -8,9 +8,9 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
-#include "Swiften/JID/JID.h"
+#include <Swiften/JID/JID.h>
#include <string>
-#include "Swiften/Avatars/CombinedAvatarProvider.h"
+#include <Swiften/Avatars/CombinedAvatarProvider.h>
using namespace Swift;
@@ -47,13 +47,13 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testGetAvatarWithNoAvatarProviderReturnsEmpty() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
CPPUNIT_ASSERT(testling->getAvatarHash(user1).empty());
}
void testGetAvatarWithSingleAvatarProvider() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->avatars[user1] = avatarHash1;
testling->addProvider(avatarProvider1);
@@ -61,7 +61,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testGetAvatarWithMultipleAvatarProviderReturnsFirstAvatar() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider2->avatars[user1] = avatarHash2;
testling->addProvider(avatarProvider1);
@@ -71,7 +71,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testGetAvatarWithMultipleAvatarProviderAndFailingFirstProviderReturnsSecondAvatar() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider2->avatars[user1] = avatarHash2;
testling->addProvider(avatarProvider1);
testling->addProvider(avatarProvider2);
@@ -80,7 +80,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testProviderUpdateTriggersChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
@@ -90,7 +90,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testProviderUpdateWithoutChangeDoesNotTriggerChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
testling->addProvider(avatarProvider2);
avatarProvider1->avatars[user1] = avatarHash1;
@@ -104,7 +104,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testProviderSecondUpdateTriggersChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
@@ -118,7 +118,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateWithAvatarDisappearingTriggersChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
@@ -131,7 +131,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testProviderUpdateAfterAvatarDisappearedTriggersChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
@@ -147,7 +147,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateAfterGetDoesNotTriggerChange() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
avatarProvider1->avatars[user1] = avatarHash1;
@@ -158,7 +158,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testRemoveProviderDisconnectsUpdates() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
testling->addProvider(avatarProvider1);
testling->addProvider(avatarProvider2);
testling->removeProvider(avatarProvider1);
@@ -170,7 +170,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
void testProviderUpdateBareJIDAfterGetFullJID() {
- std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ boost::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->useBare = true;
testling->addProvider(avatarProvider1);
@@ -183,8 +183,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
private:
- std::auto_ptr<CombinedAvatarProvider> createProvider() {
- std::auto_ptr<CombinedAvatarProvider> result(new CombinedAvatarProvider());
+ boost::shared_ptr<CombinedAvatarProvider> createProvider() {
+ boost::shared_ptr<CombinedAvatarProvider> result(new CombinedAvatarProvider());
result->onAvatarChanged.connect(boost::bind(&CombinedAvatarProviderTest::handleAvatarChanged, this, _1));
return result;
}
diff --git a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp
index be5eaea..0c2633a 100644
--- a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp
+++ b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp
@@ -4,22 +4,23 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Base/ByteArray.h"
+#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
-#include "Swiften/Elements/VCard.h"
-#include "Swiften/Avatars/VCardAvatarManager.h"
-#include "Swiften/Avatars/AvatarMemoryStorage.h"
-#include "Swiften/VCards/VCardMemoryStorage.h"
-#include "Swiften/VCards/VCardManager.h"
-#include "Swiften/MUC/MUCRegistry.h"
-#include "Swiften/Queries/IQRouter.h"
-#include "Swiften/Client/DummyStanzaChannel.h"
-#include "Swiften/StringCodecs/SHA1.h"
-#include "Swiften/StringCodecs/Hexify.h"
+#include <Swiften/Elements/VCard.h>
+#include <Swiften/Avatars/VCardAvatarManager.h>
+#include <Swiften/Avatars/AvatarMemoryStorage.h>
+#include <Swiften/VCards/VCardMemoryStorage.h>
+#include <Swiften/VCards/VCardManager.h>
+#include <Swiften/MUC/MUCRegistry.h>
+#include <Swiften/Queries/IQRouter.h>
+#include <Swiften/Client/DummyStanzaChannel.h>
+#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/StringCodecs/Hexify.h>
using namespace Swift;
@@ -42,7 +43,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
avatarStorage = new AvatarMemoryStorage();
vcardStorage = new VCardMemoryStorage();
vcardManager = new VCardManager(ownJID, iqRouter, vcardStorage);
- avatar1 = ByteArray("abcdefg");
+ avatar1 = createByteArray("abcdefg");
avatar1Hash = Hexify::hexify(SHA1::getHash(avatar1));
user1 = JID("user1@bar.com/bla");
user2 = JID("user2@foo.com/baz");
@@ -58,7 +59,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
void testGetAvatarHashKnownAvatar() {
- std::auto_ptr<VCardAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardAvatarManager> testling = createManager();
storeVCardWithPhoto(user1.toBare(), avatar1);
avatarStorage->addAvatar(avatar1Hash, avatar1);
@@ -68,7 +69,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
void testGetAvatarHashEmptyAvatar() {
- std::auto_ptr<VCardAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardAvatarManager> testling = createManager();
storeEmptyVCard(user1.toBare());
std::string result = testling->getAvatarHash(user1);
@@ -77,7 +78,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
void testGetAvatarHashUnknownAvatarKnownVCardStoresAvatar() {
- std::auto_ptr<VCardAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardAvatarManager> testling = createManager();
storeVCardWithPhoto(user1.toBare(), avatar1);
std::string result = testling->getAvatarHash(user1);
@@ -88,7 +89,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
void testGetAvatarHashUnknownAvatarUnknownVCard() {
- std::auto_ptr<VCardAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardAvatarManager> testling = createManager();
std::string result = testling->getAvatarHash(user1);
@@ -96,7 +97,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
void testVCardUpdateTriggersUpdate() {
- std::auto_ptr<VCardAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardAvatarManager> testling = createManager();
vcardManager->requestVCard(user1);
sendVCardResult();
@@ -104,8 +105,8 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture {
}
private:
- std::auto_ptr<VCardAvatarManager> createManager() {
- std::auto_ptr<VCardAvatarManager> result(new VCardAvatarManager(vcardManager, avatarStorage, mucRegistry));
+ boost::shared_ptr<VCardAvatarManager> createManager() {
+ boost::shared_ptr<VCardAvatarManager> result(new VCardAvatarManager(vcardManager, avatarStorage, mucRegistry));
result->onAvatarChanged.connect(boost::bind(&VCardAvatarManagerTest::handleAvatarChanged, this, _1));
return result;
}
diff --git a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
index cde4a45..e0fd080 100644
--- a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
+++ b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
@@ -4,22 +4,23 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Base/ByteArray.h"
+#include <Swiften/Base/ByteArray.h>
+#include <QA/Checker/IO.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
-#include "Swiften/Elements/VCardUpdate.h"
-#include "Swiften/Avatars/VCardUpdateAvatarManager.h"
-#include "Swiften/Avatars/AvatarMemoryStorage.h"
-#include "Swiften/VCards/VCardMemoryStorage.h"
-#include "Swiften/VCards/VCardManager.h"
-#include "Swiften/MUC/MUCRegistry.h"
-#include "Swiften/Queries/IQRouter.h"
-#include "Swiften/Client/DummyStanzaChannel.h"
-#include "Swiften/StringCodecs/SHA1.h"
-#include "Swiften/StringCodecs/Hexify.h"
+#include <Swiften/Elements/VCardUpdate.h>
+#include <Swiften/Avatars/VCardUpdateAvatarManager.h>
+#include <Swiften/Avatars/AvatarMemoryStorage.h>
+#include <Swiften/VCards/VCardMemoryStorage.h>
+#include <Swiften/VCards/VCardManager.h>
+#include <Swiften/MUC/MUCRegistry.h>
+#include <Swiften/Queries/IQRouter.h>
+#include <Swiften/Client/DummyStanzaChannel.h>
+#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/StringCodecs/Hexify.h>
using namespace Swift;
@@ -44,7 +45,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
avatarStorage = new AvatarMemoryStorage();
vcardStorage = new VCardMemoryStorage();
vcardManager = new VCardManager(ownJID, iqRouter, vcardStorage);
- avatar1 = ByteArray("abcdefg");
+ avatar1 = createByteArray("abcdefg");
avatar1Hash = Hexify::hexify(SHA1::getHash(avatar1));
user1 = JID("user1@bar.com/bla");
user2 = JID("user2@foo.com/baz");
@@ -60,7 +61,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testUpdate_NewHashNewVCardRequestsVCard() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
@@ -68,7 +69,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testUpdate_NewHashStoresAvatarAndEmitsNotificationOnVCardReceive() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
stanzaChannel->onIQReceived(createVCardResult(avatar1));
@@ -80,7 +81,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testUpdate_KnownHash() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
stanzaChannel->onIQReceived(createVCardResult(avatar1));
changes.clear();
@@ -93,7 +94,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testUpdate_KnownHashFromDifferentUserDoesNotRequestVCardButTriggersNotification() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
stanzaChannel->onIQReceived(createVCardResult(avatar1));
changes.clear();
@@ -108,7 +109,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testVCardWithEmptyPhoto() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
vcardManager->requestVCard(JID("foo@bar.com"));
stanzaChannel->onIQReceived(createVCardResult(ByteArray()));
@@ -117,7 +118,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testStanzaChannelReset_ClearsHash() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
stanzaChannel->onIQReceived(createVCardResult(avatar1));
changes.clear();
@@ -132,7 +133,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
void testStanzaChannelReset_ReceiveHashAfterResetUpdatesHash() {
- std::auto_ptr<VCardUpdateAvatarManager> testling = createManager();
+ boost::shared_ptr<VCardUpdateAvatarManager> testling = createManager();
stanzaChannel->onPresenceReceived(createPresenceWithPhotoHash(user1, avatar1Hash));
stanzaChannel->onIQReceived(createVCardResult(avatar1));
changes.clear();
@@ -148,8 +149,8 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
}
private:
- std::auto_ptr<VCardUpdateAvatarManager> createManager() {
- std::auto_ptr<VCardUpdateAvatarManager> result(new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry));
+ boost::shared_ptr<VCardUpdateAvatarManager> createManager() {
+ boost::shared_ptr<VCardUpdateAvatarManager> result(new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry));
result->onAvatarChanged.connect(boost::bind(&VCardUpdateAvatarManagerTest::handleAvatarChanged, this, _1));
return result;
}
@@ -163,7 +164,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
IQ::ref createVCardResult(const ByteArray& avatar) {
VCard::ref vcard(new VCard());
- if (!avatar.isEmpty()) {
+ if (!avatar.empty()) {
vcard->setPhoto(avatar);
}
return IQ::createResult(JID("baz@fum.com"), stanzaChannel->sentStanzas[0]->getID(), vcard);