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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 runner->Run(); | 389 runner->Run(); |
390 | 390 |
391 CHECK(GetAppLaunchController()->network_wait_timedout()); | 391 CHECK(GetAppLaunchController()->network_wait_timedout()); |
392 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); | 392 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); |
393 } | 393 } |
394 | 394 |
395 void EnableConsumerKioskMode() { | 395 void EnableConsumerKioskMode() { |
396 scoped_ptr<bool> locked(new bool(false)); | 396 scoped_ptr<bool> locked(new bool(false)); |
397 scoped_refptr<content::MessageLoopRunner> runner = | 397 scoped_refptr<content::MessageLoopRunner> runner = |
398 new content::MessageLoopRunner; | 398 new content::MessageLoopRunner; |
399 KioskAppManager::Get()->EnableConsumerModeKiosk( | 399 KioskAppManager::Get()->EnableConsumerKioskAutoLaunch( |
400 base::Bind(&ConsumerKioskModeLockCheck, | 400 base::Bind(&ConsumerKioskModeAutoStartLockCheck, |
401 locked.get(), | 401 locked.get(), |
402 runner->QuitClosure())); | 402 runner->QuitClosure())); |
403 runner->Run(); | 403 runner->Run(); |
404 EXPECT_TRUE(*locked.get()); | 404 EXPECT_TRUE(*locked.get()); |
405 } | 405 } |
406 | 406 |
407 KioskAppManager::ConsumerKioskModeStatus GetConsumerKioskModeStatus() { | 407 KioskAppManager::ConsumerKioskAutoLaunchStatus |
408 KioskAppManager::ConsumerKioskModeStatus status = | 408 GetConsumerKioskModeStatus() { |
409 static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1); | 409 KioskAppManager::ConsumerKioskAutoLaunchStatus status = |
| 410 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1); |
410 scoped_refptr<content::MessageLoopRunner> runner = | 411 scoped_refptr<content::MessageLoopRunner> runner = |
411 new content::MessageLoopRunner; | 412 new content::MessageLoopRunner; |
412 KioskAppManager::Get()->GetConsumerKioskModeStatus( | 413 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
413 base::Bind(&ConsumerKioskModeStatusCheck, | 414 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, |
414 &status, | 415 &status, |
415 runner->QuitClosure())); | 416 runner->QuitClosure())); |
416 runner->Run(); | 417 runner->Run(); |
417 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); | 418 CHECK_NE(status, |
| 419 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1)); |
418 return status; | 420 return status; |
419 } | 421 } |
420 | 422 |
421 AppLaunchController* GetAppLaunchController() { | 423 AppLaunchController* GetAppLaunchController() { |
422 return chromeos::LoginDisplayHostImpl::default_host() | 424 return chromeos::LoginDisplayHostImpl::default_host() |
423 ->GetAppLaunchController(); | 425 ->GetAppLaunchController(); |
424 } | 426 } |
425 | 427 |
426 scoped_ptr<MockUserManager> mock_user_manager_; | 428 scoped_ptr<MockUserManager> mock_user_manager_; |
427 }; | 429 }; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 WaitForAppLaunchSuccess(); | 607 WaitForAppLaunchSuccess(); |
606 } | 608 } |
607 | 609 |
608 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) { | 610 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) { |
609 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 611 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
610 chromeos::WizardController* wizard_controller = | 612 chromeos::WizardController* wizard_controller = |
611 chromeos::WizardController::default_controller(); | 613 chromeos::WizardController::default_controller(); |
612 CHECK(wizard_controller); | 614 CHECK(wizard_controller); |
613 | 615 |
614 // Check Kiosk mode status. | 616 // Check Kiosk mode status. |
615 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 617 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
616 GetConsumerKioskModeStatus()); | 618 GetConsumerKioskModeStatus()); |
617 | 619 |
618 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 620 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
619 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 621 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
620 content::WindowedNotificationObserver( | 622 content::WindowedNotificationObserver( |
621 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 623 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
622 content::NotificationService::AllSources()).Wait(); | 624 content::NotificationService::AllSources()).Wait(); |
623 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 625 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
624 base::StringValue("kiosk_enable")); | 626 base::StringValue("kiosk_enable")); |
625 | 627 |
626 // Wait for the kiosk_enable screen to show and cancel the screen. | 628 // Wait for the kiosk_enable screen to show and cancel the screen. |
627 content::WindowedNotificationObserver( | 629 content::WindowedNotificationObserver( |
628 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 630 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
629 content::NotificationService::AllSources()).Wait(); | 631 content::NotificationService::AllSources()).Wait(); |
630 GetLoginUI()->CallJavascriptFunction( | 632 GetLoginUI()->CallJavascriptFunction( |
631 "login.KioskEnableScreen.enableKioskForTesting", | 633 "login.KioskEnableScreen.enableKioskForTesting", |
632 base::FundamentalValue(false)); | 634 base::FundamentalValue(false)); |
633 | 635 |
634 // Wait for the kiosk_enable screen to disappear. | 636 // Wait for the kiosk_enable screen to disappear. |
635 content::WindowedNotificationObserver( | 637 content::WindowedNotificationObserver( |
636 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_COMPLETED, | 638 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_COMPLETED, |
637 content::NotificationService::AllSources()).Wait(); | 639 content::NotificationService::AllSources()).Wait(); |
638 | 640 |
639 // Check that the status still says configurable. | 641 // Check that the status still says configurable. |
640 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 642 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
641 GetConsumerKioskModeStatus()); | 643 GetConsumerKioskModeStatus()); |
642 } | 644 } |
643 | 645 |
644 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) { | 646 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) { |
645 // Start UI, find menu entry for this app and launch it. | 647 // Start UI, find menu entry for this app and launch it. |
646 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 648 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
647 chromeos::WizardController* wizard_controller = | 649 chromeos::WizardController* wizard_controller = |
648 chromeos::WizardController::default_controller(); | 650 chromeos::WizardController::default_controller(); |
649 CHECK(wizard_controller); | 651 CHECK(wizard_controller); |
650 | 652 |
651 // Check Kiosk mode status. | 653 // Check Kiosk mode status. |
652 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 654 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
653 GetConsumerKioskModeStatus()); | 655 GetConsumerKioskModeStatus()); |
654 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 656 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
655 | 657 |
656 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 658 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
657 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 659 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
658 content::WindowedNotificationObserver( | 660 content::WindowedNotificationObserver( |
659 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 661 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
660 content::NotificationService::AllSources()).Wait(); | 662 content::NotificationService::AllSources()).Wait(); |
661 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 663 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
662 base::StringValue("kiosk_enable")); | 664 base::StringValue("kiosk_enable")); |
663 | 665 |
664 // Wait for the kiosk_enable screen to show and cancel the screen. | 666 // Wait for the kiosk_enable screen to show and cancel the screen. |
665 content::WindowedNotificationObserver( | 667 content::WindowedNotificationObserver( |
666 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 668 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
667 content::NotificationService::AllSources()).Wait(); | 669 content::NotificationService::AllSources()).Wait(); |
668 GetLoginUI()->CallJavascriptFunction( | 670 GetLoginUI()->CallJavascriptFunction( |
669 "login.KioskEnableScreen.enableKioskForTesting", | 671 "login.KioskEnableScreen.enableKioskForTesting", |
670 base::FundamentalValue(true)); | 672 base::FundamentalValue(true)); |
671 | 673 |
672 // Wait for the signal that indicates Kiosk Mode is enabled. | 674 // Wait for the signal that indicates Kiosk Mode is enabled. |
673 content::WindowedNotificationObserver( | 675 content::WindowedNotificationObserver( |
674 chrome::NOTIFICATION_KIOSK_ENABLED, | 676 chrome::NOTIFICATION_KIOSK_ENABLED, |
675 content::NotificationService::AllSources()).Wait(); | 677 content::NotificationService::AllSources()).Wait(); |
676 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED, | 678 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, |
677 GetConsumerKioskModeStatus()); | 679 GetConsumerKioskModeStatus()); |
678 } | 680 } |
679 | 681 |
680 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAbortedWithAutoEnrollment) { | 682 IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAbortedWithAutoEnrollment) { |
681 // Fake an auto enrollment is going to be enforced. | 683 // Fake an auto enrollment is going to be enforced. |
682 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 684 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
683 switches::kEnterpriseEnrollmentInitialModulus, "1"); | 685 switches::kEnterpriseEnrollmentInitialModulus, "1"); |
684 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 686 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
685 switches::kEnterpriseEnrollmentModulusLimit, "2"); | 687 switches::kEnterpriseEnrollmentModulusLimit, "2"); |
686 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, true); | 688 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, true); |
687 g_browser_process->local_state()->SetInteger( | 689 g_browser_process->local_state()->SetInteger( |
688 prefs::kAutoEnrollmentPowerLimit, 3); | 690 prefs::kAutoEnrollmentPowerLimit, 3); |
689 | 691 |
690 // Start UI, find menu entry for this app and launch it. | 692 // Start UI, find menu entry for this app and launch it. |
691 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 693 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
692 chromeos::WizardController* wizard_controller = | 694 chromeos::WizardController* wizard_controller = |
693 chromeos::WizardController::default_controller(); | 695 chromeos::WizardController::default_controller(); |
694 CHECK(wizard_controller); | 696 CHECK(wizard_controller); |
695 | 697 |
696 // Check Kiosk mode status. | 698 // Check Kiosk mode status. |
697 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 699 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
698 GetConsumerKioskModeStatus()); | 700 GetConsumerKioskModeStatus()); |
699 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 701 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
700 | 702 |
701 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 703 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
702 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 704 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
703 content::WindowedNotificationObserver( | 705 content::WindowedNotificationObserver( |
704 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 706 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
705 content::NotificationService::AllSources()).Wait(); | 707 content::NotificationService::AllSources()).Wait(); |
706 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 708 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
707 base::StringValue("kiosk_enable")); | 709 base::StringValue("kiosk_enable")); |
(...skipping 15 matching lines...) Expand all Loading... |
723 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, false); | 725 g_browser_process->local_state()->SetBoolean(prefs::kShouldAutoEnroll, false); |
724 g_browser_process->local_state()->SetInteger( | 726 g_browser_process->local_state()->SetInteger( |
725 prefs::kAutoEnrollmentPowerLimit, -1); | 727 prefs::kAutoEnrollmentPowerLimit, -1); |
726 | 728 |
727 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 729 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
728 chromeos::WizardController* wizard_controller = | 730 chromeos::WizardController* wizard_controller = |
729 chromeos::WizardController::default_controller(); | 731 chromeos::WizardController::default_controller(); |
730 CHECK(wizard_controller); | 732 CHECK(wizard_controller); |
731 | 733 |
732 // Check Kiosk mode status. | 734 // Check Kiosk mode status. |
733 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_CONFIGURABLE, | 735 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
734 GetConsumerKioskModeStatus()); | 736 GetConsumerKioskModeStatus()); |
735 | 737 |
736 // Wait for the login UI to come up and switch to the kiosk_enable screen. | 738 // Wait for the login UI to come up and switch to the kiosk_enable screen. |
737 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 739 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
738 content::WindowedNotificationObserver( | 740 content::WindowedNotificationObserver( |
739 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 741 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
740 content::NotificationService::AllSources()).Wait(); | 742 content::NotificationService::AllSources()).Wait(); |
741 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 743 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
742 base::StringValue("kiosk_enable")); | 744 base::StringValue("kiosk_enable")); |
743 | 745 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 content::WindowedNotificationObserver( | 970 content::WindowedNotificationObserver( |
969 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 971 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
970 content::NotificationService::AllSources()).Wait(); | 972 content::NotificationService::AllSources()).Wait(); |
971 | 973 |
972 // Wait for the wallpaper to load. | 974 // Wait for the wallpaper to load. |
973 WaitForWallpaper(); | 975 WaitForWallpaper(); |
974 EXPECT_TRUE(wallpaper_loaded()); | 976 EXPECT_TRUE(wallpaper_loaded()); |
975 } | 977 } |
976 | 978 |
977 } // namespace chromeos | 979 } // namespace chromeos |
OLD | NEW |