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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
10 #include "chrome/browser/chromeos/login/base_login_display_host.h" | |
11 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" | 10 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" |
12 #include "chrome/browser/chromeos/login/enrollment/mock_enterprise_enrollment_sc
reen.h" | 11 #include "chrome/browser/chromeos/login/enrollment/mock_enterprise_enrollment_sc
reen.h" |
13 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 12 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
14 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 13 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
15 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 15 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" | 16 #include "chrome/browser/chromeos/login/mock_login_status_consumer.h" |
17 #include "chrome/browser/chromeos/login/screens/mock_eula_screen.h" | 17 #include "chrome/browser/chromeos/login/screens/mock_eula_screen.h" |
18 #include "chrome/browser/chromeos/login/screens/mock_network_screen.h" | 18 #include "chrome/browser/chromeos/login/screens/mock_network_screen.h" |
19 #include "chrome/browser/chromeos/login/screens/mock_update_screen.h" | 19 #include "chrome/browser/chromeos/login/screens/mock_update_screen.h" |
20 #include "chrome/browser/chromeos/login/screens/network_screen.h" | 20 #include "chrome/browser/chromeos/login/screens/network_screen.h" |
21 #include "chrome/browser/chromeos/login/screens/reset_screen.h" | 21 #include "chrome/browser/chromeos/login/screens/reset_screen.h" |
22 #include "chrome/browser/chromeos/login/screens/user_image_screen.h" | 22 #include "chrome/browser/chromeos/login/screens/user_image_screen.h" |
23 #include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h" | 23 #include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h" |
24 #include "chrome/browser/chromeos/login/test_login_utils.h" | 24 #include "chrome/browser/chromeos/login/test_login_utils.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 ControlFlowEnterpriseAutoEnrollmentCompleted) { | 279 ControlFlowEnterpriseAutoEnrollmentCompleted) { |
280 WizardController::default_controller()->SkipPostLoginScreensForTesting(); | 280 WizardController::default_controller()->SkipPostLoginScreensForTesting(); |
281 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), | 281 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), |
282 WizardController::default_controller()->current_screen()); | 282 WizardController::default_controller()->current_screen()); |
283 EXPECT_CALL(*mock_update_screen_, StartNetworkCheck()).Times(0); | 283 EXPECT_CALL(*mock_update_screen_, StartNetworkCheck()).Times(0); |
284 | 284 |
285 LoginUtils::Set(new TestLoginUtils(kUsername, kPassword)); | 285 LoginUtils::Set(new TestLoginUtils(kUsername, kPassword)); |
286 MockConsumer mock_consumer; | 286 MockConsumer mock_consumer; |
287 | 287 |
288 // Must have a pending signin to resume after auto-enrollment: | 288 // Must have a pending signin to resume after auto-enrollment: |
289 BaseLoginDisplayHost::default_host()->StartSignInScreen(); | 289 LoginDisplayHostImpl::default_host()->StartSignInScreen(); |
290 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); | 290 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); |
291 ExistingUserController::current_controller()->DoAutoEnrollment(); | 291 ExistingUserController::current_controller()->DoAutoEnrollment(); |
292 ExistingUserController::current_controller()->set_login_status_consumer( | 292 ExistingUserController::current_controller()->set_login_status_consumer( |
293 &mock_consumer); | 293 &mock_consumer); |
294 // This calls StartWizard, destroying the current controller() and its mocks; | 294 // This calls StartWizard, destroying the current controller() and its mocks; |
295 // don't set expectations on those objects. | 295 // don't set expectations on those objects. |
296 ExistingUserController::current_controller()->CompleteLogin( | 296 ExistingUserController::current_controller()->CompleteLogin( |
297 UserContext(kUsername, kPassword, "")); | 297 UserContext(kUsername, kPassword, "")); |
298 // Run the tasks posted to complete the login: | 298 // Run the tasks posted to complete the login: |
299 MessageLoop::current()->RunUntilIdle(); | 299 MessageLoop::current()->RunUntilIdle(); |
300 | 300 |
301 EnterpriseEnrollmentScreen* screen = | 301 EnterpriseEnrollmentScreen* screen = |
302 WizardController::default_controller()->GetEnterpriseEnrollmentScreen(); | 302 WizardController::default_controller()->GetEnterpriseEnrollmentScreen(); |
303 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); | 303 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); |
304 // This is the main expectation: after auto-enrollment, login is resumed. | 304 // This is the main expectation: after auto-enrollment, login is resumed. |
305 EXPECT_CALL(mock_consumer, OnLoginSuccess(_, _, _)).Times(1); | 305 EXPECT_CALL(mock_consumer, OnLoginSuccess(_, _, _)).Times(1); |
306 OnExit(ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); | 306 OnExit(ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); |
307 // Prevent browser launch when the profile is prepared: | 307 // Prevent browser launch when the profile is prepared: |
308 browser_shutdown::SetTryingToQuit(true); | 308 browser_shutdown::SetTryingToQuit(true); |
309 // Run the tasks posted to complete the login: | 309 // Run the tasks posted to complete the login: |
310 MessageLoop::current()->RunUntilIdle(); | 310 MessageLoop::current()->RunUntilIdle(); |
311 } | 311 } |
312 | 312 |
313 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowResetScreen) { | 313 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowResetScreen) { |
314 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), | 314 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), |
315 WizardController::default_controller()->current_screen()); | 315 WizardController::default_controller()->current_screen()); |
316 | 316 |
317 BaseLoginDisplayHost::default_host()->StartSignInScreen(); | 317 LoginDisplayHostImpl::default_host()->StartSignInScreen(); |
318 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); | 318 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); |
319 ExistingUserController::current_controller()->OnStartDeviceReset(); | 319 ExistingUserController::current_controller()->OnStartDeviceReset(); |
320 | 320 |
321 ResetScreen* screen = | 321 ResetScreen* screen = |
322 WizardController::default_controller()->GetResetScreen(); | 322 WizardController::default_controller()->GetResetScreen(); |
323 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); | 323 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); |
324 | 324 |
325 // After reset screen is canceled, it returns to sign-in screen. | 325 // After reset screen is canceled, it returns to sign-in screen. |
326 // And this destroys WizardController. | 326 // And this destroys WizardController. |
327 OnExit(ScreenObserver::RESET_CANCELED); | 327 OnExit(ScreenObserver::RESET_CANCELED); |
328 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); | 328 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); |
329 } | 329 } |
330 | 330 |
331 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, | 331 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, |
332 ControlFlowWrongHWIDScreenFromLogin) { | 332 ControlFlowWrongHWIDScreenFromLogin) { |
333 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), | 333 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), |
334 WizardController::default_controller()->current_screen()); | 334 WizardController::default_controller()->current_screen()); |
335 | 335 |
336 BaseLoginDisplayHost::default_host()->StartSignInScreen(); | 336 LoginDisplayHostImpl::default_host()->StartSignInScreen(); |
337 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); | 337 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); |
338 ExistingUserController::current_controller()->ShowWrongHWIDScreen(); | 338 ExistingUserController::current_controller()->ShowWrongHWIDScreen(); |
339 | 339 |
340 WrongHWIDScreen* screen = | 340 WrongHWIDScreen* screen = |
341 WizardController::default_controller()->GetWrongHWIDScreen(); | 341 WizardController::default_controller()->GetWrongHWIDScreen(); |
342 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); | 342 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); |
343 | 343 |
344 // After warning is skipped, user returns to sign-in screen. | 344 // After warning is skipped, user returns to sign-in screen. |
345 // And this destroys WizardController. | 345 // And this destroys WizardController. |
346 OnExit(ScreenObserver::WRONG_HWID_WARNING_SKIPPED); | 346 OnExit(ScreenObserver::WRONG_HWID_WARNING_SKIPPED); |
347 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); | 347 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); |
348 } | 348 } |
349 | 349 |
350 // TODO(dzhioev): Add test emaulating device with wrong HWID. | 350 // TODO(dzhioev): Add test emaulating device with wrong HWID. |
351 | 351 |
352 // TODO(nkostylev): Add test for WebUI accelerators http://crosbug.com/22571 | 352 // TODO(nkostylev): Add test for WebUI accelerators http://crosbug.com/22571 |
353 | 353 |
354 COMPILE_ASSERT(ScreenObserver::EXIT_CODES_COUNT == 15, | 354 COMPILE_ASSERT(ScreenObserver::EXIT_CODES_COUNT == 15, |
355 add_tests_for_new_control_flow_you_just_introduced); | 355 add_tests_for_new_control_flow_you_just_introduced); |
356 | 356 |
357 } // namespace chromeos | 357 } // namespace chromeos |
OLD | NEW |