summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-14 19:11:05 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-03-14 19:11:05 (GMT)
commitaebf16650e33f442d3cc3bbc87f034c3c146e596 (patch)
treef023cf222f084388733679ef4392671db8a7c293 /Swiften/Avatars/UnitTest
parent90e773d9fb6ed8e80b502cc5d8f5763d94a41039 (diff)
downloadswift-aebf16650e33f442d3cc3bbc87f034c3c146e596.zip
swift-aebf16650e33f442d3cc3bbc87f034c3c146e596.tar.bz2
Make sure the avatar gets updated in the chat window.
Combined avatar provider shouldn't look up avatars in the cache, because the specific providers can return different results if they use the bare JID. Resolves: #781 Release-Notes: Fixed a bug where the avatar was not updating in the chat window.
Diffstat (limited to 'Swiften/Avatars/UnitTest')
-rw-r--r--Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
index 3e1cba3..4894e14 100644
--- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
+++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
@@ -26,6 +26,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testProviderUpdateWithAvatarDisappearingTriggersChange);
CPPUNIT_TEST(testProviderUpdateAfterAvatarDisappearedTriggersChange);
CPPUNIT_TEST(testProviderUpdateAfterGetDoesNotTriggerChange);
+ CPPUNIT_TEST(testProviderUpdateBareJIDAfterGetFullJID);
CPPUNIT_TEST(testRemoveProviderDisconnectsUpdates);
CPPUNIT_TEST_SUITE_END();
@@ -168,6 +169,19 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
}
+ void testProviderUpdateBareJIDAfterGetFullJID() {
+ std::auto_ptr<CombinedAvatarProvider> testling(createProvider());
+ avatarProvider1->useBare = true;
+ testling->addProvider(avatarProvider1);
+
+ avatarProvider1->avatars[user1.toBare()] = avatarHash1;
+ testling->getAvatarHash(user1);
+ avatarProvider1->avatars[user1.toBare()] = avatarHash2;
+ avatarProvider1->onAvatarChanged(user1.toBare());
+
+ CPPUNIT_ASSERT_EQUAL(avatarHash2, testling->getAvatarHash(user1));
+ }
+
private:
std::auto_ptr<CombinedAvatarProvider> createProvider() {
std::auto_ptr<CombinedAvatarProvider> result(new CombinedAvatarProvider());
@@ -181,8 +195,12 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
private:
struct DummyAvatarProvider : public AvatarProvider {
+ DummyAvatarProvider() : useBare(false) {
+ }
+
std::string getAvatarHash(const JID& jid) const {
- std::map<JID, std::string>::const_iterator i = avatars.find(jid);
+ JID actualJID = useBare ? jid.toBare() : jid;
+ std::map<JID, std::string>::const_iterator i = avatars.find(actualJID);
if (i != avatars.end()) {
return i->second;
}
@@ -191,6 +209,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
}
}
+ bool useBare;
std::map<JID, std::string> avatars;
};