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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
10 #include "chrome/browser/chromeos/cros/cros_mock.h" | 10 #include "chrome/browser/chromeos/cros/cros_mock.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 scoped_refptr<Authenticator> CreateAuthenticator( | 225 scoped_refptr<Authenticator> CreateAuthenticator( |
226 LoginStatusConsumer* consumer) { | 226 LoginStatusConsumer* consumer) { |
227 return new MockAuthenticator(consumer, kUsername, kPassword); | 227 return new MockAuthenticator(consumer, kUsername, kPassword); |
228 } | 228 } |
229 | 229 |
230 scoped_refptr<Authenticator> CreateAuthenticatorNewUser( | 230 scoped_refptr<Authenticator> CreateAuthenticatorNewUser( |
231 LoginStatusConsumer* consumer) { | 231 LoginStatusConsumer* consumer) { |
232 return new MockAuthenticator(consumer, kNewUsername, kPassword); | 232 return new MockAuthenticator(consumer, kNewUsername, kPassword); |
233 } | 233 } |
234 | 234 |
235 // These tests are failing under ASan, but not natively. | 235 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
236 // See http://crbug.com/126224 | |
237 #if defined(ADDRESS_SANITIZER) | |
238 #define MAYBE_ExistingUserLogin DISABLED_ExistingUserLogin | |
239 #define MAYBE_AutoEnrollAfterSignIn DISABLED_AutoEnrollAfterSignIn | |
240 #define MAYBE_NewUserDontAutoEnrollAfterSignIn \ | |
241 DISABLED_NewUserDontAutoEnrollAfterSignIn | |
242 #else | |
243 #define MAYBE_ExistingUserLogin ExistingUserLogin | |
244 #define MAYBE_AutoEnrollAfterSignIn AutoEnrollAfterSignIn | |
245 #define MAYBE_NewUserDontAutoEnrollAfterSignIn NewUserDontAutoEnrollAfterSignIn | |
246 #endif // defined(ADDRESS_SANITIZER) | |
247 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, MAYBE_ExistingUserLogin) { | |
248 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 236 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
249 .Times(1); | 237 .Times(1); |
250 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) | 238 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) |
251 .Times(1) | 239 .Times(1) |
252 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); | 240 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator))); |
253 EXPECT_CALL(*mock_login_utils_, | 241 EXPECT_CALL(*mock_login_utils_, |
254 PrepareProfile(kUsername, _, kPassword, false, _, _, _)) | 242 PrepareProfile(kUsername, _, kPassword, false, _, _, _)) |
255 .Times(1) | 243 .Times(1) |
256 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, | 244 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, |
257 &base::Callback<void(void)>::Run)); | 245 &base::Callback<void(void)>::Run)); |
258 EXPECT_CALL(*mock_login_utils_, | 246 EXPECT_CALL(*mock_login_utils_, |
259 DoBrowserLaunch(testing_profile_.get(), | 247 DoBrowserLaunch(testing_profile_.get(), |
260 mock_login_display_host_.get())) | 248 mock_login_display_host_.get())) |
261 .Times(1); | 249 .Times(1); |
262 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) | 250 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) |
263 .Times(1); | 251 .Times(1); |
264 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 252 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
265 .Times(1); | 253 .Times(1); |
266 EXPECT_CALL(*mock_login_display_host_, | 254 EXPECT_CALL(*mock_login_display_host_, |
267 StartWizard(WizardController::kUserImageScreenName, NULL)) | 255 StartWizard(WizardController::kUserImageScreenName, NULL)) |
268 .Times(0); | 256 .Times(0); |
269 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) | 257 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) |
270 .Times(AnyNumber()) | 258 .Times(AnyNumber()) |
271 .WillRepeatedly(Return(false)); | 259 .WillRepeatedly(Return(false)); |
272 existing_user_controller()->Login(kUsername, kPassword); | 260 existing_user_controller()->Login(kUsername, kPassword); |
273 content::RunAllPendingInMessageLoop(); | 261 content::RunAllPendingInMessageLoop(); |
274 } | 262 } |
275 | 263 |
276 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 264 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { |
277 MAYBE_AutoEnrollAfterSignIn) { | |
278 EXPECT_CALL(*mock_login_display_host_, | 265 EXPECT_CALL(*mock_login_display_host_, |
279 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 266 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) |
280 .Times(1); | 267 .Times(1); |
281 EXPECT_CALL(*mock_login_display_, OnFadeOut()) | 268 EXPECT_CALL(*mock_login_display_, OnFadeOut()) |
282 .Times(1); | 269 .Times(1); |
283 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 270 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
284 .Times(1); | 271 .Times(1); |
285 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) | 272 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) |
286 .Times(AnyNumber()) | 273 .Times(AnyNumber()) |
287 .WillRepeatedly(Return(false)); | 274 .WillRepeatedly(Return(false)); |
288 existing_user_controller()->DoAutoEnrollment(); | 275 existing_user_controller()->DoAutoEnrollment(); |
289 existing_user_controller()->CompleteLogin(kUsername, kPassword); | 276 existing_user_controller()->CompleteLogin(kUsername, kPassword); |
290 content::RunAllPendingInMessageLoop(); | 277 content::RunAllPendingInMessageLoop(); |
291 } | 278 } |
292 | 279 |
293 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, | 280 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, |
294 MAYBE_NewUserDontAutoEnrollAfterSignIn) { | 281 NewUserDontAutoEnrollAfterSignIn) { |
295 EXPECT_CALL(*mock_login_display_host_, | 282 EXPECT_CALL(*mock_login_display_host_, |
296 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) | 283 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) |
297 .Times(0); | 284 .Times(0); |
298 // That will be sign in of a new user and (legacy) registration screen is | 285 // That will be sign in of a new user and (legacy) registration screen is |
299 // activated. In a real WizardController instance that is immediately switched | 286 // activated. In a real WizardController instance that is immediately switched |
300 // to image screen but this tests uses MockLoginDisplayHost instead. | 287 // to image screen but this tests uses MockLoginDisplayHost instead. |
301 EXPECT_CALL(*mock_login_display_host_, | 288 EXPECT_CALL(*mock_login_display_host_, |
302 StartWizard(AnyOf(WizardController::kRegistrationScreenName, | 289 StartWizard(AnyOf(WizardController::kRegistrationScreenName, |
303 WizardController::kUserImageScreenName), _)) | 290 WizardController::kUserImageScreenName), _)) |
304 .Times(1); | 291 .Times(1); |
(...skipping 12 matching lines...) Expand all Loading... |
317 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) | 304 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) |
318 .Times(1); | 305 .Times(1); |
319 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) | 306 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) |
320 .Times(AnyNumber()) | 307 .Times(AnyNumber()) |
321 .WillRepeatedly(Return(true)); | 308 .WillRepeatedly(Return(true)); |
322 existing_user_controller()->CompleteLogin(kNewUsername, kPassword); | 309 existing_user_controller()->CompleteLogin(kNewUsername, kPassword); |
323 content::RunAllPendingInMessageLoop(); | 310 content::RunAllPendingInMessageLoop(); |
324 } | 311 } |
325 | 312 |
326 } // namespace chromeos | 313 } // namespace chromeos |
OLD | NEW |