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

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

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 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 unified diff | Download patch
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/prefs/pref_service_syncable.h" 10 #include "chrome/browser/prefs/pref_service_syncable.h"
11 #include "chrome/browser/profiles/profile_downloader.h" 11 #include "chrome/browser/profiles/profile_downloader.h"
12 #include "chrome/browser/profiles/profile_info_cache.h" 12 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_info_cache_unittest.h" 13 #include "chrome/browser/profiles/profile_info_cache_unittest.h"
14 #include "chrome/browser/profiles/profiles_state.h" 14 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/browser/signin/account_tracker_service_factory.h"
15 #include "chrome/browser/signin/chrome_signin_client_factory.h" 16 #include "chrome/browser/signin/chrome_signin_client_factory.h"
16 #include "chrome/browser/signin/signin_manager_factory.h" 17 #include "chrome/browser/signin/signin_manager_factory.h"
17 #include "chrome/browser/signin/test_signin_client_builder.h" 18 #include "chrome/browser/signin/test_signin_client_builder.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
20 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
21 #include "chrome/test/base/testing_profile_manager.h" 22 #include "chrome/test/base/testing_profile_manager.h"
23 #include "components/signin/core/browser/account_tracker_service.h"
22 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
23 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
24 #include "ui/gfx/image/image_unittest_util.h" 26 #include "ui/gfx/image/image_unittest_util.h"
25 27
26 using ::testing::Return; 28 using ::testing::Return;
27 using ::testing::NiceMock; 29 using ::testing::NiceMock;
28 30
29 namespace { 31 namespace {
30 32
31 class ProfileDownloaderMock : public ProfileDownloader { 33 class ProfileDownloaderMock : public ProfileDownloader {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 EXPECT_FALSE(service()->timer_.IsRunning()); 275 EXPECT_FALSE(service()->timer_.IsRunning());
274 service()->ScheduleNextUpdate(); 276 service()->ScheduleNextUpdate();
275 EXPECT_TRUE(service()->timer_.IsRunning()); 277 EXPECT_TRUE(service()->timer_.IsRunning());
276 } 278 }
277 279
278 #if !defined(OS_CHROMEOS) 280 #if !defined(OS_CHROMEOS)
279 281
280 TEST_F(GAIAInfoUpdateServiceTest, LogOut) { 282 TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
281 SigninManager* signin_manager = 283 SigninManager* signin_manager =
282 SigninManagerFactory::GetForProfile(profile()); 284 SigninManagerFactory::GetForProfile(profile());
283 signin_manager->SetAuthenticatedUsername("pat@example.com"); 285 signin_manager->SetAuthenticatedAccountInfo("gaia_id", "pat@example.com");
284 base::string16 gaia_name = base::UTF8ToUTF16("Pat Foo"); 286 base::string16 gaia_name = base::UTF8ToUTF16("Pat Foo");
285 GetCache()->SetGAIANameOfProfileAtIndex(0, gaia_name); 287 GetCache()->SetGAIANameOfProfileAtIndex(0, gaia_name);
286 gfx::Image gaia_picture = gfx::test::CreateImage(256,256); 288 gfx::Image gaia_picture = gfx::test::CreateImage(256,256);
287 GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_picture); 289 GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_picture);
288 290
289 // Set a fake picture URL. 291 // Set a fake picture URL.
290 profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, 292 profile()->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
291 "example.com"); 293 "example.com");
292 294
293 EXPECT_FALSE(service()->GetCachedPictureURL().empty()); 295 EXPECT_FALSE(service()->GetCachedPictureURL().empty());
294 296
295 // Log out. 297 // Log out.
296 signin_manager->SignOut(signin_metrics::SIGNOUT_TEST); 298 signin_manager->SignOut(signin_metrics::SIGNOUT_TEST);
297 // Verify that the GAIA name and picture, and picture URL are unset. 299 // Verify that the GAIA name and picture, and picture URL are unset.
298 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty()); 300 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
299 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); 301 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
300 EXPECT_TRUE(service()->GetCachedPictureURL().empty()); 302 EXPECT_TRUE(service()->GetCachedPictureURL().empty());
301 } 303 }
302 304
303 TEST_F(GAIAInfoUpdateServiceTest, LogIn) { 305 TEST_F(GAIAInfoUpdateServiceTest, LogIn) {
304 // Log in. 306 // Log in.
305 EXPECT_CALL(*service(), Update()); 307 EXPECT_CALL(*service(), Update());
308 std::string account_id =
309 AccountTrackerServiceFactory::GetForProfile(profile())
310 ->SeedAccountInfo("gaia_id", "pat@example.com");
306 SigninManager* signin_manager = 311 SigninManager* signin_manager =
307 SigninManagerFactory::GetForProfile(profile()); 312 SigninManagerFactory::GetForProfile(profile());
308 signin_manager->OnExternalSigninCompleted("pat@example.com"); 313 signin_manager->OnExternalSigninCompleted(account_id);
309 } 314 }
310 315
311 #endif 316 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698