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 <map> | 5 #include <map> |
| 6 #include <set> |
6 #include <string> | 7 #include <string> |
| 8 #include <vector> |
7 | 9 |
8 #include "apps/app_window_registry.h" | 10 #include "apps/app_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 11 #include "apps/ui/native_app_window.h" |
10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
11 #include "ash/system/chromeos/session/logout_confirmation_controller.h" | 13 #include "ash/system/chromeos/session/logout_confirmation_controller.h" |
12 #include "ash/system/chromeos/session/logout_confirmation_dialog.h" | 14 #include "ash/system/chromeos/session/logout_confirmation_dialog.h" |
13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
14 #include "base/bind.h" | 16 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
16 #include "base/callback.h" | 18 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
27 #include "base/message_loop/message_loop_proxy.h" | 29 #include "base/message_loop/message_loop_proxy.h" |
28 #include "base/path_service.h" | 30 #include "base/path_service.h" |
29 #include "base/prefs/pref_change_registrar.h" | 31 #include "base/prefs/pref_change_registrar.h" |
30 #include "base/prefs/pref_service.h" | 32 #include "base/prefs/pref_service.h" |
31 #include "base/run_loop.h" | 33 #include "base/run_loop.h" |
32 #include "base/sequenced_task_runner.h" | 34 #include "base/sequenced_task_runner.h" |
33 #include "base/strings/string_number_conversions.h" | 35 #include "base/strings/string_number_conversions.h" |
34 #include "base/strings/string_util.h" | 36 #include "base/strings/string_util.h" |
35 #include "base/strings/stringprintf.h" | 37 #include "base/strings/stringprintf.h" |
36 #include "base/strings/utf_string_conversions.h" | 38 #include "base/strings/utf_string_conversions.h" |
| 39 #include "base/threading/sequenced_worker_pool.h" |
37 #include "base/values.h" | 40 #include "base/values.h" |
38 #include "chrome/browser/browser_process.h" | 41 #include "chrome/browser/browser_process.h" |
39 #include "chrome/browser/chrome_notification_types.h" | 42 #include "chrome/browser/chrome_notification_types.h" |
40 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" | 43 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" |
41 #include "chrome/browser/chromeos/extensions/external_cache.h" | 44 #include "chrome/browser/chromeos/extensions/external_cache.h" |
| 45 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
42 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 46 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
43 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" | 47 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" |
44 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 48 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
45 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 49 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
46 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 50 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
47 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" | 51 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" |
48 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" | 52 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" |
49 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_test_uti
l.h" | 53 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_test_uti
l.h" |
50 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 54 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
51 #include "chrome/browser/chromeos/login/users/user_manager.h" | 55 #include "chrome/browser/chromeos/login/users/user_manager.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 96 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
93 #include "components/policy/core/common/cloud/policy_builder.h" | 97 #include "components/policy/core/common/cloud/policy_builder.h" |
94 #include "components/policy/core/common/external_data_fetcher.h" | 98 #include "components/policy/core/common/external_data_fetcher.h" |
95 #include "components/policy/core/common/policy_map.h" | 99 #include "components/policy/core/common/policy_map.h" |
96 #include "components/policy/core/common/policy_namespace.h" | 100 #include "components/policy/core/common/policy_namespace.h" |
97 #include "components/policy/core/common/policy_service.h" | 101 #include "components/policy/core/common/policy_service.h" |
98 #include "components/policy/core/common/policy_switches.h" | 102 #include "components/policy/core/common/policy_switches.h" |
99 #include "components/signin/core/common/signin_pref_names.h" | 103 #include "components/signin/core/common/signin_pref_names.h" |
100 #include "components/user_manager/user.h" | 104 #include "components/user_manager/user.h" |
101 #include "components/user_manager/user_type.h" | 105 #include "components/user_manager/user_type.h" |
| 106 #include "content/public/browser/browser_thread.h" |
102 #include "content/public/browser/notification_details.h" | 107 #include "content/public/browser/notification_details.h" |
103 #include "content/public/browser/notification_service.h" | 108 #include "content/public/browser/notification_service.h" |
104 #include "content/public/browser/notification_source.h" | 109 #include "content/public/browser/notification_source.h" |
105 #include "content/public/browser/web_contents.h" | 110 #include "content/public/browser/web_contents.h" |
106 #include "content/public/browser/web_ui.h" | 111 #include "content/public/browser/web_ui.h" |
107 #include "content/public/test/browser_test_utils.h" | 112 #include "content/public/test/browser_test_utils.h" |
108 #include "content/public/test/test_utils.h" | 113 #include "content/public/test/test_utils.h" |
109 #include "crypto/rsa_private_key.h" | 114 #include "crypto/rsa_private_key.h" |
110 #include "extensions/browser/extension_system.h" | 115 #include "extensions/browser/extension_system.h" |
111 #include "extensions/browser/management_policy.h" | 116 #include "extensions/browser/management_policy.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const char kHostedAppCRXPath[] = "extensions/hosted_app.crx"; | 171 const char kHostedAppCRXPath[] = "extensions/hosted_app.crx"; |
167 const char kHostedAppVersion[] = "1.0.0.0"; | 172 const char kHostedAppVersion[] = "1.0.0.0"; |
168 const char kGoodExtensionID[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 173 const char kGoodExtensionID[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
169 const char kGoodExtensionCRXPath[] = "extensions/good.crx"; | 174 const char kGoodExtensionCRXPath[] = "extensions/good.crx"; |
170 const char kGoodExtensionVersion[] = "1.0"; | 175 const char kGoodExtensionVersion[] = "1.0"; |
171 const char kPackagedAppCRXPath[] = "extensions/platform_apps/app_window_2.crx"; | 176 const char kPackagedAppCRXPath[] = "extensions/platform_apps/app_window_2.crx"; |
172 | 177 |
173 const char kExternalData[] = "External data"; | 178 const char kExternalData[] = "External data"; |
174 const char kExternalDataURL[] = "http://localhost/external_data"; | 179 const char kExternalDataURL[] = "http://localhost/external_data"; |
175 | 180 |
| 181 const char* kSingleRecommendedLocale[] = { |
| 182 "el", |
| 183 }; |
| 184 const char* kRecommendedLocales1[] = { |
| 185 "pl", |
| 186 "et", |
| 187 "en-US", |
| 188 }; |
| 189 const char* kRecommendedLocales2[] = { |
| 190 "fr", |
| 191 "nl", |
| 192 }; |
176 const char kPublicSessionLocale[] = "de"; | 193 const char kPublicSessionLocale[] = "de"; |
177 const char kPublicSessionInputMethodIDTemplate[] = "_comp_ime_%sxkb:de:neo:ger"; | 194 const char kPublicSessionInputMethodIDTemplate[] = "_comp_ime_%sxkb:de:neo:ger"; |
178 | 195 |
| 196 // The sequence token used by GetKeyboardLayoutsForLocale() for its background |
| 197 // tasks. |
| 198 const char kSequenceToken[] = "chromeos_login_l10n_util"; |
| 199 |
179 // Helper that serves extension update manifests to Chrome. | 200 // Helper that serves extension update manifests to Chrome. |
180 class TestingUpdateManifestProvider { | 201 class TestingUpdateManifestProvider { |
181 public: | 202 public: |
182 // Update manifests will be served at |relative_update_url|. | 203 // Update manifests will be served at |relative_update_url|. |
183 explicit TestingUpdateManifestProvider( | 204 explicit TestingUpdateManifestProvider( |
184 const std::string& relative_update_url); | 205 const std::string& relative_update_url); |
185 ~TestingUpdateManifestProvider(); | 206 ~TestingUpdateManifestProvider(); |
186 | 207 |
187 // When an update manifest is requested for the given extension |id|, indicate | 208 // When an update manifest is requested for the given extension |id|, indicate |
188 // that |version| of the extension can be downloaded at |crx_url|. | 209 // that |version| of the extension can be downloaded at |crx_url|. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 net::URLRequestStatus::Status status) { | 370 net::URLRequestStatus::Status status) { |
350 task_runner->PostTask(FROM_HERE, callback); | 371 task_runner->PostTask(FROM_HERE, callback); |
351 return make_scoped_ptr(new net::FakeURLFetcher( | 372 return make_scoped_ptr(new net::FakeURLFetcher( |
352 url, delegate, response_data, response_code, status)); | 373 url, delegate, response_data, response_code, status)); |
353 } | 374 } |
354 | 375 |
355 bool IsSessionStarted() { | 376 bool IsSessionStarted() { |
356 return chromeos::UserManager::Get()->IsSessionStarted(); | 377 return chromeos::UserManager::Get()->IsSessionStarted(); |
357 } | 378 } |
358 | 379 |
| 380 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. This |
| 381 // method flushes that task runner and the current thread's message loop to |
| 382 // ensure that GetKeyboardLayoutsForLocale() is finished. |
| 383 void WaitForGetKeyboardLayoutsForLocaleToFinish() { |
| 384 base::SequencedWorkerPool* worker_pool = |
| 385 content::BrowserThread::GetBlockingPool(); |
| 386 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 387 worker_pool->GetSequencedTaskRunner( |
| 388 worker_pool->GetNamedSequenceToken(kSequenceToken)); |
| 389 base::RunLoop run_loop; |
| 390 background_task_runner->PostTaskAndReply(FROM_HERE, |
| 391 base::Bind(&base::DoNothing), |
| 392 run_loop.QuitClosure()); |
| 393 run_loop.Run(); |
| 394 base::RunLoop().RunUntilIdle(); |
| 395 } |
| 396 |
359 } // namespace | 397 } // namespace |
360 | 398 |
361 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, | 399 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, |
362 public chromeos::UserManager::Observer, | 400 public chromeos::UserManager::Observer, |
363 public chrome::BrowserListObserver, | 401 public chrome::BrowserListObserver, |
364 public apps::AppWindowRegistry::Observer { | 402 public apps::AppWindowRegistry::Observer { |
365 protected: | 403 protected: |
366 DeviceLocalAccountTest() | 404 DeviceLocalAccountTest() |
367 : user_id_1_(GenerateDeviceLocalAccountUserId( | 405 : user_id_1_(GenerateDeviceLocalAccountUserId( |
368 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), | 406 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
369 user_id_2_(GenerateDeviceLocalAccountUserId( | 407 user_id_2_(GenerateDeviceLocalAccountUserId( |
370 kAccountId2, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), | 408 kAccountId2, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
371 public_session_input_method_id_(base::StringPrintf( | 409 public_session_input_method_id_(base::StringPrintf( |
372 kPublicSessionInputMethodIDTemplate, | 410 kPublicSessionInputMethodIDTemplate, |
373 chromeos::extension_ime_util::kXkbExtensionId)) { | 411 chromeos::extension_ime_util::kXkbExtensionId)), |
| 412 contents_(NULL) { |
374 set_exit_when_last_browser_closes(false); | 413 set_exit_when_last_browser_closes(false); |
375 } | 414 } |
376 | 415 |
377 virtual ~DeviceLocalAccountTest() {} | 416 virtual ~DeviceLocalAccountTest() {} |
378 | 417 |
379 virtual void SetUp() OVERRIDE { | 418 virtual void SetUp() OVERRIDE { |
380 // Configure and start the test server. | 419 // Configure and start the test server. |
381 scoped_ptr<crypto::RSAPrivateKey> signing_key( | 420 scoped_ptr<crypto::RSAPrivateKey> signing_key( |
382 PolicyBuilder::CreateTestSigningKey()); | 421 PolicyBuilder::CreateTestSigningKey()); |
383 ASSERT_TRUE(test_server_.SetSigningKeyAndSignature( | 422 ASSERT_TRUE(test_server_.SetSigningKeyAndSignature( |
(...skipping 27 matching lines...) Expand all Loading... |
411 argv.erase(argv.begin() + argv.size() - command_line->GetArgs().size(), | 450 argv.erase(argv.begin() + argv.size() - command_line->GetArgs().size(), |
412 argv.end()); | 451 argv.end()); |
413 command_line->InitFromArgv(argv); | 452 command_line->InitFromArgv(argv); |
414 | 453 |
415 InstallOwnerKey(); | 454 InstallOwnerKey(); |
416 MarkAsEnterpriseOwned(); | 455 MarkAsEnterpriseOwned(); |
417 | 456 |
418 InitializePolicy(); | 457 InitializePolicy(); |
419 } | 458 } |
420 | 459 |
| 460 virtual void SetUpOnMainThread() OVERRIDE { |
| 461 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); |
| 462 |
| 463 content::WindowedNotificationObserver( |
| 464 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 465 content::NotificationService::AllSources()).Wait(); |
| 466 |
| 467 chromeos::LoginDisplayHostImpl* host = |
| 468 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
| 469 chromeos::LoginDisplayHostImpl::default_host()); |
| 470 ASSERT_TRUE(host); |
| 471 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
| 472 ASSERT_TRUE(web_ui_login_view); |
| 473 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); |
| 474 ASSERT_TRUE(web_ui); |
| 475 contents_ = web_ui->GetWebContents(); |
| 476 ASSERT_TRUE(contents_); |
| 477 |
| 478 // Wait for the login UI to be ready. |
| 479 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); |
| 480 ASSERT_TRUE(oobe_ui); |
| 481 base::RunLoop run_loop; |
| 482 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); |
| 483 if (!oobe_ui_ready) |
| 484 run_loop.Run(); |
| 485 |
| 486 // The network selection screen changes the application locale on load and |
| 487 // once again on blur. Wait for the screen to load and blur it so that any |
| 488 // locale changes caused by this screen happen now and do not affect any |
| 489 // subsequent parts of the test. |
| 490 bool done = false; |
| 491 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 492 contents_, |
| 493 "var languageSelect = document.getElementById('language-select');" |
| 494 "var blurAndReportSuccess = function() {" |
| 495 " languageSelect.blur();" |
| 496 " domAutomationController.send(true);" |
| 497 "};" |
| 498 "var screenLoading = document.getElementById('outer-container')" |
| 499 " .classList.contains('down');" |
| 500 "if (document.activeElement == languageSelect || !screenLoading)" |
| 501 " blurAndReportSuccess();" |
| 502 "else" |
| 503 " languageSelect.addEventListener('focus', blurAndReportSuccess);", |
| 504 &done)); |
| 505 |
| 506 // Skip to the login screen. |
| 507 chromeos::WizardController* wizard_controller = |
| 508 chromeos::WizardController::default_controller(); |
| 509 ASSERT_TRUE(wizard_controller); |
| 510 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| 511 } |
| 512 |
421 virtual void TearDownOnMainThread() OVERRIDE { | 513 virtual void TearDownOnMainThread() OVERRIDE { |
422 BrowserList::RemoveObserver(this); | 514 BrowserList::RemoveObserver(this); |
423 | 515 |
424 // This shuts down the login UI. | 516 // This shuts down the login UI. |
425 base::MessageLoop::current()->PostTask(FROM_HERE, | 517 base::MessageLoop::current()->PostTask(FROM_HERE, |
426 base::Bind(&chrome::AttemptExit)); | 518 base::Bind(&chrome::AttemptExit)); |
427 base::RunLoop().RunUntilIdle(); | 519 base::RunLoop().RunUntilIdle(); |
428 } | 520 } |
429 | 521 |
430 virtual void LocalStateChanged(chromeos::UserManager* user_manager) OVERRIDE { | 522 virtual void LocalStateChanged(chromeos::UserManager* user_manager) OVERRIDE { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 dm_protocol::kChromePublicAccountPolicyType, kAccountId1, | 565 dm_protocol::kChromePublicAccountPolicyType, kAccountId1, |
474 device_local_account_policy_.payload().SerializeAsString()); | 566 device_local_account_policy_.payload().SerializeAsString()); |
475 } | 567 } |
476 | 568 |
477 void UploadAndInstallDeviceLocalAccountPolicy() { | 569 void UploadAndInstallDeviceLocalAccountPolicy() { |
478 UploadDeviceLocalAccountPolicy(); | 570 UploadDeviceLocalAccountPolicy(); |
479 session_manager_client()->set_device_local_account_policy( | 571 session_manager_client()->set_device_local_account_policy( |
480 kAccountId1, device_local_account_policy_.GetBlob()); | 572 kAccountId1, device_local_account_policy_.GetBlob()); |
481 } | 573 } |
482 | 574 |
| 575 void SetRecommendedLocales(const char* recommended_locales[], |
| 576 size_t array_size) { |
| 577 em::StringListPolicyProto* session_locales_proto = |
| 578 device_local_account_policy_.payload().mutable_sessionlocales(); |
| 579 session_locales_proto->mutable_policy_options()->set_mode( |
| 580 em::PolicyOptions_PolicyMode_RECOMMENDED); |
| 581 session_locales_proto->mutable_value()->Clear(); |
| 582 for (size_t i = 0; i < array_size; ++i) { |
| 583 session_locales_proto->mutable_value()->add_entries( |
| 584 recommended_locales[i]); |
| 585 } |
| 586 } |
| 587 |
483 void AddPublicSessionToDevicePolicy(const std::string& username) { | 588 void AddPublicSessionToDevicePolicy(const std::string& username) { |
484 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 589 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
485 em::DeviceLocalAccountInfoProto* account = | 590 em::DeviceLocalAccountInfoProto* account = |
486 proto.mutable_device_local_accounts()->add_account(); | 591 proto.mutable_device_local_accounts()->add_account(); |
487 account->set_account_id(username); | 592 account->set_account_id(username); |
488 account->set_type( | 593 account->set_type( |
489 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 594 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
490 RefreshDevicePolicy(); | 595 RefreshDevicePolicy(); |
491 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, | 596 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
492 std::string(), proto.SerializeAsString()); | 597 std::string(), proto.SerializeAsString()); |
493 } | 598 } |
494 | 599 |
| 600 void EnableAutoLogin() { |
| 601 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
| 602 em::DeviceLocalAccountsProto* device_local_accounts = |
| 603 proto.mutable_device_local_accounts(); |
| 604 device_local_accounts->set_auto_login_id(kAccountId1); |
| 605 device_local_accounts->set_auto_login_delay(0); |
| 606 RefreshDevicePolicy(); |
| 607 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
| 608 std::string(), proto.SerializeAsString()); |
| 609 } |
| 610 |
495 void CheckPublicSessionPresent(const std::string& id) { | 611 void CheckPublicSessionPresent(const std::string& id) { |
496 const user_manager::User* user = chromeos::UserManager::Get()->FindUser(id); | 612 const user_manager::User* user = chromeos::UserManager::Get()->FindUser(id); |
497 ASSERT_TRUE(user); | 613 ASSERT_TRUE(user); |
498 EXPECT_EQ(id, user->email()); | 614 EXPECT_EQ(id, user->email()); |
499 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 615 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
500 } | 616 } |
501 | 617 |
502 base::FilePath GetExtensionCacheDirectoryForAccountID( | 618 base::FilePath GetExtensionCacheDirectoryForAccountID( |
503 const std::string& account_id) { | 619 const std::string& account_id) { |
504 base::FilePath extension_cache_root_dir; | 620 base::FilePath extension_cache_root_dir; |
(...skipping 25 matching lines...) Expand all Loading... |
530 expected_display_name).Wait(); | 646 expected_display_name).Wait(); |
531 } | 647 } |
532 | 648 |
533 void WaitForPolicy() { | 649 void WaitForPolicy() { |
534 // Wait for the display name becoming available as that indicates | 650 // Wait for the display name becoming available as that indicates |
535 // device-local account policy is fully loaded, which is a prerequisite for | 651 // device-local account policy is fully loaded, which is a prerequisite for |
536 // successful login. | 652 // successful login. |
537 WaitForDisplayName(user_id_1_, kDisplayName1); | 653 WaitForDisplayName(user_id_1_, kDisplayName1); |
538 } | 654 } |
539 | 655 |
540 void GetWebContents(content::WebContents** contents) { | |
541 chromeos::LoginDisplayHostImpl* host = | |
542 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | |
543 chromeos::LoginDisplayHostImpl::default_host()); | |
544 ASSERT_TRUE(host); | |
545 chromeos::WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | |
546 ASSERT_TRUE(web_ui_login_view); | |
547 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); | |
548 ASSERT_TRUE(web_ui); | |
549 *contents = web_ui->GetWebContents(); | |
550 ASSERT_TRUE(*contents); | |
551 } | |
552 | |
553 void WaitForLoginUI() { | |
554 // Wait for the login UI to be ready. | |
555 chromeos::LoginDisplayHostImpl* host = | |
556 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | |
557 chromeos::LoginDisplayHostImpl::default_host()); | |
558 ASSERT_TRUE(host); | |
559 chromeos::OobeUI* oobe_ui = host->GetOobeUI(); | |
560 ASSERT_TRUE(oobe_ui); | |
561 base::RunLoop run_loop; | |
562 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); | |
563 if (!oobe_ui_ready) | |
564 run_loop.Run(); | |
565 | |
566 // The network selection screen changes the application locale on load and | |
567 // once again on blur. Wait for the screen to load and blur it so that any | |
568 // locale changes caused by this screen happen now and do not affect any | |
569 // subsequent parts of the test. | |
570 content::WebContents* contents = NULL; | |
571 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); | |
572 bool done = false; | |
573 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
574 contents, | |
575 "var languageSelect = document.getElementById('language-select');" | |
576 "var blurAndReportSuccess = function() {" | |
577 " languageSelect.blur();" | |
578 " domAutomationController.send(true);" | |
579 "};" | |
580 "if (document.activeElement == languageSelect)" | |
581 " blurAndReportSuccess();" | |
582 "else" | |
583 " languageSelect.addEventListener('focus', blurAndReportSuccess);", | |
584 &done)); | |
585 } | |
586 | |
587 void StartLogin(const std::string& locale, | 656 void StartLogin(const std::string& locale, |
588 const std::string& input_method) { | 657 const std::string& input_method) { |
589 // Start login into the device-local account. | 658 // Start login into the device-local account. |
590 chromeos::LoginDisplayHostImpl* host = | 659 chromeos::LoginDisplayHostImpl* host = |
591 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 660 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
592 chromeos::LoginDisplayHostImpl::default_host()); | 661 chromeos::LoginDisplayHostImpl::default_host()); |
593 ASSERT_TRUE(host); | 662 ASSERT_TRUE(host); |
594 host->StartSignInScreen(LoginScreenContext()); | 663 host->StartSignInScreen(LoginScreenContext()); |
595 chromeos::ExistingUserController* controller = | 664 chromeos::ExistingUserController* controller = |
596 chromeos::ExistingUserController::current_controller(); | 665 chromeos::ExistingUserController::current_controller(); |
597 ASSERT_TRUE(controller); | 666 ASSERT_TRUE(controller); |
598 | 667 |
599 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 668 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
600 user_id_1_); | 669 user_id_1_); |
601 user_context.SetPublicSessionLocale(locale); | 670 user_context.SetPublicSessionLocale(locale); |
602 user_context.SetPublicSessionInputMethod(input_method); | 671 user_context.SetPublicSessionInputMethod(input_method); |
603 controller->LoginAsPublicSession(user_context); | 672 controller->LoginAsPublicSession(user_context); |
604 } | 673 } |
605 | 674 |
606 void WaitForSessionStart() { | 675 void WaitForSessionStart() { |
607 if (IsSessionStarted()) | 676 if (IsSessionStarted()) |
608 return; | 677 return; |
609 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 678 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
610 base::Bind(IsSessionStarted)).Wait(); | 679 base::Bind(IsSessionStarted)).Wait(); |
611 } | 680 } |
612 | 681 |
| 682 void VerifyKeyboardLayoutMatchesLocale() { |
| 683 chromeos::input_method::InputMethodManager* input_method_manager = |
| 684 chromeos::input_method::InputMethodManager::Get(); |
| 685 std::vector<std::string> layouts_from_locale; |
| 686 input_method_manager->GetInputMethodUtil()-> |
| 687 GetInputMethodIdsFromLanguageCode( |
| 688 g_browser_process->GetApplicationLocale(), |
| 689 chromeos::input_method::kKeyboardLayoutsOnly, |
| 690 &layouts_from_locale); |
| 691 ASSERT_FALSE(layouts_from_locale.empty()); |
| 692 EXPECT_EQ(layouts_from_locale.front(), |
| 693 input_method_manager->GetCurrentInputMethod().id()); |
| 694 } |
| 695 |
613 const std::string user_id_1_; | 696 const std::string user_id_1_; |
614 const std::string user_id_2_; | 697 const std::string user_id_2_; |
615 const std::string public_session_input_method_id_; | 698 const std::string public_session_input_method_id_; |
616 | 699 |
617 scoped_ptr<base::RunLoop> run_loop_; | 700 scoped_ptr<base::RunLoop> run_loop_; |
618 | 701 |
619 UserPolicyBuilder device_local_account_policy_; | 702 UserPolicyBuilder device_local_account_policy_; |
620 LocalPolicyTestServer test_server_; | 703 LocalPolicyTestServer test_server_; |
621 | 704 |
| 705 content::WebContents* contents_; |
| 706 |
622 private: | 707 private: |
623 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 708 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
624 }; | 709 }; |
625 | 710 |
626 static bool IsKnownUser(const std::string& account_id) { | 711 static bool IsKnownUser(const std::string& account_id) { |
627 return chromeos::UserManager::Get()->IsKnownUser(account_id); | 712 return chromeos::UserManager::Get()->IsKnownUser(account_id); |
628 } | 713 } |
629 | 714 |
630 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { | 715 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { |
631 AddPublicSessionToDevicePolicy(kAccountId1); | 716 AddPublicSessionToDevicePolicy(kAccountId1); |
632 AddPublicSessionToDevicePolicy(kAccountId2); | 717 AddPublicSessionToDevicePolicy(kAccountId2); |
633 | 718 |
634 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 719 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
635 base::Bind(&IsKnownUser, user_id_1_)) | 720 base::Bind(&IsKnownUser, user_id_1_)) |
636 .Wait(); | 721 .Wait(); |
637 EXPECT_TRUE(IsKnownUser(user_id_2_)); | 722 EXPECT_TRUE(IsKnownUser(user_id_2_)); |
638 | 723 |
639 CheckPublicSessionPresent(user_id_1_); | 724 CheckPublicSessionPresent(user_id_1_); |
640 CheckPublicSessionPresent(user_id_2_); | 725 CheckPublicSessionPresent(user_id_2_); |
641 } | 726 } |
642 | 727 |
643 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) { | 728 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) { |
644 UploadAndInstallDeviceLocalAccountPolicy(); | 729 UploadAndInstallDeviceLocalAccountPolicy(); |
645 AddPublicSessionToDevicePolicy(kAccountId1); | 730 AddPublicSessionToDevicePolicy(kAccountId1); |
646 | 731 |
647 WaitForPolicy(); | 732 WaitForPolicy(); |
648 | 733 |
649 // Skip to the login screen. | |
650 chromeos::WizardController* wizard_controller = | |
651 chromeos::WizardController::default_controller(); | |
652 ASSERT_TRUE(wizard_controller); | |
653 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | |
654 content::WindowedNotificationObserver( | |
655 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | |
656 content::NotificationService::AllSources()).Wait(); | |
657 | |
658 // Verify that the display name is shown in the UI. | 734 // Verify that the display name is shown in the UI. |
659 content::WebContents* contents = NULL; | |
660 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); | |
661 const std::string get_compact_pod_display_name = base::StringPrintf( | 735 const std::string get_compact_pod_display_name = base::StringPrintf( |
662 "domAutomationController.send(document.getElementById('pod-row')" | 736 "domAutomationController.send(document.getElementById('pod-row')" |
663 " .getPodWithUsername_('%s').nameElement.textContent);", | 737 " .getPodWithUsername_('%s').nameElement.textContent);", |
664 user_id_1_.c_str()); | 738 user_id_1_.c_str()); |
665 std::string display_name; | 739 std::string display_name; |
666 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 740 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
667 contents, | 741 contents_, |
668 get_compact_pod_display_name, | 742 get_compact_pod_display_name, |
669 &display_name)); | 743 &display_name)); |
670 EXPECT_EQ(kDisplayName1, display_name); | 744 EXPECT_EQ(kDisplayName1, display_name); |
671 const std::string get_expanded_pod_display_name = base::StringPrintf( | 745 const std::string get_expanded_pod_display_name = base::StringPrintf( |
672 "domAutomationController.send(document.getElementById('pod-row')" | 746 "domAutomationController.send(document.getElementById('pod-row')" |
673 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" | 747 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" |
674 " .textContent);", | 748 " .textContent);", |
675 user_id_1_.c_str()); | 749 user_id_1_.c_str()); |
676 display_name.clear(); | 750 display_name.clear(); |
677 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 751 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
678 contents, | 752 contents_, |
679 get_expanded_pod_display_name, | 753 get_expanded_pod_display_name, |
680 &display_name)); | 754 &display_name)); |
681 EXPECT_EQ(kDisplayName1, display_name); | 755 EXPECT_EQ(kDisplayName1, display_name); |
682 | 756 |
683 // Click on the pod to expand it. | 757 // Click on the pod to expand it. |
684 ASSERT_TRUE(content::ExecuteScript( | 758 ASSERT_TRUE(content::ExecuteScript( |
685 contents, | 759 contents_, |
686 base::StringPrintf( | 760 base::StringPrintf( |
687 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 761 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
688 " .click();", | 762 " .click();", |
689 user_id_1_.c_str()))); | 763 user_id_1_.c_str()))); |
690 | 764 |
691 // Change the display name. | 765 // Change the display name. |
692 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 766 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
693 kDisplayName2); | 767 kDisplayName2); |
694 UploadAndInstallDeviceLocalAccountPolicy(); | 768 UploadAndInstallDeviceLocalAccountPolicy(); |
695 policy::BrowserPolicyConnectorChromeOS* connector = | 769 policy::BrowserPolicyConnectorChromeOS* connector = |
696 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 770 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
697 DeviceLocalAccountPolicyBroker* broker = | 771 DeviceLocalAccountPolicyBroker* broker = |
698 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 772 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
699 user_id_1_); | 773 user_id_1_); |
700 ASSERT_TRUE(broker); | 774 ASSERT_TRUE(broker); |
701 broker->core()->store()->Load(); | 775 broker->core()->store()->Load(); |
702 WaitForDisplayName(user_id_1_, kDisplayName2); | 776 WaitForDisplayName(user_id_1_, kDisplayName2); |
703 | 777 |
704 // Verify that the new display name is shown in the UI. | 778 // Verify that the new display name is shown in the UI. |
705 display_name.clear(); | 779 display_name.clear(); |
706 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 780 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
707 contents, | 781 contents_, |
708 get_compact_pod_display_name, | 782 get_compact_pod_display_name, |
709 &display_name)); | 783 &display_name)); |
710 EXPECT_EQ(kDisplayName2, display_name); | 784 EXPECT_EQ(kDisplayName2, display_name); |
711 display_name.clear(); | 785 display_name.clear(); |
712 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 786 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
713 contents, | 787 contents_, |
714 get_expanded_pod_display_name, | 788 get_expanded_pod_display_name, |
715 &display_name)); | 789 &display_name)); |
716 EXPECT_EQ(kDisplayName2, display_name); | 790 EXPECT_EQ(kDisplayName2, display_name); |
717 | 791 |
718 // Verify that the pod is still expanded. This indicates that the UI updated | 792 // Verify that the pod is still expanded. This indicates that the UI updated |
719 // without reloading and losing state. | 793 // without reloading and losing state. |
720 bool expanded = false; | 794 bool expanded = false; |
721 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 795 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
722 contents, | 796 contents_, |
723 base::StringPrintf( | 797 base::StringPrintf( |
724 "domAutomationController.send(document.getElementById('pod-row')" | 798 "domAutomationController.send(document.getElementById('pod-row')" |
725 " .getPodWithUsername_('%s').expanded);", | 799 " .getPodWithUsername_('%s').expanded);", |
726 user_id_1_.c_str()), | 800 user_id_1_.c_str()), |
727 &expanded)); | 801 &expanded)); |
728 EXPECT_TRUE(expanded); | 802 EXPECT_TRUE(expanded); |
729 } | 803 } |
730 | 804 |
731 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { | 805 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { |
732 UploadDeviceLocalAccountPolicy(); | 806 UploadDeviceLocalAccountPolicy(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), | 842 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), |
769 policy.SerializeAsString()); | 843 policy.SerializeAsString()); |
770 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); | 844 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); |
771 | 845 |
772 // Make sure the second device-local account disappears. | 846 // Make sure the second device-local account disappears. |
773 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 847 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
774 base::Bind(&IsNotKnownUser, user_id_2_)) | 848 base::Bind(&IsNotKnownUser, user_id_2_)) |
775 .Wait(); | 849 .Wait(); |
776 } | 850 } |
777 | 851 |
778 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_StartSession) { | 852 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { |
779 // Specify startup pages. | 853 // Specify startup pages. |
780 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( | 854 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( |
781 SessionStartupPref::kPrefValueURLs); | 855 SessionStartupPref::kPrefValueURLs); |
782 em::StringListPolicyProto* startup_urls_proto = | 856 em::StringListPolicyProto* startup_urls_proto = |
783 device_local_account_policy_.payload().mutable_restoreonstartupurls(); | 857 device_local_account_policy_.payload().mutable_restoreonstartupurls(); |
784 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) | 858 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) |
785 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); | 859 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); |
786 UploadAndInstallDeviceLocalAccountPolicy(); | 860 UploadAndInstallDeviceLocalAccountPolicy(); |
787 AddPublicSessionToDevicePolicy(kAccountId1); | 861 AddPublicSessionToDevicePolicy(kAccountId1); |
788 | 862 |
789 WaitForPolicy(); | 863 WaitForPolicy(); |
790 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 864 |
791 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 865 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
792 WaitForSessionStart(); | 866 WaitForSessionStart(); |
793 | 867 |
794 // Check that the startup pages specified in policy were opened. | 868 // Check that the startup pages specified in policy were opened. |
795 BrowserList* browser_list = | 869 BrowserList* browser_list = |
796 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 870 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
797 EXPECT_EQ(1U, browser_list->size()); | 871 EXPECT_EQ(1U, browser_list->size()); |
798 Browser* browser = browser_list->get(0); | 872 Browser* browser = browser_list->get(0); |
799 ASSERT_TRUE(browser); | 873 ASSERT_TRUE(browser); |
800 | 874 |
801 TabStripModel* tabs = browser->tab_strip_model(); | 875 TabStripModel* tabs = browser->tab_strip_model(); |
802 ASSERT_TRUE(tabs); | 876 ASSERT_TRUE(tabs); |
803 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 877 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
804 EXPECT_EQ(expected_tab_count, tabs->count()); | 878 EXPECT_EQ(expected_tab_count, tabs->count()); |
805 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { | 879 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { |
806 EXPECT_EQ(GURL(kStartupURLs[i]), | 880 EXPECT_EQ(GURL(kStartupURLs[i]), |
807 tabs->GetWebContentsAt(i)->GetVisibleURL()); | 881 tabs->GetWebContentsAt(i)->GetVisibleURL()); |
808 } | 882 } |
809 | 883 |
810 // Verify that the session is not considered to be logged in with a GAIA | 884 // Verify that the session is not considered to be logged in with a GAIA |
811 // account. | 885 // account. |
812 Profile* profile = GetProfileForTest(); | 886 Profile* profile = GetProfileForTest(); |
813 ASSERT_TRUE(profile); | 887 ASSERT_TRUE(profile); |
814 EXPECT_FALSE(profile->GetPrefs()->HasPrefPath( | 888 EXPECT_FALSE(profile->GetPrefs()->HasPrefPath( |
815 prefs::kGoogleServicesUsername)); | 889 prefs::kGoogleServicesUsername)); |
816 } | 890 } |
817 | 891 |
818 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_FullscreenDisallowed) { | 892 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, FullscreenDisallowed) { |
819 UploadAndInstallDeviceLocalAccountPolicy(); | 893 UploadAndInstallDeviceLocalAccountPolicy(); |
820 AddPublicSessionToDevicePolicy(kAccountId1); | 894 AddPublicSessionToDevicePolicy(kAccountId1); |
821 | 895 |
822 WaitForPolicy(); | 896 WaitForPolicy(); |
823 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 897 |
824 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 898 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
825 WaitForSessionStart(); | 899 WaitForSessionStart(); |
826 | 900 |
827 BrowserList* browser_list = | 901 BrowserList* browser_list = |
828 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 902 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
829 EXPECT_EQ(1U, browser_list->size()); | 903 EXPECT_EQ(1U, browser_list->size()); |
830 Browser* browser = browser_list->get(0); | 904 Browser* browser = browser_list->get(0); |
831 ASSERT_TRUE(browser); | 905 ASSERT_TRUE(browser); |
832 BrowserWindow* browser_window = browser->window(); | 906 BrowserWindow* browser_window = browser->window(); |
833 ASSERT_TRUE(browser_window); | 907 ASSERT_TRUE(browser_window); |
834 | 908 |
835 // Verify that an attempt to enter fullscreen mode is denied. | 909 // Verify that an attempt to enter fullscreen mode is denied. |
836 EXPECT_FALSE(browser_window->IsFullscreen()); | 910 EXPECT_FALSE(browser_window->IsFullscreen()); |
837 chrome::ToggleFullscreenMode(browser); | 911 chrome::ToggleFullscreenMode(browser); |
838 EXPECT_FALSE(browser_window->IsFullscreen()); | 912 EXPECT_FALSE(browser_window->IsFullscreen()); |
839 } | 913 } |
840 | 914 |
841 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_ExtensionsUncached) { | 915 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsUncached) { |
842 // Make it possible to force-install a hosted app and an extension. | 916 // Make it possible to force-install a hosted app and an extension. |
843 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 917 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
844 TestingUpdateManifestProvider testing_update_manifest_provider( | 918 TestingUpdateManifestProvider testing_update_manifest_provider( |
845 kRelativeUpdateURL); | 919 kRelativeUpdateURL); |
846 testing_update_manifest_provider.AddUpdate( | 920 testing_update_manifest_provider.AddUpdate( |
847 kHostedAppID, | 921 kHostedAppID, |
848 kHostedAppVersion, | 922 kHostedAppVersion, |
849 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); | 923 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); |
850 testing_update_manifest_provider.AddUpdate( | 924 testing_update_manifest_provider.AddUpdate( |
851 kGoodExtensionID, | 925 kGoodExtensionID, |
(...skipping 12 matching lines...) Expand all Loading... |
864 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 938 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
865 forcelist->add_entries(base::StringPrintf( | 939 forcelist->add_entries(base::StringPrintf( |
866 "%s;%s", | 940 "%s;%s", |
867 kGoodExtensionID, | 941 kGoodExtensionID, |
868 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 942 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
869 | 943 |
870 UploadAndInstallDeviceLocalAccountPolicy(); | 944 UploadAndInstallDeviceLocalAccountPolicy(); |
871 AddPublicSessionToDevicePolicy(kAccountId1); | 945 AddPublicSessionToDevicePolicy(kAccountId1); |
872 | 946 |
873 WaitForPolicy(); | 947 WaitForPolicy(); |
874 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | |
875 | 948 |
876 // Start listening for app/extension installation results. | 949 // Start listening for app/extension installation results. |
877 content::WindowedNotificationObserver hosted_app_observer( | 950 content::WindowedNotificationObserver hosted_app_observer( |
878 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 951 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
879 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); | 952 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); |
880 content::WindowedNotificationObserver extension_observer( | 953 content::WindowedNotificationObserver extension_observer( |
881 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 954 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
882 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | 955 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); |
883 | 956 |
884 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 957 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
(...skipping 26 matching lines...) Expand all Loading... |
911 DeviceLocalAccountPolicyBroker* broker = | 984 DeviceLocalAccountPolicyBroker* broker = |
912 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 985 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
913 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); | 986 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); |
914 ASSERT_TRUE(broker); | 987 ASSERT_TRUE(broker); |
915 chromeos::ExternalCache* cache = | 988 chromeos::ExternalCache* cache = |
916 broker->extension_loader()->GetExternalCacheForTesting(); | 989 broker->extension_loader()->GetExternalCacheForTesting(); |
917 ASSERT_TRUE(cache); | 990 ASSERT_TRUE(cache); |
918 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); | 991 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); |
919 } | 992 } |
920 | 993 |
921 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_ExtensionsCached) { | 994 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { |
922 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 995 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
923 | 996 |
924 // Pre-populate the device local account's extension cache with a hosted app | 997 // Pre-populate the device local account's extension cache with a hosted app |
925 // and an extension. | 998 // and an extension. |
926 EXPECT_TRUE(base::CreateDirectory( | 999 EXPECT_TRUE(base::CreateDirectory( |
927 GetExtensionCacheDirectoryForAccountID(kAccountId1))); | 1000 GetExtensionCacheDirectoryForAccountID(kAccountId1))); |
928 base::FilePath test_dir; | 1001 base::FilePath test_dir; |
929 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 1002 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
930 const base::FilePath cached_hosted_app = | 1003 const base::FilePath cached_hosted_app = |
931 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); | 1004 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); |
(...skipping 12 matching lines...) Expand all Loading... |
944 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 1017 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
945 forcelist->add_entries(base::StringPrintf( | 1018 forcelist->add_entries(base::StringPrintf( |
946 "%s;%s", | 1019 "%s;%s", |
947 kGoodExtensionID, | 1020 kGoodExtensionID, |
948 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); | 1021 embedded_test_server()->GetURL(kRelativeUpdateURL).spec().c_str())); |
949 | 1022 |
950 UploadAndInstallDeviceLocalAccountPolicy(); | 1023 UploadAndInstallDeviceLocalAccountPolicy(); |
951 AddPublicSessionToDevicePolicy(kAccountId1); | 1024 AddPublicSessionToDevicePolicy(kAccountId1); |
952 | 1025 |
953 WaitForPolicy(); | 1026 WaitForPolicy(); |
954 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | |
955 | 1027 |
956 // Start listening for app/extension installation results. | 1028 // Start listening for app/extension installation results. |
957 content::WindowedNotificationObserver hosted_app_observer( | 1029 content::WindowedNotificationObserver hosted_app_observer( |
958 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 1030 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
959 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); | 1031 base::Bind(DoesInstallSuccessReferToId, kHostedAppID)); |
960 content::WindowedNotificationObserver extension_observer( | 1032 content::WindowedNotificationObserver extension_observer( |
961 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 1033 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
962 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); | 1034 base::Bind(DoesInstallFailureReferToId, kGoodExtensionID)); |
963 | 1035 |
964 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 1036 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
(...skipping 20 matching lines...) Expand all Loading... |
985 DeviceLocalAccountPolicyBroker* broker = | 1057 DeviceLocalAccountPolicyBroker* broker = |
986 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 1058 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
987 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); | 1059 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); |
988 ASSERT_TRUE(broker); | 1060 ASSERT_TRUE(broker); |
989 chromeos::ExternalCache* cache = | 1061 chromeos::ExternalCache* cache = |
990 broker->extension_loader()->GetExternalCacheForTesting(); | 1062 broker->extension_loader()->GetExternalCacheForTesting(); |
991 ASSERT_TRUE(cache); | 1063 ASSERT_TRUE(cache); |
992 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); | 1064 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); |
993 } | 1065 } |
994 | 1066 |
995 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_ExternalData) { | 1067 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) { |
996 // chromeos::UserManager requests an external data fetch whenever | 1068 // chromeos::UserManager requests an external data fetch whenever |
997 // the key::kUserAvatarImage policy is set. Since this test wants to | 1069 // the key::kUserAvatarImage policy is set. Since this test wants to |
998 // verify that the underlying policy subsystem will start a fetch | 1070 // verify that the underlying policy subsystem will start a fetch |
999 // without this request as well, the chromeos::UserManager must be | 1071 // without this request as well, the chromeos::UserManager must be |
1000 // prevented from seeing the policy change. | 1072 // prevented from seeing the policy change. |
1001 reinterpret_cast<chromeos::ChromeUserManager*>(chromeos::UserManager::Get()) | 1073 reinterpret_cast<chromeos::ChromeUserManager*>(chromeos::UserManager::Get()) |
1002 ->StopPolicyObserverForTesting(); | 1074 ->StopPolicyObserverForTesting(); |
1003 | 1075 |
1004 UploadDeviceLocalAccountPolicy(); | 1076 UploadDeviceLocalAccountPolicy(); |
1005 AddPublicSessionToDevicePolicy(kAccountId1); | 1077 AddPublicSessionToDevicePolicy(kAccountId1); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 scoped_ptr<std::string> fetched_external_data; | 1126 scoped_ptr<std::string> fetched_external_data; |
1055 policy_entry->external_data_fetcher->Fetch(base::Bind( | 1127 policy_entry->external_data_fetcher->Fetch(base::Bind( |
1056 &test::ExternalDataFetchCallback, | 1128 &test::ExternalDataFetchCallback, |
1057 &fetched_external_data, | 1129 &fetched_external_data, |
1058 run_loop->QuitClosure())); | 1130 run_loop->QuitClosure())); |
1059 run_loop->Run(); | 1131 run_loop->Run(); |
1060 | 1132 |
1061 ASSERT_TRUE(fetched_external_data); | 1133 ASSERT_TRUE(fetched_external_data); |
1062 EXPECT_EQ(kExternalData, *fetched_external_data); | 1134 EXPECT_EQ(kExternalData, *fetched_external_data); |
1063 | 1135 |
1064 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | |
1065 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 1136 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
1066 WaitForSessionStart(); | 1137 WaitForSessionStart(); |
1067 | 1138 |
1068 // Verify that the external data reference has propagated to the device-local | 1139 // Verify that the external data reference has propagated to the device-local |
1069 // account's ProfilePolicyConnector. | 1140 // account's ProfilePolicyConnector. |
1070 ProfilePolicyConnector* policy_connector = | 1141 ProfilePolicyConnector* policy_connector = |
1071 ProfilePolicyConnectorFactory::GetForProfile(GetProfileForTest()); | 1142 ProfilePolicyConnectorFactory::GetForProfile(GetProfileForTest()); |
1072 ASSERT_TRUE(policy_connector); | 1143 ASSERT_TRUE(policy_connector); |
1073 const PolicyMap& policies = policy_connector->policy_service()->GetPolicies( | 1144 const PolicyMap& policies = policy_connector->policy_service()->GetPolicies( |
1074 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 1145 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 | 1231 |
1161 scoped_ptr<gfx::ImageSkia> saved_image = | 1232 scoped_ptr<gfx::ImageSkia> saved_image = |
1162 chromeos::test::ImageLoader(saved_image_path).Load(); | 1233 chromeos::test::ImageLoader(saved_image_path).Load(); |
1163 ASSERT_TRUE(saved_image); | 1234 ASSERT_TRUE(saved_image); |
1164 | 1235 |
1165 // Check image dimensions. Images can't be compared since JPEG is lossy. | 1236 // Check image dimensions. Images can't be compared since JPEG is lossy. |
1166 EXPECT_EQ(policy_image->width(), saved_image->width()); | 1237 EXPECT_EQ(policy_image->width(), saved_image->width()); |
1167 EXPECT_EQ(policy_image->height(), saved_image->height()); | 1238 EXPECT_EQ(policy_image->height(), saved_image->height()); |
1168 } | 1239 } |
1169 | 1240 |
1170 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1241 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LastWindowClosedLogoutReminder) { |
1171 DISABLED_LastWindowClosedLogoutReminder) { | |
1172 UploadAndInstallDeviceLocalAccountPolicy(); | 1242 UploadAndInstallDeviceLocalAccountPolicy(); |
1173 AddPublicSessionToDevicePolicy(kAccountId1); | 1243 AddPublicSessionToDevicePolicy(kAccountId1); |
1174 | 1244 |
1175 WaitForPolicy(); | 1245 WaitForPolicy(); |
1176 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 1246 |
1177 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 1247 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
1178 WaitForSessionStart(); | 1248 WaitForSessionStart(); |
1179 | 1249 |
1180 Profile* profile = GetProfileForTest(); | 1250 Profile* profile = GetProfileForTest(); |
1181 ASSERT_TRUE(profile); | 1251 ASSERT_TRUE(profile); |
1182 apps::AppWindowRegistry* app_window_registry = | 1252 apps::AppWindowRegistry* app_window_registry = |
1183 apps::AppWindowRegistry::Get(profile); | 1253 apps::AppWindowRegistry::Get(profile); |
1184 app_window_registry->AddObserver(this); | 1254 app_window_registry->AddObserver(this); |
1185 | 1255 |
1186 // Verify that the logout confirmation dialog is not showing. | 1256 // Verify that the logout confirmation dialog is not showing. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 ASSERT_TRUE(dialog); | 1385 ASSERT_TRUE(dialog); |
1316 | 1386 |
1317 // Deny the logout. | 1387 // Deny the logout. |
1318 dialog->GetWidget()->Close(); | 1388 dialog->GetWidget()->Close(); |
1319 dialog = NULL; | 1389 dialog = NULL; |
1320 base::RunLoop().RunUntilIdle(); | 1390 base::RunLoop().RunUntilIdle(); |
1321 | 1391 |
1322 app_window_registry->RemoveObserver(this); | 1392 app_window_registry->RemoveObserver(this); |
1323 }; | 1393 }; |
1324 | 1394 |
1325 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1395 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
1326 DISABLED_DoNotSelectLanguageAndKeyboard) { | |
1327 chromeos::input_method::InputMethodManager* input_method_manager = | |
1328 chromeos::input_method::InputMethodManager::Get(); | |
1329 const std::string initial_locale = g_browser_process->GetApplicationLocale(); | 1396 const std::string initial_locale = g_browser_process->GetApplicationLocale(); |
1330 const std::string initial_input_method = | |
1331 input_method_manager->GetCurrentInputMethod().id(); | |
1332 | 1397 |
1333 UploadAndInstallDeviceLocalAccountPolicy(); | 1398 UploadAndInstallDeviceLocalAccountPolicy(); |
1334 AddPublicSessionToDevicePolicy(kAccountId1); | 1399 AddPublicSessionToDevicePolicy(kAccountId1); |
1335 | 1400 |
1336 WaitForPolicy(); | 1401 WaitForPolicy(); |
1337 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 1402 |
1338 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 1403 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1404 // form as there are no recommended locales. |
| 1405 bool advanced = false; |
| 1406 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1407 contents_, |
| 1408 base::StringPrintf( |
| 1409 "var pod =" |
| 1410 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1411 "pod.click();" |
| 1412 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1413 user_id_1_.c_str()), |
| 1414 &advanced)); |
| 1415 EXPECT_FALSE(advanced); |
| 1416 |
| 1417 // Click the enter button to start the session. |
| 1418 ASSERT_TRUE(content::ExecuteScript( |
| 1419 contents_, |
| 1420 base::StringPrintf( |
| 1421 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1422 " .querySelector('.enter-button').click();", |
| 1423 user_id_1_.c_str()))); |
| 1424 |
1339 WaitForSessionStart(); | 1425 WaitForSessionStart(); |
1340 | 1426 |
| 1427 // Verify that the locale has not changed and the first keyboard layout |
| 1428 // applicable to the locale was chosen. |
1341 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); | 1429 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); |
1342 EXPECT_EQ(initial_input_method, | 1430 VerifyKeyboardLayoutMatchesLocale(); |
1343 input_method_manager->GetCurrentInputMethod().id()); | |
1344 } | 1431 } |
1345 | 1432 |
1346 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1433 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
1347 DISABLED_SelectLanguageAndKeyboard) { | |
1348 // Specify startup pages. | |
1349 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( | |
1350 SessionStartupPref::kPrefValueURLs); | |
1351 em::StringListPolicyProto* startup_urls_proto = | |
1352 device_local_account_policy_.payload().mutable_restoreonstartupurls(); | |
1353 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) | |
1354 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); | |
1355 UploadAndInstallDeviceLocalAccountPolicy(); | 1434 UploadAndInstallDeviceLocalAccountPolicy(); |
1356 AddPublicSessionToDevicePolicy(kAccountId1); | 1435 AddPublicSessionToDevicePolicy(kAccountId1); |
1357 | 1436 |
1358 // Log in to the device-local account with a specific locale and keyboard | |
1359 // layout. | |
1360 WaitForPolicy(); | 1437 WaitForPolicy(); |
1361 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 1438 |
1362 ASSERT_NO_FATAL_FAILURE( | 1439 // Click on the pod to expand it. Verify that the pod expands to its basic |
1363 StartLogin(kPublicSessionLocale, public_session_input_method_id_)); | 1440 // form as there are no recommended locales. |
| 1441 bool advanced = false; |
| 1442 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1443 contents_, |
| 1444 base::StringPrintf( |
| 1445 "var pod =" |
| 1446 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1447 "pod.click();" |
| 1448 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1449 user_id_1_.c_str()), |
| 1450 &advanced)); |
| 1451 EXPECT_FALSE(advanced); |
| 1452 |
| 1453 // Click the link that switches the pod to its advanced form. Verify that the |
| 1454 // pod switches from basic to advanced. |
| 1455 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1456 contents_, |
| 1457 base::StringPrintf( |
| 1458 "var pod =" |
| 1459 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1460 "pod.querySelector('.language-and-input').click();" |
| 1461 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1462 user_id_1_.c_str()), |
| 1463 &advanced)); |
| 1464 EXPECT_FALSE(advanced); |
| 1465 |
| 1466 // Manually select a different locale. |
| 1467 ASSERT_TRUE(content::ExecuteScript( |
| 1468 contents_, |
| 1469 base::StringPrintf( |
| 1470 "var languageSelect = document.getElementById('pod-row')" |
| 1471 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1472 "languageSelect.value = '%s';" |
| 1473 "var event = document.createEvent('HTMLEvents');" |
| 1474 "event.initEvent('change', false, true);" |
| 1475 "languageSelect.dispatchEvent(event);", |
| 1476 user_id_1_.c_str(), |
| 1477 kPublicSessionLocale))); |
| 1478 |
| 1479 // The UI will have requested an updated list of keyboard layouts at this |
| 1480 // point. Wait for the constructions of this list to finish. |
| 1481 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1482 |
| 1483 // Manually select a different keyboard layout and click the enter button to |
| 1484 // start the session. |
| 1485 ASSERT_TRUE(content::ExecuteScript( |
| 1486 contents_, |
| 1487 base::StringPrintf( |
| 1488 "var pod =" |
| 1489 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1490 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1491 "pod.querySelector('.enter-button').click();", |
| 1492 user_id_1_.c_str(), |
| 1493 public_session_input_method_id_.c_str()))); |
| 1494 |
1364 WaitForSessionStart(); | 1495 WaitForSessionStart(); |
1365 | 1496 |
1366 // Verify that the locale and keyboard layout have been applied. | 1497 // Verify that the locale and keyboard layout have been applied. |
| 1498 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1499 EXPECT_EQ(public_session_input_method_id_, |
| 1500 chromeos::input_method::InputMethodManager::Get()-> |
| 1501 GetCurrentInputMethod().id()); |
| 1502 } |
| 1503 |
| 1504 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
| 1505 // Specify a recommended locale. |
| 1506 SetRecommendedLocales(kSingleRecommendedLocale, |
| 1507 arraysize(kSingleRecommendedLocale)); |
| 1508 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1509 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1510 |
| 1511 WaitForPolicy(); |
| 1512 |
| 1513 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1514 // form as there is only one recommended locale. |
| 1515 bool advanced = false; |
| 1516 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1517 contents_, |
| 1518 base::StringPrintf( |
| 1519 "var pod =" |
| 1520 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1521 "pod.click();" |
| 1522 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1523 user_id_1_.c_str()), |
| 1524 &advanced)); |
| 1525 EXPECT_FALSE(advanced); |
| 1526 |
| 1527 // Click the enter button to start the session. |
| 1528 ASSERT_TRUE(content::ExecuteScript( |
| 1529 contents_, |
| 1530 base::StringPrintf( |
| 1531 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1532 " .querySelector('.enter-button').click();", |
| 1533 user_id_1_.c_str()))); |
| 1534 |
| 1535 WaitForSessionStart(); |
| 1536 |
| 1537 // Verify that the recommended locale has been applied and the first keyboard |
| 1538 // layout applicable to the locale was chosen. |
| 1539 EXPECT_EQ(kSingleRecommendedLocale[0], |
| 1540 g_browser_process->GetApplicationLocale()); |
| 1541 VerifyKeyboardLayoutMatchesLocale(); |
| 1542 } |
| 1543 |
| 1544 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
| 1545 // Specify recommended locales. |
| 1546 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1547 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1548 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1549 AddPublicSessionToDevicePolicy(kAccountId2); |
| 1550 |
| 1551 WaitForPolicy(); |
| 1552 |
| 1553 // Click on the pod to expand it. Verify that the pod expands to its advanced |
| 1554 // form directly as there are two or more recommended locales. |
| 1555 bool advanced = false; |
| 1556 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1557 contents_, |
| 1558 base::StringPrintf( |
| 1559 "var pod =" |
| 1560 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1561 "pod.click();" |
| 1562 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1563 user_id_1_.c_str()), |
| 1564 &advanced)); |
| 1565 EXPECT_TRUE(advanced); |
| 1566 |
| 1567 // Verify that the pod shows a list of locales beginning with the recommended |
| 1568 // ones, followed by others. |
| 1569 const std::string get_locale_list = base::StringPrintf( |
| 1570 "var languageSelect = document.getElementById('pod-row')" |
| 1571 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1572 "var locales = [];" |
| 1573 "for (var i = 0; i < languageSelect.length; ++i)" |
| 1574 " locales.push(languageSelect.options[i].value);" |
| 1575 "domAutomationController.send(JSON.stringify(locales));", |
| 1576 user_id_1_.c_str()); |
| 1577 std::string json; |
| 1578 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1579 get_locale_list, |
| 1580 &json)); |
| 1581 scoped_ptr<base::Value> value_ptr(base::JSONReader::Read(json)); |
| 1582 const base::ListValue* locales = NULL; |
| 1583 ASSERT_TRUE(value_ptr); |
| 1584 ASSERT_TRUE(value_ptr->GetAsList(&locales)); |
| 1585 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); |
| 1586 |
| 1587 // Verify that the list starts with the recommended locales, in correct order. |
| 1588 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i) { |
| 1589 std::string locale; |
| 1590 EXPECT_TRUE(locales->GetString(i, &locale)); |
| 1591 EXPECT_EQ(kRecommendedLocales1[i], locale); |
| 1592 } |
| 1593 |
| 1594 // Verify that the recommended locales do not appear again in the remainder of |
| 1595 // the list. |
| 1596 std::set<std::string> recommended_locales; |
| 1597 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i) |
| 1598 recommended_locales.insert(kRecommendedLocales1[i]); |
| 1599 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); |
| 1600 ++i) { |
| 1601 std::string locale; |
| 1602 EXPECT_TRUE(locales->GetString(i, &locale)); |
| 1603 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); |
| 1604 } |
| 1605 |
| 1606 // Verify that the first recommended locale is selected. |
| 1607 const std::string get_selected_locale = |
| 1608 base::StringPrintf( |
| 1609 "domAutomationController.send(document.getElementById('pod-row')" |
| 1610 " .getPodWithUsername_('%s').querySelector('.language-select')" |
| 1611 " .value);", |
| 1612 user_id_1_.c_str()); |
| 1613 std::string selected_locale; |
| 1614 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1615 get_selected_locale, |
| 1616 &selected_locale)); |
| 1617 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); |
| 1618 |
| 1619 // Change the list of recommended locales. |
| 1620 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| 1621 |
| 1622 // Also change the display name as it is easy to ensure that policy has been |
| 1623 // updated by waiting for a display name change. |
| 1624 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 1625 kDisplayName2); |
| 1626 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1627 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1628 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 1629 DeviceLocalAccountPolicyBroker* broker = |
| 1630 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
| 1631 user_id_1_); |
| 1632 ASSERT_TRUE(broker); |
| 1633 broker->core()->store()->Load(); |
| 1634 WaitForDisplayName(user_id_1_, kDisplayName2); |
| 1635 |
| 1636 // Verify that the new list of locales is shown in the UI. |
| 1637 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1638 get_locale_list, |
| 1639 &json)); |
| 1640 value_ptr.reset(base::JSONReader::Read(json)); |
| 1641 locales = NULL; |
| 1642 ASSERT_TRUE(value_ptr); |
| 1643 ASSERT_TRUE(value_ptr->GetAsList(&locales)); |
| 1644 EXPECT_LT(arraysize(kRecommendedLocales2), locales->GetSize()); |
| 1645 for (size_t i = 0; i < arraysize(kRecommendedLocales2); ++i) { |
| 1646 std::string locale; |
| 1647 EXPECT_TRUE(locales->GetString(i, &locale)); |
| 1648 EXPECT_EQ(kRecommendedLocales2[i], locale); |
| 1649 } |
| 1650 |
| 1651 // Verify that the first new recommended locale is selected. |
| 1652 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1653 get_selected_locale, |
| 1654 &selected_locale)); |
| 1655 EXPECT_EQ(kRecommendedLocales2[0], selected_locale); |
| 1656 |
| 1657 // Manually select a different locale. |
| 1658 ASSERT_TRUE(content::ExecuteScript( |
| 1659 contents_, |
| 1660 base::StringPrintf( |
| 1661 "var languageSelect = document.getElementById('pod-row')" |
| 1662 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1663 "languageSelect.value = '%s';" |
| 1664 "var event = document.createEvent('HTMLEvents');" |
| 1665 "event.initEvent('change', false, true);" |
| 1666 "languageSelect.dispatchEvent(event);", |
| 1667 user_id_1_.c_str(), |
| 1668 kPublicSessionLocale))); |
| 1669 |
| 1670 // Change the list of recommended locales. |
| 1671 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| 1672 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 1673 kDisplayName1); |
| 1674 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1675 broker->core()->store()->Load(); |
| 1676 WaitForDisplayName(user_id_1_, kDisplayName1); |
| 1677 |
| 1678 // Verify that the manually selected locale is still selected. |
| 1679 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1680 get_selected_locale, |
| 1681 &selected_locale)); |
| 1682 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1683 |
| 1684 // The UI will request an updated list of keyboard layouts at this point. Wait |
| 1685 // for the constructions of this list to finish. |
| 1686 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1687 |
| 1688 // Manually select a different keyboard layout. |
| 1689 ASSERT_TRUE(content::ExecuteScript( |
| 1690 contents_, |
| 1691 base::StringPrintf( |
| 1692 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1693 " .querySelector('.keyboard-select').value = '%s';", |
| 1694 user_id_1_.c_str(), |
| 1695 public_session_input_method_id_.c_str()))); |
| 1696 |
| 1697 // Click on a different pod, causing focus to shift away and the pod to |
| 1698 // contract. |
| 1699 ASSERT_TRUE(content::ExecuteScript( |
| 1700 contents_, |
| 1701 base::StringPrintf( |
| 1702 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1703 " .click();", |
| 1704 user_id_2_.c_str()))); |
| 1705 |
| 1706 // Click on the pod again, causing it to expand again. Verify that the pod has |
| 1707 // kept all its state (the advanced form is being shown, the manually selected |
| 1708 // locale and keyboard layout are selected). |
| 1709 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 1710 contents_, |
| 1711 base::StringPrintf( |
| 1712 "var pod =" |
| 1713 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1714 "pod.click();" |
| 1715 "var state = {};" |
| 1716 "state.advanced = pod.classList.contains('advanced');" |
| 1717 "state.locale = pod.querySelector('.language-select').value;" |
| 1718 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" |
| 1719 "console.log(JSON.stringify(state));" |
| 1720 "domAutomationController.send(JSON.stringify(state));", |
| 1721 user_id_1_.c_str()), |
| 1722 &json)); |
| 1723 LOG(ERROR) << json; |
| 1724 value_ptr.reset(base::JSONReader::Read(json)); |
| 1725 const base::DictionaryValue* state = NULL; |
| 1726 ASSERT_TRUE(value_ptr); |
| 1727 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); |
| 1728 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); |
| 1729 EXPECT_TRUE(advanced); |
| 1730 EXPECT_TRUE(state->GetString("locale", &selected_locale)); |
| 1731 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1732 std::string selected_keyboard_layout; |
| 1733 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); |
| 1734 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); |
| 1735 |
| 1736 // Click the enter button to start the session. |
| 1737 ASSERT_TRUE(content::ExecuteScript( |
| 1738 contents_, |
| 1739 base::StringPrintf( |
| 1740 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1741 " .querySelector('.enter-button').click();", |
| 1742 user_id_1_.c_str()))); |
| 1743 |
| 1744 WaitForSessionStart(); |
| 1745 |
| 1746 // Verify that the locale and keyboard layout have been applied. |
1367 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1747 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
1368 EXPECT_EQ(public_session_input_method_id_, | 1748 EXPECT_EQ(public_session_input_method_id_, |
1369 chromeos::input_method::InputMethodManager::Get()-> | 1749 chromeos::input_method::InputMethodManager::Get()-> |
1370 GetCurrentInputMethod().id()); | 1750 GetCurrentInputMethod().id()); |
1371 } | 1751 } |
1372 | 1752 |
1373 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, | 1753 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
1374 DISABLED_SelectLanguageAndKeyboardWithTermsOfService) { | 1754 AutoLoginWithoutRecommendedLocales) { |
| 1755 const std::string initial_locale = g_browser_process->GetApplicationLocale(); |
| 1756 |
| 1757 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1758 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1759 EnableAutoLogin(); |
| 1760 |
| 1761 WaitForPolicy(); |
| 1762 |
| 1763 WaitForSessionStart(); |
| 1764 |
| 1765 // Verify that the locale has not changed and the first keyboard layout |
| 1766 // applicable to the locale was chosen. |
| 1767 EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); |
| 1768 VerifyKeyboardLayoutMatchesLocale(); |
| 1769 } |
| 1770 |
| 1771 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
| 1772 AutoLoginWithRecommendedLocales) { |
| 1773 // Specify recommended locales. |
| 1774 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1775 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1776 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1777 EnableAutoLogin(); |
| 1778 |
| 1779 WaitForPolicy(); |
| 1780 |
| 1781 WaitForSessionStart(); |
| 1782 |
| 1783 // Verify that the first recommended locale has been applied and the first |
| 1784 // keyboard layout applicable to the locale was chosen. |
| 1785 EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); |
| 1786 VerifyKeyboardLayoutMatchesLocale(); |
| 1787 } |
| 1788 |
| 1789 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
1375 // Specify Terms of Service URL. | 1790 // Specify Terms of Service URL. |
1376 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1791 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
1377 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 1792 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
1378 embedded_test_server()->GetURL( | 1793 embedded_test_server()->GetURL( |
1379 std::string("/") + kExistentTermsOfServicePath).spec()); | 1794 std::string("/") + kExistentTermsOfServicePath).spec()); |
1380 UploadAndInstallDeviceLocalAccountPolicy(); | 1795 UploadAndInstallDeviceLocalAccountPolicy(); |
1381 AddPublicSessionToDevicePolicy(kAccountId1); | 1796 AddPublicSessionToDevicePolicy(kAccountId1); |
1382 | 1797 |
1383 // Log in to the device-local account with a specific locale and keyboard | |
1384 // layout. | |
1385 WaitForPolicy(); | 1798 WaitForPolicy(); |
1386 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 1799 |
1387 ASSERT_NO_FATAL_FAILURE( | 1800 // Select a different locale. |
1388 StartLogin(kPublicSessionLocale, public_session_input_method_id_)); | 1801 ASSERT_TRUE(content::ExecuteScript( |
| 1802 contents_, |
| 1803 base::StringPrintf( |
| 1804 "var languageSelect = document.getElementById('pod-row')" |
| 1805 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1806 "languageSelect.value = '%s';" |
| 1807 "var event = document.createEvent('HTMLEvents');" |
| 1808 "event.initEvent('change', false, true);" |
| 1809 "languageSelect.dispatchEvent(event);", |
| 1810 user_id_1_.c_str(), |
| 1811 kPublicSessionLocale))); |
| 1812 |
| 1813 // The UI will have requested an updated list of keyboard layouts at this |
| 1814 // point. Wait for the constructions of this list to finish. |
| 1815 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
1389 | 1816 |
1390 // Set up an observer that will quit the message loop when login has succeeded | 1817 // Set up an observer that will quit the message loop when login has succeeded |
1391 // and the first wizard screen, if any, is being shown. | 1818 // and the first wizard screen, if any, is being shown. |
1392 base::RunLoop login_wait_run_loop; | 1819 base::RunLoop login_wait_run_loop; |
1393 chromeos::MockAuthStatusConsumer login_status_consumer; | 1820 chromeos::MockAuthStatusConsumer login_status_consumer; |
1394 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 1821 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
1395 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 1822 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
1396 | |
1397 // Spin the loop until the observer fires. Then, unregister the observer. | |
1398 chromeos::ExistingUserController* controller = | 1823 chromeos::ExistingUserController* controller = |
1399 chromeos::ExistingUserController::current_controller(); | 1824 chromeos::ExistingUserController::current_controller(); |
1400 ASSERT_TRUE(controller); | 1825 ASSERT_TRUE(controller); |
1401 controller->set_login_status_consumer(&login_status_consumer); | 1826 controller->set_login_status_consumer(&login_status_consumer); |
| 1827 |
| 1828 // Manually select a different keyboard layout and click the enter button to |
| 1829 // start the session. |
| 1830 ASSERT_TRUE(content::ExecuteScript( |
| 1831 contents_, |
| 1832 base::StringPrintf( |
| 1833 "var pod =" |
| 1834 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1835 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1836 "pod.querySelector('.enter-button').click();", |
| 1837 user_id_1_.c_str(), |
| 1838 public_session_input_method_id_.c_str()))); |
| 1839 |
| 1840 // Spin the loop until the login observer fires. Then, unregister the |
| 1841 // observer. |
1402 login_wait_run_loop.Run(); | 1842 login_wait_run_loop.Run(); |
1403 controller->set_login_status_consumer(NULL); | 1843 controller->set_login_status_consumer(NULL); |
1404 | 1844 |
1405 // Verify that the Terms of Service screen is being shown. | 1845 // Verify that the Terms of Service screen is being shown. |
1406 chromeos::WizardController* wizard_controller = | 1846 chromeos::WizardController* wizard_controller = |
1407 chromeos::WizardController::default_controller(); | 1847 chromeos::WizardController::default_controller(); |
1408 ASSERT_TRUE(wizard_controller); | 1848 ASSERT_TRUE(wizard_controller); |
1409 ASSERT_TRUE(wizard_controller->current_screen()); | 1849 ASSERT_TRUE(wizard_controller->current_screen()); |
1410 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, | 1850 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, |
1411 wizard_controller->current_screen()->GetName()); | 1851 wizard_controller->current_screen()->GetName()); |
1412 | 1852 |
1413 // Wait for the Terms of Service to finish downloading. | 1853 // Wait for the Terms of Service to finish downloading. |
1414 content::WebContents* contents = NULL; | |
1415 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); | |
1416 bool done = false; | 1854 bool done = false; |
1417 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(contents, | 1855 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(contents_, |
1418 "var screenElement = document.getElementById('terms-of-service');" | 1856 "var screenElement = document.getElementById('terms-of-service');" |
1419 "function SendReplyIfDownloadDone() {" | 1857 "function SendReplyIfDownloadDone() {" |
1420 " if (screenElement.classList.contains('tos-loading'))" | 1858 " if (screenElement.classList.contains('tos-loading'))" |
1421 " return false;" | 1859 " return false;" |
1422 " domAutomationController.send(true);" | 1860 " domAutomationController.send(true);" |
1423 " observer.disconnect();" | 1861 " observer.disconnect();" |
1424 " return true;" | 1862 " return true;" |
1425 "}" | 1863 "}" |
1426 "var observer = new MutationObserver(SendReplyIfDownloadDone);" | 1864 "var observer = new MutationObserver(SendReplyIfDownloadDone);" |
1427 "if (!SendReplyIfDownloadDone()) {" | 1865 "if (!SendReplyIfDownloadDone()) {" |
1428 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | 1866 " var options = { attributes: true, attributeFilter: [ 'class' ] };" |
1429 " observer.observe(screenElement, options);" | 1867 " observer.observe(screenElement, options);" |
1430 "}", | 1868 "}", |
1431 &done)); | 1869 &done)); |
1432 | 1870 |
1433 // Verify that the locale and keyboard layout have been applied. | 1871 // Verify that the locale and keyboard layout have been applied. |
1434 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1872 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
1435 EXPECT_EQ(public_session_input_method_id_, | 1873 EXPECT_EQ(public_session_input_method_id_, |
1436 chromeos::input_method::InputMethodManager::Get()-> | 1874 chromeos::input_method::InputMethodManager::Get()-> |
1437 GetCurrentInputMethod().id()); | 1875 GetCurrentInputMethod().id()); |
1438 | 1876 |
1439 // Click the accept button. | 1877 // Click the accept button. |
1440 ASSERT_TRUE(content::ExecuteScript(contents, | 1878 ASSERT_TRUE(content::ExecuteScript(contents_, |
1441 "$('tos-accept-button').click();")); | 1879 "$('tos-accept-button').click();")); |
1442 | 1880 |
1443 WaitForSessionStart(); | 1881 WaitForSessionStart(); |
1444 | 1882 |
1445 // Verify that the locale and keyboard layout are still in force. | 1883 // Verify that the locale and keyboard layout are still in force. |
1446 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1884 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
1447 EXPECT_EQ(public_session_input_method_id_, | 1885 EXPECT_EQ(public_session_input_method_id_, |
1448 chromeos::input_method::InputMethodManager::Get()-> | 1886 chromeos::input_method::InputMethodManager::Get()-> |
1449 GetCurrentInputMethod().id()); | 1887 GetCurrentInputMethod().id()); |
1450 } | 1888 } |
1451 | 1889 |
1452 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, | 1890 class TermsOfServiceDownloadTest : public DeviceLocalAccountTest, |
1453 public testing::WithParamInterface<bool> { | 1891 public testing::WithParamInterface<bool> { |
1454 }; | 1892 }; |
1455 | 1893 |
1456 IN_PROC_BROWSER_TEST_P(TermsOfServiceDownloadTest, | 1894 IN_PROC_BROWSER_TEST_P(TermsOfServiceDownloadTest, TermsOfServiceScreen) { |
1457 DISABLED_TermsOfServiceScreen) { | |
1458 // Specify Terms of Service URL. | 1895 // Specify Terms of Service URL. |
1459 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1896 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
1460 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( | 1897 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( |
1461 embedded_test_server()->GetURL( | 1898 embedded_test_server()->GetURL( |
1462 std::string("/") + | 1899 std::string("/") + |
1463 (GetParam() ? kExistentTermsOfServicePath | 1900 (GetParam() ? kExistentTermsOfServicePath |
1464 : kNonexistentTermsOfServicePath)).spec()); | 1901 : kNonexistentTermsOfServicePath)).spec()); |
1465 UploadAndInstallDeviceLocalAccountPolicy(); | 1902 UploadAndInstallDeviceLocalAccountPolicy(); |
1466 AddPublicSessionToDevicePolicy(kAccountId1); | 1903 AddPublicSessionToDevicePolicy(kAccountId1); |
1467 | 1904 |
1468 WaitForPolicy(); | 1905 WaitForPolicy(); |
1469 ASSERT_NO_FATAL_FAILURE(WaitForLoginUI()); | 1906 |
1470 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); | 1907 ASSERT_NO_FATAL_FAILURE(StartLogin(std::string(), std::string())); |
1471 | 1908 |
1472 // Set up an observer that will quit the message loop when login has succeeded | 1909 // Set up an observer that will quit the message loop when login has succeeded |
1473 // and the first wizard screen, if any, is being shown. | 1910 // and the first wizard screen, if any, is being shown. |
1474 base::RunLoop login_wait_run_loop; | 1911 base::RunLoop login_wait_run_loop; |
1475 chromeos::MockAuthStatusConsumer login_status_consumer; | 1912 chromeos::MockAuthStatusConsumer login_status_consumer; |
1476 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 1913 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
1477 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 1914 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
1478 | 1915 |
1479 // Spin the loop until the observer fires. Then, unregister the observer. | 1916 // Spin the loop until the observer fires. Then, unregister the observer. |
1480 chromeos::ExistingUserController* controller = | 1917 chromeos::ExistingUserController* controller = |
1481 chromeos::ExistingUserController::current_controller(); | 1918 chromeos::ExistingUserController::current_controller(); |
1482 ASSERT_TRUE(controller); | 1919 ASSERT_TRUE(controller); |
1483 controller->set_login_status_consumer(&login_status_consumer); | 1920 controller->set_login_status_consumer(&login_status_consumer); |
1484 login_wait_run_loop.Run(); | 1921 login_wait_run_loop.Run(); |
1485 controller->set_login_status_consumer(NULL); | 1922 controller->set_login_status_consumer(NULL); |
1486 | 1923 |
1487 // Verify that the Terms of Service screen is being shown. | 1924 // Verify that the Terms of Service screen is being shown. |
1488 chromeos::WizardController* wizard_controller = | 1925 chromeos::WizardController* wizard_controller = |
1489 chromeos::WizardController::default_controller(); | 1926 chromeos::WizardController::default_controller(); |
1490 ASSERT_TRUE(wizard_controller); | 1927 ASSERT_TRUE(wizard_controller); |
1491 ASSERT_TRUE(wizard_controller->current_screen()); | 1928 ASSERT_TRUE(wizard_controller->current_screen()); |
1492 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, | 1929 EXPECT_EQ(chromeos::WizardController::kTermsOfServiceScreenName, |
1493 wizard_controller->current_screen()->GetName()); | 1930 wizard_controller->current_screen()->GetName()); |
1494 | 1931 |
1495 // Wait for the Terms of Service to finish downloading, then get the status of | 1932 // Wait for the Terms of Service to finish downloading, then get the status of |
1496 // the screen's UI elements. | 1933 // the screen's UI elements. |
1497 content::WebContents* contents = NULL; | |
1498 ASSERT_NO_FATAL_FAILURE(GetWebContents(&contents)); | |
1499 std::string json; | 1934 std::string json; |
1500 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, | 1935 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
1501 "var screenElement = document.getElementById('terms-of-service');" | 1936 "var screenElement = document.getElementById('terms-of-service');" |
1502 "function SendReplyIfDownloadDone() {" | 1937 "function SendReplyIfDownloadDone() {" |
1503 " if (screenElement.classList.contains('tos-loading'))" | 1938 " if (screenElement.classList.contains('tos-loading'))" |
1504 " return false;" | 1939 " return false;" |
1505 " var status = {};" | 1940 " var status = {};" |
1506 " status.heading = document.getElementById('tos-heading').textContent;" | 1941 " status.heading = document.getElementById('tos-heading').textContent;" |
1507 " status.subheading =" | 1942 " status.subheading =" |
1508 " document.getElementById('tos-subheading').textContent;" | 1943 " document.getElementById('tos-subheading').textContent;" |
1509 " status.contentHeading =" | 1944 " status.contentHeading =" |
1510 " document.getElementById('tos-content-heading').textContent;" | 1945 " document.getElementById('tos-content-heading').textContent;" |
1511 " status.content =" | 1946 " status.content =" |
1512 " document.getElementById('tos-content-main').textContent;" | 1947 " document.getElementById('tos-content-main').textContent;" |
1513 " status.error = screenElement.classList.contains('error');" | 1948 " status.error = screenElement.classList.contains('error');" |
1514 " status.acceptEnabled =" | 1949 " status.acceptEnabled =" |
1515 " !document.getElementById('tos-accept-button').disabled;" | 1950 " !document.getElementById('tos-accept-button').disabled;" |
1516 " domAutomationController.send(JSON.stringify(status));" | 1951 " domAutomationController.send(JSON.stringify(status));" |
1517 " observer.disconnect();" | 1952 " observer.disconnect();" |
1518 " return true;" | 1953 " return true;" |
1519 "}" | 1954 "}" |
1520 "var observer = new MutationObserver(SendReplyIfDownloadDone);" | 1955 "var observer = new MutationObserver(SendReplyIfDownloadDone);" |
1521 "if (!SendReplyIfDownloadDone()) {" | 1956 "if (!SendReplyIfDownloadDone()) {" |
1522 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | 1957 " var options = { attributes: true, attributeFilter: [ 'class' ] };" |
1523 " observer.observe(screenElement, options);" | 1958 " observer.observe(screenElement, options);" |
1524 "}", | 1959 "}", |
1525 &json)); | 1960 &json)); |
1526 scoped_ptr<base::Value> value_ptr(base::JSONReader::Read(json)); | 1961 scoped_ptr<base::Value> value_ptr(base::JSONReader::Read(json)); |
1527 const base::DictionaryValue* status = NULL; | 1962 const base::DictionaryValue* status = NULL; |
1528 ASSERT_TRUE(value_ptr.get()); | 1963 ASSERT_TRUE(value_ptr); |
1529 ASSERT_TRUE(value_ptr->GetAsDictionary(&status)); | 1964 ASSERT_TRUE(value_ptr->GetAsDictionary(&status)); |
1530 std::string heading; | 1965 std::string heading; |
1531 EXPECT_TRUE(status->GetString("heading", &heading)); | 1966 EXPECT_TRUE(status->GetString("heading", &heading)); |
1532 std::string subheading; | 1967 std::string subheading; |
1533 EXPECT_TRUE(status->GetString("subheading", &subheading)); | 1968 EXPECT_TRUE(status->GetString("subheading", &subheading)); |
1534 std::string content_heading; | 1969 std::string content_heading; |
1535 EXPECT_TRUE(status->GetString("contentHeading", &content_heading)); | 1970 EXPECT_TRUE(status->GetString("contentHeading", &content_heading)); |
1536 std::string content; | 1971 std::string content; |
1537 EXPECT_TRUE(status->GetString("content", &content)); | 1972 EXPECT_TRUE(status->GetString("content", &content)); |
1538 bool error; | 1973 bool error; |
(...skipping 28 matching lines...) Expand all Loading... |
1567 base::FilePath test_dir; | 2002 base::FilePath test_dir; |
1568 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 2003 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
1569 std::string terms_of_service; | 2004 std::string terms_of_service; |
1570 ASSERT_TRUE(base::ReadFileToString( | 2005 ASSERT_TRUE(base::ReadFileToString( |
1571 test_dir.Append(kExistentTermsOfServicePath), &terms_of_service)); | 2006 test_dir.Append(kExistentTermsOfServicePath), &terms_of_service)); |
1572 EXPECT_EQ(terms_of_service, content); | 2007 EXPECT_EQ(terms_of_service, content); |
1573 EXPECT_FALSE(error); | 2008 EXPECT_FALSE(error); |
1574 EXPECT_TRUE(accept_enabled); | 2009 EXPECT_TRUE(accept_enabled); |
1575 | 2010 |
1576 // Click the accept button. | 2011 // Click the accept button. |
1577 ASSERT_TRUE(content::ExecuteScript(contents, | 2012 ASSERT_TRUE(content::ExecuteScript(contents_, |
1578 "$('tos-accept-button').click();")); | 2013 "$('tos-accept-button').click();")); |
1579 | 2014 |
1580 WaitForSessionStart(); | 2015 WaitForSessionStart(); |
1581 } | 2016 } |
1582 | 2017 |
1583 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2018 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
1584 TermsOfServiceDownloadTest, testing::Bool()); | 2019 TermsOfServiceDownloadTest, testing::Bool()); |
1585 | 2020 |
1586 } // namespace policy | 2021 } // namespace policy |
OLD | NEW |