OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/ui/global_error/global_error_service.h" | 25 #include "chrome/browser/ui/global_error/global_error_service.h" |
26 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 26 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
29 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
30 #include "chrome/test/base/testing_profile_manager.h" | 30 #include "chrome/test/base/testing_profile_manager.h" |
31 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
32 #include "components/signin/core/browser/fake_auth_status_provider.h" | 32 #include "components/signin/core/browser/fake_auth_status_provider.h" |
33 #include "components/signin/core/browser/signin_error_controller.h" | 33 #include "components/signin/core/browser/signin_error_controller.h" |
34 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
35 #include "components/syncable_prefs/pref_service_syncable.h" | 35 #include "components/sync_preferences/pref_service_syncable.h" |
36 #include "content/public/test/test_browser_thread_bundle.h" | 36 #include "content/public/test/test_browser_thread_bundle.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
38 | 38 |
39 static const char kTestAccountId[] = "id-testuser@test.com"; | 39 static const char kTestAccountId[] = "id-testuser@test.com"; |
40 static const char kTestGaiaId[] = "gaiaid-testuser@test.com"; | 40 static const char kTestGaiaId[] = "gaiaid-testuser@test.com"; |
41 static const char kTestUsername[] = "testuser@test.com"; | 41 static const char kTestUsername[] = "testuser@test.com"; |
42 | 42 |
43 class SigninGlobalErrorTest : public testing::Test { | 43 class SigninGlobalErrorTest : public testing::Test { |
44 public: | 44 public: |
45 SigninGlobalErrorTest() : | 45 SigninGlobalErrorTest() : |
46 profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 46 profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
47 | 47 |
48 void SetUp() override { | 48 void SetUp() override { |
49 ASSERT_TRUE(profile_manager_.SetUp()); | 49 ASSERT_TRUE(profile_manager_.SetUp()); |
50 | 50 |
51 // Create a signed-in profile. | 51 // Create a signed-in profile. |
52 TestingProfile::TestingFactories testing_factories; | 52 TestingProfile::TestingFactories testing_factories; |
53 testing_factories.push_back(std::make_pair( | 53 testing_factories.push_back(std::make_pair( |
54 ProfileOAuth2TokenServiceFactory::GetInstance(), | 54 ProfileOAuth2TokenServiceFactory::GetInstance(), |
55 BuildFakeProfileOAuth2TokenService)); | 55 BuildFakeProfileOAuth2TokenService)); |
56 testing_factories.push_back(std::make_pair( | 56 testing_factories.push_back(std::make_pair( |
57 SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase)); | 57 SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase)); |
58 profile_ = profile_manager_.CreateTestingProfile( | 58 profile_ = profile_manager_.CreateTestingProfile( |
59 "Person 1", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), | 59 "Person 1", std::unique_ptr<sync_preferences::PrefServiceSyncable>(), |
60 base::UTF8ToUTF16("Person 1"), 0, std::string(), testing_factories); | 60 base::UTF8ToUTF16("Person 1"), 0, std::string(), testing_factories); |
61 | 61 |
62 SigninManagerFactory::GetForProfile(profile()) | 62 SigninManagerFactory::GetForProfile(profile()) |
63 ->SetAuthenticatedAccountInfo(kTestAccountId, kTestUsername); | 63 ->SetAuthenticatedAccountInfo(kTestAccountId, kTestUsername); |
64 ProfileAttributesEntry* entry; | 64 ProfileAttributesEntry* entry; |
65 ASSERT_TRUE(profile_manager_.profile_attributes_storage()-> | 65 ASSERT_TRUE(profile_manager_.profile_attributes_storage()-> |
66 GetProfileAttributesWithPath(profile()->GetPath(), &entry)); | 66 GetProfileAttributesWithPath(profile()->GetPath(), &entry)); |
67 entry->SetAuthInfo(kTestGaiaId, base::UTF8ToUTF16(kTestUsername)); | 67 entry->SetAuthInfo(kTestGaiaId, base::UTF8ToUTF16(kTestUsername)); |
68 | 68 |
69 global_error_ = SigninGlobalErrorFactory::GetForProfile(profile()); | 69 global_error_ = SigninGlobalErrorFactory::GetForProfile(profile()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 ProfileMetrics::LogNumberOfProfiles( | 169 ProfileMetrics::LogNumberOfProfiles( |
170 testing_profile_manager()->profile_manager()); | 170 testing_profile_manager()->profile_manager()); |
171 | 171 |
172 if (table[i].is_error) | 172 if (table[i].is_error) |
173 histogram_tester.ExpectBucketCount("Signin.AuthError", i, 1); | 173 histogram_tester.ExpectBucketCount("Signin.AuthError", i, 1); |
174 histogram_tester.ExpectBucketCount( | 174 histogram_tester.ExpectBucketCount( |
175 "Profile.NumberOfProfilesWithAuthErrors", table[i].is_error, 1); | 175 "Profile.NumberOfProfilesWithAuthErrors", table[i].is_error, 1); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |