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

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

Issue 11759019: Update other unittests to use newly added TestingBrowserProcess::GetGlobal(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simpler codez Created 7 years, 11 months 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 29 matching lines...) Expand all
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 TestingPrefServiceSimple); 48 prefs_.reset(new TestingPrefServiceSimple);
49 chrome::RegisterLocalState(prefs_.get()); 49 chrome::RegisterLocalState(prefs_.get());
50 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( 50 TestingBrowserProcess::GetGlobal()->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()));
59 } 59 }
60 60
61 virtual void TearDown() OVERRIDE { 61 virtual void TearDown() OVERRIDE {
62 // Destroy the SigninManager here, because it relies on profile_ which is 62 // Destroy the SigninManager here, because it relies on profile_ which is
63 // freed in the base class. 63 // freed in the base class.
64 manager_.reset(NULL); 64 manager_.reset(NULL);
65 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(NULL); 65 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
66 prefs_.reset(NULL); 66 prefs_.reset(NULL);
67 TokenServiceTestHarness::TearDown(); 67 TokenServiceTestHarness::TearDown();
68 } 68 }
69 69
70 void SetupFetcherAndComplete(const std::string& url, 70 void SetupFetcherAndComplete(const std::string& url,
71 int response_code, 71 int response_code,
72 const net::ResponseCookies& cookies, 72 const net::ResponseCookies& cookies,
73 const std::string& response_string) { 73 const std::string& response_string) {
74 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 74 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
75 DCHECK(fetcher); 75 DCHECK(fetcher);
(...skipping 408 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

Powered by Google App Engine
This is Rietveld 408576698