| Index: chrome/browser/profiles/profile_info_cache_unittest.cc
|
| diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc
|
| index 0405b1f10a2ca288275a399fa92f95849f18031c..265d41269cab1b57a4604167d7b68d11814d2301 100644
|
| --- a/chrome/browser/profiles/profile_info_cache_unittest.cc
|
| +++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/prefs/pref_service_syncable.h"
|
| +#include "chrome/browser/profiles/profile_avatar_downloader.h"
|
| #include "chrome/browser/profiles/profile_avatar_icon_util.h"
|
| #include "chrome/browser/profiles/profile_info_cache.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -117,8 +118,6 @@ void ProfileInfoCacheTest::ResetCache() {
|
| testing_profile_manager_.DeleteProfileInfoCache();
|
| }
|
|
|
| -namespace {
|
| -
|
| TEST_F(ProfileInfoCacheTest, AddProfiles) {
|
| EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
|
|
|
| @@ -502,4 +501,40 @@ TEST_F(ProfileInfoCacheTest, AddStubProfile) {
|
| ASSERT_FALSE(names[i].empty());
|
| }
|
|
|
| -} // namespace
|
| +TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) {
|
| + EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
|
| + base::FilePath path_1 = GetProfilePath("path_1");
|
| + GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"),
|
| + base::string16(), 0, std::string());
|
| + EXPECT_EQ(1U, GetCache()->GetNumberOfProfiles());
|
| +
|
| + // We haven't downloaded any high-res avatars yet.
|
| + EXPECT_EQ(0U, GetCache()->cached_avatar_images_.size());
|
| + EXPECT_EQ(0U, GetCache()->avatar_images_downloads_in_progress_.size());
|
| + EXPECT_FALSE(GetCache()->GetHighResAvatarOfProfileAtIndex(0));
|
| +
|
| + // Simulate downloading a high-res avatar.
|
| + ProfileAvatarDownloader avatar_downloader(
|
| + TestingBrowserProcess::GetGlobal()->system_request_context(),
|
| + 0,
|
| + GetCache());
|
| +
|
| + // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels.
|
| + SkBitmap bitmap;
|
| + bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
|
| + bitmap.allocPixels();
|
| + bitmap.eraseColor(SK_ColorGREEN);
|
| +
|
| + avatar_downloader.OnFetchComplete(
|
| + GURL("http://www.google.com/avatar.png"), &bitmap);
|
| +
|
| + std::string file_name =
|
| + profiles::GetDefaultAvatarIconFileNameAtIndex(0);
|
| +
|
| + // The file should have been cached and saved.
|
| + EXPECT_EQ(0U, GetCache()->avatar_images_downloads_in_progress_.size());
|
| + EXPECT_EQ(1U, GetCache()->cached_avatar_images_.size());
|
| + EXPECT_TRUE(GetCache()->GetHighResAvatarOfProfileAtIndex(0));
|
| + EXPECT_EQ(GetCache()->cached_avatar_images_[file_name],
|
| + GetCache()->GetHighResAvatarOfProfileAtIndex(0));
|
| +}
|
|
|