Chromium Code Reviews| 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/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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/synchronization/lock.h" | |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/chromeos/app_mode/fake_cws.h" | 19 #include "chrome/browser/chromeos/app_mode/fake_cws.h" |
| 19 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 20 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 20 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 21 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 21 #include "chrome/browser/chromeos/login/app_launch_controller.h" | 22 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
| 22 #include "chrome/browser/chromeos/login/startup_utils.h" | 23 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 23 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" | 24 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" |
| 24 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | 25 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| 25 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 26 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 LOG(INFO) << "kiosk locked = " << in_locked; | 133 LOG(INFO) << "kiosk locked = " << in_locked; |
| 133 *out_locked = in_locked; | 134 *out_locked = in_locked; |
| 134 runner_quit_task.Run(); | 135 runner_quit_task.Run(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // Helper function for WaitForNetworkTimeOut. | 138 // Helper function for WaitForNetworkTimeOut. |
| 138 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { | 139 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { |
| 139 runner_quit_task.Run(); | 140 runner_quit_task.Run(); |
| 140 } | 141 } |
| 141 | 142 |
| 143 // Helper function for LockFileThread. | |
| 144 void LockAndUnlock(scoped_ptr<base::Lock> lock) { | |
|
bartfab (slow)
2014/08/20 14:45:29
Nit: #include "base/memory/scoped_ptr.h"
Joao da Silva
2014/08/21 08:00:00
Done.
| |
| 145 lock->Acquire(); | |
| 146 lock->Release(); | |
| 147 } | |
| 148 | |
| 142 // Helper functions for CanConfigureNetwork mock. | 149 // Helper functions for CanConfigureNetwork mock. |
| 143 class ScopedCanConfigureNetwork { | 150 class ScopedCanConfigureNetwork { |
| 144 public: | 151 public: |
| 145 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth) | 152 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth) |
| 146 : can_configure_(can_configure), | 153 : can_configure_(can_configure), |
| 147 needs_owner_auth_(needs_owner_auth), | 154 needs_owner_auth_(needs_owner_auth), |
| 148 can_configure_network_callback_( | 155 can_configure_network_callback_( |
| 149 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, | 156 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, |
| 150 base::Unretained(this))), | 157 base::Unretained(this))), |
| 151 needs_owner_auth_callback_(base::Bind( | 158 needs_owner_auth_callback_(base::Bind( |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 | 505 |
| 499 SimulateNetworkOnline(); | 506 SimulateNetworkOnline(); |
| 500 WaitForAppLaunchSuccess(); | 507 WaitForAppLaunchSuccess(); |
| 501 } | 508 } |
| 502 | 509 |
| 503 AppLaunchController* GetAppLaunchController() { | 510 AppLaunchController* GetAppLaunchController() { |
| 504 return chromeos::LoginDisplayHostImpl::default_host() | 511 return chromeos::LoginDisplayHostImpl::default_host() |
| 505 ->GetAppLaunchController(); | 512 ->GetAppLaunchController(); |
| 506 } | 513 } |
| 507 | 514 |
| 515 // Returns a lock that is holding a task in the FILE thread. Any tasks posted | |
|
bartfab (slow)
2014/08/20 14:45:29
Nit: s/ in / on /
Joao da Silva
2014/08/21 08:00:00
Done.
| |
| 516 // to the FILE thread after this call will be blocked until the returned | |
| 517 // lock is released. | |
| 518 // This can be used to prevent app installation from completing until some | |
| 519 // other conditions are checked and triggered. For example, this can be used | |
| 520 // to trigger the network screen during app launch without racing with the | |
| 521 // app launching process itself. | |
| 522 scoped_ptr<base::AutoLock> LockFileThread() { | |
| 523 scoped_ptr<base::Lock> lock(new base::Lock); | |
| 524 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(*lock)); | |
| 525 content::BrowserThread::PostTask( | |
|
bartfab (slow)
2014/08/20 14:45:29
Nit: #include "content/public/browser/browser_thre
Joao da Silva
2014/08/21 08:00:00
Done.
| |
| 526 content::BrowserThread::FILE, FROM_HERE, | |
|
bartfab (slow)
2014/08/20 14:45:29
Nit: #include "base/location.h"
Joao da Silva
2014/08/21 08:00:00
Done.
| |
| 527 base::Bind(&LockAndUnlock, base::Passed(&lock))); | |
|
bartfab (slow)
2014/08/20 14:45:29
Nit 1: #include "base/bind.h"
Nit 1: #include "bas
Joao da Silva
2014/08/21 08:00:00
Done.
| |
| 528 return auto_lock.Pass(); | |
| 529 } | |
| 530 | |
| 508 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } | 531 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } |
| 509 | 532 |
| 510 void set_test_app_id(const std::string& test_app_id) { | 533 void set_test_app_id(const std::string& test_app_id) { |
| 511 test_app_id_ = test_app_id; | 534 test_app_id_ = test_app_id; |
| 512 } | 535 } |
| 513 const std::string& test_app_id() const { return test_app_id_; } | 536 const std::string& test_app_id() const { return test_app_id_; } |
| 514 void set_test_app_version(const std::string& version) { | 537 void set_test_app_version(const std::string& version) { |
| 515 test_app_version_ = version; | 538 test_app_version_ = version; |
| 516 } | 539 } |
| 517 const std::string& test_app_version() const { return test_app_version_; } | 540 const std::string& test_app_version() const { return test_app_version_; } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 // Tests the network down case for the initial app download and launch. | 575 // Tests the network down case for the initial app download and launch. |
| 553 RunAppLaunchNetworkDownTest(); | 576 RunAppLaunchNetworkDownTest(); |
| 554 } | 577 } |
| 555 | 578 |
| 556 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { | 579 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { |
| 557 // Tests the network down case for launching an existing app that is | 580 // Tests the network down case for launching an existing app that is |
| 558 // installed in PRE_LaunchAppNetworkDown. | 581 // installed in PRE_LaunchAppNetworkDown. |
| 559 RunAppLaunchNetworkDownTest(); | 582 RunAppLaunchNetworkDownTest(); |
| 560 } | 583 } |
| 561 | 584 |
| 562 // TODO(zelidrag): Figure out why this test is flaky on bbots. | 585 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppWithNetworkConfigAccelerator) { |
| 563 IN_PROC_BROWSER_TEST_F(KioskTest, | |
| 564 DISABLED_LaunchAppWithNetworkConfigAccelerator) { | |
| 565 ScopedCanConfigureNetwork can_configure_network(true, false); | 586 ScopedCanConfigureNetwork can_configure_network(true, false); |
| 566 | 587 |
| 588 // Block app loading until the network screen is shown. | |
| 589 scoped_ptr<base::AutoLock> lock = LockFileThread(); | |
| 590 | |
| 567 // Start app launch and wait for network connectivity timeout. | 591 // Start app launch and wait for network connectivity timeout. |
| 568 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); | 592 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
| 569 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 593 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 570 splash_waiter.Wait(); | 594 splash_waiter.Wait(); |
| 571 | 595 |
| 572 // A network error screen should be shown after authenticating. | 596 // A network error screen should be shown after authenticating. |
| 573 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); | 597 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); |
| 574 // Simulate Ctrl+Alt+N accelerator. | 598 // Simulate Ctrl+Alt+N accelerator. |
| 575 GetLoginUI()->CallJavascriptFunction( | 599 GetLoginUI()->CallJavascriptFunction( |
| 576 "cr.ui.Oobe.handleAccelerator", | 600 "cr.ui.Oobe.handleAccelerator", |
| 577 base::StringValue("app_launch_network_config")); | 601 base::StringValue("app_launch_network_config")); |
| 578 error_screen_waiter.Wait(); | 602 error_screen_waiter.Wait(); |
| 579 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 603 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 580 | 604 |
| 581 // Continue button should be visible since we are online. | 605 // Continue button should be visible since we are online. |
| 582 JsExpect("$('continue-network-config-btn').hidden == false"); | 606 JsExpect("$('continue-network-config-btn').hidden == false"); |
| 583 | 607 |
| 584 // Click on [Continue] button. | 608 // Click on [Continue] button. |
| 585 ASSERT_TRUE(content::ExecuteScript( | 609 ASSERT_TRUE(content::ExecuteScript( |
| 586 GetLoginUI()->GetWebContents(), | 610 GetLoginUI()->GetWebContents(), |
| 587 "(function() {" | 611 "(function() {" |
| 588 "var e = new Event('click');" | 612 "var e = new Event('click');" |
| 589 "$('continue-network-config-btn').dispatchEvent(e);" | 613 "$('continue-network-config-btn').dispatchEvent(e);" |
| 590 "})();")); | 614 "})();")); |
| 591 | 615 |
| 616 // Let app launching resume. | |
| 617 lock.reset(); | |
| 618 | |
| 592 WaitForAppLaunchSuccess(); | 619 WaitForAppLaunchSuccess(); |
| 593 } | 620 } |
| 594 | 621 |
| 595 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { | 622 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { |
| 596 // Mock network could not be configured. | 623 // Mock network could not be configured. |
| 597 ScopedCanConfigureNetwork can_configure_network(false, true); | 624 ScopedCanConfigureNetwork can_configure_network(false, true); |
| 598 | 625 |
| 599 // Start app launch and wait for network connectivity timeout. | 626 // Start app launch and wait for network connectivity timeout. |
| 600 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 627 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 601 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 628 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 content::WindowedNotificationObserver( | 1399 content::WindowedNotificationObserver( |
| 1373 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1400 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 1374 content::NotificationService::AllSources()).Wait(); | 1401 content::NotificationService::AllSources()).Wait(); |
| 1375 | 1402 |
| 1376 // Wait for the wallpaper to load. | 1403 // Wait for the wallpaper to load. |
| 1377 WaitForWallpaper(); | 1404 WaitForWallpaper(); |
| 1378 EXPECT_TRUE(wallpaper_loaded()); | 1405 EXPECT_TRUE(wallpaper_loaded()); |
| 1379 } | 1406 } |
| 1380 | 1407 |
| 1381 } // namespace chromeos | 1408 } // namespace chromeos |
| OLD | NEW |