| 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/path_service.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 15 #include "chrome/browser/chromeos/login/app_launch_controller.h" | 16 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
| 16 #include "chrome/browser/chromeos/login/fake_user_manager.h" | 17 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 17 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 18 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
| 18 #include "chrome/browser/chromeos/login/oobe_base_test.h" | 19 #include "chrome/browser/chromeos/login/oobe_base_test.h" |
| 19 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 20 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 21 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 21 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 22 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 22 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 23 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 23 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 24 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 24 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 25 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/extensions/extension_test_message_listener.h" | 27 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 28 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 29 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
| 30 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
| 31 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 32 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/test/browser_test_utils.h" | 35 #include "content/public/test/browser_test_utils.h" |
| 34 #include "extensions/browser/extension_system.h" | 36 #include "extensions/browser/extension_system.h" |
| 35 #include "google_apis/gaia/gaia_constants.h" | 37 #include "google_apis/gaia/gaia_constants.h" |
| 36 #include "google_apis/gaia/gaia_switches.h" | 38 #include "google_apis/gaia/gaia_switches.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe | 50 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe |
| 49 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; | 51 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; |
| 50 | 52 |
| 51 // This app creates a window and declares usage of the identity API in its | 53 // This app creates a window and declares usage of the identity API in its |
| 52 // manifest, so we can test device robot token minting via the identity API. | 54 // manifest, so we can test device robot token minting via the identity API. |
| 53 // Webstore data json is in | 55 // Webstore data json is in |
| 54 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ | 56 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ |
| 55 // detail/ibjkkfdnfcaoapcpheeijckmpcfkifob | 57 // detail/ibjkkfdnfcaoapcpheeijckmpcfkifob |
| 56 const char kTestEnterpriseKioskApp[] = "ibjkkfdnfcaoapcpheeijckmpcfkifob"; | 58 const char kTestEnterpriseKioskApp[] = "ibjkkfdnfcaoapcpheeijckmpcfkifob"; |
| 57 | 59 |
| 60 // An offline enable test app. Webstore data json is in |
| 61 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ |
| 62 // detail/ajoggoflpgplnnjkjamcmbepjdjdnpdp |
| 63 // An app profile with version 1.0.0 installed is in |
| 64 // chrome/test/data/chromeos/app_mode/offline_enabled_app_profile |
| 65 // The version 2.0.0 crx is in |
| 66 // chrome/test/data/chromeos/app_mode/webstore/downloads/ |
| 67 const char kTestOfflineEnabledKioskApp[] = "ajoggoflpgplnnjkjamcmbepjdjdnpdp"; |
| 68 |
| 58 // Timeout while waiting for network connectivity during tests. | 69 // Timeout while waiting for network connectivity during tests. |
| 59 const int kTestNetworkTimeoutSeconds = 1; | 70 const int kTestNetworkTimeoutSeconds = 1; |
| 60 | 71 |
| 61 // Email of owner account for test. | 72 // Email of owner account for test. |
| 62 const char kTestOwnerEmail[] = "owner@example.com"; | 73 const char kTestOwnerEmail[] = "owner@example.com"; |
| 63 | 74 |
| 64 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; | 75 const char kTestEnterpriseAccountId[] = "enterprise-kiosk-app@localhost"; |
| 65 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; | 76 const char kTestEnterpriseServiceAccountId[] = "service_account@example.com"; |
| 66 const char kTestRefreshToken[] = "fake-refresh-token"; | 77 const char kTestRefreshToken[] = "fake-refresh-token"; |
| 67 const char kTestUserinfoToken[] = "fake-userinfo-token"; | 78 const char kTestUserinfoToken[] = "fake-userinfo-token"; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 248 |
| 238 class KioskTest : public OobeBaseTest { | 249 class KioskTest : public OobeBaseTest { |
| 239 public: | 250 public: |
| 240 KioskTest() { | 251 KioskTest() { |
| 241 set_exit_when_last_browser_closes(false); | 252 set_exit_when_last_browser_closes(false); |
| 242 } | 253 } |
| 243 | 254 |
| 244 virtual ~KioskTest() {} | 255 virtual ~KioskTest() {} |
| 245 | 256 |
| 246 protected: | 257 protected: |
| 247 | |
| 248 virtual void SetUp() OVERRIDE { | 258 virtual void SetUp() OVERRIDE { |
| 259 test_app_id_ = kTestKioskApp; |
| 249 mock_user_manager_.reset(new MockUserManager); | 260 mock_user_manager_.reset(new MockUserManager); |
| 250 AppLaunchController::SkipSplashWaitForTesting(); | 261 AppLaunchController::SkipSplashWaitForTesting(); |
| 251 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); | 262 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); |
| 252 | 263 |
| 253 OobeBaseTest::SetUp(); | 264 OobeBaseTest::SetUp(); |
| 254 } | 265 } |
| 255 | 266 |
| 256 virtual void CleanUpOnMainThread() OVERRIDE { | 267 virtual void CleanUpOnMainThread() OVERRIDE { |
| 257 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); | 268 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); |
| 258 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); | 269 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); |
| 259 | 270 |
| 260 OobeBaseTest::CleanUpOnMainThread(); | 271 OobeBaseTest::CleanUpOnMainThread(); |
| 261 | 272 |
| 262 // Clean up while main thread still runs. | 273 // Clean up while main thread still runs. |
| 263 // See http://crbug.com/176659. | 274 // See http://crbug.com/176659. |
| 264 KioskAppManager::Get()->CleanUp(); | 275 KioskAppManager::Get()->CleanUp(); |
| 265 } | 276 } |
| 266 | 277 |
| 267 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 278 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 268 OobeBaseTest::SetUpCommandLine(command_line); | 279 OobeBaseTest::SetUpCommandLine(command_line); |
| 269 | 280 |
| 270 // Create gaia and webstore URL from test server url but using different | 281 // Create gaia and webstore URL from test server url but using different |
| 271 // host names. This is to avoid gaia response being tagged as from | 282 // host names. This is to avoid gaia response being tagged as from |
| 272 // webstore in chrome_resource_dispatcher_host_delegate.cc. | 283 // webstore in chrome_resource_dispatcher_host_delegate.cc. |
| 273 const GURL& server_url = embedded_test_server()->base_url(); | 284 GURL webstore_url = GetTestWebstoreUrl(); |
| 274 std::string webstore_host("webstore"); | |
| 275 GURL::Replacements replace_webstore_host; | |
| 276 replace_webstore_host.SetHostStr(webstore_host); | |
| 277 GURL webstore_url = server_url.ReplaceComponents(replace_webstore_host); | |
| 278 command_line->AppendSwitchASCII( | 285 command_line->AppendSwitchASCII( |
| 279 ::switches::kAppsGalleryURL, | 286 ::switches::kAppsGalleryURL, |
| 280 webstore_url.Resolve("/chromeos/app_mode/webstore").spec()); | 287 webstore_url.Resolve("/chromeos/app_mode/webstore").spec()); |
| 281 command_line->AppendSwitchASCII( | 288 command_line->AppendSwitchASCII( |
| 282 ::switches::kAppsGalleryDownloadURL, | 289 ::switches::kAppsGalleryDownloadURL, |
| 283 webstore_url.Resolve( | 290 webstore_url.Resolve( |
| 284 "/chromeos/app_mode/webstore/downloads/%s.crx").spec()); | 291 "/chromeos/app_mode/webstore/downloads/%s.crx").spec()); |
| 285 } | 292 } |
| 286 | 293 |
| 294 GURL GetTestWebstoreUrl() { |
| 295 const GURL& server_url = embedded_test_server()->base_url(); |
| 296 std::string webstore_host("webstore"); |
| 297 GURL::Replacements replace_webstore_host; |
| 298 replace_webstore_host.SetHostStr(webstore_host); |
| 299 return server_url.ReplaceComponents(replace_webstore_host); |
| 300 } |
| 301 |
| 287 void ReloadKioskApps() { | 302 void ReloadKioskApps() { |
| 288 KioskAppManager::Get()->AddApp(kTestKioskApp); | 303 KioskAppManager::Get()->AddApp(test_app_id_); |
| 289 } | 304 } |
| 290 | 305 |
| 291 void ReloadAutolaunchKioskApps() { | 306 void ReloadAutolaunchKioskApps() { |
| 292 KioskAppManager::Get()->AddApp(kTestKioskApp); | 307 KioskAppManager::Get()->AddApp(test_app_id_); |
| 293 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); | 308 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); |
| 294 } | 309 } |
| 295 | 310 |
| 296 void PrepareAppLaunch() { | 311 void PrepareAppLaunch() { |
| 297 EnableConsumerKioskMode(); | 312 EnableConsumerKioskMode(); |
| 298 | 313 |
| 299 // Start UI, find menu entry for this app and launch it. | 314 // Start UI, find menu entry for this app and launch it. |
| 300 content::WindowedNotificationObserver login_signal( | 315 content::WindowedNotificationObserver login_signal( |
| 301 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 316 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 302 content::NotificationService::AllSources()); | 317 content::NotificationService::AllSources()); |
| 303 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 318 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 316 } | 331 } |
| 317 | 332 |
| 318 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { | 333 void StartAppLaunchFromLoginScreen(const base::Closure& network_setup_cb) { |
| 319 PrepareAppLaunch(); | 334 PrepareAppLaunch(); |
| 320 | 335 |
| 321 if (!network_setup_cb.is_null()) | 336 if (!network_setup_cb.is_null()) |
| 322 network_setup_cb.Run(); | 337 network_setup_cb.Run(); |
| 323 | 338 |
| 324 GetLoginUI()->CallJavascriptFunction( | 339 GetLoginUI()->CallJavascriptFunction( |
| 325 "login.AppsMenuButton.runAppForTesting", | 340 "login.AppsMenuButton.runAppForTesting", |
| 326 base::StringValue(kTestKioskApp)); | 341 base::StringValue(test_app_id_)); |
| 342 } |
| 343 |
| 344 const extensions::Extension* GetInstalledApp() { |
| 345 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); |
| 346 return extensions::ExtensionSystem::Get(app_profile)-> |
| 347 extension_service()->GetInstalledExtension(test_app_id_); |
| 348 } |
| 349 |
| 350 const Version& GetInstalledAppVersion() { |
| 351 return *GetInstalledApp()->version(); |
| 327 } | 352 } |
| 328 | 353 |
| 329 void WaitForAppLaunchSuccess() { | 354 void WaitForAppLaunchSuccess() { |
| 330 SimulateNetworkOnline(); | |
| 331 | |
| 332 ExtensionTestMessageListener | 355 ExtensionTestMessageListener |
| 333 launch_data_check_listener("launchData.isKioskSession = true", false); | 356 launch_data_check_listener("launchData.isKioskSession = true", false); |
| 334 | 357 |
| 335 // Wait for the Kiosk App to launch. | 358 // Wait for the Kiosk App to launch. |
| 336 content::WindowedNotificationObserver( | 359 content::WindowedNotificationObserver( |
| 337 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, | 360 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, |
| 338 content::NotificationService::AllSources()).Wait(); | 361 content::NotificationService::AllSources()).Wait(); |
| 339 | 362 |
| 340 // Default profile switches to app profile after app is launched. | 363 // Default profile switches to app profile after app is launched. |
| 341 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); | 364 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); |
| 342 ASSERT_TRUE(app_profile); | 365 ASSERT_TRUE(app_profile); |
| 343 | 366 |
| 344 // Check installer status. | 367 // Check installer status. |
| 345 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, | 368 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, |
| 346 chromeos::KioskAppLaunchError::Get()); | 369 chromeos::KioskAppLaunchError::Get()); |
| 347 | 370 |
| 348 // Check if the kiosk webapp is really installed for the default profile. | 371 // Check if the kiosk webapp is really installed for the default profile. |
| 349 const extensions::Extension* app = | 372 const extensions::Extension* app = |
| 350 extensions::ExtensionSystem::Get(app_profile)-> | 373 extensions::ExtensionSystem::Get(app_profile)-> |
| 351 extension_service()->GetInstalledExtension(kTestKioskApp); | 374 extension_service()->GetInstalledExtension(test_app_id_); |
| 352 EXPECT_TRUE(app); | 375 EXPECT_TRUE(app); |
| 353 | 376 |
| 354 // App should appear with its window. | 377 // App should appear with its window. |
| 355 apps::ShellWindowRegistry* shell_window_registry = | 378 apps::ShellWindowRegistry* shell_window_registry = |
| 356 apps::ShellWindowRegistry::Get(app_profile); | 379 apps::ShellWindowRegistry::Get(app_profile); |
| 357 apps::ShellWindow* window = | 380 apps::ShellWindow* window = |
| 358 ShellWindowObserver(shell_window_registry, kTestKioskApp).Wait(); | 381 ShellWindowObserver(shell_window_registry, test_app_id_).Wait(); |
| 359 EXPECT_TRUE(window); | 382 EXPECT_TRUE(window); |
| 360 | 383 |
| 361 // Login screen should be gone or fading out. | 384 // Login screen should be gone or fading out. |
| 362 chromeos::LoginDisplayHost* login_display_host = | 385 chromeos::LoginDisplayHost* login_display_host = |
| 363 chromeos::LoginDisplayHostImpl::default_host(); | 386 chromeos::LoginDisplayHostImpl::default_host(); |
| 364 EXPECT_TRUE( | 387 EXPECT_TRUE( |
| 365 login_display_host == NULL || | 388 login_display_host == NULL || |
| 366 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() == | 389 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() == |
| 367 0.0f); | 390 0.0f); |
| 368 | 391 |
| 369 // Wait until the app terminates if it is still running. | 392 // Wait until the app terminates if it is still running. |
| 370 if (!shell_window_registry->GetShellWindowsForApp(kTestKioskApp).empty()) | 393 if (!shell_window_registry->GetShellWindowsForApp(test_app_id_).empty()) |
| 371 content::RunMessageLoop(); | 394 content::RunMessageLoop(); |
| 372 | 395 |
| 373 // Check that the app had been informed that it is running in a kiosk | 396 // Check that the app had been informed that it is running in a kiosk |
| 374 // session. | 397 // session. |
| 375 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); | 398 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); |
| 376 } | 399 } |
| 377 | 400 |
| 378 void WaitForAppLaunchNetworkTimeout() { | 401 void WaitForAppLaunchNetworkTimeout() { |
| 379 if (GetAppLaunchController()->network_wait_timedout()) | 402 if (GetAppLaunchController()->network_wait_timedout()) |
| 380 return; | 403 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( | 436 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
| 414 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, | 437 base::Bind(&ConsumerKioskAutoLaunchStatusCheck, |
| 415 &status, | 438 &status, |
| 416 runner->QuitClosure())); | 439 runner->QuitClosure())); |
| 417 runner->Run(); | 440 runner->Run(); |
| 418 CHECK_NE(status, | 441 CHECK_NE(status, |
| 419 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1)); | 442 static_cast<KioskAppManager::ConsumerKioskAutoLaunchStatus>(-1)); |
| 420 return status; | 443 return status; |
| 421 } | 444 } |
| 422 | 445 |
| 446 // Copies the app profile from |relative_app_profile_dir| from test directory |
| 447 // to the app profile directory (assuming "user") under testing profile. This |
| 448 // is for that needs to have a kiosk app already installed from a previous |
| 449 // run. Note this must be called before app profile is loaded. |
| 450 void SetupAppProfile(const std::string& relative_app_profile_dir) { |
| 451 base::FilePath app_profile_dir; |
| 452 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &app_profile_dir)); |
| 453 app_profile_dir = app_profile_dir.AppendASCII("user"); |
| 454 ASSERT_TRUE(base::CreateDirectory(app_profile_dir)); |
| 455 |
| 456 base::FilePath test_data_dir; |
| 457 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
| 458 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir); |
| 459 ASSERT_TRUE(base::CopyFile(test_data_dir.AppendASCII("Preferences"), |
| 460 app_profile_dir.AppendASCII("Preferences"))); |
| 461 ASSERT_TRUE( |
| 462 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"), |
| 463 app_profile_dir, |
| 464 true)); |
| 465 } |
| 466 |
| 423 AppLaunchController* GetAppLaunchController() { | 467 AppLaunchController* GetAppLaunchController() { |
| 424 return chromeos::LoginDisplayHostImpl::default_host() | 468 return chromeos::LoginDisplayHostImpl::default_host() |
| 425 ->GetAppLaunchController(); | 469 ->GetAppLaunchController(); |
| 426 } | 470 } |
| 427 | 471 |
| 472 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } |
| 473 |
| 474 void set_test_app_id(const std::string& test_app_id) { |
| 475 test_app_id_ = test_app_id; |
| 476 } |
| 477 const std::string& test_app_id() const { return test_app_id_; } |
| 478 |
| 479 private: |
| 480 std::string test_app_id_; |
| 428 scoped_ptr<MockUserManager> mock_user_manager_; | 481 scoped_ptr<MockUserManager> mock_user_manager_; |
| 482 |
| 483 DISALLOW_COPY_AND_ASSIGN(KioskTest); |
| 429 }; | 484 }; |
| 430 | 485 |
| 431 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { | 486 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { |
| 432 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); | 487 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
| 433 WaitForAppLaunchSuccess(); | 488 WaitForAppLaunchSuccess(); |
| 434 } | 489 } |
| 435 | 490 |
| 436 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { | 491 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { |
| 437 // Mock network could be configured with owner's password. | 492 // Mock network could be configured with owner's password. |
| 438 ScopedCanConfigureNetwork can_configure_network(true, true); | 493 ScopedCanConfigureNetwork can_configure_network(true, true); |
| 439 | 494 |
| 440 // Start app launch and wait for network connectivity timeout. | 495 // Start app launch and wait for network connectivity timeout. |
| 441 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 496 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 442 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 497 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 443 splash_waiter.Wait(); | 498 splash_waiter.Wait(); |
| 444 WaitForAppLaunchNetworkTimeout(); | 499 WaitForAppLaunchNetworkTimeout(); |
| 445 | 500 |
| 446 // Configure network link should be visible. | 501 // Configure network link should be visible. |
| 447 JsExpect("$('splash-config-network').hidden == false"); | 502 JsExpect("$('splash-config-network').hidden == false"); |
| 448 | 503 |
| 449 // Set up fake user manager with an owner for the test. | 504 // Set up fake user manager with an owner for the test. |
| 450 mock_user_manager_->SetActiveUser(kTestOwnerEmail); | 505 mock_user_manager()->SetActiveUser(kTestOwnerEmail); |
| 451 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); | 506 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager()); |
| 452 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()) | 507 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()) |
| 453 ->GetOobeUI()->ShowOobeUI(false); | 508 ->GetOobeUI()->ShowOobeUI(false); |
| 454 | 509 |
| 455 // Configure network should bring up lock screen for owner. | 510 // Configure network should bring up lock screen for owner. |
| 456 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); | 511 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); |
| 457 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController()) | 512 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController()) |
| 458 ->OnConfigureNetwork(); | 513 ->OnConfigureNetwork(); |
| 459 lock_screen_waiter.Wait(); | 514 lock_screen_waiter.Wait(); |
| 460 | 515 |
| 461 // A network error screen should be shown after authenticating. | 516 // A network error screen should be shown after authenticating. |
| 462 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); | 517 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); |
| 463 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController()) | 518 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController()) |
| 464 ->OnOwnerSigninSuccess(); | 519 ->OnOwnerSigninSuccess(); |
| 465 error_screen_waiter.Wait(); | 520 error_screen_waiter.Wait(); |
| 466 | 521 |
| 467 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 522 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 468 | 523 |
| 524 SimulateNetworkOnline(); |
| 469 WaitForAppLaunchSuccess(); | 525 WaitForAppLaunchSuccess(); |
| 470 } | 526 } |
| 471 | 527 |
| 472 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { | 528 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { |
| 473 // Mock network could not be configured. | 529 // Mock network could not be configured. |
| 474 ScopedCanConfigureNetwork can_configure_network(false, true); | 530 ScopedCanConfigureNetwork can_configure_network(false, true); |
| 475 | 531 |
| 476 // Start app launch and wait for network connectivity timeout. | 532 // Start app launch and wait for network connectivity timeout. |
| 477 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 533 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 478 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 534 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 479 splash_waiter.Wait(); | 535 splash_waiter.Wait(); |
| 480 WaitForAppLaunchNetworkTimeout(); | 536 WaitForAppLaunchNetworkTimeout(); |
| 481 | 537 |
| 482 // Configure network link should not be visible. | 538 // Configure network link should not be visible. |
| 483 JsExpect("$('splash-config-network').hidden == true"); | 539 JsExpect("$('splash-config-network').hidden == true"); |
| 484 | 540 |
| 485 // Network becomes online and app launch is resumed. | 541 // Network becomes online and app launch is resumed. |
| 542 SimulateNetworkOnline(); |
| 486 WaitForAppLaunchSuccess(); | 543 WaitForAppLaunchSuccess(); |
| 487 } | 544 } |
| 488 | 545 |
| 489 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { | 546 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { |
| 490 // Mock network could be configured without the owner password. | 547 // Mock network could be configured without the owner password. |
| 491 ScopedCanConfigureNetwork can_configure_network(true, false); | 548 ScopedCanConfigureNetwork can_configure_network(true, false); |
| 492 | 549 |
| 493 // Start app launch with network portal state. | 550 // Start app launch with network portal state. |
| 494 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); | 551 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); |
| 495 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) | 552 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) |
| 496 .WaitNoAssertCurrentScreen(); | 553 .WaitNoAssertCurrentScreen(); |
| 497 WaitForAppLaunchNetworkTimeout(); | 554 WaitForAppLaunchNetworkTimeout(); |
| 498 | 555 |
| 499 // Network error should show up automatically since this test does not | 556 // Network error should show up automatically since this test does not |
| 500 // require owner auth to configure network. | 557 // require owner auth to configure network. |
| 501 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); | 558 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 502 | 559 |
| 503 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 560 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 561 SimulateNetworkOnline(); |
| 504 WaitForAppLaunchSuccess(); | 562 WaitForAppLaunchSuccess(); |
| 505 } | 563 } |
| 506 | 564 |
| 507 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { | 565 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { |
| 508 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 566 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 509 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 567 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 510 splash_waiter.Wait(); | 568 splash_waiter.Wait(); |
| 511 | 569 |
| 512 CrosSettings::Get()->SetBoolean( | 570 CrosSettings::Get()->SetBoolean( |
| 513 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); | 571 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 539 login_contents, | 597 login_contents, |
| 540 "(function() {" | 598 "(function() {" |
| 541 "var e = new Event('click');" | 599 "var e = new Event('click');" |
| 542 "$('show-apps-button').confirmDiagnosticMode_." | 600 "$('show-apps-button').confirmDiagnosticMode_." |
| 543 "okButton_.dispatchEvent(e);" | 601 "okButton_.dispatchEvent(e);" |
| 544 "})();")); | 602 "})();")); |
| 545 | 603 |
| 546 WaitForAppLaunchSuccess(); | 604 WaitForAppLaunchSuccess(); |
| 547 } | 605 } |
| 548 | 606 |
| 607 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoNetwork) { |
| 608 set_test_app_id(kTestOfflineEnabledKioskApp); |
| 609 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
| 610 |
| 611 PrepareAppLaunch(); |
| 612 SimulateNetworkOffline(); |
| 613 |
| 614 GetLoginUI()->CallJavascriptFunction( |
| 615 "login.AppsMenuButton.runAppForTesting", |
| 616 base::StringValue(test_app_id())); |
| 617 WaitForAppLaunchSuccess(); |
| 618 } |
| 619 |
| 620 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoUpdate) { |
| 621 set_test_app_id(kTestOfflineEnabledKioskApp); |
| 622 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
| 623 |
| 624 GURL webstore_url = GetTestWebstoreUrl(); |
| 625 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 626 ::switches::kAppsGalleryUpdateURL, |
| 627 webstore_url.Resolve( |
| 628 "/chromeos/app_mode/webstore/update_check/no_update.xml").spec()); |
| 629 |
| 630 PrepareAppLaunch(); |
| 631 SimulateNetworkOnline(); |
| 632 |
| 633 GetLoginUI()->CallJavascriptFunction( |
| 634 "login.AppsMenuButton.runAppForTesting", |
| 635 base::StringValue(test_app_id())); |
| 636 WaitForAppLaunchSuccess(); |
| 637 |
| 638 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); |
| 639 } |
| 640 |
| 641 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppHasUpdate) { |
| 642 set_test_app_id(kTestOfflineEnabledKioskApp); |
| 643 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
| 644 |
| 645 GURL webstore_url = GetTestWebstoreUrl(); |
| 646 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 647 ::switches::kAppsGalleryUpdateURL, |
| 648 webstore_url.Resolve( |
| 649 "/chromeos/app_mode/webstore/update_check/has_update.xml").spec()); |
| 650 |
| 651 PrepareAppLaunch(); |
| 652 SimulateNetworkOnline(); |
| 653 |
| 654 GetLoginUI()->CallJavascriptFunction( |
| 655 "login.AppsMenuButton.runAppForTesting", |
| 656 base::StringValue(test_app_id())); |
| 657 WaitForAppLaunchSuccess(); |
| 658 |
| 659 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); |
| 660 } |
| 661 |
| 549 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { | 662 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { |
| 550 EnableConsumerKioskMode(); | 663 EnableConsumerKioskMode(); |
| 551 // Start UI, find menu entry for this app and launch it. | 664 // Start UI, find menu entry for this app and launch it. |
| 552 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 665 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 553 chromeos::WizardController* wizard_controller = | 666 chromeos::WizardController* wizard_controller = |
| 554 chromeos::WizardController::default_controller(); | 667 chromeos::WizardController::default_controller(); |
| 555 CHECK(wizard_controller); | 668 CHECK(wizard_controller); |
| 556 ReloadAutolaunchKioskApps(); | 669 ReloadAutolaunchKioskApps(); |
| 557 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 670 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| 558 | 671 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 content::WindowedNotificationObserver( | 1083 content::WindowedNotificationObserver( |
| 971 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1084 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 972 content::NotificationService::AllSources()).Wait(); | 1085 content::NotificationService::AllSources()).Wait(); |
| 973 | 1086 |
| 974 // Wait for the wallpaper to load. | 1087 // Wait for the wallpaper to load. |
| 975 WaitForWallpaper(); | 1088 WaitForWallpaper(); |
| 976 EXPECT_TRUE(wallpaper_loaded()); | 1089 EXPECT_TRUE(wallpaper_loaded()); |
| 977 } | 1090 } |
| 978 | 1091 |
| 979 } // namespace chromeos | 1092 } // namespace chromeos |
| OLD | NEW |