summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Disco')
-rw-r--r--Swiften/Disco/UnitTest/CapsManagerTest.cpp19
-rw-r--r--Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp16
2 files changed, 15 insertions, 20 deletions
diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
index ca727c2..153e821 100644
--- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
@@ -4,6 +4,7 @@
* See the COPYING file for more information.
*/
+#include <memory>
#include <vector>
#include <boost/bind.hpp>
@@ -46,9 +47,9 @@ class CapsManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = new DummyStanzaChannel();
- iqRouter = new IQRouter(stanzaChannel);
- storage = new CapsMemoryStorage();
+ stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
+ iqRouter = std::unique_ptr<IQRouter>(new IQRouter(stanzaChannel.get()));
+ storage = std::unique_ptr<CapsMemoryStorage>(new CapsMemoryStorage());
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
discoInfo1->addFeature("http://swift.im/feature1");
@@ -63,9 +64,7 @@ class CapsManagerTest : public CppUnit::TestFixture {
}
void tearDown() {
- delete storage;
- delete iqRouter;
- delete stanzaChannel;
+ iqRouter.reset();
}
void testReceiveNewHashRequestsDisco() {
@@ -251,7 +250,7 @@ class CapsManagerTest : public CppUnit::TestFixture {
private:
std::shared_ptr<CapsManager> createManager() {
- std::shared_ptr<CapsManager> manager(new CapsManager(storage, stanzaChannel, iqRouter, crypto.get()));
+ std::shared_ptr<CapsManager> manager(new CapsManager(storage.get(), stanzaChannel.get(), iqRouter.get(), crypto.get()));
manager->setWarnOnInvalidHash(false);
//manager->onCapsChanged.connect(boost::bind(&CapsManagerTest::handleCapsChanged, this, _1));
return manager;
@@ -273,9 +272,9 @@ class CapsManagerTest : public CppUnit::TestFixture {
}
private:
- DummyStanzaChannel* stanzaChannel;
- IQRouter* iqRouter;
- CapsStorage* storage;
+ std::unique_ptr<DummyStanzaChannel> stanzaChannel;
+ std::unique_ptr<IQRouter> iqRouter;
+ std::unique_ptr<CapsStorage> storage;
std::vector<JID> changes;
JID user1;
std::shared_ptr<DiscoInfo> discoInfo1;
diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
index d775f6c..8c59741 100644
--- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
@@ -4,6 +4,7 @@
* See the COPYING file for more information.
*/
+#include <memory>
#include <vector>
#include <boost/bind.hpp>
@@ -36,8 +37,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = new DummyStanzaChannel();
- capsProvider = new DummyCapsProvider();
+ stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
+ capsProvider = std::unique_ptr<DummyCapsProvider>(new DummyCapsProvider());
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
@@ -52,11 +53,6 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
legacyCapsInfo = std::make_shared<CapsInfo>("http://swift.im", "ver1", "");
}
- void tearDown() {
- delete capsProvider;
- delete stanzaChannel;
- }
-
void testReceiveKnownHash() {
std::shared_ptr<EntityCapsManager> testling = createManager();
capsProvider->caps[capsInfo1->getVersion()] = discoInfo1;
@@ -140,7 +136,7 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
private:
std::shared_ptr<EntityCapsManager> createManager() {
- std::shared_ptr<EntityCapsManager> manager(new EntityCapsManager(capsProvider, stanzaChannel));
+ std::shared_ptr<EntityCapsManager> manager(new EntityCapsManager(capsProvider.get(), stanzaChannel.get()));
manager->onCapsChanged.connect(boost::bind(&EntityCapsManagerTest::handleCapsChanged, this, _1));
return manager;
}
@@ -177,8 +173,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
};
private:
- DummyStanzaChannel* stanzaChannel;
- DummyCapsProvider* capsProvider;
+ std::unique_ptr<DummyStanzaChannel> stanzaChannel;
+ std::unique_ptr<DummyCapsProvider> capsProvider;
JID user1;
std::shared_ptr<DiscoInfo> discoInfo1;
std::shared_ptr<CapsInfo> capsInfo1;