| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/location.h" | 15 #include "base/location.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/prefs/scoped_user_pref_update.h" | 19 #include "base/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_browser_main.h" | 21 #include "chrome/browser/chrome_browser_main.h" |
| 21 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 22 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| 22 #include "chrome/browser/chrome_content_browser_client.h" | 23 #include "chrome/browser/chrome_content_browser_client.h" |
| 23 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
| 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 25 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 25 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 26 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 26 #include "chrome/browser/chromeos/login/app_launch_controller.h" | 27 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
| 27 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h" | 28 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h" |
| 28 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 29 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 29 #include "chrome/browser/chromeos/login/fake_user_manager.h" | 30 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 31 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 31 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 32 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 32 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 33 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 33 #include "chrome/browser/chromeos/login/webui_login_display.h" | 34 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 34 #include "chrome/browser/chromeos/login/wizard_controller.h" | 35 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 36 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
| 35 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 37 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 36 #include "chrome/browser/chromeos/settings/cros_settings.h" | 38 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 37 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 39 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 38 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 40 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 39 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
| 40 #include "chrome/browser/extensions/extension_system.h" | 42 #include "chrome/browser/extensions/extension_system.h" |
| 41 #include "chrome/browser/extensions/extension_test_message_listener.h" | 43 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 42 #include "chrome/browser/lifetime/application_lifetime.h" | 44 #include "chrome/browser/lifetime/application_lifetime.h" |
| 43 #include "chrome/browser/policy/cloud/policy_builder.h" | 45 #include "chrome/browser/policy/cloud/policy_builder.h" |
| 44 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 46 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 const int kTestNetworkTimeoutSeconds = 1; | 97 const int kTestNetworkTimeoutSeconds = 1; |
| 96 | 98 |
| 97 // Email of owner account for test. | 99 // Email of owner account for test. |
| 98 const char kTestOwnerEmail[] = "owner@example.com"; | 100 const char kTestOwnerEmail[] = "owner@example.com"; |
| 99 | 101 |
| 100 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; | 102 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; |
| 101 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; | 103 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; |
| 102 const char kTestRefreshToken[] = "fake-refresh-token"; | 104 const char kTestRefreshToken[] = "fake-refresh-token"; |
| 103 const char kTestAccessToken[] = "fake-access-token"; | 105 const char kTestAccessToken[] = "fake-access-token"; |
| 104 | 106 |
| 107 // Note the path name must be the same as in shill stub. |
| 108 const char kStubEthernetServicePath[] = "eth1"; |
| 109 |
| 105 // Helper function for GetConsumerKioskModeStatusCallback. | 110 // Helper function for GetConsumerKioskModeStatusCallback. |
| 106 void ConsumerKioskModeStatusCheck( | 111 void ConsumerKioskModeStatusCheck( |
| 107 KioskAppManager::ConsumerKioskModeStatus* out_status, | 112 KioskAppManager::ConsumerKioskModeStatus* out_status, |
| 108 const base::Closure& runner_quit_task, | 113 const base::Closure& runner_quit_task, |
| 109 KioskAppManager::ConsumerKioskModeStatus in_status) { | 114 KioskAppManager::ConsumerKioskModeStatus in_status) { |
| 110 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; | 115 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; |
| 111 *out_status = in_status; | 116 *out_status = in_status; |
| 112 runner_quit_task.Run(); | 117 runner_quit_task.Run(); |
| 113 } | 118 } |
| 114 | 119 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 129 | 134 |
| 130 // Helper function for DeviceOAuth2TokenServiceFactory::Get(). | 135 // Helper function for DeviceOAuth2TokenServiceFactory::Get(). |
| 131 void CopyTokenService(DeviceOAuth2TokenService** out_token_service, | 136 void CopyTokenService(DeviceOAuth2TokenService** out_token_service, |
| 132 DeviceOAuth2TokenService* in_token_service) { | 137 DeviceOAuth2TokenService* in_token_service) { |
| 133 *out_token_service = in_token_service; | 138 *out_token_service = in_token_service; |
| 134 } | 139 } |
| 135 | 140 |
| 136 // Helper functions for CanConfigureNetwork mock. | 141 // Helper functions for CanConfigureNetwork mock. |
| 137 class ScopedCanConfigureNetwork { | 142 class ScopedCanConfigureNetwork { |
| 138 public: | 143 public: |
| 139 explicit ScopedCanConfigureNetwork(bool can_configure) | 144 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth) |
| 140 : can_configure_(can_configure), | 145 : can_configure_(can_configure), |
| 141 callback_(base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, | 146 needs_owner_auth_(needs_owner_auth), |
| 142 base::Unretained(this))) { | 147 can_configure_network_callback_( |
| 143 AppLaunchController::SetCanConfigureNetworkCallbackForTesting(&callback_); | 148 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, |
| 149 base::Unretained(this))), |
| 150 needs_owner_auth_callback_(base::Bind( |
| 151 &ScopedCanConfigureNetwork::NeedsOwnerAuthToConfigureNetwork, |
| 152 base::Unretained(this))) { |
| 153 AppLaunchController::SetCanConfigureNetworkCallbackForTesting( |
| 154 &can_configure_network_callback_); |
| 155 AppLaunchController::SetNeedOwnerAuthToConfigureNetworkCallbackForTesting( |
| 156 &needs_owner_auth_callback_); |
| 144 } | 157 } |
| 145 ~ScopedCanConfigureNetwork() { | 158 ~ScopedCanConfigureNetwork() { |
| 146 AppLaunchController::SetCanConfigureNetworkCallbackForTesting(NULL); | 159 AppLaunchController::SetCanConfigureNetworkCallbackForTesting(NULL); |
| 160 AppLaunchController::SetNeedOwnerAuthToConfigureNetworkCallbackForTesting( |
| 161 NULL); |
| 147 } | 162 } |
| 148 | 163 |
| 149 bool CanConfigureNetwork() { | 164 bool CanConfigureNetwork() { |
| 150 return can_configure_; | 165 return can_configure_; |
| 151 } | 166 } |
| 152 | 167 |
| 168 bool NeedsOwnerAuthToConfigureNetwork() { |
| 169 return needs_owner_auth_; |
| 170 } |
| 171 |
| 153 private: | 172 private: |
| 154 bool can_configure_; | 173 bool can_configure_; |
| 155 AppLaunchController::CanConfigureNetworkCallback callback_; | 174 bool needs_owner_auth_; |
| 175 AppLaunchController::ReturnBoolCallback can_configure_network_callback_; |
| 176 AppLaunchController::ReturnBoolCallback needs_owner_auth_callback_; |
| 156 DISALLOW_COPY_AND_ASSIGN(ScopedCanConfigureNetwork); | 177 DISALLOW_COPY_AND_ASSIGN(ScopedCanConfigureNetwork); |
| 157 }; | 178 }; |
| 158 | 179 |
| 159 } // namespace | 180 } // namespace |
| 160 | 181 |
| 161 // Fake NetworkChangeNotifier used to simulate network connectivity. | |
| 162 class FakeNetworkChangeNotifier : public net::NetworkChangeNotifier { | |
| 163 public: | |
| 164 FakeNetworkChangeNotifier() : connection_type_(CONNECTION_NONE) {} | |
| 165 | |
| 166 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE { | |
| 167 return connection_type_; | |
| 168 } | |
| 169 | |
| 170 void GoOnline() { | |
| 171 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET); | |
| 172 } | |
| 173 | |
| 174 void GoOffline() { | |
| 175 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE); | |
| 176 } | |
| 177 | |
| 178 void SetConnectionType(ConnectionType type) { | |
| 179 connection_type_ = type; | |
| 180 NotifyObserversOfNetworkChange(type); | |
| 181 base::RunLoop().RunUntilIdle(); | |
| 182 } | |
| 183 | |
| 184 virtual ~FakeNetworkChangeNotifier() {} | |
| 185 | |
| 186 private: | |
| 187 ConnectionType connection_type_; | |
| 188 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier); | |
| 189 }; | |
| 190 | |
| 191 // Helper class that monitors app windows to wait for a window to appear. | 182 // Helper class that monitors app windows to wait for a window to appear. |
| 192 class ShellWindowObserver : public apps::ShellWindowRegistry::Observer { | 183 class ShellWindowObserver : public apps::ShellWindowRegistry::Observer { |
| 193 public: | 184 public: |
| 194 ShellWindowObserver(apps::ShellWindowRegistry* registry, | 185 ShellWindowObserver(apps::ShellWindowRegistry* registry, |
| 195 const std::string& app_id) | 186 const std::string& app_id) |
| 196 : registry_(registry), app_id_(app_id), window_(NULL), running_(false) { | 187 : registry_(registry), app_id_(app_id), window_(NULL), running_(false) { |
| 197 registry_->AddObserver(this); | 188 registry_->AddObserver(this); |
| 198 } | 189 } |
| 199 virtual ~ShellWindowObserver() { | 190 virtual ~ShellWindowObserver() { |
| 200 registry_->RemoveObserver(this); | 191 registry_->RemoveObserver(this); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 243 |
| 253 mock_user_manager_.reset(new MockUserManager); | 244 mock_user_manager_.reset(new MockUserManager); |
| 254 AppLaunchController::SkipSplashWaitForTesting(); | 245 AppLaunchController::SkipSplashWaitForTesting(); |
| 255 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); | 246 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); |
| 256 | 247 |
| 257 InProcessBrowserTest::SetUp(); | 248 InProcessBrowserTest::SetUp(); |
| 258 } | 249 } |
| 259 | 250 |
| 260 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 251 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 261 host_resolver()->AddRule("*", "127.0.0.1"); | 252 host_resolver()->AddRule("*", "127.0.0.1"); |
| 253 |
| 254 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 255 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 256 network_portal_detector_->SetDefaultNetworkPathForTesting( |
| 257 kStubEthernetServicePath); |
| 262 } | 258 } |
| 263 | 259 |
| 264 virtual void CleanUpOnMainThread() OVERRIDE { | 260 virtual void CleanUpOnMainThread() OVERRIDE { |
| 265 // We need to clean up these objects in this specific order. | |
| 266 fake_network_notifier_.reset(NULL); | |
| 267 disable_network_notifier_.reset(NULL); | |
| 268 | |
| 269 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); | 261 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); |
| 270 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); | 262 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); |
| 271 | 263 |
| 272 // If the login display is still showing, exit gracefully. | 264 // If the login display is still showing, exit gracefully. |
| 273 if (LoginDisplayHostImpl::default_host()) { | 265 if (LoginDisplayHostImpl::default_host()) { |
| 274 base::MessageLoop::current()->PostTask(FROM_HERE, | 266 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 275 base::Bind(&chrome::AttemptExit)); | 267 base::Bind(&chrome::AttemptExit)); |
| 276 content::RunMessageLoop(); | 268 content::RunMessageLoop(); |
| 277 } | 269 } |
| 278 | 270 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 308 |
| 317 void ReloadKioskApps() { | 309 void ReloadKioskApps() { |
| 318 KioskAppManager::Get()->AddApp(kTestKioskApp); | 310 KioskAppManager::Get()->AddApp(kTestKioskApp); |
| 319 } | 311 } |
| 320 | 312 |
| 321 void ReloadAutolaunchKioskApps() { | 313 void ReloadAutolaunchKioskApps() { |
| 322 KioskAppManager::Get()->AddApp(kTestKioskApp); | 314 KioskAppManager::Get()->AddApp(kTestKioskApp); |
| 323 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); | 315 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); |
| 324 } | 316 } |
| 325 | 317 |
| 326 void StartAppLaunchFromLoginScreen(bool has_connectivity) { | 318 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { |
| 327 EnableConsumerKioskMode(); | 319 EnableConsumerKioskMode(); |
| 328 | 320 |
| 329 // Start UI, find menu entry for this app and launch it. | 321 // Start UI, find menu entry for this app and launch it. |
| 330 content::WindowedNotificationObserver login_signal( | 322 content::WindowedNotificationObserver login_signal( |
| 331 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 323 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 332 content::NotificationService::AllSources()); | 324 content::NotificationService::AllSources()); |
| 333 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 325 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 334 chromeos::WizardController* wizard_controller = | 326 chromeos::WizardController* wizard_controller = |
| 335 chromeos::WizardController::default_controller(); | 327 chromeos::WizardController::default_controller(); |
| 336 CHECK(wizard_controller); | 328 CHECK(wizard_controller); |
| 337 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 329 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| 338 login_signal.Wait(); | 330 login_signal.Wait(); |
| 339 | 331 |
| 340 // Wait for the Kiosk App configuration to reload, then launch the app. | 332 // Wait for the Kiosk App configuration to reload, then launch the app. |
| 341 content::WindowedNotificationObserver apps_loaded_signal( | 333 content::WindowedNotificationObserver apps_loaded_signal( |
| 342 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 334 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
| 343 content::NotificationService::AllSources()); | 335 content::NotificationService::AllSources()); |
| 344 ReloadKioskApps(); | 336 ReloadKioskApps(); |
| 345 apps_loaded_signal.Wait(); | 337 apps_loaded_signal.Wait(); |
| 346 | 338 |
| 347 if (!has_connectivity) | 339 if (!network_setup_cb.is_null()) |
| 348 SimulateNetworkOffline(); | 340 network_setup_cb.Run(); |
| 349 | 341 |
| 350 GetLoginUI()->CallJavascriptFunction( | 342 GetLoginUI()->CallJavascriptFunction( |
| 351 "login.AppsMenuButton.runAppForTesting", | 343 "login.AppsMenuButton.runAppForTesting", |
| 352 base::StringValue(kTestKioskApp)); | 344 base::StringValue(kTestKioskApp)); |
| 353 } | 345 } |
| 354 | 346 |
| 355 void WaitForAppLaunchSuccess() { | 347 void WaitForAppLaunchSuccess() { |
| 356 SimulateNetworkOnline(); | 348 SimulateNetworkOnline(); |
| 357 | 349 |
| 358 ExtensionTestMessageListener | 350 ExtensionTestMessageListener |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 // Wait until the app terminates if it is still running. | 387 // Wait until the app terminates if it is still running. |
| 396 if (!shell_window_registry->GetShellWindowsForApp(kTestKioskApp).empty()) | 388 if (!shell_window_registry->GetShellWindowsForApp(kTestKioskApp).empty()) |
| 397 content::RunMessageLoop(); | 389 content::RunMessageLoop(); |
| 398 | 390 |
| 399 // Check that the app had been informed that it is running in a kiosk | 391 // Check that the app had been informed that it is running in a kiosk |
| 400 // session. | 392 // session. |
| 401 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); | 393 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); |
| 402 } | 394 } |
| 403 | 395 |
| 404 void SimulateNetworkOffline() { | 396 void SimulateNetworkOffline() { |
| 405 disable_network_notifier_.reset( | 397 NetworkPortalDetector::CaptivePortalState offline_state; |
| 406 new net::NetworkChangeNotifier::DisableForTest); | 398 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; |
| 399 network_portal_detector_->SetDetectionResultsForTesting( |
| 400 kStubEthernetServicePath, offline_state); |
| 401 network_portal_detector_->NotifyObserversForTesting(); |
| 402 } |
| 407 | 403 |
| 408 fake_network_notifier_.reset(new FakeNetworkChangeNotifier); | 404 base::Closure SimulateNetworkOfflineClosure() { |
| 405 return base::Bind(&KioskTest::SimulateNetworkOffline, |
| 406 base::Unretained(this)); |
| 409 } | 407 } |
| 410 | 408 |
| 411 void SimulateNetworkOnline() { | 409 void SimulateNetworkOnline() { |
| 412 if (fake_network_notifier_.get()) | 410 NetworkPortalDetector::CaptivePortalState online_state; |
| 413 fake_network_notifier_->GoOnline(); | 411 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 412 online_state.response_code = 204; |
| 413 network_portal_detector_->SetDetectionResultsForTesting( |
| 414 kStubEthernetServicePath, online_state); |
| 415 network_portal_detector_->NotifyObserversForTesting(); |
| 416 } |
| 417 |
| 418 base::Closure SimulateNetworkOnlineClosure() { |
| 419 return base::Bind(&KioskTest::SimulateNetworkOnline, |
| 420 base::Unretained(this)); |
| 421 } |
| 422 |
| 423 void SimulateNetworkPortal() { |
| 424 NetworkPortalDetector::CaptivePortalState portal_state; |
| 425 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 426 network_portal_detector_->SetDetectionResultsForTesting( |
| 427 kStubEthernetServicePath, portal_state); |
| 428 network_portal_detector_->NotifyObserversForTesting(); |
| 429 } |
| 430 |
| 431 base::Closure SimulateNetworkPortalClosure() { |
| 432 return base::Bind(&KioskTest::SimulateNetworkPortal, |
| 433 base::Unretained(this)); |
| 414 } | 434 } |
| 415 | 435 |
| 416 void WaitForAppLaunchNetworkTimeout() { | 436 void WaitForAppLaunchNetworkTimeout() { |
| 417 if (GetAppLaunchController()->network_wait_timedout()) | 437 if (GetAppLaunchController()->network_wait_timedout()) |
| 418 return; | 438 return; |
| 419 | 439 |
| 420 scoped_refptr<content::MessageLoopRunner> runner = | 440 scoped_refptr<content::MessageLoopRunner> runner = |
| 421 new content::MessageLoopRunner; | 441 new content::MessageLoopRunner; |
| 422 | 442 |
| 423 base::Closure callback = base::Bind( | 443 base::Closure callback = base::Bind( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 ->GetOobeUI() | 496 ->GetOobeUI() |
| 477 ->signin_screen_handler_for_test(); | 497 ->signin_screen_handler_for_test(); |
| 478 } | 498 } |
| 479 | 499 |
| 480 AppLaunchController* GetAppLaunchController() { | 500 AppLaunchController* GetAppLaunchController() { |
| 481 return chromeos::LoginDisplayHostImpl::default_host() | 501 return chromeos::LoginDisplayHostImpl::default_host() |
| 482 ->GetAppLaunchController(); | 502 ->GetAppLaunchController(); |
| 483 } | 503 } |
| 484 | 504 |
| 485 FakeGaia fake_gaia_; | 505 FakeGaia fake_gaia_; |
| 486 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> | |
| 487 disable_network_notifier_; | |
| 488 scoped_ptr<FakeNetworkChangeNotifier> fake_network_notifier_; | |
| 489 scoped_ptr<MockUserManager> mock_user_manager_; | 506 scoped_ptr<MockUserManager> mock_user_manager_; |
| 507 NetworkPortalDetectorTestImpl* network_portal_detector_; |
| 490 }; | 508 }; |
| 491 | 509 |
| 492 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { | 510 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { |
| 493 StartAppLaunchFromLoginScreen(true); | 511 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
| 494 WaitForAppLaunchSuccess(); | 512 WaitForAppLaunchSuccess(); |
| 495 } | 513 } |
| 496 | 514 |
| 497 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { | 515 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { |
| 498 // Mock network could be configured. | 516 // Mock network could be configured with owner's password. |
| 499 ScopedCanConfigureNetwork can_configure_network(true); | 517 ScopedCanConfigureNetwork can_configure_network(true, true); |
| 500 | 518 |
| 501 // Start app launch and wait for network connectivity timeout. | 519 // Start app launch and wait for network connectivity timeout. |
| 502 StartAppLaunchFromLoginScreen(false); | 520 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 503 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 521 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 504 splash_waiter.Wait(); | 522 splash_waiter.Wait(); |
| 505 WaitForAppLaunchNetworkTimeout(); | 523 WaitForAppLaunchNetworkTimeout(); |
| 506 | 524 |
| 507 // Configure network link should be visible. | 525 // Configure network link should be visible. |
| 508 JsExpect("$('splash-config-network').hidden == false"); | 526 JsExpect("$('splash-config-network').hidden == false"); |
| 509 | 527 |
| 510 // Set up fake user manager with an owner for the test. | 528 // Set up fake user manager with an owner for the test. |
| 511 mock_user_manager_->SetActiveUser(kTestOwnerEmail); | 529 mock_user_manager_->SetActiveUser(kTestOwnerEmail); |
| 512 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); | 530 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 525 ->OnOwnerSigninSuccess(); | 543 ->OnOwnerSigninSuccess(); |
| 526 error_screen_waiter.Wait(); | 544 error_screen_waiter.Wait(); |
| 527 | 545 |
| 528 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 546 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 529 | 547 |
| 530 WaitForAppLaunchSuccess(); | 548 WaitForAppLaunchSuccess(); |
| 531 } | 549 } |
| 532 | 550 |
| 533 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { | 551 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { |
| 534 // Mock network could not be configured. | 552 // Mock network could not be configured. |
| 535 ScopedCanConfigureNetwork can_configure_network(false); | 553 ScopedCanConfigureNetwork can_configure_network(false, true); |
| 536 | 554 |
| 537 // Start app launch and wait for network connectivity timeout. | 555 // Start app launch and wait for network connectivity timeout. |
| 538 StartAppLaunchFromLoginScreen(false); | 556 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 539 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 557 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 540 splash_waiter.Wait(); | 558 splash_waiter.Wait(); |
| 541 WaitForAppLaunchNetworkTimeout(); | 559 WaitForAppLaunchNetworkTimeout(); |
| 542 | 560 |
| 543 // Configure network link should not be visible. | 561 // Configure network link should not be visible. |
| 544 JsExpect("$('splash-config-network').hidden == true"); | 562 JsExpect("$('splash-config-network').hidden == true"); |
| 545 | 563 |
| 546 // Network becomes online and app launch is resumed. | 564 // Network becomes online and app launch is resumed. |
| 547 WaitForAppLaunchSuccess(); | 565 WaitForAppLaunchSuccess(); |
| 548 } | 566 } |
| 549 | 567 |
| 568 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { |
| 569 // Mock network could be configured without the owner password. |
| 570 ScopedCanConfigureNetwork can_configure_network(true, false); |
| 571 |
| 572 // Start app launch with network portal state. |
| 573 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); |
| 574 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) |
| 575 .WaitNoAssertCurrentScreen(); |
| 576 WaitForAppLaunchNetworkTimeout(); |
| 577 |
| 578 // Network error should show up automatically since this test does not |
| 579 // require owner auth to configure network. |
| 580 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 581 |
| 582 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 583 WaitForAppLaunchSuccess(); |
| 584 } |
| 585 |
| 550 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { | 586 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { |
| 551 StartAppLaunchFromLoginScreen(false); | 587 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 552 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 588 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 553 splash_waiter.Wait(); | 589 splash_waiter.Wait(); |
| 554 | 590 |
| 555 CrosSettings::Get()->SetBoolean( | 591 CrosSettings::Get()->SetBoolean( |
| 556 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); | 592 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); |
| 557 content::WindowedNotificationObserver signal( | 593 content::WindowedNotificationObserver signal( |
| 558 chrome::NOTIFICATION_APP_TERMINATING, | 594 chrome::NOTIFICATION_APP_TERMINATING, |
| 559 content::NotificationService::AllSources()); | 595 content::NotificationService::AllSources()); |
| 560 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 596 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
| 561 base::StringValue("app_launch_bailout")); | 597 base::StringValue("app_launch_bailout")); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 content::WindowedNotificationObserver( | 1002 content::WindowedNotificationObserver( |
| 967 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1003 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 968 content::NotificationService::AllSources()).Wait(); | 1004 content::NotificationService::AllSources()).Wait(); |
| 969 | 1005 |
| 970 // Wait for the wallpaper to load. | 1006 // Wait for the wallpaper to load. |
| 971 WaitForWallpaper(); | 1007 WaitForWallpaper(); |
| 972 EXPECT_TRUE(wallpaper_loaded()); | 1008 EXPECT_TRUE(wallpaper_loaded()); |
| 973 } | 1009 } |
| 974 | 1010 |
| 975 } // namespace chromeos | 1011 } // namespace chromeos |
| OLD | NEW |