Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1743)

Side by Side Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 158833003: Represent kiosk apps as user pods instead of menu items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review + fixes Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 const char kLaunchAppForTestNewAPI[] =
75 "login.AccountPickerScreen.runAppForTesting";
76 const char kLaunchAppForTestOldAPI[] =
77 "login.AppsMenuButton.runAppForTesting";
78
79 const char kCheckDiagnosticModeNewAPI[] =
80 "$('pod_row').confirmDiagnosticMode_";
81 const char kCheckDiagnosticModeOldAPI[] =
82 "$('show-apps-button').confirmDiagnosticMode_";
83
74 // Helper function for GetConsumerKioskModeStatusCallback. 84 // Helper function for GetConsumerKioskModeStatusCallback.
75 void ConsumerKioskModeStatusCheck( 85 void ConsumerKioskModeStatusCheck(
76 KioskAppManager::ConsumerKioskModeStatus* out_status, 86 KioskAppManager::ConsumerKioskModeStatus* out_status,
77 const base::Closure& runner_quit_task, 87 const base::Closure& runner_quit_task,
78 KioskAppManager::ConsumerKioskModeStatus in_status) { 88 KioskAppManager::ConsumerKioskModeStatus in_status) {
79 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; 89 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status;
80 *out_status = in_status; 90 *out_status = in_status;
81 runner_quit_task.Run(); 91 runner_quit_task.Run();
82 } 92 }
83 93
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 GURL webstore_url = server_url.ReplaceComponents(replace_webstore_host); 287 GURL webstore_url = server_url.ReplaceComponents(replace_webstore_host);
278 command_line->AppendSwitchASCII( 288 command_line->AppendSwitchASCII(
279 ::switches::kAppsGalleryURL, 289 ::switches::kAppsGalleryURL,
280 webstore_url.Resolve("/chromeos/app_mode/webstore").spec()); 290 webstore_url.Resolve("/chromeos/app_mode/webstore").spec());
281 command_line->AppendSwitchASCII( 291 command_line->AppendSwitchASCII(
282 ::switches::kAppsGalleryDownloadURL, 292 ::switches::kAppsGalleryDownloadURL,
283 webstore_url.Resolve( 293 webstore_url.Resolve(
284 "/chromeos/app_mode/webstore/downloads/%s.crx").spec()); 294 "/chromeos/app_mode/webstore/downloads/%s.crx").spec());
285 } 295 }
286 296
297 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
298 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()->
299 HasSwitch(switches::kDisableNewKioskUI);
300 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
301 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
302 base::StringValue(app_id),
303 base::FundamentalValue(diagnostic_mode));
304 }
305
287 void ReloadKioskApps() { 306 void ReloadKioskApps() {
288 KioskAppManager::Get()->AddApp(kTestKioskApp); 307 KioskAppManager::Get()->AddApp(kTestKioskApp);
289 } 308 }
290 309
291 void ReloadAutolaunchKioskApps() { 310 void ReloadAutolaunchKioskApps() {
292 KioskAppManager::Get()->AddApp(kTestKioskApp); 311 KioskAppManager::Get()->AddApp(kTestKioskApp);
293 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); 312 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp);
294 } 313 }
295 314
296 void PrepareAppLaunch() { 315 void PrepareAppLaunch() {
(...skipping 17 matching lines...) Expand all
314 ReloadKioskApps(); 333 ReloadKioskApps();
315 apps_loaded_signal.Wait(); 334 apps_loaded_signal.Wait();
316 } 335 }
317 336
318 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { 337 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) {
319 PrepareAppLaunch(); 338 PrepareAppLaunch();
320 339
321 if (!network_setup_cb.is_null()) 340 if (!network_setup_cb.is_null())
322 network_setup_cb.Run(); 341 network_setup_cb.Run();
323 342
324 GetLoginUI()->CallJavascriptFunction( 343 LaunchApp(kTestKioskApp, false);
325 "login.AppsMenuButton.runAppForTesting",
326 base::StringValue(kTestKioskApp));
327 } 344 }
328 345
329 void WaitForAppLaunchSuccess() { 346 void WaitForAppLaunchSuccess() {
330 SimulateNetworkOnline(); 347 SimulateNetworkOnline();
331 348
332 ExtensionTestMessageListener 349 ExtensionTestMessageListener
333 launch_data_check_listener("launchData.isKioskSession = true", false); 350 launch_data_check_listener("launchData.isKioskSession = true", false);
334 351
335 // Wait for the Kiosk App to launch. 352 // Wait for the Kiosk App to launch.
336 content::WindowedNotificationObserver( 353 content::WindowedNotificationObserver(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 base::StringValue("app_launch_bailout")); 533 base::StringValue("app_launch_bailout"));
517 signal.Wait(); 534 signal.Wait();
518 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL, 535 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL,
519 chromeos::KioskAppLaunchError::Get()); 536 chromeos::KioskAppLaunchError::Get());
520 } 537 }
521 538
522 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchInDiagnosticMode) { 539 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchInDiagnosticMode) {
523 PrepareAppLaunch(); 540 PrepareAppLaunch();
524 SimulateNetworkOnline(); 541 SimulateNetworkOnline();
525 542
526 GetLoginUI()->CallJavascriptFunction( 543 LaunchApp(kTestKioskApp, true);
527 "login.AppsMenuButton.runAppForTesting",
528 base::StringValue(kTestKioskApp),
529 base::FundamentalValue(true));
530 544
531 content::WebContents* login_contents = GetLoginUI()->GetWebContents(); 545 content::WebContents* login_contents = GetLoginUI()->GetWebContents();
532 546
533 JsConditionWaiter(login_contents, 547 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()->
534 "$('show-apps-button').confirmDiagnosticMode_").Wait(); 548 HasSwitch(switches::kDisableNewKioskUI);
549 JsConditionWaiter(login_contents, new_kiosk_ui ?
550 kCheckDiagnosticModeNewAPI : kCheckDiagnosticModeOldAPI).Wait();
535 551
552 std::string diagnosticMode(new_kiosk_ui ?
553 kCheckDiagnosticModeNewAPI : kCheckDiagnosticModeOldAPI);
536 ASSERT_TRUE(content::ExecuteScript( 554 ASSERT_TRUE(content::ExecuteScript(
537 login_contents, 555 login_contents,
538 "(function() {" 556 "(function() {"
539 "var e = new Event('click');" 557 "var e = new Event('click');" +
540 "$('show-apps-button').confirmDiagnosticMode_." 558 diagnosticMode + "."
541 "okButton_.dispatchEvent(e);" 559 "okButton_.dispatchEvent(e);"
542 "})();")); 560 "})();"));
543 561
544 WaitForAppLaunchSuccess(); 562 WaitForAppLaunchSuccess();
545 } 563 }
546 564
547 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { 565 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) {
548 EnableConsumerKioskMode(); 566 EnableConsumerKioskMode();
549 // Start UI, find menu entry for this app and launch it. 567 // Start UI, find menu entry for this app and launch it.
550 chromeos::WizardController::SkipPostLoginScreensForTesting(); 568 chromeos::WizardController::SkipPostLoginScreensForTesting();
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); 873 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
856 874
857 // Wait for the Kiosk App configuration to reload, then launch the app. 875 // Wait for the Kiosk App configuration to reload, then launch the app.
858 KioskAppManager::App app; 876 KioskAppManager::App app;
859 content::WindowedNotificationObserver( 877 content::WindowedNotificationObserver(
860 chrome::NOTIFICATION_KIOSK_APPS_LOADED, 878 chrome::NOTIFICATION_KIOSK_APPS_LOADED,
861 base::Bind(&KioskAppManager::GetApp, 879 base::Bind(&KioskAppManager::GetApp,
862 base::Unretained(KioskAppManager::Get()), 880 base::Unretained(KioskAppManager::Get()),
863 kTestEnterpriseKioskApp, &app)).Wait(); 881 kTestEnterpriseKioskApp, &app)).Wait();
864 882
865 GetLoginUI()->CallJavascriptFunction( 883 LaunchApp(kTestEnterpriseKioskApp, false);
866 "login.AppsMenuButton.runAppForTesting",
867 base::StringValue(kTestEnterpriseKioskApp));
868 884
869 // Wait for the Kiosk App to launch. 885 // Wait for the Kiosk App to launch.
870 content::WindowedNotificationObserver( 886 content::WindowedNotificationObserver(
871 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, 887 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
872 content::NotificationService::AllSources()).Wait(); 888 content::NotificationService::AllSources()).Wait();
873 889
874 // Check installer status. 890 // Check installer status.
875 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, 891 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
876 chromeos::KioskAppLaunchError::Get()); 892 chromeos::KioskAppLaunchError::Get());
877 893
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 content::WindowedNotificationObserver( 984 content::WindowedNotificationObserver(
969 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 985 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
970 content::NotificationService::AllSources()).Wait(); 986 content::NotificationService::AllSources()).Wait();
971 987
972 // Wait for the wallpaper to load. 988 // Wait for the wallpaper to load.
973 WaitForWallpaper(); 989 WaitForWallpaper();
974 EXPECT_TRUE(wallpaper_loaded()); 990 EXPECT_TRUE(wallpaper_loaded());
975 } 991 }
976 992
977 } // namespace chromeos 993 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698