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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; | 75 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; |
76 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; | 76 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; |
77 const char kTestRefreshToken[] = "fake-refresh-token"; | 77 const char kTestRefreshToken[] = "fake-refresh-token"; |
78 const char kTestUserinfoToken[] = "fake-userinfo-token"; | 78 const char kTestUserinfoToken[] = "fake-userinfo-token"; |
79 const char kTestLoginToken[] = "fake-login-token"; | 79 const char kTestLoginToken[] = "fake-login-token"; |
80 const char kTestAccessToken[] = "fake-access-token"; | 80 const char kTestAccessToken[] = "fake-access-token"; |
81 const char kTestClientId[] = "fake-client-id"; | 81 const char kTestClientId[] = "fake-client-id"; |
82 const char kTestAppScope[] = | 82 const char kTestAppScope[] = |
83 "https://www.googleapis.com/auth/userinfo.profile"; | 83 "https://www.googleapis.com/auth/userinfo.profile"; |
84 | 84 |
| 85 // Test JS API. |
| 86 const char kLaunchAppForTestNewAPI[] = |
| 87 "login.AccountPickerScreen.runAppForTesting"; |
| 88 const char kLaunchAppForTestOldAPI[] = |
| 89 "login.AppsMenuButton.runAppForTesting"; |
| 90 const char kCheckDiagnosticModeNewAPI[] = |
| 91 "$('oobe').confirmDiagnosticMode_"; |
| 92 const char kCheckDiagnosticModeOldAPI[] = |
| 93 "$('show-apps-button').confirmDiagnosticMode_"; |
| 94 |
85 // Helper function for GetConsumerKioskAutoLaunchStatusCallback. | 95 // Helper function for GetConsumerKioskAutoLaunchStatusCallback. |
86 void ConsumerKioskAutoLaunchStatusCheck( | 96 void ConsumerKioskAutoLaunchStatusCheck( |
87 KioskAppManager::ConsumerKioskAutoLaunchStatus* out_status, | 97 KioskAppManager::ConsumerKioskAutoLaunchStatus* out_status, |
88 const base::Closure& runner_quit_task, | 98 const base::Closure& runner_quit_task, |
89 KioskAppManager::ConsumerKioskAutoLaunchStatus in_status) { | 99 KioskAppManager::ConsumerKioskAutoLaunchStatus in_status) { |
90 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; | 100 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; |
91 *out_status = in_status; | 101 *out_status = in_status; |
92 runner_quit_task.Run(); | 102 runner_quit_task.Run(); |
93 } | 103 } |
94 | 104 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 302 } |
293 | 303 |
294 GURL GetTestWebstoreUrl() { | 304 GURL GetTestWebstoreUrl() { |
295 const GURL& server_url = embedded_test_server()->base_url(); | 305 const GURL& server_url = embedded_test_server()->base_url(); |
296 std::string webstore_host("webstore"); | 306 std::string webstore_host("webstore"); |
297 GURL::Replacements replace_webstore_host; | 307 GURL::Replacements replace_webstore_host; |
298 replace_webstore_host.SetHostStr(webstore_host); | 308 replace_webstore_host.SetHostStr(webstore_host); |
299 return server_url.ReplaceComponents(replace_webstore_host); | 309 return server_url.ReplaceComponents(replace_webstore_host); |
300 } | 310 } |
301 | 311 |
| 312 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { |
| 313 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()-> |
| 314 HasSwitch(switches::kDisableNewKioskUI); |
| 315 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? |
| 316 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, |
| 317 base::StringValue(app_id), |
| 318 base::FundamentalValue(diagnostic_mode)); |
| 319 } |
| 320 |
302 void ReloadKioskApps() { | 321 void ReloadKioskApps() { |
303 KioskAppManager::Get()->AddApp(test_app_id_); | 322 KioskAppManager::Get()->AddApp(test_app_id_); |
304 } | 323 } |
305 | 324 |
306 void ReloadAutolaunchKioskApps() { | 325 void ReloadAutolaunchKioskApps() { |
307 KioskAppManager::Get()->AddApp(test_app_id_); | 326 KioskAppManager::Get()->AddApp(test_app_id_); |
308 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); | 327 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); |
309 } | 328 } |
310 | 329 |
311 void PrepareAppLaunch() { | 330 void PrepareAppLaunch() { |
(...skipping 17 matching lines...) Expand all Loading... |
329 ReloadKioskApps(); | 348 ReloadKioskApps(); |
330 apps_loaded_signal.Wait(); | 349 apps_loaded_signal.Wait(); |
331 } | 350 } |
332 | 351 |
333 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { | 352 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { |
334 PrepareAppLaunch(); | 353 PrepareAppLaunch(); |
335 | 354 |
336 if (!network_setup_cb.is_null()) | 355 if (!network_setup_cb.is_null()) |
337 network_setup_cb.Run(); | 356 network_setup_cb.Run(); |
338 | 357 |
339 GetLoginUI()->CallJavascriptFunction( | 358 LaunchApp(test_app_id(), false); |
340 "login.AppsMenuButton.runAppForTesting", | |
341 base::StringValue(test_app_id_)); | |
342 } | 359 } |
343 | 360 |
344 const extensions::Extension* GetInstalledApp() { | 361 const extensions::Extension* GetInstalledApp() { |
345 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); | 362 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); |
346 return extensions::ExtensionSystem::Get(app_profile)-> | 363 return extensions::ExtensionSystem::Get(app_profile)-> |
347 extension_service()->GetInstalledExtension(test_app_id_); | 364 extension_service()->GetInstalledExtension(test_app_id_); |
348 } | 365 } |
349 | 366 |
350 const Version& GetInstalledAppVersion() { | 367 const Version& GetInstalledAppVersion() { |
351 return *GetInstalledApp()->version(); | 368 return *GetInstalledApp()->version(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 base::StringValue("app_launch_bailout")); | 593 base::StringValue("app_launch_bailout")); |
577 signal.Wait(); | 594 signal.Wait(); |
578 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL, | 595 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL, |
579 chromeos::KioskAppLaunchError::Get()); | 596 chromeos::KioskAppLaunchError::Get()); |
580 } | 597 } |
581 | 598 |
582 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchInDiagnosticMode) { | 599 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchInDiagnosticMode) { |
583 PrepareAppLaunch(); | 600 PrepareAppLaunch(); |
584 SimulateNetworkOnline(); | 601 SimulateNetworkOnline(); |
585 | 602 |
586 GetLoginUI()->CallJavascriptFunction( | 603 LaunchApp(kTestKioskApp, true); |
587 "login.AppsMenuButton.runAppForTesting", | |
588 base::StringValue(kTestKioskApp), | |
589 base::FundamentalValue(true)); | |
590 | 604 |
591 content::WebContents* login_contents = GetLoginUI()->GetWebContents(); | 605 content::WebContents* login_contents = GetLoginUI()->GetWebContents(); |
592 | 606 |
593 JsConditionWaiter(login_contents, | 607 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()-> |
594 "$('show-apps-button').confirmDiagnosticMode_").Wait(); | 608 HasSwitch(switches::kDisableNewKioskUI); |
| 609 JsConditionWaiter(login_contents, new_kiosk_ui ? |
| 610 kCheckDiagnosticModeNewAPI : kCheckDiagnosticModeOldAPI).Wait(); |
595 | 611 |
| 612 std::string diagnosticMode(new_kiosk_ui ? |
| 613 kCheckDiagnosticModeNewAPI : kCheckDiagnosticModeOldAPI); |
596 ASSERT_TRUE(content::ExecuteScript( | 614 ASSERT_TRUE(content::ExecuteScript( |
597 login_contents, | 615 login_contents, |
598 "(function() {" | 616 "(function() {" |
599 "var e = new Event('click');" | 617 "var e = new Event('click');" + |
600 "$('show-apps-button').confirmDiagnosticMode_." | 618 diagnosticMode + "." |
601 "okButton_.dispatchEvent(e);" | 619 "okButton_.dispatchEvent(e);" |
602 "})();")); | 620 "})();")); |
603 | 621 |
604 WaitForAppLaunchSuccess(); | 622 WaitForAppLaunchSuccess(); |
605 } | 623 } |
606 | 624 |
607 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoNetwork) { | 625 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoNetwork) { |
608 set_test_app_id(kTestOfflineEnabledKioskApp); | 626 set_test_app_id(kTestOfflineEnabledKioskApp); |
609 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 627 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
610 | 628 |
611 PrepareAppLaunch(); | 629 PrepareAppLaunch(); |
612 SimulateNetworkOffline(); | 630 SimulateNetworkOffline(); |
613 | 631 |
614 GetLoginUI()->CallJavascriptFunction( | 632 LaunchApp(test_app_id(), false); |
615 "login.AppsMenuButton.runAppForTesting", | |
616 base::StringValue(test_app_id())); | |
617 WaitForAppLaunchSuccess(); | 633 WaitForAppLaunchSuccess(); |
618 } | 634 } |
619 | 635 |
620 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoUpdate) { | 636 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoUpdate) { |
621 set_test_app_id(kTestOfflineEnabledKioskApp); | 637 set_test_app_id(kTestOfflineEnabledKioskApp); |
622 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 638 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
623 | 639 |
624 GURL webstore_url = GetTestWebstoreUrl(); | 640 GURL webstore_url = GetTestWebstoreUrl(); |
625 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 641 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
626 ::switches::kAppsGalleryUpdateURL, | 642 ::switches::kAppsGalleryUpdateURL, |
627 webstore_url.Resolve( | 643 webstore_url.Resolve( |
628 "/chromeos/app_mode/webstore/update_check/no_update.xml").spec()); | 644 "/chromeos/app_mode/webstore/update_check/no_update.xml").spec()); |
629 | 645 |
630 PrepareAppLaunch(); | 646 PrepareAppLaunch(); |
631 SimulateNetworkOnline(); | 647 SimulateNetworkOnline(); |
632 | 648 |
633 GetLoginUI()->CallJavascriptFunction( | 649 LaunchApp(test_app_id(), false); |
634 "login.AppsMenuButton.runAppForTesting", | |
635 base::StringValue(test_app_id())); | |
636 WaitForAppLaunchSuccess(); | 650 WaitForAppLaunchSuccess(); |
637 | 651 |
638 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); | 652 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); |
639 } | 653 } |
640 | 654 |
641 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppHasUpdate) { | 655 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppHasUpdate) { |
642 set_test_app_id(kTestOfflineEnabledKioskApp); | 656 set_test_app_id(kTestOfflineEnabledKioskApp); |
643 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 657 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
644 | 658 |
645 GURL webstore_url = GetTestWebstoreUrl(); | 659 GURL webstore_url = GetTestWebstoreUrl(); |
646 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 660 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
647 ::switches::kAppsGalleryUpdateURL, | 661 ::switches::kAppsGalleryUpdateURL, |
648 webstore_url.Resolve( | 662 webstore_url.Resolve( |
649 "/chromeos/app_mode/webstore/update_check/has_update.xml").spec()); | 663 "/chromeos/app_mode/webstore/update_check/has_update.xml").spec()); |
650 | 664 |
651 PrepareAppLaunch(); | 665 PrepareAppLaunch(); |
652 SimulateNetworkOnline(); | 666 SimulateNetworkOnline(); |
653 | 667 |
654 GetLoginUI()->CallJavascriptFunction( | 668 LaunchApp(test_app_id(), false); |
655 "login.AppsMenuButton.runAppForTesting", | |
656 base::StringValue(test_app_id())); | |
657 WaitForAppLaunchSuccess(); | 669 WaitForAppLaunchSuccess(); |
658 | 670 |
659 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); | 671 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); |
660 } | 672 } |
661 | 673 |
662 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { | 674 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { |
663 EnableConsumerKioskMode(); | 675 EnableConsumerKioskMode(); |
664 // Start UI, find menu entry for this app and launch it. | 676 // Start UI, find menu entry for this app and launch it. |
665 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 677 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
666 chromeos::WizardController* wizard_controller = | 678 chromeos::WizardController* wizard_controller = |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 982 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
971 | 983 |
972 // Wait for the Kiosk App configuration to reload, then launch the app. | 984 // Wait for the Kiosk App configuration to reload, then launch the app. |
973 KioskAppManager::App app; | 985 KioskAppManager::App app; |
974 content::WindowedNotificationObserver( | 986 content::WindowedNotificationObserver( |
975 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 987 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
976 base::Bind(&KioskAppManager::GetApp, | 988 base::Bind(&KioskAppManager::GetApp, |
977 base::Unretained(KioskAppManager::Get()), | 989 base::Unretained(KioskAppManager::Get()), |
978 kTestEnterpriseKioskApp, &app)).Wait(); | 990 kTestEnterpriseKioskApp, &app)).Wait(); |
979 | 991 |
980 GetLoginUI()->CallJavascriptFunction( | 992 LaunchApp(kTestEnterpriseKioskApp, false); |
981 "login.AppsMenuButton.runAppForTesting", | |
982 base::StringValue(kTestEnterpriseKioskApp)); | |
983 | 993 |
984 // Wait for the Kiosk App to launch. | 994 // Wait for the Kiosk App to launch. |
985 content::WindowedNotificationObserver( | 995 content::WindowedNotificationObserver( |
986 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, | 996 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, |
987 content::NotificationService::AllSources()).Wait(); | 997 content::NotificationService::AllSources()).Wait(); |
988 | 998 |
989 // Check installer status. | 999 // Check installer status. |
990 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, | 1000 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, |
991 chromeos::KioskAppLaunchError::Get()); | 1001 chromeos::KioskAppLaunchError::Get()); |
992 | 1002 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 content::WindowedNotificationObserver( | 1093 content::WindowedNotificationObserver( |
1084 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1094 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
1085 content::NotificationService::AllSources()).Wait(); | 1095 content::NotificationService::AllSources()).Wait(); |
1086 | 1096 |
1087 // Wait for the wallpaper to load. | 1097 // Wait for the wallpaper to load. |
1088 WaitForWallpaper(); | 1098 WaitForWallpaper(); |
1089 EXPECT_TRUE(wallpaper_loaded()); | 1099 EXPECT_TRUE(wallpaper_loaded()); |
1090 } | 1100 } |
1091 | 1101 |
1092 } // namespace chromeos | 1102 } // namespace chromeos |
OLD | NEW |