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 <set> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 412 } |
413 | 413 |
414 } // namespace | 414 } // namespace |
415 | 415 |
416 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, | 416 class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, |
417 public user_manager::UserManager::Observer, | 417 public user_manager::UserManager::Observer, |
418 public chrome::BrowserListObserver, | 418 public chrome::BrowserListObserver, |
419 public extensions::AppWindowRegistry::Observer { | 419 public extensions::AppWindowRegistry::Observer { |
420 protected: | 420 protected: |
421 DeviceLocalAccountTest() | 421 DeviceLocalAccountTest() |
422 : public_session_input_method_id_( | 422 : user_id_1_(GenerateDeviceLocalAccountUserId( |
423 base::StringPrintf(kPublicSessionInputMethodIDTemplate, | 423 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
424 chromeos::extension_ime_util::kXkbExtensionId)), | 424 user_id_2_(GenerateDeviceLocalAccountUserId( |
| 425 kAccountId2, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
| 426 public_session_input_method_id_(base::StringPrintf( |
| 427 kPublicSessionInputMethodIDTemplate, |
| 428 chromeos::extension_ime_util::kXkbExtensionId)), |
425 contents_(NULL) { | 429 contents_(NULL) { |
426 set_exit_when_last_browser_closes(false); | 430 set_exit_when_last_browser_closes(false); |
427 } | 431 } |
428 | 432 |
429 ~DeviceLocalAccountTest() override {} | 433 ~DeviceLocalAccountTest() override {} |
430 | 434 |
431 void SetUp() override { | 435 void SetUp() override { |
432 // Configure and start the test server. | 436 // Configure and start the test server. |
433 scoped_ptr<crypto::RSAPrivateKey> signing_key( | 437 scoped_ptr<crypto::RSAPrivateKey> signing_key( |
434 PolicyBuilder::CreateTestSigningKey()); | 438 PolicyBuilder::CreateTestSigningKey()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 em::DeviceLocalAccountsProto* device_local_accounts = | 627 em::DeviceLocalAccountsProto* device_local_accounts = |
624 proto.mutable_device_local_accounts(); | 628 proto.mutable_device_local_accounts(); |
625 device_local_accounts->set_auto_login_id(kAccountId1); | 629 device_local_accounts->set_auto_login_id(kAccountId1); |
626 device_local_accounts->set_auto_login_delay(0); | 630 device_local_accounts->set_auto_login_delay(0); |
627 RefreshDevicePolicy(); | 631 RefreshDevicePolicy(); |
628 ASSERT_TRUE(test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, | 632 ASSERT_TRUE(test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
629 std::string(), | 633 std::string(), |
630 proto.SerializeAsString())); | 634 proto.SerializeAsString())); |
631 } | 635 } |
632 | 636 |
633 void CheckPublicSessionPresent(const AccountId& account_id) { | 637 void CheckPublicSessionPresent(const std::string& id) { |
634 const user_manager::User* user = | 638 const user_manager::User* user = |
635 user_manager::UserManager::Get()->FindUser(account_id); | 639 user_manager::UserManager::Get()->FindUser(id); |
636 ASSERT_TRUE(user); | 640 ASSERT_TRUE(user); |
637 EXPECT_EQ(account_id, user->GetAccountId()); | 641 EXPECT_EQ(id, user->email()); |
638 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 642 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
639 } | 643 } |
640 | 644 |
641 base::FilePath GetExtensionCacheDirectoryForAccountID( | 645 base::FilePath GetExtensionCacheDirectoryForAccountID( |
642 const std::string& account_id) { | 646 const std::string& account_id) { |
643 base::FilePath extension_cache_root_dir; | 647 base::FilePath extension_cache_root_dir; |
644 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, | 648 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, |
645 &extension_cache_root_dir)) { | 649 &extension_cache_root_dir)) { |
646 ADD_FAILURE(); | 650 ADD_FAILURE(); |
647 } | 651 } |
(...skipping 25 matching lines...) Expand all Loading... |
673 const std::string& expected_display_name) { | 677 const std::string& expected_display_name) { |
674 DictionaryPrefValueWaiter("UserDisplayName", | 678 DictionaryPrefValueWaiter("UserDisplayName", |
675 user_id, | 679 user_id, |
676 expected_display_name).Wait(); | 680 expected_display_name).Wait(); |
677 } | 681 } |
678 | 682 |
679 void WaitForPolicy() { | 683 void WaitForPolicy() { |
680 // Wait for the display name becoming available as that indicates | 684 // Wait for the display name becoming available as that indicates |
681 // device-local account policy is fully loaded, which is a prerequisite for | 685 // device-local account policy is fully loaded, which is a prerequisite for |
682 // successful login. | 686 // successful login. |
683 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); | 687 WaitForDisplayName(user_id_1_, kDisplayName1); |
684 } | 688 } |
685 | 689 |
686 void ExpandPublicSessionPod(bool expect_advanced) { | 690 void ExpandPublicSessionPod(bool expect_advanced) { |
687 bool advanced = false; | 691 bool advanced = false; |
688 // Click on the pod to expand it. | 692 // Click on the pod to expand it. |
689 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 693 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
690 contents_, | 694 contents_, |
691 base::StringPrintf( | 695 base::StringPrintf( |
692 "var pod =" | 696 "var pod =" |
693 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 697 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
694 "pod.click();" | 698 "pod.click();" |
695 "domAutomationController.send(pod.classList.contains('advanced'));", | 699 "domAutomationController.send(pod.classList.contains('advanced'));", |
696 account_id_1_.GetUserEmail().c_str()), | 700 user_id_1_.c_str()), |
697 &advanced)); | 701 &advanced)); |
698 // Verify that the pod expanded to its basic/advanced form, as expected. | 702 // Verify that the pod expanded to its basic/advanced form, as expected. |
699 EXPECT_EQ(expect_advanced, advanced); | 703 EXPECT_EQ(expect_advanced, advanced); |
700 | 704 |
701 // Verify that the construction of the pod's language list did not affect | 705 // Verify that the construction of the pod's language list did not affect |
702 // the current ICU locale. | 706 // the current ICU locale. |
703 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 707 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
704 } | 708 } |
705 | 709 |
706 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. | 710 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. |
(...skipping 23 matching lines...) Expand all Loading... |
730 chromeos::LoginDisplayHostImpl* host = | 734 chromeos::LoginDisplayHostImpl* host = |
731 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( | 735 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( |
732 chromeos::LoginDisplayHostImpl::default_host()); | 736 chromeos::LoginDisplayHostImpl::default_host()); |
733 ASSERT_TRUE(host); | 737 ASSERT_TRUE(host); |
734 host->StartSignInScreen(LoginScreenContext()); | 738 host->StartSignInScreen(LoginScreenContext()); |
735 chromeos::ExistingUserController* controller = | 739 chromeos::ExistingUserController* controller = |
736 chromeos::ExistingUserController::current_controller(); | 740 chromeos::ExistingUserController::current_controller(); |
737 ASSERT_TRUE(controller); | 741 ASSERT_TRUE(controller); |
738 | 742 |
739 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 743 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
740 account_id_1_.GetUserEmail()); | 744 user_id_1_); |
741 user_context.SetPublicSessionLocale(locale); | 745 user_context.SetPublicSessionLocale(locale); |
742 user_context.SetPublicSessionInputMethod(input_method); | 746 user_context.SetPublicSessionInputMethod(input_method); |
743 controller->Login(user_context, chromeos::SigninSpecifics()); | 747 controller->Login(user_context, chromeos::SigninSpecifics()); |
744 } | 748 } |
745 | 749 |
746 void WaitForSessionStart() { | 750 void WaitForSessionStart() { |
747 if (IsSessionStarted()) | 751 if (IsSessionStarted()) |
748 return; | 752 return; |
749 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 753 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
750 base::Bind(IsSessionStarted)).Wait(); | 754 base::Bind(IsSessionStarted)).Wait(); |
(...skipping 25 matching lines...) Expand all Loading... |
776 WaitForPolicy(); | 780 WaitForPolicy(); |
777 | 781 |
778 WaitForSessionStart(); | 782 WaitForSessionStart(); |
779 | 783 |
780 EXPECT_EQ(locales[0], g_browser_process->GetApplicationLocale()); | 784 EXPECT_EQ(locales[0], g_browser_process->GetApplicationLocale()); |
781 EXPECT_EQ(l10n_util::GetLanguage(locales[0]), | 785 EXPECT_EQ(l10n_util::GetLanguage(locales[0]), |
782 icu::Locale::getDefault().getLanguage()); | 786 icu::Locale::getDefault().getLanguage()); |
783 VerifyKeyboardLayoutMatchesLocale(); | 787 VerifyKeyboardLayoutMatchesLocale(); |
784 } | 788 } |
785 | 789 |
786 const AccountId account_id_1_ = | 790 const std::string user_id_1_; |
787 AccountId::FromUserEmail(GenerateDeviceLocalAccountUserId( | 791 const std::string user_id_2_; |
788 kAccountId1, | |
789 DeviceLocalAccount::TYPE_PUBLIC_SESSION)); | |
790 const AccountId account_id_2_ = | |
791 AccountId::FromUserEmail(GenerateDeviceLocalAccountUserId( | |
792 kAccountId2, | |
793 DeviceLocalAccount::TYPE_PUBLIC_SESSION)); | |
794 const std::string public_session_input_method_id_; | 792 const std::string public_session_input_method_id_; |
795 | 793 |
796 std::string initial_locale_; | 794 std::string initial_locale_; |
797 std::string initial_language_; | 795 std::string initial_language_; |
798 | 796 |
799 scoped_ptr<base::RunLoop> run_loop_; | 797 scoped_ptr<base::RunLoop> run_loop_; |
800 | 798 |
801 UserPolicyBuilder device_local_account_policy_; | 799 UserPolicyBuilder device_local_account_policy_; |
802 LocalPolicyTestServer test_server_; | 800 LocalPolicyTestServer test_server_; |
803 | 801 |
804 content::WebContents* contents_; | 802 content::WebContents* contents_; |
805 | 803 |
806 private: | 804 private: |
807 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 805 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
808 }; | 806 }; |
809 | 807 |
810 static bool IsKnownUser(const AccountId& account_id) { | 808 static bool IsKnownUser(const std::string& account_id) { |
811 return user_manager::UserManager::Get()->IsKnownUser(account_id); | 809 return user_manager::UserManager::Get()->IsKnownUser(account_id); |
812 } | 810 } |
813 | 811 |
814 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { | 812 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { |
815 AddPublicSessionToDevicePolicy(kAccountId1); | 813 AddPublicSessionToDevicePolicy(kAccountId1); |
816 AddPublicSessionToDevicePolicy(kAccountId2); | 814 AddPublicSessionToDevicePolicy(kAccountId2); |
817 | 815 |
818 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 816 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
819 base::Bind(&IsKnownUser, account_id_1_)) | 817 base::Bind(&IsKnownUser, user_id_1_)) |
820 .Wait(); | 818 .Wait(); |
821 EXPECT_TRUE(IsKnownUser(account_id_2_)); | 819 EXPECT_TRUE(IsKnownUser(user_id_2_)); |
822 | 820 |
823 CheckPublicSessionPresent(account_id_1_); | 821 CheckPublicSessionPresent(user_id_1_); |
824 CheckPublicSessionPresent(account_id_2_); | 822 CheckPublicSessionPresent(user_id_2_); |
825 } | 823 } |
826 | 824 |
827 // Flaky: http://crbug.com/512670. | 825 // Flaky: http://crbug.com/512670. |
828 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { | 826 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { |
829 UploadAndInstallDeviceLocalAccountPolicy(); | 827 UploadAndInstallDeviceLocalAccountPolicy(); |
830 AddPublicSessionToDevicePolicy(kAccountId1); | 828 AddPublicSessionToDevicePolicy(kAccountId1); |
831 | 829 |
832 WaitForPolicy(); | 830 WaitForPolicy(); |
833 | 831 |
834 // Verify that the display name is shown in the UI. | 832 // Verify that the display name is shown in the UI. |
835 const std::string get_compact_pod_display_name = base::StringPrintf( | 833 const std::string get_compact_pod_display_name = base::StringPrintf( |
836 "domAutomationController.send(document.getElementById('pod-row')" | 834 "domAutomationController.send(document.getElementById('pod-row')" |
837 " .getPodWithUsername_('%s').nameElement.textContent);", | 835 " .getPodWithUsername_('%s').nameElement.textContent);", |
838 account_id_1_.GetUserEmail().c_str()); | 836 user_id_1_.c_str()); |
839 std::string display_name; | 837 std::string display_name; |
840 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 838 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
841 contents_, | 839 contents_, |
842 get_compact_pod_display_name, | 840 get_compact_pod_display_name, |
843 &display_name)); | 841 &display_name)); |
844 EXPECT_EQ(kDisplayName1, display_name); | 842 EXPECT_EQ(kDisplayName1, display_name); |
845 const std::string get_expanded_pod_display_name = base::StringPrintf( | 843 const std::string get_expanded_pod_display_name = base::StringPrintf( |
846 "domAutomationController.send(document.getElementById('pod-row')" | 844 "domAutomationController.send(document.getElementById('pod-row')" |
847 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" | 845 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" |
848 " .textContent);", | 846 " .textContent);", |
849 account_id_1_.GetUserEmail().c_str()); | 847 user_id_1_.c_str()); |
850 display_name.clear(); | 848 display_name.clear(); |
851 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 849 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
852 contents_, | 850 contents_, |
853 get_expanded_pod_display_name, | 851 get_expanded_pod_display_name, |
854 &display_name)); | 852 &display_name)); |
855 EXPECT_EQ(kDisplayName1, display_name); | 853 EXPECT_EQ(kDisplayName1, display_name); |
856 | 854 |
857 // Click on the pod to expand it. | 855 // Click on the pod to expand it. |
858 ASSERT_TRUE(content::ExecuteScript( | 856 ASSERT_TRUE(content::ExecuteScript( |
859 contents_, | 857 contents_, |
860 base::StringPrintf( | 858 base::StringPrintf( |
861 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 859 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
862 " .click();", | 860 " .click();", |
863 account_id_1_.GetUserEmail().c_str()))); | 861 user_id_1_.c_str()))); |
864 | 862 |
865 // Change the display name. | 863 // Change the display name. |
866 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 864 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
867 kDisplayName2); | 865 kDisplayName2); |
868 UploadAndInstallDeviceLocalAccountPolicy(); | 866 UploadAndInstallDeviceLocalAccountPolicy(); |
869 policy::BrowserPolicyConnectorChromeOS* connector = | 867 policy::BrowserPolicyConnectorChromeOS* connector = |
870 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 868 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
871 DeviceLocalAccountPolicyBroker* broker = | 869 DeviceLocalAccountPolicyBroker* broker = |
872 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 870 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
873 account_id_1_.GetUserEmail()); | 871 user_id_1_); |
874 ASSERT_TRUE(broker); | 872 ASSERT_TRUE(broker); |
875 broker->core()->store()->Load(); | 873 broker->core()->store()->Load(); |
876 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName2); | 874 WaitForDisplayName(user_id_1_, kDisplayName2); |
877 | 875 |
878 // Verify that the new display name is shown in the UI. | 876 // Verify that the new display name is shown in the UI. |
879 display_name.clear(); | 877 display_name.clear(); |
880 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 878 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
881 contents_, | 879 contents_, |
882 get_compact_pod_display_name, | 880 get_compact_pod_display_name, |
883 &display_name)); | 881 &display_name)); |
884 EXPECT_EQ(kDisplayName2, display_name); | 882 EXPECT_EQ(kDisplayName2, display_name); |
885 display_name.clear(); | 883 display_name.clear(); |
886 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 884 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
887 contents_, | 885 contents_, |
888 get_expanded_pod_display_name, | 886 get_expanded_pod_display_name, |
889 &display_name)); | 887 &display_name)); |
890 EXPECT_EQ(kDisplayName2, display_name); | 888 EXPECT_EQ(kDisplayName2, display_name); |
891 | 889 |
892 // Verify that the pod is still expanded. This indicates that the UI updated | 890 // Verify that the pod is still expanded. This indicates that the UI updated |
893 // without reloading and losing state. | 891 // without reloading and losing state. |
894 bool expanded = false; | 892 bool expanded = false; |
895 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 893 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
896 contents_, | 894 contents_, |
897 base::StringPrintf( | 895 base::StringPrintf( |
898 "domAutomationController.send(document.getElementById('pod-row')" | 896 "domAutomationController.send(document.getElementById('pod-row')" |
899 " .getPodWithUsername_('%s').expanded);", | 897 " .getPodWithUsername_('%s').expanded);", |
900 account_id_1_.GetUserEmail().c_str()), | 898 user_id_1_.c_str()), |
901 &expanded)); | 899 &expanded)); |
902 EXPECT_TRUE(expanded); | 900 EXPECT_TRUE(expanded); |
903 } | 901 } |
904 | 902 |
905 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { | 903 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { |
906 UploadDeviceLocalAccountPolicy(); | 904 UploadDeviceLocalAccountPolicy(); |
907 AddPublicSessionToDevicePolicy(kAccountId1); | 905 AddPublicSessionToDevicePolicy(kAccountId1); |
908 | 906 |
909 WaitForPolicy(); | 907 WaitForPolicy(); |
910 | 908 |
911 // Sanity check: The policy should be present now. | 909 // Sanity check: The policy should be present now. |
912 ASSERT_FALSE(session_manager_client()->device_local_account_policy( | 910 ASSERT_FALSE(session_manager_client()->device_local_account_policy( |
913 kAccountId1).empty()); | 911 kAccountId1).empty()); |
914 } | 912 } |
915 | 913 |
916 static bool IsNotKnownUser(const AccountId& account_id) { | 914 static bool IsNotKnownUser(const std::string& account_id) { |
917 return !IsKnownUser(account_id); | 915 return !IsKnownUser(account_id); |
918 } | 916 } |
919 | 917 |
920 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, AccountListChange) { | 918 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, AccountListChange) { |
921 AddPublicSessionToDevicePolicy(kAccountId1); | 919 AddPublicSessionToDevicePolicy(kAccountId1); |
922 AddPublicSessionToDevicePolicy(kAccountId2); | 920 AddPublicSessionToDevicePolicy(kAccountId2); |
923 | 921 |
924 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 922 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
925 base::Bind(&IsKnownUser, account_id_1_)) | 923 base::Bind(&IsKnownUser, user_id_1_)) |
926 .Wait(); | 924 .Wait(); |
927 EXPECT_TRUE(IsKnownUser(account_id_2_)); | 925 EXPECT_TRUE(IsKnownUser(user_id_2_)); |
928 | 926 |
929 // Update policy to remove kAccountId2. | 927 // Update policy to remove kAccountId2. |
930 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 928 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
931 proto.mutable_device_local_accounts()->clear_account(); | 929 proto.mutable_device_local_accounts()->clear_account(); |
932 AddPublicSessionToDevicePolicy(kAccountId1); | 930 AddPublicSessionToDevicePolicy(kAccountId1); |
933 | 931 |
934 em::ChromeDeviceSettingsProto policy; | 932 em::ChromeDeviceSettingsProto policy; |
935 policy.mutable_show_user_names()->set_show_user_names(true); | 933 policy.mutable_show_user_names()->set_show_user_names(true); |
936 em::DeviceLocalAccountInfoProto* account1 = | 934 em::DeviceLocalAccountInfoProto* account1 = |
937 policy.mutable_device_local_accounts()->add_account(); | 935 policy.mutable_device_local_accounts()->add_account(); |
938 account1->set_account_id(kAccountId1); | 936 account1->set_account_id(kAccountId1); |
939 account1->set_type( | 937 account1->set_type( |
940 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 938 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
941 | 939 |
942 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), | 940 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), |
943 policy.SerializeAsString()); | 941 policy.SerializeAsString()); |
944 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); | 942 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); |
945 | 943 |
946 // Make sure the second device-local account disappears. | 944 // Make sure the second device-local account disappears. |
947 content::WindowedNotificationObserver( | 945 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
948 chrome::NOTIFICATION_USER_LIST_CHANGED, | 946 base::Bind(&IsNotKnownUser, user_id_2_)) |
949 base::Bind(&IsNotKnownUser, account_id_2_)) | |
950 .Wait(); | 947 .Wait(); |
951 } | 948 } |
952 | 949 |
953 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { | 950 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { |
954 // Specify startup pages. | 951 // Specify startup pages. |
955 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( | 952 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( |
956 SessionStartupPref::kPrefValueURLs); | 953 SessionStartupPref::kPrefValueURLs); |
957 em::StringListPolicyProto* startup_urls_proto = | 954 em::StringListPolicyProto* startup_urls_proto = |
958 device_local_account_policy_.payload().mutable_restoreonstartupurls(); | 955 device_local_account_policy_.payload().mutable_restoreonstartupurls(); |
959 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) | 956 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 // Verify that the app was downloaded to the account's extension cache. | 1071 // Verify that the app was downloaded to the account's extension cache. |
1075 base::FilePath test_dir; | 1072 base::FilePath test_dir; |
1076 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 1073 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
1077 EXPECT_TRUE(ContentsEqual( | 1074 EXPECT_TRUE(ContentsEqual( |
1078 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion), | 1075 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion), |
1079 test_dir.Append(kHostedAppCRXPath))); | 1076 test_dir.Append(kHostedAppCRXPath))); |
1080 | 1077 |
1081 // Verify that the extension was removed from the account's extension cache | 1078 // Verify that the extension was removed from the account's extension cache |
1082 // after the installation failure. | 1079 // after the installation failure. |
1083 DeviceLocalAccountPolicyBroker* broker = | 1080 DeviceLocalAccountPolicyBroker* broker = |
1084 g_browser_process->platform_part() | 1081 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
1085 ->browser_policy_connector_chromeos() | 1082 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); |
1086 ->GetDeviceLocalAccountPolicyService() | |
1087 ->GetBrokerForUser(account_id_1_.GetUserEmail()); | |
1088 ASSERT_TRUE(broker); | 1083 ASSERT_TRUE(broker); |
1089 chromeos::ExternalCache* cache = | 1084 chromeos::ExternalCache* cache = |
1090 broker->extension_loader()->GetExternalCacheForTesting(); | 1085 broker->extension_loader()->GetExternalCacheForTesting(); |
1091 ASSERT_TRUE(cache); | 1086 ASSERT_TRUE(cache); |
1092 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); | 1087 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); |
1093 } | 1088 } |
1094 | 1089 |
1095 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { | 1090 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { |
1096 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1091 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
1097 | 1092 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); | 1144 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); |
1150 | 1145 |
1151 // Verify that the extension was not installed. | 1146 // Verify that the extension was not installed. |
1152 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); | 1147 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); |
1153 | 1148 |
1154 // Verify that the app is still in the account's extension cache. | 1149 // Verify that the app is still in the account's extension cache. |
1155 EXPECT_TRUE(PathExists(cached_hosted_app)); | 1150 EXPECT_TRUE(PathExists(cached_hosted_app)); |
1156 | 1151 |
1157 // Verify that the extension was removed from the account's extension cache. | 1152 // Verify that the extension was removed from the account's extension cache. |
1158 DeviceLocalAccountPolicyBroker* broker = | 1153 DeviceLocalAccountPolicyBroker* broker = |
1159 g_browser_process->platform_part() | 1154 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
1160 ->browser_policy_connector_chromeos() | 1155 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); |
1161 ->GetDeviceLocalAccountPolicyService() | |
1162 ->GetBrokerForUser(account_id_1_.GetUserEmail()); | |
1163 ASSERT_TRUE(broker); | 1156 ASSERT_TRUE(broker); |
1164 chromeos::ExternalCache* cache = | 1157 chromeos::ExternalCache* cache = |
1165 broker->extension_loader()->GetExternalCacheForTesting(); | 1158 broker->extension_loader()->GetExternalCacheForTesting(); |
1166 ASSERT_TRUE(cache); | 1159 ASSERT_TRUE(cache); |
1167 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); | 1160 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); |
1168 } | 1161 } |
1169 | 1162 |
1170 static void OnPutExtension(scoped_ptr<base::RunLoop>* run_loop, | 1163 static void OnPutExtension(scoped_ptr<base::RunLoop>* run_loop, |
1171 const base::FilePath& file_path, | 1164 const base::FilePath& file_path, |
1172 bool file_ownership_passed) { | 1165 bool file_ownership_passed) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 test::ConstructExternalDataReference(kExternalDataURL, kExternalData); | 1304 test::ConstructExternalDataReference(kExternalDataURL, kExternalData); |
1312 std::string policy; | 1305 std::string policy; |
1313 base::JSONWriter::Write(*metadata, &policy); | 1306 base::JSONWriter::Write(*metadata, &policy); |
1314 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( | 1307 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( |
1315 policy); | 1308 policy); |
1316 UploadAndInstallDeviceLocalAccountPolicy(); | 1309 UploadAndInstallDeviceLocalAccountPolicy(); |
1317 policy::BrowserPolicyConnectorChromeOS* connector = | 1310 policy::BrowserPolicyConnectorChromeOS* connector = |
1318 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1311 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1319 DeviceLocalAccountPolicyBroker* broker = | 1312 DeviceLocalAccountPolicyBroker* broker = |
1320 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 1313 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
1321 account_id_1_.GetUserEmail()); | 1314 user_id_1_); |
1322 ASSERT_TRUE(broker); | 1315 ASSERT_TRUE(broker); |
1323 broker->core()->store()->Load(); | 1316 broker->core()->store()->Load(); |
1324 | 1317 |
1325 // The external data should be fetched and cached automatically. Wait for this | 1318 // The external data should be fetched and cached automatically. Wait for this |
1326 // fetch. | 1319 // fetch. |
1327 run_loop->Run(); | 1320 run_loop->Run(); |
1328 | 1321 |
1329 // Stop serving external data at |kExternalDataURL|. | 1322 // Stop serving external data at |kExternalDataURL|. |
1330 fetcher_factory.reset(); | 1323 fetcher_factory.reset(); |
1331 | 1324 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 .spec(), | 1394 .spec(), |
1402 image_data), | 1395 image_data), |
1403 &policy); | 1396 &policy); |
1404 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( | 1397 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( |
1405 policy); | 1398 policy); |
1406 UploadAndInstallDeviceLocalAccountPolicy(); | 1399 UploadAndInstallDeviceLocalAccountPolicy(); |
1407 policy::BrowserPolicyConnectorChromeOS* connector = | 1400 policy::BrowserPolicyConnectorChromeOS* connector = |
1408 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1401 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1409 DeviceLocalAccountPolicyBroker* broker = | 1402 DeviceLocalAccountPolicyBroker* broker = |
1410 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 1403 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
1411 account_id_1_.GetUserEmail()); | 1404 user_id_1_); |
1412 ASSERT_TRUE(broker); | 1405 ASSERT_TRUE(broker); |
1413 | 1406 |
1414 run_loop_.reset(new base::RunLoop); | 1407 run_loop_.reset(new base::RunLoop); |
1415 user_manager::UserManager::Get()->AddObserver(this); | 1408 user_manager::UserManager::Get()->AddObserver(this); |
1416 broker->core()->store()->Load(); | 1409 broker->core()->store()->Load(); |
1417 run_loop_->Run(); | 1410 run_loop_->Run(); |
1418 user_manager::UserManager::Get()->RemoveObserver(this); | 1411 user_manager::UserManager::Get()->RemoveObserver(this); |
1419 | 1412 |
1420 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader( | 1413 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader( |
1421 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load(); | 1414 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load(); |
1422 ASSERT_TRUE(policy_image); | 1415 ASSERT_TRUE(policy_image); |
1423 | 1416 |
1424 const user_manager::User* user = | 1417 const user_manager::User* user = |
1425 user_manager::UserManager::Get()->FindUser(account_id_1_); | 1418 user_manager::UserManager::Get()->FindUser(user_id_1_); |
1426 ASSERT_TRUE(user); | 1419 ASSERT_TRUE(user); |
1427 | 1420 |
1428 base::FilePath user_data_dir; | 1421 base::FilePath user_data_dir; |
1429 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 1422 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
1430 const base::FilePath saved_image_path = | 1423 const base::FilePath saved_image_path = |
1431 user_data_dir.Append(account_id_1_.GetUserEmail()).AddExtension("jpg"); | 1424 user_data_dir.Append(user_id_1_).AddExtension("jpg"); |
1432 | 1425 |
1433 EXPECT_FALSE(user->HasDefaultImage()); | 1426 EXPECT_FALSE(user->HasDefaultImage()); |
1434 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, user->image_index()); | 1427 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, user->image_index()); |
1435 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); | 1428 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); |
1436 const base::DictionaryValue* images_pref = | 1429 const base::DictionaryValue* images_pref = |
1437 g_browser_process->local_state()->GetDictionary("user_image_info"); | 1430 g_browser_process->local_state()->GetDictionary("user_image_info"); |
1438 ASSERT_TRUE(images_pref); | 1431 ASSERT_TRUE(images_pref); |
1439 const base::DictionaryValue* image_properties; | 1432 const base::DictionaryValue* image_properties; |
1440 ASSERT_TRUE(images_pref->GetDictionaryWithoutPathExpansion( | 1433 ASSERT_TRUE(images_pref->GetDictionaryWithoutPathExpansion( |
1441 account_id_1_.GetUserEmail(), &image_properties)); | 1434 user_id_1_, |
| 1435 &image_properties)); |
1442 int image_index; | 1436 int image_index; |
1443 std::string image_path; | 1437 std::string image_path; |
1444 ASSERT_TRUE(image_properties->GetInteger("index", &image_index)); | 1438 ASSERT_TRUE(image_properties->GetInteger("index", &image_index)); |
1445 ASSERT_TRUE(image_properties->GetString("path", &image_path)); | 1439 ASSERT_TRUE(image_properties->GetString("path", &image_path)); |
1446 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, image_index); | 1440 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, image_index); |
1447 EXPECT_EQ(saved_image_path.value(), image_path); | 1441 EXPECT_EQ(saved_image_path.value(), image_path); |
1448 | 1442 |
1449 scoped_ptr<gfx::ImageSkia> saved_image = | 1443 scoped_ptr<gfx::ImageSkia> saved_image = |
1450 chromeos::test::ImageLoader(saved_image_path).Load(); | 1444 chromeos::test::ImageLoader(saved_image_path).Load(); |
1451 ASSERT_TRUE(saved_image); | 1445 ASSERT_TRUE(saved_image); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 WaitForPolicy(); | 1611 WaitForPolicy(); |
1618 | 1612 |
1619 ExpandPublicSessionPod(false); | 1613 ExpandPublicSessionPod(false); |
1620 | 1614 |
1621 // Click the enter button to start the session. | 1615 // Click the enter button to start the session. |
1622 ASSERT_TRUE(content::ExecuteScript( | 1616 ASSERT_TRUE(content::ExecuteScript( |
1623 contents_, | 1617 contents_, |
1624 base::StringPrintf( | 1618 base::StringPrintf( |
1625 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1619 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1626 " .querySelector('.enter-button').click();", | 1620 " .querySelector('.enter-button').click();", |
1627 account_id_1_.GetUserEmail().c_str()))); | 1621 user_id_1_.c_str()))); |
1628 | 1622 |
1629 WaitForSessionStart(); | 1623 WaitForSessionStart(); |
1630 | 1624 |
1631 // Verify that the locale has not changed and the first keyboard layout | 1625 // Verify that the locale has not changed and the first keyboard layout |
1632 // applicable to the locale was chosen. | 1626 // applicable to the locale was chosen. |
1633 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 1627 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
1634 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 1628 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
1635 VerifyKeyboardLayoutMatchesLocale(); | 1629 VerifyKeyboardLayoutMatchesLocale(); |
1636 } | 1630 } |
1637 | 1631 |
1638 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1632 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
1639 UploadAndInstallDeviceLocalAccountPolicy(); | 1633 UploadAndInstallDeviceLocalAccountPolicy(); |
1640 AddPublicSessionToDevicePolicy(kAccountId1); | 1634 AddPublicSessionToDevicePolicy(kAccountId1); |
1641 | 1635 |
1642 WaitForPolicy(); | 1636 WaitForPolicy(); |
1643 | 1637 |
1644 ExpandPublicSessionPod(false); | 1638 ExpandPublicSessionPod(false); |
1645 | 1639 |
1646 // Click the link that switches the pod to its advanced form. Verify that the | 1640 // Click the link that switches the pod to its advanced form. Verify that the |
1647 // pod switches from basic to advanced. | 1641 // pod switches from basic to advanced. |
1648 bool advanced = false; | 1642 bool advanced = false; |
1649 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1643 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1650 contents_, | 1644 contents_, |
1651 base::StringPrintf( | 1645 base::StringPrintf( |
1652 "var pod =" | 1646 "var pod =" |
1653 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1647 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1654 "pod.querySelector('.language-and-input').click();" | 1648 "pod.querySelector('.language-and-input').click();" |
1655 "domAutomationController.send(pod.classList.contains('advanced'));", | 1649 "domAutomationController.send(pod.classList.contains('advanced'));", |
1656 account_id_1_.GetUserEmail().c_str()), | 1650 user_id_1_.c_str()), |
1657 &advanced)); | 1651 &advanced)); |
1658 EXPECT_FALSE(advanced); | 1652 EXPECT_FALSE(advanced); |
1659 | 1653 |
1660 // Manually select a different locale. | 1654 // Manually select a different locale. |
1661 ASSERT_TRUE(content::ExecuteScript( | 1655 ASSERT_TRUE(content::ExecuteScript( |
1662 contents_, | 1656 contents_, |
1663 base::StringPrintf( | 1657 base::StringPrintf( |
1664 "var languageSelect = document.getElementById('pod-row')" | 1658 "var languageSelect = document.getElementById('pod-row')" |
1665 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1659 " .getPodWithUsername_('%s').querySelector('.language-select');" |
1666 "languageSelect.value = '%s';" | 1660 "languageSelect.value = '%s';" |
1667 "var event = document.createEvent('HTMLEvents');" | 1661 "var event = document.createEvent('HTMLEvents');" |
1668 "event.initEvent('change', false, true);" | 1662 "event.initEvent('change', false, true);" |
1669 "languageSelect.dispatchEvent(event);", | 1663 "languageSelect.dispatchEvent(event);", |
1670 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 1664 user_id_1_.c_str(), |
| 1665 kPublicSessionLocale))); |
1671 | 1666 |
1672 // The UI will have requested an updated list of keyboard layouts at this | 1667 // The UI will have requested an updated list of keyboard layouts at this |
1673 // point. Wait for the constructions of this list to finish. | 1668 // point. Wait for the constructions of this list to finish. |
1674 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1669 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
1675 | 1670 |
1676 // Manually select a different keyboard layout and click the enter button to | 1671 // Manually select a different keyboard layout and click the enter button to |
1677 // start the session. | 1672 // start the session. |
1678 ASSERT_TRUE(content::ExecuteScript( | 1673 ASSERT_TRUE(content::ExecuteScript( |
1679 contents_, | 1674 contents_, |
1680 base::StringPrintf( | 1675 base::StringPrintf( |
1681 "var pod =" | 1676 "var pod =" |
1682 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1677 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1683 "pod.querySelector('.keyboard-select').value = '%s';" | 1678 "pod.querySelector('.keyboard-select').value = '%s';" |
1684 "pod.querySelector('.enter-button').click();", | 1679 "pod.querySelector('.enter-button').click();", |
1685 account_id_1_.GetUserEmail().c_str(), | 1680 user_id_1_.c_str(), |
1686 public_session_input_method_id_.c_str()))); | 1681 public_session_input_method_id_.c_str()))); |
1687 | 1682 |
1688 WaitForSessionStart(); | 1683 WaitForSessionStart(); |
1689 | 1684 |
1690 // Verify that the locale and keyboard layout have been applied. | 1685 // Verify that the locale and keyboard layout have been applied. |
1691 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1686 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
1692 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1687 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
1693 icu::Locale::getDefault().getLanguage()); | 1688 icu::Locale::getDefault().getLanguage()); |
1694 EXPECT_EQ(public_session_input_method_id_, | 1689 EXPECT_EQ(public_session_input_method_id_, |
1695 chromeos::input_method::InputMethodManager::Get() | 1690 chromeos::input_method::InputMethodManager::Get() |
(...skipping 12 matching lines...) Expand all Loading... |
1708 WaitForPolicy(); | 1703 WaitForPolicy(); |
1709 | 1704 |
1710 ExpandPublicSessionPod(false); | 1705 ExpandPublicSessionPod(false); |
1711 | 1706 |
1712 // Click the enter button to start the session. | 1707 // Click the enter button to start the session. |
1713 ASSERT_TRUE(content::ExecuteScript( | 1708 ASSERT_TRUE(content::ExecuteScript( |
1714 contents_, | 1709 contents_, |
1715 base::StringPrintf( | 1710 base::StringPrintf( |
1716 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1711 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1717 " .querySelector('.enter-button').click();", | 1712 " .querySelector('.enter-button').click();", |
1718 account_id_1_.GetUserEmail().c_str()))); | 1713 user_id_1_.c_str()))); |
1719 | 1714 |
1720 WaitForSessionStart(); | 1715 WaitForSessionStart(); |
1721 | 1716 |
1722 // Verify that the recommended locale has been applied and the first keyboard | 1717 // Verify that the recommended locale has been applied and the first keyboard |
1723 // layout applicable to the locale was chosen. | 1718 // layout applicable to the locale was chosen. |
1724 EXPECT_EQ(kSingleRecommendedLocale[0], | 1719 EXPECT_EQ(kSingleRecommendedLocale[0], |
1725 g_browser_process->GetApplicationLocale()); | 1720 g_browser_process->GetApplicationLocale()); |
1726 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), | 1721 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
1727 icu::Locale::getDefault().getLanguage()); | 1722 icu::Locale::getDefault().getLanguage()); |
1728 VerifyKeyboardLayoutMatchesLocale(); | 1723 VerifyKeyboardLayoutMatchesLocale(); |
(...skipping 12 matching lines...) Expand all Loading... |
1741 | 1736 |
1742 // Verify that the pod shows a list of locales beginning with the recommended | 1737 // Verify that the pod shows a list of locales beginning with the recommended |
1743 // ones, followed by others. | 1738 // ones, followed by others. |
1744 const std::string get_locale_list = base::StringPrintf( | 1739 const std::string get_locale_list = base::StringPrintf( |
1745 "var languageSelect = document.getElementById('pod-row')" | 1740 "var languageSelect = document.getElementById('pod-row')" |
1746 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1741 " .getPodWithUsername_('%s').querySelector('.language-select');" |
1747 "var locales = [];" | 1742 "var locales = [];" |
1748 "for (var i = 0; i < languageSelect.length; ++i)" | 1743 "for (var i = 0; i < languageSelect.length; ++i)" |
1749 " locales.push(languageSelect.options[i].value);" | 1744 " locales.push(languageSelect.options[i].value);" |
1750 "domAutomationController.send(JSON.stringify(locales));", | 1745 "domAutomationController.send(JSON.stringify(locales));", |
1751 account_id_1_.GetUserEmail().c_str()); | 1746 user_id_1_.c_str()); |
1752 std::string json; | 1747 std::string json; |
1753 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1748 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
1754 get_locale_list, | 1749 get_locale_list, |
1755 &json)); | 1750 &json)); |
1756 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); | 1751 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); |
1757 const base::ListValue* locales = NULL; | 1752 const base::ListValue* locales = NULL; |
1758 ASSERT_TRUE(value_ptr); | 1753 ASSERT_TRUE(value_ptr); |
1759 ASSERT_TRUE(value_ptr->GetAsList(&locales)); | 1754 ASSERT_TRUE(value_ptr->GetAsList(&locales)); |
1760 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); | 1755 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); |
1761 | 1756 |
(...skipping 10 matching lines...) Expand all Loading... |
1772 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i) | 1767 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i) |
1773 recommended_locales.insert(kRecommendedLocales1[i]); | 1768 recommended_locales.insert(kRecommendedLocales1[i]); |
1774 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); | 1769 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); |
1775 ++i) { | 1770 ++i) { |
1776 std::string locale; | 1771 std::string locale; |
1777 EXPECT_TRUE(locales->GetString(i, &locale)); | 1772 EXPECT_TRUE(locales->GetString(i, &locale)); |
1778 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); | 1773 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); |
1779 } | 1774 } |
1780 | 1775 |
1781 // Verify that the first recommended locale is selected. | 1776 // Verify that the first recommended locale is selected. |
1782 const std::string get_selected_locale = base::StringPrintf( | 1777 const std::string get_selected_locale = |
1783 "domAutomationController.send(document.getElementById('pod-row')" | 1778 base::StringPrintf( |
1784 " .getPodWithUsername_('%s').querySelector('.language-select')" | 1779 "domAutomationController.send(document.getElementById('pod-row')" |
1785 " .value);", | 1780 " .getPodWithUsername_('%s').querySelector('.language-select')" |
1786 account_id_1_.GetUserEmail().c_str()); | 1781 " .value);", |
| 1782 user_id_1_.c_str()); |
1787 std::string selected_locale; | 1783 std::string selected_locale; |
1788 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1784 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
1789 get_selected_locale, | 1785 get_selected_locale, |
1790 &selected_locale)); | 1786 &selected_locale)); |
1791 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); | 1787 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); |
1792 | 1788 |
1793 // Change the list of recommended locales. | 1789 // Change the list of recommended locales. |
1794 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1790 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
1795 | 1791 |
1796 // Also change the display name as it is easy to ensure that policy has been | 1792 // Also change the display name as it is easy to ensure that policy has been |
1797 // updated by waiting for a display name change. | 1793 // updated by waiting for a display name change. |
1798 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 1794 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
1799 kDisplayName2); | 1795 kDisplayName2); |
1800 UploadAndInstallDeviceLocalAccountPolicy(); | 1796 UploadAndInstallDeviceLocalAccountPolicy(); |
1801 policy::BrowserPolicyConnectorChromeOS* connector = | 1797 policy::BrowserPolicyConnectorChromeOS* connector = |
1802 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1798 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1803 DeviceLocalAccountPolicyBroker* broker = | 1799 DeviceLocalAccountPolicyBroker* broker = |
1804 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 1800 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
1805 account_id_1_.GetUserEmail()); | 1801 user_id_1_); |
1806 ASSERT_TRUE(broker); | 1802 ASSERT_TRUE(broker); |
1807 broker->core()->store()->Load(); | 1803 broker->core()->store()->Load(); |
1808 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName2); | 1804 WaitForDisplayName(user_id_1_, kDisplayName2); |
1809 | 1805 |
1810 // Verify that the new list of locales is shown in the UI. | 1806 // Verify that the new list of locales is shown in the UI. |
1811 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1807 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
1812 get_locale_list, | 1808 get_locale_list, |
1813 &json)); | 1809 &json)); |
1814 value_ptr = base::JSONReader::Read(json); | 1810 value_ptr = base::JSONReader::Read(json); |
1815 locales = NULL; | 1811 locales = NULL; |
1816 ASSERT_TRUE(value_ptr); | 1812 ASSERT_TRUE(value_ptr); |
1817 ASSERT_TRUE(value_ptr->GetAsList(&locales)); | 1813 ASSERT_TRUE(value_ptr->GetAsList(&locales)); |
1818 EXPECT_LT(arraysize(kRecommendedLocales2), locales->GetSize()); | 1814 EXPECT_LT(arraysize(kRecommendedLocales2), locales->GetSize()); |
(...skipping 12 matching lines...) Expand all Loading... |
1831 // Manually select a different locale. | 1827 // Manually select a different locale. |
1832 ASSERT_TRUE(content::ExecuteScript( | 1828 ASSERT_TRUE(content::ExecuteScript( |
1833 contents_, | 1829 contents_, |
1834 base::StringPrintf( | 1830 base::StringPrintf( |
1835 "var languageSelect = document.getElementById('pod-row')" | 1831 "var languageSelect = document.getElementById('pod-row')" |
1836 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1832 " .getPodWithUsername_('%s').querySelector('.language-select');" |
1837 "languageSelect.value = '%s';" | 1833 "languageSelect.value = '%s';" |
1838 "var event = document.createEvent('HTMLEvents');" | 1834 "var event = document.createEvent('HTMLEvents');" |
1839 "event.initEvent('change', false, true);" | 1835 "event.initEvent('change', false, true);" |
1840 "languageSelect.dispatchEvent(event);", | 1836 "languageSelect.dispatchEvent(event);", |
1841 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 1837 user_id_1_.c_str(), |
| 1838 kPublicSessionLocale))); |
1842 | 1839 |
1843 // Change the list of recommended locales. | 1840 // Change the list of recommended locales. |
1844 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1841 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
1845 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 1842 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
1846 kDisplayName1); | 1843 kDisplayName1); |
1847 UploadAndInstallDeviceLocalAccountPolicy(); | 1844 UploadAndInstallDeviceLocalAccountPolicy(); |
1848 broker->core()->store()->Load(); | 1845 broker->core()->store()->Load(); |
1849 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); | 1846 WaitForDisplayName(user_id_1_, kDisplayName1); |
1850 | 1847 |
1851 // Verify that the manually selected locale is still selected. | 1848 // Verify that the manually selected locale is still selected. |
1852 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1849 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
1853 get_selected_locale, | 1850 get_selected_locale, |
1854 &selected_locale)); | 1851 &selected_locale)); |
1855 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1852 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
1856 | 1853 |
1857 // The UI will request an updated list of keyboard layouts at this point. Wait | 1854 // The UI will request an updated list of keyboard layouts at this point. Wait |
1858 // for the constructions of this list to finish. | 1855 // for the constructions of this list to finish. |
1859 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1856 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
1860 | 1857 |
1861 // Manually select a different keyboard layout. | 1858 // Manually select a different keyboard layout. |
1862 ASSERT_TRUE(content::ExecuteScript( | 1859 ASSERT_TRUE(content::ExecuteScript( |
1863 contents_, | 1860 contents_, |
1864 base::StringPrintf( | 1861 base::StringPrintf( |
1865 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1862 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1866 " .querySelector('.keyboard-select').value = '%s';", | 1863 " .querySelector('.keyboard-select').value = '%s';", |
1867 account_id_1_.GetUserEmail().c_str(), | 1864 user_id_1_.c_str(), |
1868 public_session_input_method_id_.c_str()))); | 1865 public_session_input_method_id_.c_str()))); |
1869 | 1866 |
1870 // Click on a different pod, causing focus to shift away and the pod to | 1867 // Click on a different pod, causing focus to shift away and the pod to |
1871 // contract. | 1868 // contract. |
1872 ASSERT_TRUE(content::ExecuteScript( | 1869 ASSERT_TRUE(content::ExecuteScript( |
1873 contents_, | 1870 contents_, |
1874 base::StringPrintf( | 1871 base::StringPrintf( |
1875 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1872 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1876 " .click();", | 1873 " .click();", |
1877 account_id_2_.GetUserEmail().c_str()))); | 1874 user_id_2_.c_str()))); |
1878 | 1875 |
1879 // Click on the pod again, causing it to expand again. Verify that the pod has | 1876 // Click on the pod again, causing it to expand again. Verify that the pod has |
1880 // kept all its state (the advanced form is being shown, the manually selected | 1877 // kept all its state (the advanced form is being shown, the manually selected |
1881 // locale and keyboard layout are selected). | 1878 // locale and keyboard layout are selected). |
1882 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 1879 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
1883 contents_, | 1880 contents_, |
1884 base::StringPrintf( | 1881 base::StringPrintf( |
1885 "var pod =" | 1882 "var pod =" |
1886 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1883 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1887 "pod.click();" | 1884 "pod.click();" |
1888 "var state = {};" | 1885 "var state = {};" |
1889 "state.advanced = pod.classList.contains('advanced');" | 1886 "state.advanced = pod.classList.contains('advanced');" |
1890 "state.locale = pod.querySelector('.language-select').value;" | 1887 "state.locale = pod.querySelector('.language-select').value;" |
1891 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" | 1888 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" |
1892 "console.log(JSON.stringify(state));" | 1889 "console.log(JSON.stringify(state));" |
1893 "domAutomationController.send(JSON.stringify(state));", | 1890 "domAutomationController.send(JSON.stringify(state));", |
1894 account_id_1_.GetUserEmail().c_str()), | 1891 user_id_1_.c_str()), |
1895 &json)); | 1892 &json)); |
1896 LOG(ERROR) << json; | 1893 LOG(ERROR) << json; |
1897 value_ptr = base::JSONReader::Read(json); | 1894 value_ptr = base::JSONReader::Read(json); |
1898 const base::DictionaryValue* state = NULL; | 1895 const base::DictionaryValue* state = NULL; |
1899 ASSERT_TRUE(value_ptr); | 1896 ASSERT_TRUE(value_ptr); |
1900 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); | 1897 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); |
1901 bool advanced = false; | 1898 bool advanced = false; |
1902 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); | 1899 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); |
1903 EXPECT_TRUE(advanced); | 1900 EXPECT_TRUE(advanced); |
1904 EXPECT_TRUE(state->GetString("locale", &selected_locale)); | 1901 EXPECT_TRUE(state->GetString("locale", &selected_locale)); |
1905 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1902 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
1906 std::string selected_keyboard_layout; | 1903 std::string selected_keyboard_layout; |
1907 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); | 1904 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); |
1908 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); | 1905 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); |
1909 | 1906 |
1910 // Click the enter button to start the session. | 1907 // Click the enter button to start the session. |
1911 ASSERT_TRUE(content::ExecuteScript( | 1908 ASSERT_TRUE(content::ExecuteScript( |
1912 contents_, | 1909 contents_, |
1913 base::StringPrintf( | 1910 base::StringPrintf( |
1914 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1911 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1915 " .querySelector('.enter-button').click();", | 1912 " .querySelector('.enter-button').click();", |
1916 account_id_1_.GetUserEmail().c_str()))); | 1913 user_id_1_.c_str()))); |
1917 | 1914 |
1918 WaitForSessionStart(); | 1915 WaitForSessionStart(); |
1919 | 1916 |
1920 // Verify that the locale and keyboard layout have been applied. | 1917 // Verify that the locale and keyboard layout have been applied. |
1921 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1918 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
1922 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1919 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
1923 icu::Locale::getDefault().getLanguage()); | 1920 icu::Locale::getDefault().getLanguage()); |
1924 EXPECT_EQ(public_session_input_method_id_, | 1921 EXPECT_EQ(public_session_input_method_id_, |
1925 chromeos::input_method::InputMethodManager::Get() | 1922 chromeos::input_method::InputMethodManager::Get() |
1926 ->GetActiveIMEState() | 1923 ->GetActiveIMEState() |
(...skipping 13 matching lines...) Expand all Loading... |
1940 // Click on the pod to expand it. Verify that the pod expands to its basic | 1937 // Click on the pod to expand it. Verify that the pod expands to its basic |
1941 // form as there is only one recommended locale. | 1938 // form as there is only one recommended locale. |
1942 bool advanced = false; | 1939 bool advanced = false; |
1943 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1940 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
1944 contents_, | 1941 contents_, |
1945 base::StringPrintf( | 1942 base::StringPrintf( |
1946 "var pod =" | 1943 "var pod =" |
1947 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1944 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
1948 "pod.click();" | 1945 "pod.click();" |
1949 "domAutomationController.send(pod.classList.contains('advanced'));", | 1946 "domAutomationController.send(pod.classList.contains('advanced'));", |
1950 account_id_1_.GetUserEmail().c_str()), | 1947 user_id_1_.c_str()), |
1951 &advanced)); | 1948 &advanced)); |
1952 EXPECT_FALSE(advanced); | 1949 EXPECT_FALSE(advanced); |
1953 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 1950 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
1954 icu::Locale::getDefault().getLanguage()); | 1951 icu::Locale::getDefault().getLanguage()); |
1955 | 1952 |
1956 // Click the enter button to start the session. | 1953 // Click the enter button to start the session. |
1957 ASSERT_TRUE(content::ExecuteScript( | 1954 ASSERT_TRUE(content::ExecuteScript( |
1958 contents_, | 1955 contents_, |
1959 base::StringPrintf( | 1956 base::StringPrintf( |
1960 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1957 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
1961 " .querySelector('.enter-button').click();", | 1958 " .querySelector('.enter-button').click();", |
1962 account_id_1_.GetUserEmail().c_str()))); | 1959 user_id_1_.c_str()))); |
1963 | 1960 |
1964 WaitForSessionStart(); | 1961 WaitForSessionStart(); |
1965 | 1962 |
1966 // Verify that since the recommended locale was invalid, the locale has not | 1963 // Verify that since the recommended locale was invalid, the locale has not |
1967 // changed and the first keyboard layout applicable to the locale was chosen. | 1964 // changed and the first keyboard layout applicable to the locale was chosen. |
1968 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 1965 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
1969 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 1966 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
1970 icu::Locale::getDefault().getLanguage()); | 1967 icu::Locale::getDefault().getLanguage()); |
1971 VerifyKeyboardLayoutMatchesLocale(); | 1968 VerifyKeyboardLayoutMatchesLocale(); |
1972 } | 1969 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 // Select a different locale. | 2042 // Select a different locale. |
2046 ASSERT_TRUE(content::ExecuteScript( | 2043 ASSERT_TRUE(content::ExecuteScript( |
2047 contents_, | 2044 contents_, |
2048 base::StringPrintf( | 2045 base::StringPrintf( |
2049 "var languageSelect = document.getElementById('pod-row')" | 2046 "var languageSelect = document.getElementById('pod-row')" |
2050 " .getPodWithUsername_('%s').querySelector('.language-select');" | 2047 " .getPodWithUsername_('%s').querySelector('.language-select');" |
2051 "languageSelect.value = '%s';" | 2048 "languageSelect.value = '%s';" |
2052 "var event = document.createEvent('HTMLEvents');" | 2049 "var event = document.createEvent('HTMLEvents');" |
2053 "event.initEvent('change', false, true);" | 2050 "event.initEvent('change', false, true);" |
2054 "languageSelect.dispatchEvent(event);", | 2051 "languageSelect.dispatchEvent(event);", |
2055 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 2052 user_id_1_.c_str(), |
| 2053 kPublicSessionLocale))); |
2056 | 2054 |
2057 // The UI will have requested an updated list of keyboard layouts at this | 2055 // The UI will have requested an updated list of keyboard layouts at this |
2058 // point. Wait for the constructions of this list to finish. | 2056 // point. Wait for the constructions of this list to finish. |
2059 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 2057 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
2060 | 2058 |
2061 // Set up an observer that will quit the message loop when login has succeeded | 2059 // Set up an observer that will quit the message loop when login has succeeded |
2062 // and the first wizard screen, if any, is being shown. | 2060 // and the first wizard screen, if any, is being shown. |
2063 base::RunLoop login_wait_run_loop; | 2061 base::RunLoop login_wait_run_loop; |
2064 chromeos::MockAuthStatusConsumer login_status_consumer; | 2062 chromeos::MockAuthStatusConsumer login_status_consumer; |
2065 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 2063 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
2066 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 2064 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
2067 chromeos::ExistingUserController* controller = | 2065 chromeos::ExistingUserController* controller = |
2068 chromeos::ExistingUserController::current_controller(); | 2066 chromeos::ExistingUserController::current_controller(); |
2069 ASSERT_TRUE(controller); | 2067 ASSERT_TRUE(controller); |
2070 controller->set_login_status_consumer(&login_status_consumer); | 2068 controller->set_login_status_consumer(&login_status_consumer); |
2071 | 2069 |
2072 // Manually select a different keyboard layout and click the enter button to | 2070 // Manually select a different keyboard layout and click the enter button to |
2073 // start the session. | 2071 // start the session. |
2074 ASSERT_TRUE(content::ExecuteScript( | 2072 ASSERT_TRUE(content::ExecuteScript( |
2075 contents_, | 2073 contents_, |
2076 base::StringPrintf( | 2074 base::StringPrintf( |
2077 "var pod =" | 2075 "var pod =" |
2078 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 2076 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
2079 "pod.querySelector('.keyboard-select').value = '%s';" | 2077 "pod.querySelector('.keyboard-select').value = '%s';" |
2080 "pod.querySelector('.enter-button').click();", | 2078 "pod.querySelector('.enter-button').click();", |
2081 account_id_1_.GetUserEmail().c_str(), | 2079 user_id_1_.c_str(), |
2082 public_session_input_method_id_.c_str()))); | 2080 public_session_input_method_id_.c_str()))); |
2083 | 2081 |
2084 // Spin the loop until the login observer fires. Then, unregister the | 2082 // Spin the loop until the login observer fires. Then, unregister the |
2085 // observer. | 2083 // observer. |
2086 login_wait_run_loop.Run(); | 2084 login_wait_run_loop.Run(); |
2087 controller->set_login_status_consumer(NULL); | 2085 controller->set_login_status_consumer(NULL); |
2088 | 2086 |
2089 // Verify that the Terms of Service screen is being shown. | 2087 // Verify that the Terms of Service screen is being shown. |
2090 chromeos::WizardController* wizard_controller = | 2088 chromeos::WizardController* wizard_controller = |
2091 chromeos::WizardController::default_controller(); | 2089 chromeos::WizardController::default_controller(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 ASSERT_TRUE(content::ExecuteScript(contents_, | 2383 ASSERT_TRUE(content::ExecuteScript(contents_, |
2386 "$('tos-accept-button').click();")); | 2384 "$('tos-accept-button').click();")); |
2387 | 2385 |
2388 WaitForSessionStart(); | 2386 WaitForSessionStart(); |
2389 } | 2387 } |
2390 | 2388 |
2391 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2389 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
2392 TermsOfServiceDownloadTest, testing::Bool()); | 2390 TermsOfServiceDownloadTest, testing::Bool()); |
2393 | 2391 |
2394 } // namespace policy | 2392 } // namespace policy |
OLD | NEW |