| 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/chromeos/login/mock_authenticator.h" | 5 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 using content::BrowserThread; | 10 using content::BrowserThread; |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 void MockAuthenticator::AuthenticateToLogin(Profile* profile, | 14 void MockAuthenticator::AuthenticateToLogin(Profile* profile, |
| 15 const std::string& username, | 15 const std::string& username, |
| 16 const std::string& password, | 16 const std::string& password, |
| 17 const std::string& login_token, | 17 const std::string& login_token, |
| 18 const std::string& login_captcha) { | 18 const std::string& login_captcha) { |
| 19 if (expected_username_ == username && expected_password_ == password) { | 19 if (expected_username_ == username && expected_password_ == password) { |
| 20 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 20 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 21 base::Bind(&MockAuthenticator::OnLoginSuccess, this, false)); | 21 base::Bind(&MockAuthenticator::OnLoginSuccess, this, false)); |
| 22 return; |
| 22 } | 23 } |
| 23 GoogleServiceAuthError error( | 24 GoogleServiceAuthError error( |
| 24 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 25 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 25 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 26 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 26 base::Bind(&MockAuthenticator::OnLoginFailure, this, | 27 base::Bind(&MockAuthenticator::OnLoginFailure, this, |
| 27 LoginFailure::FromNetworkAuthFailure(error))); | 28 LoginFailure::FromNetworkAuthFailure(error))); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void MockAuthenticator::CompleteLogin(Profile* profile, | 31 void MockAuthenticator::CompleteLogin(Profile* profile, |
| 31 const std::string& username, | 32 const std::string& username, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 61 expected_password_, | 62 expected_password_, |
| 62 request_pending, | 63 request_pending, |
| 63 false); | 64 false); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void MockAuthenticator::OnLoginFailure(const LoginFailure& failure) { | 67 void MockAuthenticator::OnLoginFailure(const LoginFailure& failure) { |
| 67 consumer_->OnLoginFailure(failure); | 68 consumer_->OnLoginFailure(failure); |
| 68 } | 69 } |
| 69 | 70 |
| 70 //////////////////////////////////////////////////////////////////////////////// | 71 //////////////////////////////////////////////////////////////////////////////// |
| 71 // MockLoginUtils | 72 // TestLoginUtils |
| 72 | 73 |
| 73 MockLoginUtils::MockLoginUtils(const std::string& expected_username, | 74 TestLoginUtils::TestLoginUtils(const std::string& expected_username, |
| 74 const std::string& expected_password) | 75 const std::string& expected_password) |
| 75 : expected_username_(expected_username), | 76 : expected_username_(expected_username), |
| 76 expected_password_(expected_password) { | 77 expected_password_(expected_password) { |
| 77 } | 78 } |
| 78 | 79 |
| 79 MockLoginUtils::~MockLoginUtils() {} | 80 TestLoginUtils::~TestLoginUtils() {} |
| 80 | 81 |
| 81 void MockLoginUtils::PrepareProfile( | 82 void TestLoginUtils::PrepareProfile( |
| 82 const std::string& username, | 83 const std::string& username, |
| 83 const std::string& display_email, | 84 const std::string& display_email, |
| 84 const std::string& password, | 85 const std::string& password, |
| 85 bool pending_requests, | 86 bool pending_requests, |
| 86 bool using_oauth, | 87 bool using_oauth, |
| 87 bool has_cookies, | 88 bool has_cookies, |
| 88 Delegate* delegate) { | 89 Delegate* delegate) { |
| 89 DCHECK_EQ(expected_username_, username); | 90 DCHECK_EQ(expected_username_, username); |
| 90 DCHECK_EQ(expected_password_, password); | 91 DCHECK_EQ(expected_password_, password); |
| 91 // Profile hasn't been loaded. | 92 // Profile hasn't been loaded. |
| 92 delegate->OnProfilePrepared(NULL); | 93 delegate->OnProfilePrepared(NULL); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void MockLoginUtils::DelegateDeleted(Delegate* delegate) { | 96 void TestLoginUtils::DelegateDeleted(Delegate* delegate) { |
| 96 } | 97 } |
| 97 | 98 |
| 98 scoped_refptr<Authenticator> MockLoginUtils::CreateAuthenticator( | 99 scoped_refptr<Authenticator> TestLoginUtils::CreateAuthenticator( |
| 99 LoginStatusConsumer* consumer) { | 100 LoginStatusConsumer* consumer) { |
| 100 return new MockAuthenticator( | 101 return new MockAuthenticator( |
| 101 consumer, expected_username_, expected_password_); | 102 consumer, expected_username_, expected_password_); |
| 102 } | 103 } |
| 103 | 104 |
| 104 std::string MockLoginUtils::GetOffTheRecordCommandLine( | 105 std::string TestLoginUtils::GetOffTheRecordCommandLine( |
| 105 const GURL& start_url, | 106 const GURL& start_url, |
| 106 const CommandLine& base_command_line, | 107 const CommandLine& base_command_line, |
| 107 CommandLine* command_line) { | 108 CommandLine* command_line) { |
| 108 return std::string(); | 109 return std::string(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void MockLoginUtils::TransferDefaultCookies(Profile* default_profile, | 112 void TestLoginUtils::TransferDefaultCookies(Profile* default_profile, |
| 112 Profile* new_profile) { | 113 Profile* new_profile) { |
| 113 } | 114 } |
| 114 | 115 |
| 115 void MockLoginUtils::TransferDefaultAuthCache(Profile* default_profile, | 116 void TestLoginUtils::TransferDefaultAuthCache(Profile* default_profile, |
| 116 Profile* new_profile) { | 117 Profile* new_profile) { |
| 117 } | 118 } |
| 118 | 119 |
| 119 void MockLoginUtils::StopBackgroundFetchers() { | 120 void TestLoginUtils::StopBackgroundFetchers() { |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace chromeos | 123 } // namespace chromeos |
| OLD | NEW |