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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/testing_profile_manager.h" 5 #include "chrome/test/base/testing_profile_manager.h"
6 6
7 #include "base/files/file_util.h"
7 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/prefs/pref_service_syncable.h" 10 #include "chrome/browser/prefs/pref_service_syncable.h"
11 #include "chrome/browser/profiles/profile_avatar_downloader.h"
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
13 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #endif 21 #endif
19 22
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 TestingProfile* profile = builder.Build().release(); 94 TestingProfile* profile = builder.Build().release();
92 profile->set_profile_name(profile_name); 95 profile->set_profile_name(profile_name);
93 profile_manager_->AddProfile(profile); // Takes ownership. 96 profile_manager_->AddProfile(profile); // Takes ownership.
94 97
95 // Update the user metadata. 98 // Update the user metadata.
96 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 99 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
97 size_t index = cache.GetIndexOfProfileWithPath(profile_path); 100 size_t index = cache.GetIndexOfProfileWithPath(profile_path);
98 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); 101 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
99 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); 102 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id);
103
104 // Cache a "high res" icon if none exists to avoid a network fetch.
105 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index);
106 if (!base::PathExists(profiles::GetPathOfHighResAvatarAtIndex(icon_index))) {
107 ProfileAvatarDownloader avatar_downloader(
108 cache.GetAvatarIconIndexOfProfileAtIndex(index), profile_path, &cache);
109
110 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels.
111 SkBitmap bitmap;
112 bitmap.allocN32Pixels(2, 2);
113 bitmap.eraseColor(SK_ColorGREEN);
114 avatar_downloader.OnFetchComplete(
115 GURL("http://www.google.com/avatar.png"), &bitmap);
116 }
117
100 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it 118 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
101 // last. 119 // last.
102 cache.SetNameOfProfileAtIndex(index, user_name); 120 cache.SetNameOfProfileAtIndex(index, user_name);
103 121
104 testing_profiles_.insert(std::make_pair(profile_name, profile)); 122 testing_profiles_.insert(std::make_pair(profile_name, profile));
105 123
106 return profile; 124 return profile;
107 } 125 }
108 126
109 TestingProfile* TestingProfileManager::CreateTestingProfile( 127 TestingProfile* TestingProfileManager::CreateTestingProfile(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 << "ProfileManager already exists"; 253 << "ProfileManager already exists";
236 254
237 // Set up the directory for profiles. 255 // Set up the directory for profiles.
238 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); 256 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir());
239 257
240 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); 258 profile_manager_ = new testing::ProfileManager(profiles_dir_.path());
241 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. 259 browser_process_->SetProfileManager(profile_manager_); // Takes ownership.
242 260
243 called_set_up_ = true; 261 called_set_up_ = true;
244 } 262 }
OLDNEW
« 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