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

Side by Side Diff: chrome/browser/signin/signin_global_error_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/signin/signin_global_error.h" 5 #include "chrome/browser/signin/signin_global_error.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/testing_browser_process.h" 24 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/testing_profile_manager.h" 26 #include "chrome/test/base/testing_profile_manager.h"
27 #include "components/signin/core/browser/fake_auth_status_provider.h" 27 #include "components/signin/core/browser/fake_auth_status_provider.h"
28 #include "components/signin/core/browser/signin_error_controller.h" 28 #include "components/signin/core/browser/signin_error_controller.h"
29 #include "components/signin/core/browser/signin_manager.h" 29 #include "components/signin/core/browser/signin_manager.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 30 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 32
33 static const char kTestAccountId[] = "testuser@test.com"; 33 static const char kTestAccountId[] = "id-testuser@test.com";
34 static const char kTestUsername[] = "testuser@test.com"; 34 static const char kTestUsername[] = "testuser@test.com";
35 35
36 class SigninGlobalErrorTest : public testing::Test { 36 class SigninGlobalErrorTest : public testing::Test {
37 public: 37 public:
38 SigninGlobalErrorTest() : 38 SigninGlobalErrorTest() :
39 profile_manager_(TestingBrowserProcess::GetGlobal()) {} 39 profile_manager_(TestingBrowserProcess::GetGlobal()) {}
40 40
41 void SetUp() override { 41 void SetUp() override {
42 ASSERT_TRUE(profile_manager_.SetUp()); 42 ASSERT_TRUE(profile_manager_.SetUp());
43 43
44 // Create a signed-in profile. 44 // Create a signed-in profile.
45 TestingProfile::TestingFactories testing_factories; 45 TestingProfile::TestingFactories testing_factories;
46 testing_factories.push_back(std::make_pair( 46 testing_factories.push_back(std::make_pair(
47 ProfileOAuth2TokenServiceFactory::GetInstance(), 47 ProfileOAuth2TokenServiceFactory::GetInstance(),
48 BuildFakeProfileOAuth2TokenService)); 48 BuildFakeProfileOAuth2TokenService));
49 testing_factories.push_back(std::make_pair( 49 testing_factories.push_back(std::make_pair(
50 SigninManagerFactory::GetInstance(), 50 SigninManagerFactory::GetInstance(),
51 FakeSigninManagerBase::Build)); 51 FakeSigninManagerBase::Build));
52 profile_ = profile_manager_.CreateTestingProfile( 52 profile_ = profile_manager_.CreateTestingProfile(
53 "Person 1", scoped_ptr<PrefServiceSyncable>(), 53 "Person 1", scoped_ptr<PrefServiceSyncable>(),
54 base::UTF8ToUTF16("Person 1"), 0, std::string(), testing_factories); 54 base::UTF8ToUTF16("Person 1"), 0, std::string(), testing_factories);
55 55
56 SigninManagerFactory::GetForProfile(profile()) 56 SigninManagerFactory::GetForProfile(profile())
57 ->SetAuthenticatedUsername(kTestAccountId); 57 ->SetAuthenticatedAccountInfo(kTestAccountId, kTestUsername);
58 ProfileInfoCache& cache = 58 ProfileInfoCache& cache =
59 profile_manager_.profile_manager()->GetProfileInfoCache(); 59 profile_manager_.profile_manager()->GetProfileInfoCache();
60 cache.SetUserNameOfProfileAtIndex( 60 cache.SetUserNameOfProfileAtIndex(
61 cache.GetIndexOfProfileWithPath(profile()->GetPath()), 61 cache.GetIndexOfProfileWithPath(profile()->GetPath()),
62 base::UTF8ToUTF16(kTestAccountId)); 62 base::UTF8ToUTF16(kTestUsername));
63 63
64 global_error_ = SigninGlobalErrorFactory::GetForProfile(profile()); 64 global_error_ = SigninGlobalErrorFactory::GetForProfile(profile());
65 error_controller_ = SigninErrorControllerFactory::GetForProfile(profile()); 65 error_controller_ = SigninErrorControllerFactory::GetForProfile(profile());
66 } 66 }
67 67
68 TestingProfile* profile() { return profile_; } 68 TestingProfile* profile() { return profile_; }
69 TestingProfileManager* testing_profile_manager() { 69 TestingProfileManager* testing_profile_manager() {
70 return &profile_manager_; 70 return &profile_manager_;
71 } 71 }
72 SigninGlobalError* global_error() { return global_error_; } 72 SigninGlobalError* global_error() { return global_error_; }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 ProfileMetrics::LogNumberOfProfiles( 164 ProfileMetrics::LogNumberOfProfiles(
165 testing_profile_manager()->profile_manager()); 165 testing_profile_manager()->profile_manager());
166 166
167 if (table[i].is_error) 167 if (table[i].is_error)
168 histogram_tester.ExpectBucketCount("Signin.AuthError", i, 1); 168 histogram_tester.ExpectBucketCount("Signin.AuthError", i, 1);
169 histogram_tester.ExpectBucketCount( 169 histogram_tester.ExpectBucketCount(
170 "Profile.NumberOfProfilesWithAuthErrors", table[i].is_error, 1); 170 "Profile.NumberOfProfilesWithAuthErrors", table[i].is_error, 1);
171 } 171 }
172 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698