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

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: 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
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 311 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
312 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()-> 312 bool new_kiosk_ui = !CommandLine::ForCurrentProcess()->
313 HasSwitch(switches::kDisableNewKioskUI); 313 HasSwitch(switches::kDisableNewKioskUI);
314 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 314 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
315 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 315 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
316 base::StringValue(app_id), 316 base::StringValue(app_id),
317 base::FundamentalValue(diagnostic_mode)); 317 base::FundamentalValue(diagnostic_mode));
318 } 318 }
319 319
320 void ReloadKioskApps() { 320 void ReloadKioskApps() {
321 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires.
322 KioskAppManager::Get()->RemoveApp(test_app_id_);
321 KioskAppManager::Get()->AddApp(test_app_id_); 323 KioskAppManager::Get()->AddApp(test_app_id_);
322 } 324 }
323 325
324 void ReloadAutolaunchKioskApps() { 326 void ReloadAutolaunchKioskApps() {
325 KioskAppManager::Get()->AddApp(test_app_id_); 327 KioskAppManager::Get()->AddApp(test_app_id_);
326 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); 328 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_);
327 } 329 }
328 330
329 void PrepareAppLaunch() { 331 void PrepareAppLaunch() {
330 EnableConsumerKioskMode(); 332 EnableConsumerKioskMode();
331 333
332 // Start UI, find menu entry for this app and launch it. 334 // Start UI
333 content::WindowedNotificationObserver login_signal( 335 content::WindowedNotificationObserver login_signal(
334 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 336 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
335 content::NotificationService::AllSources()); 337 content::NotificationService::AllSources());
336 chromeos::WizardController::SkipPostLoginScreensForTesting(); 338 chromeos::WizardController::SkipPostLoginScreensForTesting();
337 chromeos::WizardController* wizard_controller = 339 chromeos::WizardController* wizard_controller =
338 chromeos::WizardController::default_controller(); 340 chromeos::WizardController::default_controller();
339 CHECK(wizard_controller); 341 if (wizard_controller) {
340 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); 342 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
341 login_signal.Wait(); 343 login_signal.Wait();
344 } else {
345 // No wizard and running with an existing profile and it should land
346 // on account picker.
347 OobeScreenWaiter(OobeDisplay::SCREEN_ACCOUNT_PICKER).Wait();
348 }
342 349
343 // Wait for the Kiosk App configuration to reload, then launch the app. 350 // Wait for the Kiosk App configuration to reload.
344 content::WindowedNotificationObserver apps_loaded_signal( 351 content::WindowedNotificationObserver apps_loaded_signal(
345 chrome::NOTIFICATION_KIOSK_APPS_LOADED, 352 chrome::NOTIFICATION_KIOSK_APPS_LOADED,
346 content::NotificationService::AllSources()); 353 content::NotificationService::AllSources());
347 ReloadKioskApps(); 354 ReloadKioskApps();
348 apps_loaded_signal.Wait(); 355 apps_loaded_signal.Wait();
349 } 356 }
350 357
351 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { 358 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) {
352 PrepareAppLaunch(); 359 PrepareAppLaunch();
353 360
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); 480 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
474 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir); 481 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir);
475 ASSERT_TRUE(base::CopyFile(test_data_dir.AppendASCII("Preferences"), 482 ASSERT_TRUE(base::CopyFile(test_data_dir.AppendASCII("Preferences"),
476 app_profile_dir.AppendASCII("Preferences"))); 483 app_profile_dir.AppendASCII("Preferences")));
477 ASSERT_TRUE( 484 ASSERT_TRUE(
478 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"), 485 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"),
479 app_profile_dir, 486 app_profile_dir,
480 true)); 487 true));
481 } 488 }
482 489
490 void RunAppLaunchNetworkDownTest() {
491 // Mock network could be configured with owner's password.
492 ScopedCanConfigureNetwork can_configure_network(true, true);
493
494 // Start app launch and wait for network connectivity timeout.
495 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
496 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
497 splash_waiter.Wait();
498 WaitForAppLaunchNetworkTimeout();
499
500 // Configure network link should be visible.
501 JsExpect("$('splash-config-network').hidden == false");
502
503 // Set up fake user manager with an owner for the test.
504 mock_user_manager()->SetActiveUser(kTestOwnerEmail);
505 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager());
506 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host())
507 ->GetOobeUI()->ShowOobeUI(false);
508
509 // Configure network should bring up lock screen for owner.
510 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
511 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController())
512 ->OnConfigureNetwork();
Tim Song 2014/03/05 18:36:34 nit: indent
xiyuan 2014/03/06 17:56:59 Done.
513 lock_screen_waiter.Wait();
514
515 // A network error screen should be shown after authenticating.
516 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE);
517 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController())
518 ->OnOwnerSigninSuccess();
519 error_screen_waiter.Wait();
520
521 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
522
523 SimulateNetworkOnline();
524 WaitForAppLaunchSuccess();
525 }
526
483 AppLaunchController* GetAppLaunchController() { 527 AppLaunchController* GetAppLaunchController() {
484 return chromeos::LoginDisplayHostImpl::default_host() 528 return chromeos::LoginDisplayHostImpl::default_host()
485 ->GetAppLaunchController(); 529 ->GetAppLaunchController();
486 } 530 }
487 531
488 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } 532 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); }
489 533
490 void set_test_app_id(const std::string& test_app_id) { 534 void set_test_app_id(const std::string& test_app_id) {
491 test_app_id_ = test_app_id; 535 test_app_id_ = test_app_id;
492 } 536 }
493 const std::string& test_app_id() const { return test_app_id_; } 537 const std::string& test_app_id() const { return test_app_id_; }
494 538
495 private: 539 private:
496 std::string test_app_id_; 540 std::string test_app_id_;
497 scoped_ptr<MockUserManager> mock_user_manager_; 541 scoped_ptr<MockUserManager> mock_user_manager_;
498 542
499 DISALLOW_COPY_AND_ASSIGN(KioskTest); 543 DISALLOW_COPY_AND_ASSIGN(KioskTest);
500 }; 544 };
501 545
502 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { 546 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) {
503 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 547 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
504 WaitForAppLaunchSuccess(); 548 WaitForAppLaunchSuccess();
505 } 549 }
506 550
551 IN_PROC_BROWSER_TEST_F(KioskTest, PRE_LaunchAppNetworkDown) {
552 // Tests the network down case for the initial app download and launch.
553 RunAppLaunchNetworkDownTest();
554 }
555
507 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { 556 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) {
508 // Mock network could be configured with owner's password. 557 // Tests the network down case for launching an existing app.
509 ScopedCanConfigureNetwork can_configure_network(true, true); 558 RunAppLaunchNetworkDownTest();
510
511 // Start app launch and wait for network connectivity timeout.
512 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
513 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
514 splash_waiter.Wait();
515 WaitForAppLaunchNetworkTimeout();
516
517 // Configure network link should be visible.
518 JsExpect("$('splash-config-network').hidden == false");
519
520 // Set up fake user manager with an owner for the test.
521 mock_user_manager()->SetActiveUser(kTestOwnerEmail);
522 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager());
523 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host())
524 ->GetOobeUI()->ShowOobeUI(false);
525
526 // Configure network should bring up lock screen for owner.
527 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
528 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController())
529 ->OnConfigureNetwork();
530 lock_screen_waiter.Wait();
531
532 // A network error screen should be shown after authenticating.
533 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE);
534 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController())
535 ->OnOwnerSigninSuccess();
536 error_screen_waiter.Wait();
537
538 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
539
540 SimulateNetworkOnline();
541 WaitForAppLaunchSuccess();
542 } 559 }
543 560
544 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { 561 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) {
545 // Mock network could not be configured. 562 // Mock network could not be configured.
546 ScopedCanConfigureNetwork can_configure_network(false, true); 563 ScopedCanConfigureNetwork can_configure_network(false, true);
547 564
548 // Start app launch and wait for network connectivity timeout. 565 // Start app launch and wait for network connectivity timeout.
549 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); 566 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
550 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 567 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
551 splash_waiter.Wait(); 568 splash_waiter.Wait();
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 content::WindowedNotificationObserver( 1186 content::WindowedNotificationObserver(
1170 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1187 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1171 content::NotificationService::AllSources()).Wait(); 1188 content::NotificationService::AllSources()).Wait();
1172 1189
1173 // Wait for the wallpaper to load. 1190 // Wait for the wallpaper to load.
1174 WaitForWallpaper(); 1191 WaitForWallpaper();
1175 EXPECT_TRUE(wallpaper_loaded()); 1192 EXPECT_TRUE(wallpaper_loaded());
1176 } 1193 }
1177 1194
1178 } // namespace chromeos 1195 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698