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