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

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

Issue 181233007: kiosk: Fix network check skipped regression. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 6 years, 9 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/manifest/offline_enabled.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_window.h" 5 #include "apps/app_window.h"
6 #include "apps/app_window_registry.h" 6 #include "apps/app_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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 312 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
313 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()-> 313 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()->
314 HasSwitch(switches::kDisableNewKioskUI); 314 HasSwitch(switches::kDisableNewKioskUI);
315 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 315 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
316 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 316 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
317 base::StringValue(app_id), 317 base::StringValue(app_id),
318 base::FundamentalValue(diagnostic_mode)); 318 base::FundamentalValue(diagnostic_mode));
319 } 319 }
320 320
321 void ReloadKioskApps() { 321 void ReloadKioskApps() {
322 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires.
323 KioskAppManager::Get()->RemoveApp(test_app_id_);
322 KioskAppManager::Get()->AddApp(test_app_id_); 324 KioskAppManager::Get()->AddApp(test_app_id_);
323 } 325 }
324 326
325 void ReloadAutolaunchKioskApps() { 327 void ReloadAutolaunchKioskApps() {
326 KioskAppManager::Get()->AddApp(test_app_id_); 328 KioskAppManager::Get()->AddApp(test_app_id_);
327 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); 329 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_);
328 } 330 }
329 331
330 void PrepareAppLaunch() { 332 void PrepareAppLaunch() {
331 EnableConsumerKioskMode(); 333 EnableConsumerKioskMode();
332 334
333 // Start UI, find menu entry for this app and launch it. 335 // Start UI
334 content::WindowedNotificationObserver login_signal( 336 content::WindowedNotificationObserver login_signal(
335 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 337 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
336 content::NotificationService::AllSources()); 338 content::NotificationService::AllSources());
337 chromeos::WizardController::SkipPostLoginScreensForTesting(); 339 chromeos::WizardController::SkipPostLoginScreensForTesting();
338 chromeos::WizardController* wizard_controller = 340 chromeos::WizardController* wizard_controller =
339 chromeos::WizardController::default_controller(); 341 chromeos::WizardController::default_controller();
340 CHECK(wizard_controller); 342 if (wizard_controller) {
341 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); 343 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
342 login_signal.Wait(); 344 login_signal.Wait();
345 } else {
346 // No wizard and running with an existing profile and it should land
347 // on account picker.
348 OobeScreenWaiter(OobeDisplay::SCREEN_ACCOUNT_PICKER).Wait();
349 }
343 350
344 // Wait for the Kiosk App configuration to reload, then launch the app. 351 // Wait for the Kiosk App configuration to reload.
345 content::WindowedNotificationObserver apps_loaded_signal( 352 content::WindowedNotificationObserver apps_loaded_signal(
346 chrome::NOTIFICATION_KIOSK_APPS_LOADED, 353 chrome::NOTIFICATION_KIOSK_APPS_LOADED,
347 content::NotificationService::AllSources()); 354 content::NotificationService::AllSources());
348 ReloadKioskApps(); 355 ReloadKioskApps();
349 apps_loaded_signal.Wait(); 356 apps_loaded_signal.Wait();
350 } 357 }
351 358
352 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { 359 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) {
353 PrepareAppLaunch(); 360 PrepareAppLaunch();
354 361
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir); 482 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir);
476 ASSERT_TRUE( 483 ASSERT_TRUE(
477 base::CopyFile(test_data_dir.Append(chrome::kPreferencesFilename), 484 base::CopyFile(test_data_dir.Append(chrome::kPreferencesFilename),
478 app_profile_dir.Append(chrome::kPreferencesFilename))); 485 app_profile_dir.Append(chrome::kPreferencesFilename)));
479 ASSERT_TRUE( 486 ASSERT_TRUE(
480 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"), 487 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"),
481 app_profile_dir, 488 app_profile_dir,
482 true)); 489 true));
483 } 490 }
484 491
492 void RunAppLaunchNetworkDownTest() {
493 // Mock network could be configured with owner's password.
494 ScopedCanConfigureNetwork can_configure_network(true, true);
495
496 // Start app launch and wait for network connectivity timeout.
497 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
498 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
499 splash_waiter.Wait();
500 WaitForAppLaunchNetworkTimeout();
501
502 // Configure network link should be visible.
503 JsExpect("$('splash-config-network').hidden == false");
504
505 // Set up fake user manager with an owner for the test.
506 mock_user_manager()->SetActiveUser(kTestOwnerEmail);
507 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager());
508 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host())
509 ->GetOobeUI()->ShowOobeUI(false);
510
511 // Configure network should bring up lock screen for owner.
512 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
513 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController())
514 ->OnConfigureNetwork();
515 lock_screen_waiter.Wait();
516
517 // A network error screen should be shown after authenticating.
518 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE);
519 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController())
520 ->OnOwnerSigninSuccess();
521 error_screen_waiter.Wait();
522
523 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
524
525 SimulateNetworkOnline();
526 WaitForAppLaunchSuccess();
527 }
528
485 AppLaunchController* GetAppLaunchController() { 529 AppLaunchController* GetAppLaunchController() {
486 return chromeos::LoginDisplayHostImpl::default_host() 530 return chromeos::LoginDisplayHostImpl::default_host()
487 ->GetAppLaunchController(); 531 ->GetAppLaunchController();
488 } 532 }
489 533
490 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } 534 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); }
491 535
492 void set_test_app_id(const std::string& test_app_id) { 536 void set_test_app_id(const std::string& test_app_id) {
493 test_app_id_ = test_app_id; 537 test_app_id_ = test_app_id;
494 } 538 }
495 const std::string& test_app_id() const { return test_app_id_; } 539 const std::string& test_app_id() const { return test_app_id_; }
496 540
497 private: 541 private:
498 std::string test_app_id_; 542 std::string test_app_id_;
499 scoped_ptr<MockUserManager> mock_user_manager_; 543 scoped_ptr<MockUserManager> mock_user_manager_;
500 544
501 DISALLOW_COPY_AND_ASSIGN(KioskTest); 545 DISALLOW_COPY_AND_ASSIGN(KioskTest);
502 }; 546 };
503 547
504 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { 548 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) {
505 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 549 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
506 WaitForAppLaunchSuccess(); 550 WaitForAppLaunchSuccess();
507 } 551 }
508 552
553 IN_PROC_BROWSER_TEST_F(KioskTest, PRE_LaunchAppNetworkDown) {
554 // Tests the network down case for the initial app download and launch.
555 RunAppLaunchNetworkDownTest();
556 }
557
509 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { 558 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) {
510 // Mock network could be configured with owner's password. 559 // Tests the network down case for launching an existing app that is
511 ScopedCanConfigureNetwork can_configure_network(true, true); 560 // installed in PRE_LaunchAppNetworkDown.
512 561 RunAppLaunchNetworkDownTest();
513 // Start app launch and wait for network connectivity timeout.
514 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
515 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
516 splash_waiter.Wait();
517 WaitForAppLaunchNetworkTimeout();
518
519 // Configure network link should be visible.
520 JsExpect("$('splash-config-network').hidden == false");
521
522 // Set up fake user manager with an owner for the test.
523 mock_user_manager()->SetActiveUser(kTestOwnerEmail);
524 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager());
525 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host())
526 ->GetOobeUI()->ShowOobeUI(false);
527
528 // Configure network should bring up lock screen for owner.
529 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
530 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController())
531 ->OnConfigureNetwork();
532 lock_screen_waiter.Wait();
533
534 // A network error screen should be shown after authenticating.
535 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE);
536 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController())
537 ->OnOwnerSigninSuccess();
538 error_screen_waiter.Wait();
539
540 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
541
542 SimulateNetworkOnline();
543 WaitForAppLaunchSuccess();
544 } 562 }
545 563
546 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { 564 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) {
547 // Mock network could not be configured. 565 // Mock network could not be configured.
548 ScopedCanConfigureNetwork can_configure_network(false, true); 566 ScopedCanConfigureNetwork can_configure_network(false, true);
549 567
550 // Start app launch and wait for network connectivity timeout. 568 // Start app launch and wait for network connectivity timeout.
551 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); 569 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
552 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 570 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
553 splash_waiter.Wait(); 571 splash_waiter.Wait();
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 content::WindowedNotificationObserver( 1189 content::WindowedNotificationObserver(
1172 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1190 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1173 content::NotificationService::AllSources()).Wait(); 1191 content::NotificationService::AllSources()).Wait();
1174 1192
1175 // Wait for the wallpaper to load. 1193 // Wait for the wallpaper to load.
1176 WaitForWallpaper(); 1194 WaitForWallpaper();
1177 EXPECT_TRUE(wallpaper_loaded()); 1195 EXPECT_TRUE(wallpaper_loaded());
1178 } 1196 }
1179 1197
1180 } // namespace chromeos 1198 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/articles/manifest/offline_enabled.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698