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