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

Side by Side Diff: chrome/browser/profiles/gaia_info_update_service_unittest.cc

Issue 186803003: Use custom profile names (if available) for signed in profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_info_cache.h » ('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/browser/profiles/gaia_info_update_service.h" 5 #include "chrome/browser/profiles/gaia_info_update_service.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_downloader.h" 10 #include "chrome/browser/profiles/profile_downloader.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 MOCK_METHOD0(Update, void()); 51 MOCK_METHOD0(Update, void());
52 }; 52 };
53 53
54 class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest { 54 class GAIAInfoUpdateServiceTest : public ProfileInfoCacheTest {
55 protected: 55 protected:
56 GAIAInfoUpdateServiceTest() : profile_(NULL) { 56 GAIAInfoUpdateServiceTest() : profile_(NULL) {
57 } 57 }
58 58
59 Profile* profile() { 59 Profile* profile() {
60 if (!profile_) 60 if (!profile_) {
61 profile_ = testing_profile_manager_.CreateTestingProfile("profile_1"); 61 profile_ = testing_profile_manager_.CreateTestingProfile("Person 1");
62 // The testing manager sets the profile name manually, which counts as
63 // a user-customized profile name. Reset this to match the default name
64 // we are actually using.
65 size_t index = GetCache()->GetIndexOfProfileWithPath(profile_->GetPath());
66 GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true);
67 }
62 return profile_; 68 return profile_;
63 } 69 }
64 70
65 private: 71 private:
66 Profile* profile_; 72 Profile* profile_;
67 }; 73 };
68 74
69 } // namespace 75 } // namespace
70 76
71 TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) { 77 TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
(...skipping 11 matching lines...) Expand all
83 EXPECT_CALL(downloader, GetProfilePictureURL()).WillOnce(Return(url)); 89 EXPECT_CALL(downloader, GetProfilePictureURL()).WillOnce(Return(url));
84 90
85 // No URL should be cached yet. 91 // No URL should be cached yet.
86 EXPECT_EQ(std::string(), service.GetCachedPictureURL()); 92 EXPECT_EQ(std::string(), service.GetCachedPictureURL());
87 93
88 service.OnProfileDownloadSuccess(&downloader); 94 service.OnProfileDownloadSuccess(&downloader);
89 95
90 // On success both the profile info and GAIA info should be updated. 96 // On success both the profile info and GAIA info should be updated.
91 size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); 97 size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath());
92 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(index)); 98 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(index));
99 EXPECT_TRUE(GetCache()->IsUsingGAIANameOfProfileAtIndex(index));
93 EXPECT_EQ(name, GetCache()->GetNameOfProfileAtIndex(index)); 100 EXPECT_EQ(name, GetCache()->GetNameOfProfileAtIndex(index));
94 EXPECT_EQ(name, GetCache()->GetGAIANameOfProfileAtIndex(index)); 101 EXPECT_EQ(name, GetCache()->GetGAIANameOfProfileAtIndex(index));
95 EXPECT_TRUE(gfx::test::IsEqual( 102 EXPECT_TRUE(gfx::test::IsEqual(
96 image, GetCache()->GetAvatarIconOfProfileAtIndex(index))); 103 image, GetCache()->GetAvatarIconOfProfileAtIndex(index)));
97 EXPECT_TRUE(gfx::test::IsEqual( 104 EXPECT_TRUE(gfx::test::IsEqual(
98 image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index))); 105 image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index)));
99 EXPECT_EQ(url, service.GetCachedPictureURL()); 106 EXPECT_EQ(url, service.GetCachedPictureURL());
100 } 107 }
101 108
102 TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) { 109 TEST_F(GAIAInfoUpdateServiceTest, DownloadFailure) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 TEST_F(GAIAInfoUpdateServiceTest, LogIn) { 203 TEST_F(GAIAInfoUpdateServiceTest, LogIn) {
197 profile()->GetPrefs() 204 profile()->GetPrefs()
198 ->SetString(prefs::kGoogleServicesUsername, std::string()); 205 ->SetString(prefs::kGoogleServicesUsername, std::string());
199 GAIAInfoUpdateServiceMock service(profile()); 206 GAIAInfoUpdateServiceMock service(profile());
200 207
201 // Log in. 208 // Log in.
202 EXPECT_CALL(service, Update()); 209 EXPECT_CALL(service, Update());
203 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 210 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
204 "pat@example.com"); 211 "pat@example.com");
205 } 212 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698