OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "apps/shell_window.h" | 5 #include "apps/shell_window.h" |
6 #include "apps/shell_window_registry.h" | 6 #include "apps/shell_window_registry.h" |
7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
8 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; | 64 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; |
65 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; | 65 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; |
66 const char kTestRefreshToken[] = "fake-refresh-token"; | 66 const char kTestRefreshToken[] = "fake-refresh-token"; |
67 const char kTestUserinfoToken[] = "fake-userinfo-token"; | 67 const char kTestUserinfoToken[] = "fake-userinfo-token"; |
68 const char kTestLoginToken[] = "fake-login-token"; | 68 const char kTestLoginToken[] = "fake-login-token"; |
69 const char kTestAccessToken[] = "fake-access-token"; | 69 const char kTestAccessToken[] = "fake-access-token"; |
70 const char kTestClientId[] = "fake-client-id"; | 70 const char kTestClientId[] = "fake-client-id"; |
71 const char kTestAppScope[] = | 71 const char kTestAppScope[] = |
72 "https://www.googleapis.com/auth/userinfo.profile"; | 72 "https://www.googleapis.com/auth/userinfo.profile"; |
73 | 73 |
74 // Helper function for GetConsumerKioskModeStatusCallback. | 74 // Helper function for GetConsumerKioskAutoLaunchStatusCallback. |
75 void ConsumerKioskModeStatusCheck( | 75 void ConsumerKioskAutoLaunchStatusCheck( |
76 KioskAppManager::ConsumerKioskModeStatus* out_status, | 76 KioskAppManager::ConsumerKioskAutoLaunchStatus* out_status, |
77 const base::Closure& runner_quit_task, | 77 const base::Closure& runner_quit_task, |
78 KioskAppManager::ConsumerKioskModeStatus in_status) { | 78 KioskAppManager::ConsumerKioskAutoLaunchStatus in_status) { |
79 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; | 79 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; |
80 *out_status = in_status; | 80 *out_status = in_status; |
81 runner_quit_task.Run(); | 81 runner_quit_task.Run(); |
82 } | 82 } |
83 | 83 |
84 // Helper KioskAppManager::EnableKioskModeCallback implementation. | 84 // Helper KioskAppManager::EnableKioskModeCallback implementation. |
85 void ConsumerKioskModeLockCheck( | 85 void ConsumerKioskModeAutoStartLockCheck( |
86 bool* out_locked, | 86 bool* out_locked, |
87 const base::Closure& runner_quit_task, | 87 const base::Closure& runner_quit_task, |
88 bool in_locked) { | 88 bool in_locked) { |
89 LOG(INFO) << "kiosk locked = " << in_locked; | 89 LOG(INFO) << "kiosk locked = " << in_locked; |
90 *out_locked = in_locked; | 90 *out_locked = in_locked; |
91 runner_quit_task.Run(); | 91 runner_quit_task.Run(); |
92 } | 92 } |
93 | 93 |
94 // Helper function for WaitForNetworkTimeOut. | 94 // Helper function for WaitForNetworkTimeOut. |
95 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { | 95 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 runner->Run(); | 338 runner->Run(); |
339 | 339 |
340 CHECK(GetAppLaunchController()->network_wait_timedout()); | 340 CHECK(GetAppLaunchController()->network_wait_timedout()); |
341 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); | 341 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); |
342 } | 342 } |
343 | 343 |
344 void EnableConsumerKioskMode() { | 344 void EnableConsumerKioskMode() { |
345 scoped_ptr<bool> locked(new bool(false)); | 345 scoped_ptr<bool> locked(new bool(false)); |
346 scoped_refptr<content::MessageLoopRunner> runner = | 346 scoped_refptr<content::MessageLoopRunner> runner = |
347 new content::MessageLoopRunner; | 347 new content::MessageLoopRunner; |
348 KioskAppManager::Get()->EnableConsumerModeKiosk( | 348 KioskAppManager::Get()->EnableConsumerModeKioskAutoStart( |
349 base::Bind(&ConsumerKioskModeLockCheck, | 349 base::Bind(&ConsumerKioskModeAutoStartLockCheck, |
350 locked.get(), | 350 locked.get(), |
351 runner->QuitClosure())); | 351 runner->QuitClosure())); |
352 runner->Run(); | 352 runner->Run(); |
353 EXPECT_TRUE(*locked.get()); | 353 EXPECT_TRUE(*locked.get()); |
354 } | 354 } |
355 | 355 |
356 KioskAppManager::ConsumerKioskModeStatus GetConsumerKioskModeStatus() { | 356 KioskAppManager::ConsumerKioskAutoLaunchStatus |
357 KioskAppManager::ConsumerKioskModeStatus status = | 357 GetConsumerKioskModeStatus() { |
358 static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1); | 358 KioskAppManager::ConsumerKioskAutoLaunchStatus status = |
| 359 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1); |
359 scoped_refptr<content::MessageLoopRunner> runner = | 360 scoped_refptr<content::MessageLoopRunner> runner = |
360 new content::MessageLoopRunner; | 361 new content::MessageLoopRunner; |
361 KioskAppManager::Get()->GetConsumerKioskModeStatus( | 362 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
362 base::Bind(&ConsumerKioskModeStatusCheck, | 363 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, |
363 &status, | 364 &status, |
364 runner->QuitClosure())); | 365 runner->QuitClosure())); |
365 runner->Run(); | 366 runner->Run(); |
366 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); | 367 CHECK_NE(status, |
| 368 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1)); |
367 return status; | 369 return status; |
368 } | 370 } |
369 | 371 |
370 AppLaunchController* GetAppLaunchController() { | 372 AppLaunchController* GetAppLaunchController() { |
371 return chromeos::LoginDisplayHostImpl::default_host() | 373 return chromeos::LoginDisplayHostImpl::default_host() |
372 ->GetAppLaunchController(); | 374 ->GetAppLaunchController(); |
373 } | 375 } |
374 | 376 |
375 scoped_ptr<MockUserManager> mock_user_manager_; | 377 scoped_ptr<MockUserManager> mock_user_manager_; |
376 }; | 378 }; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 WaitForAppLaunchSuccess(); | 531 WaitForAppLaunchSuccess(); |
530 } | 532 } |
531 | 533 |
532 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) { | 534 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) { |
533 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 535 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
534 chromeos::WizardController* wizard_controller = | 536 chromeos::WizardController* wizard_controller = |
535 chromeos::WizardController::default_controller(); | 537 chromeos::WizardController::default_controller(); |
536 CHECK(wizard_controller); | 538 CHECK(wizard_controller); |
537 | 539 |
538 // Check Kiosk mode status. | 540 // Check Kiosk mode status. |
539 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 541 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
540 GetConsumerKioskModeStatus()); | 542 GetConsumerKioskModeStatus()); |
541 | 543 |
542 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 544 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
543 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 545 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
544 content::WindowedNotificationObserver( | 546 content::WindowedNotificationObserver( |
545 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 547 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
546 content::NotificationService::AllSources()).Wait(); | 548 content::NotificationService::AllSources()).Wait(); |
547 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 549 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
548 base::StringValue("kiosk_enable")); | 550 base::StringValue("kiosk_enable")); |
549 | 551 |
550 // Wait for the kiosk_enable screen to show and cancel the screen. | 552 // Wait for the kiosk_enable screen to show and cancel the screen. |
551 content::WindowedNotificationObserver( | 553 content::WindowedNotificationObserver( |
552 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 554 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
553 content::NotificationService::AllSources()).Wait(); | 555 content::NotificationService::AllSources()).Wait(); |
554 GetLoginUI()->CallJavascriptFunction( | 556 GetLoginUI()->CallJavascriptFunction( |
555 "login.KioskEnableScreen.enableKioskForTesting", | 557 "login.KioskEnableScreen.enableKioskForTesting", |
556 base::FundamentalValue(false)); | 558 base::FundamentalValue(false)); |
557 | 559 |
558 // Wait for the kiosk_enable screen to disappear. | 560 // Wait for the kiosk_enable screen to disappear. |
559 content::WindowedNotificationObserver( | 561 content::WindowedNotificationObserver( |
560 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_COMPLETED, | 562 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_COMPLETED, |
561 content::NotificationService::AllSources()).Wait(); | 563 content::NotificationService::AllSources()).Wait(); |
562 | 564 |
563 // Check that the status still says configurable. | 565 // Check that the status still says configurable. |
564 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 566 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
565 GetConsumerKioskModeStatus()); | 567 GetConsumerKioskModeStatus()); |
566 } | 568 } |
567 | 569 |
568 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) { | 570 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) { |
569 // Start UI, find menu entry for this app and launch it. | 571 // Start UI, find menu entry for this app and launch it. |
570 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 572 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
571 chromeos::WizardController* wizard_controller = | 573 chromeos::WizardController* wizard_controller = |
572 chromeos::WizardController::default_controller(); | 574 chromeos::WizardController::default_controller(); |
573 CHECK(wizard_controller); | 575 CHECK(wizard_controller); |
574 | 576 |
575 // Check Kiosk mode status. | 577 // Check Kiosk mode status. |
576 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 578 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
577 GetConsumerKioskModeStatus()); | 579 GetConsumerKioskModeStatus()); |
578 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 580 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
579 | 581 |
580 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 582 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
581 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 583 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
582 content::WindowedNotificationObserver( | 584 content::WindowedNotificationObserver( |
583 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 585 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
584 content::NotificationService::AllSources()).Wait(); | 586 content::NotificationService::AllSources()).Wait(); |
585 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 587 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
586 base::StringValue("kiosk_enable")); | 588 base::StringValue("kiosk_enable")); |
587 | 589 |
588 // Wait for the kiosk_enable screen to show and cancel the screen. | 590 // Wait for the kiosk_enable screen to show and cancel the screen. |
589 content::WindowedNotificationObserver( | 591 content::WindowedNotificationObserver( |
590 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 592 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
591 content::NotificationService::AllSources()).Wait(); | 593 content::NotificationService::AllSources()).Wait(); |
592 GetLoginUI()->CallJavascriptFunction( | 594 GetLoginUI()->CallJavascriptFunction( |
593 "login.KioskEnableScreen.enableKioskForTesting", | 595 "login.KioskEnableScreen.enableKioskForTesting", |
594 base::FundamentalValue(true)); | 596 base::FundamentalValue(true)); |
595 | 597 |
596 // Wait for the signal that indicates Kiosk Mode is enabled. | 598 // Wait for the signal that indicates Kiosk Mode is enabled. |
597 content::WindowedNotificationObserver( | 599 content::WindowedNotificationObserver( |
598 chrome::NOTIFICATION_KIOSK_ENABLED, | 600 chrome::NOTIFICATION_KIOSK_ENABLED, |
599 content::NotificationService::AllSources()).Wait(); | 601 content::NotificationService::AllSources()).Wait(); |
600 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED, | 602 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, |
601 GetConsumerKioskModeStatus()); | 603 GetConsumerKioskModeStatus()); |
602 } | 604 } |
603 | 605 |
604 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAbortedWithAutoEnrollment) { | 606 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAbortedWithAutoEnrollment) { |
605 // Fake an auto enrollment is going to be enforced. | 607 // Fake an auto enrollment is going to be enforced. |
606 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 608 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
607 switches::kEnterpriseEnrollmentInitialModulus, "1"); | 609 switches::kEnterpriseEnrollmentInitialModulus, "1"); |
608 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 610 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
609 switches::kEnterpriseEnrollmentModulusLimit, "2"); | 611 switches::kEnterpriseEnrollmentModulusLimit, "2"); |
610 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, true); | 612 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, true); |
611 g_browser_process->local_state()->SetInteger( | 613 g_browser_process->local_state()->SetInteger( |
612 prefs::kAutoEnrollmentPowerLimit, 3); | 614 prefs::kAutoEnrollmentPowerLimit, 3); |
613 | 615 |
614 // Start UI, find menu entry for this app and launch it. | 616 // Start UI, find menu entry for this app and launch it. |
615 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 617 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
616 chromeos::WizardController* wizard_controller = | 618 chromeos::WizardController* wizard_controller = |
617 chromeos::WizardController::default_controller(); | 619 chromeos::WizardController::default_controller(); |
618 CHECK(wizard_controller); | 620 CHECK(wizard_controller); |
619 | 621 |
620 // Check Kiosk mode status. | 622 // Check Kiosk mode status. |
621 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 623 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
622 GetConsumerKioskModeStatus()); | 624 GetConsumerKioskModeStatus()); |
623 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 625 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
624 | 626 |
625 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 627 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
626 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 628 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
627 content::WindowedNotificationObserver( | 629 content::WindowedNotificationObserver( |
628 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 630 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
629 content::NotificationService::AllSources()).Wait(); | 631 content::NotificationService::AllSources()).Wait(); |
630 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 632 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
631 base::StringValue("kiosk_enable")); | 633 base::StringValue("kiosk_enable")); |
(...skipping 15 matching lines...) Expand all Loading... |
647 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, false); | 649 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, false); |
648 g_browser_process->local_state()->SetInteger( | 650 g_browser_process->local_state()->SetInteger( |
649 prefs::kAutoEnrollmentPowerLimit, -1); | 651 prefs::kAutoEnrollmentPowerLimit, -1); |
650 | 652 |
651 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 653 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
652 chromeos::WizardController* wizard_controller = | 654 chromeos::WizardController* wizard_controller = |
653 chromeos::WizardController::default_controller(); | 655 chromeos::WizardController::default_controller(); |
654 CHECK(wizard_controller); | 656 CHECK(wizard_controller); |
655 | 657 |
656 // Check Kiosk mode status. | 658 // Check Kiosk mode status. |
657 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 659 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
658 GetConsumerKioskModeStatus()); | 660 GetConsumerKioskModeStatus()); |
659 | 661 |
660 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 662 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
661 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 663 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
662 content::WindowedNotificationObserver( | 664 content::WindowedNotificationObserver( |
663 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 665 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
664 content::NotificationService::AllSources()).Wait(); | 666 content::NotificationService::AllSources()).Wait(); |
665 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 667 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
666 base::StringValue("kiosk_enable")); | 668 base::StringValue("kiosk_enable")); |
667 | 669 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 content::WindowedNotificationObserver( | 894 content::WindowedNotificationObserver( |
893 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 895 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
894 content::NotificationService::AllSources()).Wait(); | 896 content::NotificationService::AllSources()).Wait(); |
895 | 897 |
896 // Wait for the wallpaper to load. | 898 // Wait for the wallpaper to load. |
897 WaitForWallpaper(); | 899 WaitForWallpaper(); |
898 EXPECT_TRUE(wallpaper_loaded()); | 900 EXPECT_TRUE(wallpaper_loaded()); |
899 } | 901 } |
900 | 902 |
901 } // namespace chromeos | 903 } // namespace chromeos |
OLD | NEW |