Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: chrome/browser/profiles/profile_info_cache_unittest.cc

Issue 222313005: [Profiles] Download high-res avatars using the --new-profile-management flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: msw comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c137de97167de78b889694229f5c9edf16dfe1db 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "base/file_util.h"
#include "base/prefs/testing_pref_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -13,6 +14,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 +119,6 @@ void ProfileInfoCacheTest::ResetCache() {
testing_profile_manager_.DeleteProfileInfoCache();
}
-namespace {
-
TEST_F(ProfileInfoCacheTest, AddProfiles) {
EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
@@ -502,4 +502,38 @@ 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.
+ const size_t kIconIndex = 0;
+ ProfileAvatarDownloader avatar_downloader(kIconIndex, 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(kIconIndex);
+
+ // 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));
+}

Powered by Google App Engine
This is Rietveld 408576698