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

Side by Side Diff: chrome/browser/signin/signin_manager_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 27 matching lines...) Expand all
38 " \"expires_in\": 3600," 38 " \"expires_in\": 3600,"
39 " \"token_type\": \"Bearer\"" 39 " \"token_type\": \"Bearer\""
40 "}"; 40 "}";
41 41
42 } // namespace 42 } // namespace
43 43
44 44
45 class SigninManagerTest : public TokenServiceTestHarness { 45 class SigninManagerTest : public TokenServiceTestHarness {
46 public: 46 public:
47 virtual void SetUp() OVERRIDE { 47 virtual void SetUp() OVERRIDE {
48 prefs_.reset(new TestingPrefService); 48 prefs_.reset(new TestingPrefServiceSimple);
49 chrome::RegisterLocalState(prefs_.get()); 49 chrome::RegisterLocalState(prefs_.get());
50 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( 50 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(
51 prefs_.get()); 51 prefs_.get());
52 TokenServiceTestHarness::SetUp(); 52 TokenServiceTestHarness::SetUp();
53 manager_.reset(new SigninManager()); 53 manager_.reset(new SigninManager());
54 google_login_success_.ListenFor( 54 google_login_success_.ListenFor(
55 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 55 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
56 content::Source<Profile>(profile_.get())); 56 content::Source<Profile>(profile_.get()));
57 google_login_failure_.ListenFor(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, 57 google_login_failure_.ListenFor(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
58 content::Source<Profile>(profile_.get())); 58 content::Source<Profile>(profile_.get()));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 "email=user@gmail.com\ndisplayEmail=USER@gmail.com\n" 180 "email=user@gmail.com\ndisplayEmail=USER@gmail.com\n"
181 "allServices="; 181 "allServices=";
182 SetupFetcherAndComplete(GaiaUrls::GetInstance()->get_user_info_url(), 200, 182 SetupFetcherAndComplete(GaiaUrls::GetInstance()->get_user_info_url(), 200,
183 net::ResponseCookies(), response_string); 183 net::ResponseCookies(), response_string);
184 } 184 }
185 185
186 net::TestURLFetcherFactory factory_; 186 net::TestURLFetcherFactory factory_;
187 scoped_ptr<SigninManager> manager_; 187 scoped_ptr<SigninManager> manager_;
188 content::TestNotificationTracker google_login_success_; 188 content::TestNotificationTracker google_login_success_;
189 content::TestNotificationTracker google_login_failure_; 189 content::TestNotificationTracker google_login_failure_;
190 scoped_ptr<TestingPrefService> prefs_; 190 scoped_ptr<TestingPrefServiceSimple> prefs_;
191 }; 191 };
192 192
193 // NOTE: ClientLogin's "StartSignin" is called after collecting credentials 193 // NOTE: ClientLogin's "StartSignin" is called after collecting credentials
194 // from the user. 194 // from the user.
195 TEST_F(SigninManagerTest, SignInClientLogin) { 195 TEST_F(SigninManagerTest, SignInClientLogin) {
196 manager_->Initialize(profile_.get()); 196 manager_->Initialize(profile_.get());
197 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); 197 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
198 198
199 manager_->StartSignIn("user@gmail.com", "password", "", ""); 199 manager_->StartSignIn("user@gmail.com", "password", "", "");
200 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); 200 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 manager_->ProvideOAuthChallengeResponse( 485 manager_->ProvideOAuthChallengeResponse(
486 GoogleServiceAuthError::CAPTCHA_REQUIRED, "token", "solution"); 486 GoogleServiceAuthError::CAPTCHA_REQUIRED, "token", "solution");
487 487
488 SimulateProvideOAuthChallengeResponseValid(); 488 SimulateProvideOAuthChallengeResponseValid();
489 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); 489 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
490 490
491 EXPECT_EQ(1U, google_login_success_.size()); 491 EXPECT_EQ(1U, google_login_success_.size());
492 EXPECT_EQ(1U, google_login_failure_.size()); 492 EXPECT_EQ(1U, google_login_failure_.size());
493 } 493 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager_factory.cc ('k') | chrome/browser/speech/chrome_speech_recognition_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698