| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Number of times that the callback is called with SYNC_SETUP_FAILURE. | 90 // Number of times that the callback is called with SYNC_SETUP_FAILURE. |
| 91 int failed_count_; | 91 int failed_count_; |
| 92 | 92 |
| 93 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. | 93 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. |
| 94 int succeeded_count_; | 94 int succeeded_count_; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 static std::unique_ptr<KeyedService> BuildSigninManager( | 97 static std::unique_ptr<KeyedService> BuildSigninManager( |
| 98 content::BrowserContext* context) { | 98 content::BrowserContext* context) { |
| 99 Profile* profile = static_cast<Profile*>(context); | 99 Profile* profile = static_cast<Profile*>(context); |
| 100 return base::WrapUnique(new FakeSigninManager( | 100 return base::MakeUnique<FakeSigninManager>( |
| 101 ChromeSigninClientFactory::GetForProfile(profile), | 101 ChromeSigninClientFactory::GetForProfile(profile), |
| 102 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 102 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 103 AccountTrackerServiceFactory::GetForProfile(profile), | 103 AccountTrackerServiceFactory::GetForProfile(profile), |
| 104 GaiaCookieManagerServiceFactory::GetForProfile(profile))); | 104 GaiaCookieManagerServiceFactory::GetForProfile(profile)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); | 107 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // Verifies that the callback is invoked when sync setup fails. | 110 // Verifies that the callback is invoked when sync setup fails. |
| 111 TEST_F(OneClickSigninSyncStarterTest, CallbackSigninFailed) { | 111 TEST_F(OneClickSigninSyncStarterTest, CallbackSigninFailed) { |
| 112 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, | 112 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, |
| 113 base::Unretained(this)), | 113 base::Unretained(this)), |
| 114 GURL()); | 114 GURL()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 const GURL kTestURL = GURL("http://www.example.com"); | 142 const GURL kTestURL = GURL("http://www.example.com"); |
| 143 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, | 143 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, |
| 144 base::Unretained(this)), | 144 base::Unretained(this)), |
| 145 kTestURL); | 145 kTestURL); |
| 146 sync_starter_->AccountAddedToCookie( | 146 sync_starter_->AccountAddedToCookie( |
| 147 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | 147 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); |
| 148 EXPECT_EQ(1, succeeded_count_); | 148 EXPECT_EQ(1, succeeded_count_); |
| 149 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); | 149 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); |
| 150 } | 150 } |
| OLD | NEW |