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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 | 173 |
174 void ExpectPasswordChange() { | 174 void ExpectPasswordChange() { |
175 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) | 175 EXPECT_CALL(consumer_, OnPasswordChangeDetected()) |
176 .WillOnce(Invoke(MockConsumer::OnMigrateQuit)) | 176 .WillOnce(Invoke(MockConsumer::OnMigrateQuit)) |
177 .RetiresOnSaturation(); | 177 .RetiresOnSaturation(); |
178 } | 178 } |
179 | 179 |
180 void RunResolve(ParallelAuthenticator* auth) { | 180 void RunResolve(ParallelAuthenticator* auth) { |
181 auth->Resolve(); | 181 auth->Resolve(); |
182 message_loop_.RunAllPending(); | 182 message_loop_.RunUntilIdle(); |
183 } | 183 } |
184 | 184 |
185 void SetAttemptState(ParallelAuthenticator* auth, TestAttemptState* state) { | 185 void SetAttemptState(ParallelAuthenticator* auth, TestAttemptState* state) { |
186 auth->set_attempt_state(state); | 186 auth->set_attempt_state(state); |
187 } | 187 } |
188 | 188 |
189 ParallelAuthenticator::AuthState SetAndResolveState( | 189 ParallelAuthenticator::AuthState SetAndResolveState( |
190 ParallelAuthenticator* auth, TestAttemptState* state) { | 190 ParallelAuthenticator* auth, TestAttemptState* state) { |
191 auth->set_attempt_state(state); | 191 auth->set_attempt_state(state); |
192 return auth->ResolveState(); | 192 return auth->ResolveState(); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 658 |
659 MockURLFetcherFactory<SuccessFetcher> factory; | 659 MockURLFetcherFactory<SuccessFetcher> factory; |
660 TestingProfile profile; | 660 TestingProfile profile; |
661 | 661 |
662 auth_->RetryAuth(&profile, | 662 auth_->RetryAuth(&profile, |
663 username_, | 663 username_, |
664 std::string(), | 664 std::string(), |
665 std::string(), | 665 std::string(), |
666 std::string()); | 666 std::string()); |
667 message_loop_.Run(); | 667 message_loop_.Run(); |
668 message_loop_.RunAllPending(); | 668 message_loop_.RunUntilIdle(); |
669 } | 669 } |
670 | 670 |
671 TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) { | 671 TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) { |
672 ExpectLoginSuccess(username_, password_, true); | 672 ExpectLoginSuccess(username_, password_, true); |
673 FailOnLoginFailure(); | 673 FailOnLoginFailure(); |
674 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 674 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
675 .WillOnce(Return(std::string())) | 675 .WillOnce(Return(std::string())) |
676 .RetiresOnSaturation(); | 676 .RetiresOnSaturation(); |
677 | 677 |
678 // Set up state as though a cryptohome mount attempt has occurred and | 678 // Set up state as though a cryptohome mount attempt has occurred and |
(...skipping 22 matching lines...) Expand all Loading... |
701 | 701 |
702 MockURLFetcherFactory<CaptchaFetcher> factory; | 702 MockURLFetcherFactory<CaptchaFetcher> factory; |
703 TestingProfile profile; | 703 TestingProfile profile; |
704 | 704 |
705 auth_->RetryAuth(&profile, | 705 auth_->RetryAuth(&profile, |
706 username_, | 706 username_, |
707 std::string(), | 707 std::string(), |
708 std::string(), | 708 std::string(), |
709 std::string()); | 709 std::string()); |
710 message_loop_.Run(); | 710 message_loop_.Run(); |
711 message_loop_.RunAllPending(); | 711 message_loop_.RunUntilIdle(); |
712 } | 712 } |
713 | 713 |
714 TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) { | 714 TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) { |
715 ExpectLoginSuccess(username_, password_, false); | 715 ExpectLoginSuccess(username_, password_, false); |
716 FailOnLoginFailure(); | 716 FailOnLoginFailure(); |
717 | 717 |
718 // Set up state as though a cryptohome mount attempt has occurred and | 718 // Set up state as though a cryptohome mount attempt has occurred and |
719 // succeeded. | 719 // succeeded. |
720 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); | 720 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); |
721 state_->PresetOnlineLoginStatus(LoginFailure::None()); | 721 state_->PresetOnlineLoginStatus(LoginFailure::None()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 .RetiresOnSaturation(); | 755 .RetiresOnSaturation(); |
756 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 756 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
757 .WillOnce(Return(std::string())) | 757 .WillOnce(Return(std::string())) |
758 .RetiresOnSaturation(); | 758 .RetiresOnSaturation(); |
759 | 759 |
760 auth_->AuthenticateToUnlock(username_, ""); | 760 auth_->AuthenticateToUnlock(username_, ""); |
761 message_loop_.Run(); | 761 message_loop_.Run(); |
762 } | 762 } |
763 | 763 |
764 } // namespace chromeos | 764 } // namespace chromeos |
OLD | NEW |