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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Deletes itself when SigninFailed() or SigninSuccess() is called. | 87 // Deletes itself when SigninFailed() or SigninSuccess() is called. |
88 OneClickSigninSyncStarter* sync_starter_; | 88 OneClickSigninSyncStarter* sync_starter_; |
89 | 89 |
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 KeyedService* BuildSigninManager(content::BrowserContext* profile) { | 97 static scoped_ptr<KeyedService> BuildSigninManager( |
98 return new FakeSigninManager(static_cast<Profile*>(profile)); | 98 content::BrowserContext* profile) { |
| 99 return make_scoped_ptr( |
| 100 new FakeSigninManager(static_cast<Profile*>(profile))); |
99 } | 101 } |
100 | 102 |
101 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); | 103 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest); |
102 }; | 104 }; |
103 | 105 |
104 // Verifies that the callback is invoked when sync setup fails. | 106 // Verifies that the callback is invoked when sync setup fails. |
105 TEST_F(OneClickSigninSyncStarterTest, CallbackSigninFailed) { | 107 TEST_F(OneClickSigninSyncStarterTest, CallbackSigninFailed) { |
106 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, | 108 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, |
107 base::Unretained(this)), | 109 base::Unretained(this)), |
108 GURL()); | 110 GURL()); |
(...skipping 19 matching lines...) Expand all Loading... |
128 | 130 |
129 const GURL kTestURL = GURL("http://www.example.com"); | 131 const GURL kTestURL = GURL("http://www.example.com"); |
130 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, | 132 CreateSyncStarter(base::Bind(&OneClickSigninSyncStarterTest::Callback, |
131 base::Unretained(this)), | 133 base::Unretained(this)), |
132 kTestURL); | 134 kTestURL); |
133 sync_starter_->AccountAddedToCookie( | 135 sync_starter_->AccountAddedToCookie( |
134 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | 136 GoogleServiceAuthError(GoogleServiceAuthError::NONE)); |
135 EXPECT_EQ(1, succeeded_count_); | 137 EXPECT_EQ(1, succeeded_count_); |
136 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); | 138 EXPECT_EQ(kTestURL, controller.GetPendingEntry()->GetURL()); |
137 } | 139 } |
OLD | NEW |