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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 246 |
256 mock_user_manager_.reset(new MockUserManager); | 247 mock_user_manager_.reset(new MockUserManager); |
257 AppLaunchController::SkipSplashWaitForTesting(); | 248 AppLaunchController::SkipSplashWaitForTesting(); |
258 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); | 249 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); |
259 | 250 |
260 InProcessBrowserTest::SetUp(); | 251 InProcessBrowserTest::SetUp(); |
261 } | 252 } |
262 | 253 |
263 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 254 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
264 host_resolver()->AddRule("*", "127.0.0.1"); | 255 host_resolver()->AddRule("*", "127.0.0.1"); |
| 256 |
| 257 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 258 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 259 network_portal_detector_->SetDefaultNetworkPathForTesting( |
| 260 kStubEthernetServicePath); |
265 } | 261 } |
266 | 262 |
267 virtual void SetUpOnMainThread() OVERRIDE { | 263 virtual void SetUpOnMainThread() OVERRIDE { |
268 // Restart the thread as the sandbox host process has already been spawned. | 264 // Restart the thread as the sandbox host process has already been spawned. |
269 embedded_test_server()->RestartThreadAndListen(); | 265 embedded_test_server()->RestartThreadAndListen(); |
270 } | 266 } |
271 | 267 |
272 virtual void CleanUpOnMainThread() OVERRIDE { | 268 virtual void CleanUpOnMainThread() OVERRIDE { |
273 // We need to clean up these objects in this specific order. | |
274 fake_network_notifier_.reset(NULL); | |
275 disable_network_notifier_.reset(NULL); | |
276 | |
277 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); | 269 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); |
278 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); | 270 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); |
279 | 271 |
280 // If the login display is still showing, exit gracefully. | 272 // If the login display is still showing, exit gracefully. |
281 if (LoginDisplayHostImpl::default_host()) { | 273 if (LoginDisplayHostImpl::default_host()) { |
282 base::MessageLoop::current()->PostTask(FROM_HERE, | 274 base::MessageLoop::current()->PostTask(FROM_HERE, |
283 base::Bind(&chrome::AttemptExit)); | 275 base::Bind(&chrome::AttemptExit)); |
284 content::RunMessageLoop(); | 276 content::RunMessageLoop(); |
285 } | 277 } |
286 | 278 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 316 |
325 void ReloadKioskApps() { | 317 void ReloadKioskApps() { |
326 KioskAppManager::Get()->AddApp(kTestKioskApp); | 318 KioskAppManager::Get()->AddApp(kTestKioskApp); |
327 } | 319 } |
328 | 320 |
329 void ReloadAutolaunchKioskApps() { | 321 void ReloadAutolaunchKioskApps() { |
330 KioskAppManager::Get()->AddApp(kTestKioskApp); | 322 KioskAppManager::Get()->AddApp(kTestKioskApp); |
331 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); | 323 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); |
332 } | 324 } |
333 | 325 |
334 void StartAppLaunchFromLoginScreen(bool has_connectivity) { | 326 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { |
335 EnableConsumerKioskMode(); | 327 EnableConsumerKioskMode(); |
336 | 328 |
337 // Start UI, find menu entry for this app and launch it. | 329 // Start UI, find menu entry for this app and launch it. |
338 content::WindowedNotificationObserver login_signal( | 330 content::WindowedNotificationObserver login_signal( |
339 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 331 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
340 content::NotificationService::AllSources()); | 332 content::NotificationService::AllSources()); |
341 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 333 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
342 chromeos::WizardController* wizard_controller = | 334 chromeos::WizardController* wizard_controller = |
343 chromeos::WizardController::default_controller(); | 335 chromeos::WizardController::default_controller(); |
344 CHECK(wizard_controller); | 336 CHECK(wizard_controller); |
345 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 337 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
346 login_signal.Wait(); | 338 login_signal.Wait(); |
347 | 339 |
348 // Wait for the Kiosk App configuration to reload, then launch the app. | 340 // Wait for the Kiosk App configuration to reload, then launch the app. |
349 content::WindowedNotificationObserver apps_loaded_signal( | 341 content::WindowedNotificationObserver apps_loaded_signal( |
350 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 342 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
351 content::NotificationService::AllSources()); | 343 content::NotificationService::AllSources()); |
352 ReloadKioskApps(); | 344 ReloadKioskApps(); |
353 apps_loaded_signal.Wait(); | 345 apps_loaded_signal.Wait(); |
354 | 346 |
355 if (!has_connectivity) | 347 if (!network_setup_cb.is_null()) |
356 SimulateNetworkOffline(); | 348 network_setup_cb.Run(); |
357 | 349 |
358 GetLoginUI()->CallJavascriptFunction( | 350 GetLoginUI()->CallJavascriptFunction( |
359 "login.AppsMenuButton.runAppForTesting", | 351 "login.AppsMenuButton.runAppForTesting", |
360 base::StringValue(kTestKioskApp)); | 352 base::StringValue(kTestKioskApp)); |
361 } | 353 } |
362 | 354 |
363 void WaitForAppLaunchSuccess() { | 355 void WaitForAppLaunchSuccess() { |
364 SimulateNetworkOnline(); | 356 SimulateNetworkOnline(); |
365 | 357 |
366 ExtensionTestMessageListener | 358 ExtensionTestMessageListener |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // Wait until the app terminates if it is still running. | 395 // Wait until the app terminates if it is still running. |
404 if (!shell_window_registry->GetShellWindowsForApp(kTestKioskApp).empty()) | 396 if (!shell_window_registry->GetShellWindowsForApp(kTestKioskApp).empty()) |
405 content::RunMessageLoop(); | 397 content::RunMessageLoop(); |
406 | 398 |
407 // Check that the app had been informed that it is running in a kiosk | 399 // Check that the app had been informed that it is running in a kiosk |
408 // session. | 400 // session. |
409 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); | 401 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); |
410 } | 402 } |
411 | 403 |
412 void SimulateNetworkOffline() { | 404 void SimulateNetworkOffline() { |
413 disable_network_notifier_.reset( | 405 NetworkPortalDetector::CaptivePortalState offline_state; |
414 new net::NetworkChangeNotifier::DisableForTest); | 406 offline_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; |
| 407 network_portal_detector_->SetDetectionResultsForTesting( |
| 408 kStubEthernetServicePath, offline_state); |
| 409 network_portal_detector_->NotifyObserversForTesting(); |
| 410 } |
415 | 411 |
416 fake_network_notifier_.reset(new FakeNetworkChangeNotifier); | 412 base::Closure SimulateNetworkOfflineClosure() { |
| 413 return base::Bind(&KioskTest::SimulateNetworkOffline, |
| 414 base::Unretained(this)); |
417 } | 415 } |
418 | 416 |
419 void SimulateNetworkOnline() { | 417 void SimulateNetworkOnline() { |
420 if (fake_network_notifier_.get()) | 418 NetworkPortalDetector::CaptivePortalState online_state; |
421 fake_network_notifier_->GoOnline(); | 419 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 420 online_state.response_code = 204; |
| 421 network_portal_detector_->SetDetectionResultsForTesting( |
| 422 kStubEthernetServicePath, online_state); |
| 423 network_portal_detector_->NotifyObserversForTesting(); |
| 424 } |
| 425 |
| 426 base::Closure SimulateNetworkOnlineClosure() { |
| 427 return base::Bind(&KioskTest::SimulateNetworkOnline, |
| 428 base::Unretained(this)); |
| 429 } |
| 430 |
| 431 void SimulateNetworkPortal() { |
| 432 NetworkPortalDetector::CaptivePortalState portal_state; |
| 433 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 434 network_portal_detector_->SetDetectionResultsForTesting( |
| 435 kStubEthernetServicePath, portal_state); |
| 436 network_portal_detector_->NotifyObserversForTesting(); |
| 437 } |
| 438 |
| 439 base::Closure SimulateNetworkPortalClosure() { |
| 440 return base::Bind(&KioskTest::SimulateNetworkPortal, |
| 441 base::Unretained(this)); |
422 } | 442 } |
423 | 443 |
424 void WaitForAppLaunchNetworkTimeout() { | 444 void WaitForAppLaunchNetworkTimeout() { |
425 if (GetAppLaunchController()->network_wait_timedout()) | 445 if (GetAppLaunchController()->network_wait_timedout()) |
426 return; | 446 return; |
427 | 447 |
428 scoped_refptr<content::MessageLoopRunner> runner = | 448 scoped_refptr<content::MessageLoopRunner> runner = |
429 new content::MessageLoopRunner; | 449 new content::MessageLoopRunner; |
430 | 450 |
431 base::Closure callback = base::Bind( | 451 base::Closure callback = base::Bind( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 ->GetOobeUI() | 504 ->GetOobeUI() |
485 ->signin_screen_handler_for_test(); | 505 ->signin_screen_handler_for_test(); |
486 } | 506 } |
487 | 507 |
488 AppLaunchController* GetAppLaunchController() { | 508 AppLaunchController* GetAppLaunchController() { |
489 return chromeos::LoginDisplayHostImpl::default_host() | 509 return chromeos::LoginDisplayHostImpl::default_host() |
490 ->GetAppLaunchController(); | 510 ->GetAppLaunchController(); |
491 } | 511 } |
492 | 512 |
493 FakeGaia fake_gaia_; | 513 FakeGaia fake_gaia_; |
494 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> | |
495 disable_network_notifier_; | |
496 scoped_ptr<FakeNetworkChangeNotifier> fake_network_notifier_; | |
497 scoped_ptr<MockUserManager> mock_user_manager_; | 514 scoped_ptr<MockUserManager> mock_user_manager_; |
| 515 NetworkPortalDetectorTestImpl* network_portal_detector_; |
498 }; | 516 }; |
499 | 517 |
500 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { | 518 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { |
501 StartAppLaunchFromLoginScreen(true); | 519 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
502 WaitForAppLaunchSuccess(); | 520 WaitForAppLaunchSuccess(); |
503 } | 521 } |
504 | 522 |
505 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { | 523 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { |
506 // Mock network could be configured. | 524 // Mock network could be configured with owner's password. |
507 ScopedCanConfigureNetwork can_configure_network(true); | 525 ScopedCanConfigureNetwork can_configure_network(true, true); |
508 | 526 |
509 // Start app launch and wait for network connectivity timeout. | 527 // Start app launch and wait for network connectivity timeout. |
510 StartAppLaunchFromLoginScreen(false); | 528 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
511 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 529 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
512 splash_waiter.Wait(); | 530 splash_waiter.Wait(); |
513 WaitForAppLaunchNetworkTimeout(); | 531 WaitForAppLaunchNetworkTimeout(); |
514 | 532 |
515 // Configure network link should be visible. | 533 // Configure network link should be visible. |
516 JsExpect("$('splash-config-network').hidden == false"); | 534 JsExpect("$('splash-config-network').hidden == false"); |
517 | 535 |
518 // Set up fake user manager with an owner for the test. | 536 // Set up fake user manager with an owner for the test. |
519 mock_user_manager_->SetActiveUser(kTestOwnerEmail); | 537 mock_user_manager_->SetActiveUser(kTestOwnerEmail); |
520 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); | 538 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); |
(...skipping 12 matching lines...) Expand all Loading... |
533 ->OnOwnerSigninSuccess(); | 551 ->OnOwnerSigninSuccess(); |
534 error_screen_waiter.Wait(); | 552 error_screen_waiter.Wait(); |
535 | 553 |
536 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 554 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
537 | 555 |
538 WaitForAppLaunchSuccess(); | 556 WaitForAppLaunchSuccess(); |
539 } | 557 } |
540 | 558 |
541 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { | 559 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { |
542 // Mock network could not be configured. | 560 // Mock network could not be configured. |
543 ScopedCanConfigureNetwork can_configure_network(false); | 561 ScopedCanConfigureNetwork can_configure_network(false, true); |
544 | 562 |
545 // Start app launch and wait for network connectivity timeout. | 563 // Start app launch and wait for network connectivity timeout. |
546 StartAppLaunchFromLoginScreen(false); | 564 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
547 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 565 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
548 splash_waiter.Wait(); | 566 splash_waiter.Wait(); |
549 WaitForAppLaunchNetworkTimeout(); | 567 WaitForAppLaunchNetworkTimeout(); |
550 | 568 |
551 // Configure network link should not be visible. | 569 // Configure network link should not be visible. |
552 JsExpect("$('splash-config-network').hidden == true"); | 570 JsExpect("$('splash-config-network').hidden == true"); |
553 | 571 |
554 // Network becomes online and app launch is resumed. | 572 // Network becomes online and app launch is resumed. |
555 WaitForAppLaunchSuccess(); | 573 WaitForAppLaunchSuccess(); |
556 } | 574 } |
557 | 575 |
| 576 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { |
| 577 // Mock network could be configured without the owner password. |
| 578 ScopedCanConfigureNetwork can_configure_network(true, false); |
| 579 |
| 580 // Start app launch with network portal state. |
| 581 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); |
| 582 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) |
| 583 .WaitNoAssertCurrentScreen(); |
| 584 WaitForAppLaunchNetworkTimeout(); |
| 585 |
| 586 // Network error should show up automatically since this test does not |
| 587 // require owner auth to configure network. |
| 588 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 589 |
| 590 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 591 WaitForAppLaunchSuccess(); |
| 592 } |
| 593 |
558 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { | 594 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { |
559 StartAppLaunchFromLoginScreen(false); | 595 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
560 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 596 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
561 splash_waiter.Wait(); | 597 splash_waiter.Wait(); |
562 | 598 |
563 CrosSettings::Get()->SetBoolean( | 599 CrosSettings::Get()->SetBoolean( |
564 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); | 600 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); |
565 content::WindowedNotificationObserver signal( | 601 content::WindowedNotificationObserver signal( |
566 chrome::NOTIFICATION_APP_TERMINATING, | 602 chrome::NOTIFICATION_APP_TERMINATING, |
567 content::NotificationService::AllSources()); | 603 content::NotificationService::AllSources()); |
568 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 604 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
569 base::StringValue("app_launch_bailout")); | 605 base::StringValue("app_launch_bailout")); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 content::WindowedNotificationObserver( | 1009 content::WindowedNotificationObserver( |
974 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1010 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
975 content::NotificationService::AllSources()).Wait(); | 1011 content::NotificationService::AllSources()).Wait(); |
976 | 1012 |
977 // Wait for the wallpaper to load. | 1013 // Wait for the wallpaper to load. |
978 WaitForWallpaper(); | 1014 WaitForWallpaper(); |
979 EXPECT_TRUE(wallpaper_loaded()); | 1015 EXPECT_TRUE(wallpaper_loaded()); |
980 } | 1016 } |
981 | 1017 |
982 } // namespace chromeos | 1018 } // namespace chromeos |
OLD | NEW |