OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
11 #include "chrome/browser/signin/account_tracker_service_factory.h" | 13 #include "chrome/browser/signin/account_tracker_service_factory.h" |
12 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 14 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
13 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" | 15 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
18 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
19 #include "components/browser_sync/common/browser_sync_switches.h" | 21 #include "components/browser_sync/common/browser_sync_switches.h" |
20 #include "components/signin/core/browser/account_tracker_service.h" | 22 #include "components/signin/core/browser/account_tracker_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Deletes itself when SigninFailed() or SigninSuccess() is called. | 86 // Deletes itself when SigninFailed() or SigninSuccess() is called. |
85 OneClickSigninSyncStarter* sync_starter_; | 87 OneClickSigninSyncStarter* sync_starter_; |
86 | 88 |
87 // Number of times that the callback is called with SYNC_SETUP_FAILURE. | 89 // Number of times that the callback is called with SYNC_SETUP_FAILURE. |
88 int failed_count_; | 90 int failed_count_; |
89 | 91 |
90 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. | 92 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. |
91 int succeeded_count_; | 93 int succeeded_count_; |
92 | 94 |
93 private: | 95 private: |
94 static scoped_ptr<KeyedService> BuildSigninManager( | 96 static std::unique_ptr<KeyedService> BuildSigninManager( |
95 content::BrowserContext* context) { | 97 content::BrowserContext* context) { |
96 Profile* profile = static_cast<Profile*>(context); | 98 Profile* profile = static_cast<Profile*>(context); |
97 return make_scoped_ptr(new FakeSigninManager( | 99 return base::WrapUnique(new FakeSigninManager( |
98 ChromeSigninClientFactory::GetForProfile(profile), | 100 ChromeSigninClientFactory::GetForProfile(profile), |
99 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 101 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
100 AccountTrackerServiceFactory::GetForProfile(profile), | 102 AccountTrackerServiceFactory::GetForProfile(profile), |
101 GaiaCookieManagerServiceFactory::GetForProfile(profile))); | 103 GaiaCookieManagerServiceFactory::GetForProfile(profile))); |
102 } | 104 } |
103 | 105 |
104 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); | 106 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); |
105 }; | 107 }; |
106 | 108 |
107 // Verifies that the callback is invoked when sync setup fails. | 109 // Verifies that the callback is invoked when sync setup fails. |
(...skipping 23 matching lines...) Expand all Loading... |
131 | 133 |
132 const GURL kTestURL = GURL("http://www.example.com"); | 134 const GURL kTestURL = GURL("http://www.example.com"); |
133 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, | 135 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, |
134 base::Unretained(this)), | 136 base::Unretained(this)), |
135 kTestURL); | 137 kTestURL); |
136 sync_starter_->AccountAddedToCookie( | 138 sync_starter_->AccountAddedToCookie( |
137 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | 139 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); |
138 EXPECT_EQ(1, succeeded_count_); | 140 EXPECT_EQ(1, succeeded_count_); |
139 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); | 141 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); |
140 } | 142 } |
OLD | NEW |