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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chrome_browser_main.h" | 11 #include "chrome/browser/chrome_browser_main.h" |
12 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 12 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
13 #include "chrome/browser/chrome_content_browser_client.h" | 13 #include "chrome/browser/chrome_content_browser_client.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
17 #include "chrome/browser/chromeos/login/app_launch_controller.h" | 17 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
| 18 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h" |
18 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 19 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
19 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 20 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 21 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
20 #include "chrome/browser/chromeos/login/webui_login_display.h" | 22 #include "chrome/browser/chromeos/login/webui_login_display.h" |
21 #include "chrome/browser/chromeos/login/wizard_controller.h" | 23 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 25 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/extensions/extension_system.h" | 27 #include "chrome/browser/extensions/extension_system.h" |
24 #include "chrome/browser/lifetime/application_lifetime.h" | 28 #include "chrome/browser/lifetime/application_lifetime.h" |
25 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 29 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
27 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 32 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
29 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
30 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
32 #include "chrome/test/base/in_process_browser_test.h" | 36 #include "chrome/test/base/in_process_browser_test.h" |
33 #include "chrome/test/base/interactive_test_utils.h" | 37 #include "chrome/test/base/interactive_test_utils.h" |
34 #include "chrome/test/base/ui_test_utils.h" | 38 #include "chrome/test/base/ui_test_utils.h" |
35 #include "chromeos/chromeos_switches.h" | 39 #include "chromeos/chromeos_switches.h" |
36 #include "content/public/browser/notification_observer.h" | 40 #include "content/public/browser/notification_observer.h" |
37 #include "content/public/browser/notification_registrar.h" | 41 #include "content/public/browser/notification_registrar.h" |
38 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
39 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" |
40 #include "google_apis/gaia/gaia_switches.h" | 44 #include "google_apis/gaia/gaia_switches.h" |
41 #include "net/base/host_port_pair.h" | 45 #include "net/base/host_port_pair.h" |
| 46 #include "net/base/network_change_notifier.h" |
42 #include "net/dns/mock_host_resolver.h" | 47 #include "net/dns/mock_host_resolver.h" |
43 #include "net/test/embedded_test_server/embedded_test_server.h" | 48 #include "net/test/embedded_test_server/embedded_test_server.h" |
44 #include "net/test/embedded_test_server/http_request.h" | 49 #include "net/test/embedded_test_server/http_request.h" |
45 #include "net/test/embedded_test_server/http_response.h" | 50 #include "net/test/embedded_test_server/http_response.h" |
46 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
47 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
48 | 53 |
49 using namespace net::test_server; | 54 using namespace net::test_server; |
50 | 55 |
51 namespace chromeos { | 56 namespace chromeos { |
52 | 57 |
53 namespace { | 58 namespace { |
54 | 59 |
55 const char kWebstoreDomain[] = "cws.com"; | 60 const char kWebstoreDomain[] = "cws.com"; |
56 const base::FilePath kServiceLogin("chromeos/service_login.html"); | 61 const base::FilePath kServiceLogin("chromeos/service_login.html"); |
57 | 62 |
58 // Webstore data json is in | 63 // Webstore data json is in |
59 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ | 64 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ |
60 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe | 65 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe |
61 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; | 66 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; |
62 | 67 |
| 68 // Timeout while waiting for network connectivity during tests. |
| 69 const int kTestNetworkTimeoutSeconds = 1; |
| 70 |
| 71 // Email of owner account for test. |
| 72 const char kTestOwnerEmail[] = "owner@example.com"; |
| 73 |
63 // Helper function for GetConsumerKioskModeStatusCallback. | 74 // Helper function for GetConsumerKioskModeStatusCallback. |
64 void ConsumerKioskModeStatusCheck( | 75 void ConsumerKioskModeStatusCheck( |
65 KioskAppManager::ConsumerKioskModeStatus* out_status, | 76 KioskAppManager::ConsumerKioskModeStatus* out_status, |
66 const base::Closure& runner_quit_task, | 77 const base::Closure& runner_quit_task, |
67 KioskAppManager::ConsumerKioskModeStatus in_status) { | 78 KioskAppManager::ConsumerKioskModeStatus in_status) { |
68 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; | 79 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; |
69 *out_status = in_status; | 80 *out_status = in_status; |
70 runner_quit_task.Run(); | 81 runner_quit_task.Run(); |
71 } | 82 } |
72 | 83 |
73 // Helper KioskAppManager::EnableKioskModeCallback implementation. | 84 // Helper KioskAppManager::EnableKioskModeCallback implementation. |
74 void ConsumerKioskModeLockCheck( | 85 void ConsumerKioskModeLockCheck( |
75 bool* out_locked, | 86 bool* out_locked, |
76 const base::Closure& runner_quit_task, | 87 const base::Closure& runner_quit_task, |
77 bool in_locked) { | 88 bool in_locked) { |
78 LOG(INFO) << "kioks locked = " << in_locked; | 89 LOG(INFO) << "kioks locked = " << in_locked; |
79 *out_locked = in_locked; | 90 *out_locked = in_locked; |
80 runner_quit_task.Run(); | 91 runner_quit_task.Run(); |
81 } | 92 } |
82 | 93 |
83 } // namespace | 94 } // namespace |
84 | 95 |
| 96 class FakeNetworkChangeNotifier : public net::NetworkChangeNotifier { |
| 97 public: |
| 98 FakeNetworkChangeNotifier() : connection_type_(CONNECTION_NONE) {} |
| 99 |
| 100 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE { |
| 101 return connection_type_; |
| 102 } |
| 103 |
| 104 void GoOnline() { |
| 105 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET); |
| 106 } |
| 107 |
| 108 void GoOffline() { |
| 109 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE); |
| 110 } |
| 111 |
| 112 void SetConnectionType(ConnectionType type) { |
| 113 connection_type_ = type; |
| 114 NotifyObserversOfNetworkChange(type); |
| 115 base::RunLoop().RunUntilIdle(); |
| 116 } |
| 117 |
| 118 virtual ~FakeNetworkChangeNotifier() {} |
| 119 |
| 120 private: |
| 121 ConnectionType connection_type_; |
| 122 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier); |
| 123 }; |
| 124 |
85 class KioskTest : public InProcessBrowserTest, | 125 class KioskTest : public InProcessBrowserTest, |
86 // Param defining is multi-profiles enabled. | 126 // Param defining is multi-profiles enabled. |
87 public testing::WithParamInterface<bool> { | 127 public testing::WithParamInterface<bool> { |
88 public: | 128 public: |
89 KioskTest() { | 129 KioskTest() { |
90 set_exit_when_last_browser_closes(false); | 130 set_exit_when_last_browser_closes(false); |
91 } | 131 } |
92 | 132 |
93 virtual ~KioskTest() {} | 133 virtual ~KioskTest() {} |
94 | 134 |
95 protected: | 135 protected: |
96 virtual void SetUpOnMainThread() OVERRIDE { | 136 virtual void SetUpOnMainThread() OVERRIDE { |
97 test_server_.reset(new EmbeddedTestServer( | 137 test_server_.reset(new EmbeddedTestServer( |
98 content::BrowserThread::GetMessageLoopProxyForThread( | 138 content::BrowserThread::GetMessageLoopProxyForThread( |
99 content::BrowserThread::IO))); | 139 content::BrowserThread::IO))); |
100 CHECK(test_server_->InitializeAndWaitUntilReady()); | 140 CHECK(test_server_->InitializeAndWaitUntilReady()); |
101 test_server_->RegisterRequestHandler( | 141 test_server_->RegisterRequestHandler( |
102 base::Bind(&KioskTest::HandleRequest, base::Unretained(this))); | 142 base::Bind(&KioskTest::HandleRequest, base::Unretained(this))); |
103 LOG(INFO) << "Set up http server at " << test_server_->base_url(); | 143 LOG(INFO) << "Set up http server at " << test_server_->base_url(); |
104 | 144 |
105 const GURL gaia_url("http://localhost:" + test_server_->base_url().port()); | 145 const GURL gaia_url("http://localhost:" + test_server_->base_url().port()); |
106 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 146 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
107 ::switches::kGaiaUrl, gaia_url.spec()); | 147 ::switches::kGaiaUrl, gaia_url.spec()); |
| 148 |
| 149 mock_user_manager_.reset(new MockUserManager); |
108 } | 150 } |
109 | 151 |
110 virtual void CleanUpOnMainThread() OVERRIDE { | 152 virtual void CleanUpOnMainThread() OVERRIDE { |
| 153 // We need to clean up these objects in this specific order. |
| 154 fake_network_notifier_.reset(NULL); |
| 155 disable_network_notifier_.reset(NULL); |
| 156 |
111 // If the login display is still showing, exit gracefully. | 157 // If the login display is still showing, exit gracefully. |
112 if (LoginDisplayHostImpl::default_host()) { | 158 if (LoginDisplayHostImpl::default_host()) { |
113 base::MessageLoop::current()->PostTask(FROM_HERE, | 159 base::MessageLoop::current()->PostTask(FROM_HERE, |
114 base::Bind(&chrome::AttemptExit)); | 160 base::Bind(&chrome::AttemptExit)); |
115 content::RunMessageLoop(); | 161 content::RunMessageLoop(); |
116 } | 162 } |
117 | 163 |
118 // Clean up while main thread still runs. | 164 // Clean up while main thread still runs. |
119 // See http://crbug.com/176659. | 165 // See http://crbug.com/176659. |
120 KioskAppManager::Get()->CleanUp(); | 166 KioskAppManager::Get()->CleanUp(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 235 |
190 void ReloadKioskApps() { | 236 void ReloadKioskApps() { |
191 KioskAppManager::Get()->AddApp(kTestKioskApp); | 237 KioskAppManager::Get()->AddApp(kTestKioskApp); |
192 } | 238 } |
193 | 239 |
194 void ReloadAutolaunchKioskApps() { | 240 void ReloadAutolaunchKioskApps() { |
195 KioskAppManager::Get()->AddApp(kTestKioskApp); | 241 KioskAppManager::Get()->AddApp(kTestKioskApp); |
196 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); | 242 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); |
197 } | 243 } |
198 | 244 |
| 245 void StartAppLaunchFromLoginScreen(bool has_connectivity) { |
| 246 EnableConsumerKioskMode(); |
| 247 |
| 248 // Start UI, find menu entry for this app and launch it. |
| 249 content::WindowedNotificationObserver login_signal( |
| 250 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 251 content::NotificationService::AllSources()); |
| 252 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 253 chromeos::WizardController* wizard_controller = |
| 254 chromeos::WizardController::default_controller(); |
| 255 CHECK(wizard_controller); |
| 256 wizard_controller->SkipToLoginForTesting(); |
| 257 login_signal.Wait(); |
| 258 |
| 259 // Wait for the Kiosk App configuration to reload, then launch the app. |
| 260 content::WindowedNotificationObserver apps_loaded_signal( |
| 261 chrome::NOTIFICATION_KIOSK_APPS_LOADED, |
| 262 content::NotificationService::AllSources()); |
| 263 ReloadKioskApps(); |
| 264 apps_loaded_signal.Wait(); |
| 265 |
| 266 if (!has_connectivity) |
| 267 SimulateNetworkOffline(); |
| 268 |
| 269 content::WindowedNotificationObserver screen_change_signal( |
| 270 chrome::NOTIFICATION_CURRENT_SCREEN_CHANGED, |
| 271 content::NotificationService::AllSources()); |
| 272 GetLoginUI()->CallJavascriptFunction( |
| 273 "login.AppsMenuButton.runAppForTesting", |
| 274 base::StringValue(kTestKioskApp)); |
| 275 screen_change_signal.Wait(); |
| 276 ASSERT_EQ(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH, GetCurrentScreen()); |
| 277 GetAppLaunchController()->SkipSplashWaitForTesting(); |
| 278 } |
| 279 |
| 280 void WaitForAppLaunchSuccess() { |
| 281 SimulateNetworkOnline(); |
| 282 |
| 283 // Wait for the Kiosk App to launch. |
| 284 content::WindowedNotificationObserver( |
| 285 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, |
| 286 content::NotificationService::AllSources()).Wait(); |
| 287 |
| 288 // Check installer status. |
| 289 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, |
| 290 chromeos::KioskAppLaunchError::Get()); |
| 291 |
| 292 // Check if the kiosk webapp is really installed for the default profile. |
| 293 ASSERT_TRUE(ProfileManager::GetDefaultProfile()); |
| 294 const extensions::Extension* app = |
| 295 extensions::ExtensionSystem::Get(ProfileManager::GetDefaultProfile())-> |
| 296 extension_service()->GetInstalledExtension(kTestKioskApp); |
| 297 EXPECT_TRUE(app); |
| 298 |
| 299 // Wait until the app terminates. |
| 300 content::RunMessageLoop(); |
| 301 } |
| 302 |
| 303 void SimulateNetworkOffline() { |
| 304 disable_network_notifier_.reset( |
| 305 new net::NetworkChangeNotifier::DisableForTest); |
| 306 |
| 307 fake_network_notifier_.reset(new FakeNetworkChangeNotifier); |
| 308 } |
| 309 |
| 310 void SimulateNetworkOnline() { |
| 311 if (fake_network_notifier_.get()) |
| 312 fake_network_notifier_->GoOnline(); |
| 313 } |
| 314 |
199 void EnableConsumerKioskMode() { | 315 void EnableConsumerKioskMode() { |
200 scoped_ptr<bool> locked(new bool(false)); | 316 scoped_ptr<bool> locked(new bool(false)); |
201 scoped_refptr<content::MessageLoopRunner> runner = | 317 scoped_refptr<content::MessageLoopRunner> runner = |
202 new content::MessageLoopRunner; | 318 new content::MessageLoopRunner; |
203 KioskAppManager::Get()->EnableConsumerModeKiosk( | 319 KioskAppManager::Get()->EnableConsumerModeKiosk( |
204 base::Bind(&ConsumerKioskModeLockCheck, | 320 base::Bind(&ConsumerKioskModeLockCheck, |
205 locked.get(), | 321 locked.get(), |
206 runner->QuitClosure())); | 322 runner->QuitClosure())); |
207 runner->Run(); | 323 runner->Run(); |
208 EXPECT_TRUE(*locked.get()); | 324 EXPECT_TRUE(*locked.get()); |
(...skipping 11 matching lines...) Expand all Loading... |
220 runner->Run(); | 336 runner->Run(); |
221 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); | 337 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); |
222 return status; | 338 return status; |
223 } | 339 } |
224 | 340 |
225 content::WebUI* GetLoginUI() { | 341 content::WebUI* GetLoginUI() { |
226 return static_cast<chromeos::LoginDisplayHostImpl*>( | 342 return static_cast<chromeos::LoginDisplayHostImpl*>( |
227 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); | 343 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); |
228 } | 344 } |
229 | 345 |
| 346 OobeDisplay::Screen GetCurrentScreen() { |
| 347 OobeUI* oobe_ui = static_cast<chromeos::LoginDisplayHostImpl*>( |
| 348 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI(); |
| 349 return oobe_ui->current_screen(); |
| 350 } |
| 351 |
| 352 AppLaunchController* GetAppLaunchController() { |
| 353 return chromeos::LoginDisplayHostImpl::default_host() |
| 354 ->GetAppLaunchController(); |
| 355 } |
| 356 |
230 std::string service_login_response_; | 357 std::string service_login_response_; |
231 scoped_ptr<EmbeddedTestServer> test_server_; | 358 scoped_ptr<EmbeddedTestServer> test_server_; |
| 359 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> |
| 360 disable_network_notifier_; |
| 361 scoped_ptr<FakeNetworkChangeNotifier> fake_network_notifier_; |
| 362 scoped_ptr<MockUserManager> mock_user_manager_; |
232 }; | 363 }; |
233 | 364 |
234 IN_PROC_BROWSER_TEST_P(KioskTest, InstallAndLaunchApp) { | 365 IN_PROC_BROWSER_TEST_P(KioskTest, InstallAndLaunchApp) { |
235 EnableConsumerKioskMode(); | 366 StartAppLaunchFromLoginScreen(true); |
236 chromeos::AppLaunchController::SkipSplashWaitForTesting(); | 367 WaitForAppLaunchSuccess(); |
237 // Start UI, find menu entry for this app and launch it. | 368 } |
238 chromeos::WizardController::SkipPostLoginScreensForTesting(); | |
239 chromeos::WizardController* wizard_controller = | |
240 chromeos::WizardController::default_controller(); | |
241 CHECK(wizard_controller); | |
242 wizard_controller->SkipToLoginForTesting(); | |
243 | 369 |
244 ReloadKioskApps(); | 370 IN_PROC_BROWSER_TEST_P(KioskTest, LaunchAppNetworkDown) { |
| 371 // Start app launch and wait for network connectivity timeout. |
| 372 content::WindowedNotificationObserver network_timeout_signal( |
| 373 chrome::NOTIFICATION_KIOSK_APP_LAUNCH_NO_NETWORK, |
| 374 content::NotificationService::AllSources()); |
| 375 StartAppLaunchFromLoginScreen(false); |
| 376 network_timeout_signal.Wait(); |
245 | 377 |
246 // Wait for the Kiosk App configuration to reload, then launch the app. | 378 // Set up fake user manager with an owner for the test. |
247 content::WindowedNotificationObserver( | 379 mock_user_manager_->SetActiveUser(kTestOwnerEmail); |
248 chrome::NOTIFICATION_KIOSK_APPS_LOADED, | 380 AppLaunchController* controller = GetAppLaunchController(); |
249 content::NotificationService::AllSources()).Wait(); | 381 controller->SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); |
250 GetLoginUI()->CallJavascriptFunction("login.AppsMenuButton.runAppForTesting", | 382 controller->SetUserManagerForTesting(mock_user_manager_.get()); |
251 base::StringValue(kTestKioskApp)); | 383 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()) |
| 384 ->GetOobeUI()->ShowOobeUI(false); |
252 | 385 |
253 // Wait for the Kiosk App to launch. | 386 // Configure network should bring up lock screen for owner. |
254 content::WindowedNotificationObserver( | 387 content::WindowedNotificationObserver lock_screen_signal( |
255 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, | 388 chrome::NOTIFICATION_CURRENT_SCREEN_CHANGED, |
256 content::NotificationService::AllSources()).Wait(); | 389 content::NotificationService::AllSources()); |
| 390 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController()) |
| 391 ->OnConfigureNetwork(); |
| 392 lock_screen_signal.Wait(); |
| 393 ASSERT_EQ(OobeDisplay::SCREEN_ACCOUNT_PICKER, GetCurrentScreen()); |
257 | 394 |
258 // Check installer status. | 395 // A network error screen should be shown after authenticating. |
259 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, | 396 content::WindowedNotificationObserver network_error_signal( |
| 397 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
| 398 content::NotificationService::AllSources()); |
| 399 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController()) |
| 400 ->OnOwnerSigninSuccess(); |
| 401 network_error_signal.Wait(); |
| 402 |
| 403 WaitForAppLaunchSuccess(); |
| 404 } |
| 405 |
| 406 IN_PROC_BROWSER_TEST_P(KioskTest, LaunchAppUserCancel) { |
| 407 StartAppLaunchFromLoginScreen(false); |
| 408 CrosSettings::Get()->SetBoolean( |
| 409 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); |
| 410 content::WindowedNotificationObserver signal( |
| 411 chrome::NOTIFICATION_APP_TERMINATING, |
| 412 content::NotificationService::AllSources()); |
| 413 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
| 414 base::StringValue("app_launch_bailout")); |
| 415 signal.Wait(); |
| 416 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL, |
260 chromeos::KioskAppLaunchError::Get()); | 417 chromeos::KioskAppLaunchError::Get()); |
261 | |
262 // Check if the kiosk webapp is really installed for the default profile. | |
263 ASSERT_TRUE(ProfileManager::GetDefaultProfile()); | |
264 const extensions::Extension* app = | |
265 extensions::ExtensionSystem::Get(ProfileManager::GetDefaultProfile())-> | |
266 extension_service()->GetInstalledExtension(kTestKioskApp); | |
267 EXPECT_TRUE(app); | |
268 | |
269 // Wait until the app terminates. | |
270 content::RunMessageLoop(); | |
271 } | 418 } |
272 | 419 |
273 IN_PROC_BROWSER_TEST_P(KioskTest, AutolaunchWarningCancel) { | 420 IN_PROC_BROWSER_TEST_P(KioskTest, AutolaunchWarningCancel) { |
274 EnableConsumerKioskMode(); | 421 EnableConsumerKioskMode(); |
275 // Start UI, find menu entry for this app and launch it. | 422 // Start UI, find menu entry for this app and launch it. |
276 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 423 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
277 chromeos::WizardController* wizard_controller = | 424 chromeos::WizardController* wizard_controller = |
278 chromeos::WizardController::default_controller(); | 425 chromeos::WizardController::default_controller(); |
279 CHECK(wizard_controller); | 426 CHECK(wizard_controller); |
280 ReloadAutolaunchKioskApps(); | 427 ReloadAutolaunchKioskApps(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 content::WindowedNotificationObserver( | 563 content::WindowedNotificationObserver( |
417 chrome::NOTIFICATION_KIOSK_ENABLED, | 564 chrome::NOTIFICATION_KIOSK_ENABLED, |
418 content::NotificationService::AllSources()).Wait(); | 565 content::NotificationService::AllSources()).Wait(); |
419 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED, | 566 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED, |
420 GetConsumerKioskModeStatus()); | 567 GetConsumerKioskModeStatus()); |
421 } | 568 } |
422 | 569 |
423 INSTANTIATE_TEST_CASE_P(KioskTestInstantiation, KioskTest, testing::Bool()); | 570 INSTANTIATE_TEST_CASE_P(KioskTestInstantiation, KioskTest, testing::Bool()); |
424 | 571 |
425 } // namespace chromeos | 572 } // namespace chromeos |
OLD | NEW |