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