| 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/parallel_authenticator.h" | 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void ExpectRetailModeLoginSuccess() { | 139 void ExpectRetailModeLoginSuccess() { |
| 140 EXPECT_CALL(consumer_, OnRetailModeLoginSuccess(_)) | 140 EXPECT_CALL(consumer_, OnRetailModeLoginSuccess(_)) |
| 141 .WillOnce(Invoke(MockConsumer::OnRetailModeSuccessQuit)) | 141 .WillOnce(Invoke(MockConsumer::OnRetailModeSuccessQuit)) |
| 142 .RetiresOnSaturation(); | 142 .RetiresOnSaturation(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ExpectLoginSuccess(const std::string& username, | 145 void ExpectLoginSuccess(const std::string& username, |
| 146 const std::string& password, | 146 const std::string& password, |
| 147 const std::string& username_hash_, | 147 const std::string& username_hash_, |
| 148 bool pending) { | 148 bool pending) { |
| 149 EXPECT_CALL(consumer_, OnLoginSuccess(UserContext(username, | 149 EXPECT_CALL(consumer_, OnLoginSuccess(UserContext( |
| 150 password, | 150 username, |
| 151 std::string(), | 151 password, |
| 152 username_hash_, | 152 std::string(), |
| 153 true /* using_oauth */))) | 153 username_hash_, |
| 154 true, // using_oauth |
| 155 UserContext::AUTH_FLOW_OFFLINE))) |
| 154 .WillOnce(Invoke(MockConsumer::OnSuccessQuit)) | 156 .WillOnce(Invoke(MockConsumer::OnSuccessQuit)) |
| 155 .RetiresOnSaturation(); | 157 .RetiresOnSaturation(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void ExpectGuestLoginSuccess() { | 160 void ExpectGuestLoginSuccess() { |
| 159 EXPECT_CALL(consumer_, OnOffTheRecordLoginSuccess()) | 161 EXPECT_CALL(consumer_, OnOffTheRecordLoginSuccess()) |
| 160 .WillOnce(Invoke(MockConsumer::OnGuestSuccessQuit)) | 162 .WillOnce(Invoke(MockConsumer::OnGuestSuccessQuit)) |
| 161 .RetiresOnSaturation(); | 163 .RetiresOnSaturation(); |
| 162 } | 164 } |
| 163 | 165 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 202 |
| 201 cryptohome::MockAsyncMethodCaller* mock_caller_; | 203 cryptohome::MockAsyncMethodCaller* mock_caller_; |
| 202 | 204 |
| 203 MockConsumer consumer_; | 205 MockConsumer consumer_; |
| 204 scoped_refptr<ParallelAuthenticator> auth_; | 206 scoped_refptr<ParallelAuthenticator> auth_; |
| 205 scoped_ptr<TestAttemptState> state_; | 207 scoped_ptr<TestAttemptState> state_; |
| 206 FakeCryptohomeClient* fake_cryptohome_client_; | 208 FakeCryptohomeClient* fake_cryptohome_client_; |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) { | 211 TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) { |
| 210 EXPECT_CALL(consumer_, OnLoginSuccess(UserContext(username_, | 212 EXPECT_CALL(consumer_, OnLoginSuccess(UserContext( |
| 211 password_, | 213 username_, |
| 212 std::string(), | 214 password_, |
| 213 username_hash_, | 215 std::string(), |
| 214 true /* using oauth */))) | 216 username_hash_, |
| 217 true, // using oauth |
| 218 UserContext::AUTH_FLOW_OFFLINE))) |
| 215 .Times(1) | 219 .Times(1) |
| 216 .RetiresOnSaturation(); | 220 .RetiresOnSaturation(); |
| 217 | 221 |
| 218 SetAttemptState(auth_.get(), state_.release()); | 222 SetAttemptState(auth_.get(), state_.release()); |
| 219 auth_->OnLoginSuccess(); | 223 auth_->OnLoginSuccess(); |
| 220 } | 224 } |
| 221 | 225 |
| 222 TEST_F(ParallelAuthenticatorTest, OnPasswordChangeDetected) { | 226 TEST_F(ParallelAuthenticatorTest, OnPasswordChangeDetected) { |
| 223 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) | 227 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) |
| 224 .Times(1) | 228 .Times(1) |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 .Times(1) | 609 .Times(1) |
| 606 .RetiresOnSaturation(); | 610 .RetiresOnSaturation(); |
| 607 | 611 |
| 608 auth_->AuthenticateToUnlock(UserContext(username_, | 612 auth_->AuthenticateToUnlock(UserContext(username_, |
| 609 std::string(), | 613 std::string(), |
| 610 std::string())); | 614 std::string())); |
| 611 base::MessageLoop::current()->Run(); | 615 base::MessageLoop::current()->Run(); |
| 612 } | 616 } |
| 613 | 617 |
| 614 } // namespace chromeos | 618 } // namespace chromeos |
| OLD | NEW |