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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 SetupFetcherAndComplete(GaiaUrls::GetInstance()->merge_session_url(), 200, 169 SetupFetcherAndComplete(GaiaUrls::GetInstance()->merge_session_url(), 200,
170 cookies, "<html></html>"); 170 cookies, "<html></html>");
171 } 171 }
172 172
173 void WaitUntilUIDone() { 173 void WaitUntilUIDone() {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
175 BrowserThread::PostTask( 175 BrowserThread::PostTask(
176 BrowserThread::IO, FROM_HERE, 176 BrowserThread::IO, FROM_HERE,
177 base::Bind(&SigninManagerTest::NotifyUIOnComplete, 177 base::Bind(&SigninManagerTest::NotifyUIOnComplete,
178 base::Unretained(this))); 178 base::Unretained(this)));
179 MessageLoop::current()->Run(); 179 base::MessageLoop::current()->Run();
180 } 180 }
181 181
182 void NotifyUIOnComplete () { 182 void NotifyUIOnComplete () {
183 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 183 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
184 // Redo on UI thread. 184 // Redo on UI thread.
185 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 185 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
186 base::Bind(&SigninManagerTest::NotifyUIOnComplete, 186 base::Bind(&SigninManagerTest::NotifyUIOnComplete,
187 base::Unretained(this))); 187 base::Unretained(this)));
188 return; 188 return;
189 } 189 }
190 MessageLoop::current()->Quit(); 190 base::MessageLoop::current()->Quit();
191 } 191 }
192 192
193 void ExpectSignInWithCredentialsSuccess() { 193 void ExpectSignInWithCredentialsSuccess() {
194 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); 194 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
195 195
196 SimulateValidResponseSignInWithCredentials(); 196 SimulateValidResponseSignInWithCredentials();
197 197
198 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); 198 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
199 199
200 // This is flow, the oauth2 credentials should already be available in 200 // This is flow, the oauth2 credentials should already be available in
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 TEST_F(SigninManagerTest, ProhibitedAfterStartup) { 651 TEST_F(SigninManagerTest, ProhibitedAfterStartup) {
652 std::string user("monkey@invalid.com"); 652 std::string user("monkey@invalid.com");
653 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); 653 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user);
654 manager_->Initialize(profile_.get(), g_browser_process->local_state()); 654 manager_->Initialize(profile_.get(), g_browser_process->local_state());
655 EXPECT_EQ(user, manager_->GetAuthenticatedUsername()); 655 EXPECT_EQ(user, manager_->GetAuthenticatedUsername());
656 // Update the profile - user should be signed out. 656 // Update the profile - user should be signed out.
657 g_browser_process->local_state()->SetString( 657 g_browser_process->local_state()->SetString(
658 prefs::kGoogleServicesUsernamePattern, ".*@google.com"); 658 prefs::kGoogleServicesUsernamePattern, ".*@google.com");
659 EXPECT_EQ("", manager_->GetAuthenticatedUsername()); 659 EXPECT_EQ("", manager_->GetAuthenticatedUsername());
660 } 660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698