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

Unified Diff: chrome/test/base/testing_profile_manager.cc

Issue 845373002: Change default code flag to NewAvatarMenu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test comment. GetAvatarIcon's no longer const. Created 5 years, 9 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | components/signin/core/common/profile_management_switches.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile_manager.cc
diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc
index ce2cf195f83dccd163005ece4605b9df85f269f3..fe5aa5248f11a153701c251073e9073442c605a1 100644
--- a/chrome/test/base/testing_profile_manager.cc
+++ b/chrome/test/base/testing_profile_manager.cc
@@ -4,9 +4,12 @@
#include "chrome/test/base/testing_profile_manager.h"
+#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.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"
#include "chrome/common/chrome_constants.h"
@@ -97,6 +100,21 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
size_t index = cache.GetIndexOfProfileWithPath(profile_path);
cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id);
+
+ // Cache a "high res" icon if none exists to avoid a network fetch.
+ size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index);
+ if (!base::PathExists(profiles::GetPathOfHighResAvatarAtIndex(icon_index))) {
+ ProfileAvatarDownloader avatar_downloader(
+ cache.GetAvatarIconIndexOfProfileAtIndex(index), profile_path, &cache);
+
+ // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels.
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(2, 2);
+ bitmap.eraseColor(SK_ColorGREEN);
+ avatar_downloader.OnFetchComplete(
+ GURL("http://www.google.com/avatar.png"), &bitmap);
+ }
+
// SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
// last.
cache.SetNameOfProfileAtIndex(index, user_name);
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | components/signin/core/common/profile_management_switches.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698