Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "apps/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 offlien enable test app. Webstore data json is in | |
|
Tim Song
2014/02/12 03:25:29
fix typo here and in all other places below to "of
xiyuan
2014/02/12 18:10:42
Done.
| |
| 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 kTestOfflienEnabledKioskApp[] = "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 30 matching lines...) Expand all Loading... | |
| 411 new content::MessageLoopRunner; | 434 new content::MessageLoopRunner; |
| 412 KioskAppManager::Get()->GetConsumerKioskModeStatus( | 435 KioskAppManager::Get()->GetConsumerKioskModeStatus( |
| 413 base::Bind(&ConsumerKioskModeStatusCheck, | 436 base::Bind(&ConsumerKioskModeStatusCheck, |
| 414 &status, | 437 &status, |
| 415 runner->QuitClosure())); | 438 runner->QuitClosure())); |
| 416 runner->Run(); | 439 runner->Run(); |
| 417 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); | 440 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); |
| 418 return status; | 441 return status; |
| 419 } | 442 } |
| 420 | 443 |
| 444 // Copies the app profile from |relative_app_profile_dir| from test directory | |
| 445 // to the app profile directory under testing profile. | |
| 446 // Note this must be called before app profile is loaded. | |
| 447 void SetupAppProfile(const std::string& relative_app_profile_dir) { | |
|
Tim Song
2014/02/12 03:25:29
Please also comment that this is used for tests wh
xiyuan
2014/02/12 18:10:42
Done.
| |
| 448 base::FilePath app_profile_dir; | |
| 449 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &app_profile_dir)); | |
| 450 app_profile_dir = app_profile_dir.AppendASCII("user"); | |
| 451 ASSERT_TRUE(base::CreateDirectory(app_profile_dir)); | |
| 452 | |
| 453 base::FilePath test_data_dir; | |
| 454 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | |
| 455 test_data_dir = test_data_dir.AppendASCII(relative_app_profile_dir); | |
| 456 ASSERT_TRUE(base::CopyFile(test_data_dir.AppendASCII("Preferences"), | |
| 457 app_profile_dir.AppendASCII("Preferences"))); | |
| 458 ASSERT_TRUE( | |
| 459 base::CopyDirectory(test_data_dir.AppendASCII("Extensions"), | |
| 460 app_profile_dir, | |
| 461 true)); | |
| 462 } | |
| 463 | |
| 421 AppLaunchController* GetAppLaunchController() { | 464 AppLaunchController* GetAppLaunchController() { |
| 422 return chromeos::LoginDisplayHostImpl::default_host() | 465 return chromeos::LoginDisplayHostImpl::default_host() |
| 423 ->GetAppLaunchController(); | 466 ->GetAppLaunchController(); |
| 424 } | 467 } |
| 425 | 468 |
| 469 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } | |
| 470 | |
| 471 void set_test_app_id(const std::string& test_app_id) { | |
| 472 test_app_id_ = test_app_id; | |
| 473 } | |
| 474 const std::string& test_app_id() const { return test_app_id_; } | |
| 475 | |
| 476 private: | |
| 477 std::string test_app_id_; | |
| 426 scoped_ptr<MockUserManager> mock_user_manager_; | 478 scoped_ptr<MockUserManager> mock_user_manager_; |
| 479 | |
| 480 DISALLOW_COPY_AND_ASSIGN(KioskTest); | |
| 427 }; | 481 }; |
| 428 | 482 |
| 429 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { | 483 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { |
| 430 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); | 484 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
| 431 WaitForAppLaunchSuccess(); | 485 WaitForAppLaunchSuccess(); |
| 432 } | 486 } |
| 433 | 487 |
| 434 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { | 488 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { |
| 435 // Mock network could be configured with owner's password. | 489 // Mock network could be configured with owner's password. |
| 436 ScopedCanConfigureNetwork can_configure_network(true, true); | 490 ScopedCanConfigureNetwork can_configure_network(true, true); |
| 437 | 491 |
| 438 // Start app launch and wait for network connectivity timeout. | 492 // Start app launch and wait for network connectivity timeout. |
| 439 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 493 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 440 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 494 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 441 splash_waiter.Wait(); | 495 splash_waiter.Wait(); |
| 442 WaitForAppLaunchNetworkTimeout(); | 496 WaitForAppLaunchNetworkTimeout(); |
| 443 | 497 |
| 444 // Configure network link should be visible. | 498 // Configure network link should be visible. |
| 445 JsExpect("$('splash-config-network').hidden == false"); | 499 JsExpect("$('splash-config-network').hidden == false"); |
| 446 | 500 |
| 447 // Set up fake user manager with an owner for the test. | 501 // Set up fake user manager with an owner for the test. |
| 448 mock_user_manager_->SetActiveUser(kTestOwnerEmail); | 502 mock_user_manager()->SetActiveUser(kTestOwnerEmail); |
| 449 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager_.get()); | 503 AppLaunchSigninScreen::SetUserManagerForTesting(mock_user_manager()); |
| 450 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()) | 504 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()) |
| 451 ->GetOobeUI()->ShowOobeUI(false); | 505 ->GetOobeUI()->ShowOobeUI(false); |
| 452 | 506 |
| 453 // Configure network should bring up lock screen for owner. | 507 // Configure network should bring up lock screen for owner. |
| 454 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); | 508 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); |
| 455 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController()) | 509 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController()) |
| 456 ->OnConfigureNetwork(); | 510 ->OnConfigureNetwork(); |
| 457 lock_screen_waiter.Wait(); | 511 lock_screen_waiter.Wait(); |
| 458 | 512 |
| 459 // A network error screen should be shown after authenticating. | 513 // A network error screen should be shown after authenticating. |
| 460 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); | 514 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); |
| 461 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController()) | 515 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController()) |
| 462 ->OnOwnerSigninSuccess(); | 516 ->OnOwnerSigninSuccess(); |
| 463 error_screen_waiter.Wait(); | 517 error_screen_waiter.Wait(); |
| 464 | 518 |
| 465 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 519 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 466 | 520 |
| 521 SimulateNetworkOnline(); | |
| 467 WaitForAppLaunchSuccess(); | 522 WaitForAppLaunchSuccess(); |
| 468 } | 523 } |
| 469 | 524 |
| 470 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { | 525 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { |
| 471 // Mock network could not be configured. | 526 // Mock network could not be configured. |
| 472 ScopedCanConfigureNetwork can_configure_network(false, true); | 527 ScopedCanConfigureNetwork can_configure_network(false, true); |
| 473 | 528 |
| 474 // Start app launch and wait for network connectivity timeout. | 529 // Start app launch and wait for network connectivity timeout. |
| 475 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 530 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 476 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 531 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 477 splash_waiter.Wait(); | 532 splash_waiter.Wait(); |
| 478 WaitForAppLaunchNetworkTimeout(); | 533 WaitForAppLaunchNetworkTimeout(); |
| 479 | 534 |
| 480 // Configure network link should not be visible. | 535 // Configure network link should not be visible. |
| 481 JsExpect("$('splash-config-network').hidden == true"); | 536 JsExpect("$('splash-config-network').hidden == true"); |
| 482 | 537 |
| 483 // Network becomes online and app launch is resumed. | 538 // Network becomes online and app launch is resumed. |
| 539 SimulateNetworkOnline(); | |
| 484 WaitForAppLaunchSuccess(); | 540 WaitForAppLaunchSuccess(); |
| 485 } | 541 } |
| 486 | 542 |
| 487 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { | 543 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) { |
| 488 // Mock network could be configured without the owner password. | 544 // Mock network could be configured without the owner password. |
| 489 ScopedCanConfigureNetwork can_configure_network(true, false); | 545 ScopedCanConfigureNetwork can_configure_network(true, false); |
| 490 | 546 |
| 491 // Start app launch with network portal state. | 547 // Start app launch with network portal state. |
| 492 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); | 548 StartAppLaunchFromLoginScreen(SimulateNetworkPortalClosure()); |
| 493 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) | 549 OobeScreenWaiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH) |
| 494 .WaitNoAssertCurrentScreen(); | 550 .WaitNoAssertCurrentScreen(); |
| 495 WaitForAppLaunchNetworkTimeout(); | 551 WaitForAppLaunchNetworkTimeout(); |
| 496 | 552 |
| 497 // Network error should show up automatically since this test does not | 553 // Network error should show up automatically since this test does not |
| 498 // require owner auth to configure network. | 554 // require owner auth to configure network. |
| 499 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); | 555 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 500 | 556 |
| 501 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); | 557 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); |
| 558 SimulateNetworkOnline(); | |
| 502 WaitForAppLaunchSuccess(); | 559 WaitForAppLaunchSuccess(); |
| 503 } | 560 } |
| 504 | 561 |
| 505 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { | 562 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppUserCancel) { |
| 506 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); | 563 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); |
| 507 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); | 564 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); |
| 508 splash_waiter.Wait(); | 565 splash_waiter.Wait(); |
| 509 | 566 |
| 510 CrosSettings::Get()->SetBoolean( | 567 CrosSettings::Get()->SetBoolean( |
| 511 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); | 568 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 537 login_contents, | 594 login_contents, |
| 538 "(function() {" | 595 "(function() {" |
| 539 "var e = new Event('click');" | 596 "var e = new Event('click');" |
| 540 "$('show-apps-button').confirmDiagnosticMode_." | 597 "$('show-apps-button').confirmDiagnosticMode_." |
| 541 "okButton_.dispatchEvent(e);" | 598 "okButton_.dispatchEvent(e);" |
| 542 "})();")); | 599 "})();")); |
| 543 | 600 |
| 544 WaitForAppLaunchSuccess(); | 601 WaitForAppLaunchSuccess(); |
| 545 } | 602 } |
| 546 | 603 |
| 604 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoNetwork) { | |
| 605 set_test_app_id(kTestOfflienEnabledKioskApp); | |
| 606 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | |
| 607 | |
| 608 PrepareAppLaunch(); | |
| 609 SimulateNetworkOffline(); | |
| 610 | |
| 611 GetLoginUI()->CallJavascriptFunction( | |
| 612 "login.AppsMenuButton.runAppForTesting", | |
| 613 base::StringValue(test_app_id())); | |
| 614 WaitForAppLaunchSuccess(); | |
| 615 } | |
| 616 | |
| 617 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppNoUpdate) { | |
| 618 set_test_app_id(kTestOfflienEnabledKioskApp); | |
| 619 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | |
| 620 | |
| 621 GURL webstore_url = GetTestWebstoreUrl(); | |
| 622 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 623 ::switches::kAppsGalleryUpdateURL, | |
| 624 webstore_url.Resolve( | |
| 625 "/chromeos/app_mode/webstore/update_check/no_update.xml").spec()); | |
| 626 | |
| 627 PrepareAppLaunch(); | |
| 628 SimulateNetworkOnline(); | |
| 629 | |
| 630 GetLoginUI()->CallJavascriptFunction( | |
| 631 "login.AppsMenuButton.runAppForTesting", | |
| 632 base::StringValue(test_app_id())); | |
| 633 WaitForAppLaunchSuccess(); | |
| 634 | |
| 635 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); | |
| 636 } | |
| 637 | |
| 638 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchOfflineEnabledAppHasUpdate) { | |
| 639 set_test_app_id(kTestOfflienEnabledKioskApp); | |
| 640 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | |
| 641 | |
| 642 GURL webstore_url = GetTestWebstoreUrl(); | |
| 643 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 644 ::switches::kAppsGalleryUpdateURL, | |
| 645 webstore_url.Resolve( | |
| 646 "/chromeos/app_mode/webstore/update_check/has_update.xml").spec()); | |
| 647 | |
| 648 PrepareAppLaunch(); | |
| 649 SimulateNetworkOnline(); | |
| 650 | |
| 651 GetLoginUI()->CallJavascriptFunction( | |
| 652 "login.AppsMenuButton.runAppForTesting", | |
| 653 base::StringValue(test_app_id())); | |
| 654 WaitForAppLaunchSuccess(); | |
| 655 | |
| 656 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); | |
| 657 } | |
| 658 | |
| 547 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { | 659 IN_PROC_BROWSER_TEST_F(KioskTest, AutolaunchWarningCancel) { |
| 548 EnableConsumerKioskMode(); | 660 EnableConsumerKioskMode(); |
| 549 // Start UI, find menu entry for this app and launch it. | 661 // Start UI, find menu entry for this app and launch it. |
| 550 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 662 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| 551 chromeos::WizardController* wizard_controller = | 663 chromeos::WizardController* wizard_controller = |
| 552 chromeos::WizardController::default_controller(); | 664 chromeos::WizardController::default_controller(); |
| 553 CHECK(wizard_controller); | 665 CHECK(wizard_controller); |
| 554 ReloadAutolaunchKioskApps(); | 666 ReloadAutolaunchKioskApps(); |
| 555 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 667 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| 556 | 668 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 content::WindowedNotificationObserver( | 1080 content::WindowedNotificationObserver( |
| 969 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1081 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
| 970 content::NotificationService::AllSources()).Wait(); | 1082 content::NotificationService::AllSources()).Wait(); |
| 971 | 1083 |
| 972 // Wait for the wallpaper to load. | 1084 // Wait for the wallpaper to load. |
| 973 WaitForWallpaper(); | 1085 WaitForWallpaper(); |
| 974 EXPECT_TRUE(wallpaper_loaded()); | 1086 EXPECT_TRUE(wallpaper_loaded()); |
| 975 } | 1087 } |
| 976 | 1088 |
| 977 } // namespace chromeos | 1089 } // namespace chromeos |
| OLD | NEW |