diff options
Diffstat (limited to 'Swiften/VCards/UnitTest/VCardManagerTest.cpp')
| -rw-r--r-- | Swiften/VCards/UnitTest/VCardManagerTest.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Swiften/VCards/UnitTest/VCardManagerTest.cpp b/Swiften/VCards/UnitTest/VCardManagerTest.cpp index 32c91cf..278449b 100644 --- a/Swiften/VCards/UnitTest/VCardManagerTest.cpp +++ b/Swiften/VCards/UnitTest/VCardManagerTest.cpp | |||
| @@ -1,25 +1,26 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2013 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <Swiften/Base/ByteArray.h> | ||
| 8 | |||
| 9 | #include <cppunit/extensions/HelperMacros.h> | ||
| 10 | #include <cppunit/extensions/TestFactoryRegistry.h> | ||
| 11 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 12 | #include <boost/bind.hpp> | 9 | #include <boost/bind.hpp> |
| 13 | #include <boost/smart_ptr/make_shared.hpp> | 10 | #include <boost/smart_ptr/make_shared.hpp> |
| 14 | 11 | ||
| 15 | #include <Swiften/VCards/VCardManager.h> | 12 | #include <cppunit/extensions/HelperMacros.h> |
| 16 | #include <Swiften/VCards/VCardMemoryStorage.h> | 13 | #include <cppunit/extensions/TestFactoryRegistry.h> |
| 17 | #include <Swiften/Queries/IQRouter.h> | 14 | |
| 15 | #include <Swiften/Base/ByteArray.h> | ||
| 18 | #include <Swiften/Client/DummyStanzaChannel.h> | 16 | #include <Swiften/Client/DummyStanzaChannel.h> |
| 19 | #include <Swiften/Crypto/CryptoProvider.h> | 17 | #include <Swiften/Crypto/CryptoProvider.h> |
| 20 | #include <Swiften/Crypto/PlatformCryptoProvider.h> | 18 | #include <Swiften/Crypto/PlatformCryptoProvider.h> |
| 19 | #include <Swiften/Queries/IQRouter.h> | ||
| 20 | #include <Swiften/VCards/VCardManager.h> | ||
| 21 | #include <Swiften/VCards/VCardMemoryStorage.h> | ||
| 21 | 22 | ||
| 22 | using namespace Swift; | 23 | using namespace Swift; |
| 23 | 24 | ||
| 24 | class VCardManagerTest : public CppUnit::TestFixture { | 25 | class VCardManagerTest : public CppUnit::TestFixture { |
| 25 | CPPUNIT_TEST_SUITE(VCardManagerTest); | 26 | CPPUNIT_TEST_SUITE(VCardManagerTest); |
| @@ -35,10 +36,12 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 35 | CPPUNIT_TEST(testCreateSetVCardRequest_Error); | 36 | CPPUNIT_TEST(testCreateSetVCardRequest_Error); |
| 36 | CPPUNIT_TEST_SUITE_END(); | 37 | CPPUNIT_TEST_SUITE_END(); |
| 37 | 38 | ||
| 38 | public: | 39 | public: |
| 39 | void setUp() { | 40 | void setUp() { |
| 41 | changes.clear(); | ||
| 42 | ownChanges.clear(); | ||
| 40 | ownJID = JID("baz@fum.com/dum"); | 43 | ownJID = JID("baz@fum.com/dum"); |
| 41 | crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); | 44 | crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); |
| 42 | stanzaChannel = new DummyStanzaChannel(); | 45 | stanzaChannel = new DummyStanzaChannel(); |
| 43 | iqRouter = new IQRouter(stanzaChannel); | 46 | iqRouter = new IQRouter(stanzaChannel); |
| 44 | vcardStorage = new VCardMemoryStorage(crypto.get()); | 47 | vcardStorage = new VCardMemoryStorage(crypto.get()); |
| @@ -95,14 +98,12 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 95 | void testRequest_Error() { | 98 | void testRequest_Error() { |
| 96 | boost::shared_ptr<VCardManager> testling = createManager(); | 99 | boost::shared_ptr<VCardManager> testling = createManager(); |
| 97 | testling->requestVCard(JID("foo@bar.com/baz")); | 100 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 98 | stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID())); | 101 | stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID())); |
| 99 | 102 | ||
| 100 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | 103 | // On error, cached vCards should not be changed. |
| 101 | CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first); | 104 | CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size())); |
| 102 | CPPUNIT_ASSERT_EQUAL(std::string(""), changes[0].second->getFullName()); | ||
| 103 | CPPUNIT_ASSERT_EQUAL(std::string(""), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName()); | ||
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | void testRequest_VCardAlreadyRequested() { | 107 | void testRequest_VCardAlreadyRequested() { |
| 107 | boost::shared_ptr<VCardManager> testling = createManager(); | 108 | boost::shared_ptr<VCardManager> testling = createManager(); |
| 108 | testling->requestVCard(JID("foo@bar.com/baz")); | 109 | testling->requestVCard(JID("foo@bar.com/baz")); |
Swift