Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Rebased. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 : user_id_1_(AccountId::FromUserEmail(GenerateDeviceLocalAccountUserId(
423 kAccountId1, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), 423 kAccountId1,
424 user_id_2_(GenerateDeviceLocalAccountUserId( 424 DeviceLocalAccount::TYPE_PUBLIC_SESSION))),
425 kAccountId2, DeviceLocalAccount::TYPE_PUBLIC_SESSION)), 425 user_id_2_(AccountId::FromUserEmail(GenerateDeviceLocalAccountUserId(
426 public_session_input_method_id_(base::StringPrintf( 426 kAccountId2,
427 kPublicSessionInputMethodIDTemplate, 427 DeviceLocalAccount::TYPE_PUBLIC_SESSION))),
428 chromeos::extension_ime_util::kXkbExtensionId)), 428 public_session_input_method_id_(
429 base::StringPrintf(kPublicSessionInputMethodIDTemplate,
430 chromeos::extension_ime_util::kXkbExtensionId)),
429 contents_(NULL) { 431 contents_(NULL) {
430 set_exit_when_last_browser_closes(false); 432 set_exit_when_last_browser_closes(false);
431 } 433 }
432 434
433 ~DeviceLocalAccountTest() override {} 435 ~DeviceLocalAccountTest() override {}
434 436
435 void SetUp() override { 437 void SetUp() override {
436 // Configure and start the test server. 438 // Configure and start the test server.
437 scoped_ptr<crypto::RSAPrivateKey> signing_key( 439 scoped_ptr<crypto::RSAPrivateKey> signing_key(
438 PolicyBuilder::CreateTestSigningKey()); 440 PolicyBuilder::CreateTestSigningKey());
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 em::DeviceLocalAccountsProto* device_local_accounts = 629 em::DeviceLocalAccountsProto* device_local_accounts =
628 proto.mutable_device_local_accounts(); 630 proto.mutable_device_local_accounts();
629 device_local_accounts->set_auto_login_id(kAccountId1); 631 device_local_accounts->set_auto_login_id(kAccountId1);
630 device_local_accounts->set_auto_login_delay(0); 632 device_local_accounts->set_auto_login_delay(0);
631 RefreshDevicePolicy(); 633 RefreshDevicePolicy();
632 ASSERT_TRUE(test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, 634 ASSERT_TRUE(test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType,
633 std::string(), 635 std::string(),
634 proto.SerializeAsString())); 636 proto.SerializeAsString()));
635 } 637 }
636 638
637 void CheckPublicSessionPresent(const std::string& id) { 639 void CheckPublicSessionPresent(const AccountId& id) {
638 const user_manager::User* user = 640 const user_manager::User* user =
639 user_manager::UserManager::Get()->FindUser(id); 641 user_manager::UserManager::Get()->FindUser(id);
640 ASSERT_TRUE(user); 642 ASSERT_TRUE(user);
641 EXPECT_EQ(id, user->email()); 643 EXPECT_EQ(id, user->GetUserID());
642 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); 644 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType());
643 } 645 }
644 646
645 base::FilePath GetExtensionCacheDirectoryForAccountID( 647 base::FilePath GetExtensionCacheDirectoryForAccountID(
646 const std::string& account_id) { 648 const std::string& account_id) {
647 base::FilePath extension_cache_root_dir; 649 base::FilePath extension_cache_root_dir;
648 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, 650 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
649 &extension_cache_root_dir)) { 651 &extension_cache_root_dir)) {
650 ADD_FAILURE(); 652 ADD_FAILURE();
651 } 653 }
(...skipping 25 matching lines...) Expand all
677 const std::string& expected_display_name) { 679 const std::string& expected_display_name) {
678 DictionaryPrefValueWaiter("UserDisplayName", 680 DictionaryPrefValueWaiter("UserDisplayName",
679 user_id, 681 user_id,
680 expected_display_name).Wait(); 682 expected_display_name).Wait();
681 } 683 }
682 684
683 void WaitForPolicy() { 685 void WaitForPolicy() {
684 // Wait for the display name becoming available as that indicates 686 // Wait for the display name becoming available as that indicates
685 // device-local account policy is fully loaded, which is a prerequisite for 687 // device-local account policy is fully loaded, which is a prerequisite for
686 // successful login. 688 // successful login.
687 WaitForDisplayName(user_id_1_, kDisplayName1); 689 WaitForDisplayName(user_id_1_.GetUserEmail(), kDisplayName1);
688 } 690 }
689 691
690 void ExpandPublicSessionPod(bool expect_advanced) { 692 void ExpandPublicSessionPod(bool expect_advanced) {
691 bool advanced = false; 693 bool advanced = false;
692 // Click on the pod to expand it. 694 // Click on the pod to expand it.
693 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 695 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
694 contents_, 696 contents_,
695 base::StringPrintf( 697 base::StringPrintf(
696 "var pod =" 698 "var pod ="
697 " document.getElementById('pod-row').getPodWithUsername_('%s');" 699 " document.getElementById('pod-row').getPodWithUsername_('%s');"
698 "pod.click();" 700 "pod.click();"
699 "domAutomationController.send(pod.classList.contains('advanced'));", 701 "domAutomationController.send(pod.classList.contains('advanced'));",
700 user_id_1_.c_str()), 702 user_id_1_.GetUserEmail().c_str()),
701 &advanced)); 703 &advanced));
702 // Verify that the pod expanded to its basic/advanced form, as expected. 704 // Verify that the pod expanded to its basic/advanced form, as expected.
703 EXPECT_EQ(expect_advanced, advanced); 705 EXPECT_EQ(expect_advanced, advanced);
704 706
705 // Verify that the construction of the pod's language list did not affect 707 // Verify that the construction of the pod's language list did not affect
706 // the current ICU locale. 708 // the current ICU locale.
707 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); 709 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage());
708 } 710 }
709 711
710 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. 712 // GetKeyboardLayoutsForLocale() posts a task to a background task runner.
(...skipping 23 matching lines...) Expand all
734 chromeos::LoginDisplayHostImpl* host = 736 chromeos::LoginDisplayHostImpl* host =
735 reinterpret_cast<chromeos::LoginDisplayHostImpl*>( 737 reinterpret_cast<chromeos::LoginDisplayHostImpl*>(
736 chromeos::LoginDisplayHostImpl::default_host()); 738 chromeos::LoginDisplayHostImpl::default_host());
737 ASSERT_TRUE(host); 739 ASSERT_TRUE(host);
738 host->StartSignInScreen(LoginScreenContext()); 740 host->StartSignInScreen(LoginScreenContext());
739 chromeos::ExistingUserController* controller = 741 chromeos::ExistingUserController* controller =
740 chromeos::ExistingUserController::current_controller(); 742 chromeos::ExistingUserController::current_controller();
741 ASSERT_TRUE(controller); 743 ASSERT_TRUE(controller);
742 744
743 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, 745 chromeos::UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT,
744 user_id_1_); 746 user_id_1_.GetUserEmail());
745 user_context.SetPublicSessionLocale(locale); 747 user_context.SetPublicSessionLocale(locale);
746 user_context.SetPublicSessionInputMethod(input_method); 748 user_context.SetPublicSessionInputMethod(input_method);
747 controller->Login(user_context, chromeos::SigninSpecifics()); 749 controller->Login(user_context, chromeos::SigninSpecifics());
748 } 750 }
749 751
750 void WaitForSessionStart() { 752 void WaitForSessionStart() {
751 if (IsSessionStarted()) 753 if (IsSessionStarted())
752 return; 754 return;
753 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, 755 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
754 base::Bind(IsSessionStarted)).Wait(); 756 base::Bind(IsSessionStarted)).Wait();
(...skipping 25 matching lines...) Expand all
780 WaitForPolicy(); 782 WaitForPolicy();
781 783
782 WaitForSessionStart(); 784 WaitForSessionStart();
783 785
784 EXPECT_EQ(locales[0], g_browser_process->GetApplicationLocale()); 786 EXPECT_EQ(locales[0], g_browser_process->GetApplicationLocale());
785 EXPECT_EQ(l10n_util::GetLanguage(locales[0]), 787 EXPECT_EQ(l10n_util::GetLanguage(locales[0]),
786 icu::Locale::getDefault().getLanguage()); 788 icu::Locale::getDefault().getLanguage());
787 VerifyKeyboardLayoutMatchesLocale(); 789 VerifyKeyboardLayoutMatchesLocale();
788 } 790 }
789 791
790 const std::string user_id_1_; 792 const AccountId user_id_1_;
791 const std::string user_id_2_; 793 const AccountId user_id_2_;
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, user_id_1_))
818 .Wait(); 820 .Wait();
819 EXPECT_TRUE(IsKnownUser(user_id_2_)); 821 EXPECT_TRUE(IsKnownUser(user_id_2_));
820 822
821 CheckPublicSessionPresent(user_id_1_); 823 CheckPublicSessionPresent(user_id_1_);
822 CheckPublicSessionPresent(user_id_2_); 824 CheckPublicSessionPresent(user_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 user_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 user_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 user_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 user_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(user_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 user_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, user_id_1_))
924 .Wait(); 926 .Wait();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 // Verify that the app was downloaded to the account's extension cache. 1073 // Verify that the app was downloaded to the account's extension cache.
1072 base::FilePath test_dir; 1074 base::FilePath test_dir;
1073 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 1075 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
1074 EXPECT_TRUE(ContentsEqual( 1076 EXPECT_TRUE(ContentsEqual(
1075 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion), 1077 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion),
1076 test_dir.Append(kHostedAppCRXPath))); 1078 test_dir.Append(kHostedAppCRXPath)));
1077 1079
1078 // Verify that the extension was removed from the account's extension cache 1080 // Verify that the extension was removed from the account's extension cache
1079 // after the installation failure. 1081 // after the installation failure.
1080 DeviceLocalAccountPolicyBroker* broker = 1082 DeviceLocalAccountPolicyBroker* broker =
1081 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 1083 g_browser_process->platform_part()
1082 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); 1084 ->browser_policy_connector_chromeos()
1085 ->GetDeviceLocalAccountPolicyService()
1086 ->GetBrokerForUser(user_id_1_.GetUserEmail());
1083 ASSERT_TRUE(broker); 1087 ASSERT_TRUE(broker);
1084 chromeos::ExternalCache* cache = 1088 chromeos::ExternalCache* cache =
1085 broker->extension_loader()->GetExternalCacheForTesting(); 1089 broker->extension_loader()->GetExternalCacheForTesting();
1086 ASSERT_TRUE(cache); 1090 ASSERT_TRUE(cache);
1087 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); 1091 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL));
1088 } 1092 }
1089 1093
1090 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { 1094 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) {
1091 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 1095 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
1092 1096
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true)); 1148 EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true));
1145 1149
1146 // Verify that the extension was not installed. 1150 // Verify that the extension was not installed.
1147 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true)); 1151 EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true));
1148 1152
1149 // Verify that the app is still in the account's extension cache. 1153 // Verify that the app is still in the account's extension cache.
1150 EXPECT_TRUE(PathExists(cached_hosted_app)); 1154 EXPECT_TRUE(PathExists(cached_hosted_app));
1151 1155
1152 // Verify that the extension was removed from the account's extension cache. 1156 // Verify that the extension was removed from the account's extension cache.
1153 DeviceLocalAccountPolicyBroker* broker = 1157 DeviceLocalAccountPolicyBroker* broker =
1154 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 1158 g_browser_process->platform_part()
1155 GetDeviceLocalAccountPolicyService()->GetBrokerForUser(user_id_1_); 1159 ->browser_policy_connector_chromeos()
1160 ->GetDeviceLocalAccountPolicyService()
1161 ->GetBrokerForUser(user_id_1_.GetUserEmail());
1156 ASSERT_TRUE(broker); 1162 ASSERT_TRUE(broker);
1157 chromeos::ExternalCache* cache = 1163 chromeos::ExternalCache* cache =
1158 broker->extension_loader()->GetExternalCacheForTesting(); 1164 broker->extension_loader()->GetExternalCacheForTesting();
1159 ASSERT_TRUE(cache); 1165 ASSERT_TRUE(cache);
1160 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL)); 1166 EXPECT_FALSE(cache->GetExtension(kGoodExtensionID, NULL, NULL));
1161 } 1167 }
1162 1168
1163 static void OnPutExtension(scoped_ptr<base::RunLoop>* run_loop, 1169 static void OnPutExtension(scoped_ptr<base::RunLoop>* run_loop,
1164 const base::FilePath& file_path, 1170 const base::FilePath& file_path,
1165 bool file_ownership_passed) { 1171 bool file_ownership_passed) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 test::ConstructExternalDataReference(kExternalDataURL, kExternalData); 1310 test::ConstructExternalDataReference(kExternalDataURL, kExternalData);
1305 std::string policy; 1311 std::string policy;
1306 base::JSONWriter::Write(*metadata, &policy); 1312 base::JSONWriter::Write(*metadata, &policy);
1307 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( 1313 device_local_account_policy_.payload().mutable_useravatarimage()->set_value(
1308 policy); 1314 policy);
1309 UploadAndInstallDeviceLocalAccountPolicy(); 1315 UploadAndInstallDeviceLocalAccountPolicy();
1310 policy::BrowserPolicyConnectorChromeOS* connector = 1316 policy::BrowserPolicyConnectorChromeOS* connector =
1311 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 1317 g_browser_process->platform_part()->browser_policy_connector_chromeos();
1312 DeviceLocalAccountPolicyBroker* broker = 1318 DeviceLocalAccountPolicyBroker* broker =
1313 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( 1319 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser(
1314 user_id_1_); 1320 user_id_1_.GetUserEmail());
1315 ASSERT_TRUE(broker); 1321 ASSERT_TRUE(broker);
1316 broker->core()->store()->Load(); 1322 broker->core()->store()->Load();
1317 1323
1318 // The external data should be fetched and cached automatically. Wait for this 1324 // The external data should be fetched and cached automatically. Wait for this
1319 // fetch. 1325 // fetch.
1320 run_loop->Run(); 1326 run_loop->Run();
1321 1327
1322 // Stop serving external data at |kExternalDataURL|. 1328 // Stop serving external data at |kExternalDataURL|.
1323 fetcher_factory.reset(); 1329 fetcher_factory.reset();
1324 1330
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 .spec(), 1400 .spec(),
1395 image_data), 1401 image_data),
1396 &policy); 1402 &policy);
1397 device_local_account_policy_.payload().mutable_useravatarimage()->set_value( 1403 device_local_account_policy_.payload().mutable_useravatarimage()->set_value(
1398 policy); 1404 policy);
1399 UploadAndInstallDeviceLocalAccountPolicy(); 1405 UploadAndInstallDeviceLocalAccountPolicy();
1400 policy::BrowserPolicyConnectorChromeOS* connector = 1406 policy::BrowserPolicyConnectorChromeOS* connector =
1401 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 1407 g_browser_process->platform_part()->browser_policy_connector_chromeos();
1402 DeviceLocalAccountPolicyBroker* broker = 1408 DeviceLocalAccountPolicyBroker* broker =
1403 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( 1409 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser(
1404 user_id_1_); 1410 user_id_1_.GetUserEmail());
1405 ASSERT_TRUE(broker); 1411 ASSERT_TRUE(broker);
1406 1412
1407 run_loop_.reset(new base::RunLoop); 1413 run_loop_.reset(new base::RunLoop);
1408 user_manager::UserManager::Get()->AddObserver(this); 1414 user_manager::UserManager::Get()->AddObserver(this);
1409 broker->core()->store()->Load(); 1415 broker->core()->store()->Load();
1410 run_loop_->Run(); 1416 run_loop_->Run();
1411 user_manager::UserManager::Get()->RemoveObserver(this); 1417 user_manager::UserManager::Get()->RemoveObserver(this);
1412 1418
1413 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader( 1419 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader(
1414 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load(); 1420 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load();
1415 ASSERT_TRUE(policy_image); 1421 ASSERT_TRUE(policy_image);
1416 1422
1417 const user_manager::User* user = 1423 const user_manager::User* user =
1418 user_manager::UserManager::Get()->FindUser(user_id_1_); 1424 user_manager::UserManager::Get()->FindUser(user_id_1_);
1419 ASSERT_TRUE(user); 1425 ASSERT_TRUE(user);
1420 1426
1421 base::FilePath user_data_dir; 1427 base::FilePath user_data_dir;
1422 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 1428 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
1423 const base::FilePath saved_image_path = 1429 const base::FilePath saved_image_path =
1424 user_data_dir.Append(user_id_1_).AddExtension("jpg"); 1430 user_data_dir.Append(user_id_1_.GetUserEmail()).AddExtension("jpg");
1425 1431
1426 EXPECT_FALSE(user->HasDefaultImage()); 1432 EXPECT_FALSE(user->HasDefaultImage());
1427 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, user->image_index()); 1433 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, user->image_index());
1428 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); 1434 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage()));
1429 const base::DictionaryValue* images_pref = 1435 const base::DictionaryValue* images_pref =
1430 g_browser_process->local_state()->GetDictionary("user_image_info"); 1436 g_browser_process->local_state()->GetDictionary("user_image_info");
1431 ASSERT_TRUE(images_pref); 1437 ASSERT_TRUE(images_pref);
1432 const base::DictionaryValue* image_properties; 1438 const base::DictionaryValue* image_properties;
1433 ASSERT_TRUE(images_pref->GetDictionaryWithoutPathExpansion( 1439 ASSERT_TRUE(images_pref->GetDictionaryWithoutPathExpansion(
1434 user_id_1_, 1440 user_id_1_.GetUserEmail(), &image_properties));
1435 &image_properties));
1436 int image_index; 1441 int image_index;
1437 std::string image_path; 1442 std::string image_path;
1438 ASSERT_TRUE(image_properties->GetInteger("index", &image_index)); 1443 ASSERT_TRUE(image_properties->GetInteger("index", &image_index));
1439 ASSERT_TRUE(image_properties->GetString("path", &image_path)); 1444 ASSERT_TRUE(image_properties->GetString("path", &image_path));
1440 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, image_index); 1445 EXPECT_EQ(user_manager::User::USER_IMAGE_EXTERNAL, image_index);
1441 EXPECT_EQ(saved_image_path.value(), image_path); 1446 EXPECT_EQ(saved_image_path.value(), image_path);
1442 1447
1443 scoped_ptr<gfx::ImageSkia> saved_image = 1448 scoped_ptr<gfx::ImageSkia> saved_image =
1444 chromeos::test::ImageLoader(saved_image_path).Load(); 1449 chromeos::test::ImageLoader(saved_image_path).Load();
1445 ASSERT_TRUE(saved_image); 1450 ASSERT_TRUE(saved_image);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 WaitForPolicy(); 1616 WaitForPolicy();
1612 1617
1613 ExpandPublicSessionPod(false); 1618 ExpandPublicSessionPod(false);
1614 1619
1615 // Click the enter button to start the session. 1620 // Click the enter button to start the session.
1616 ASSERT_TRUE(content::ExecuteScript( 1621 ASSERT_TRUE(content::ExecuteScript(
1617 contents_, 1622 contents_,
1618 base::StringPrintf( 1623 base::StringPrintf(
1619 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1624 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1620 " .querySelector('.enter-button').click();", 1625 " .querySelector('.enter-button').click();",
1621 user_id_1_.c_str()))); 1626 user_id_1_.GetUserEmail().c_str())));
1622 1627
1623 WaitForSessionStart(); 1628 WaitForSessionStart();
1624 1629
1625 // Verify that the locale has not changed and the first keyboard layout 1630 // Verify that the locale has not changed and the first keyboard layout
1626 // applicable to the locale was chosen. 1631 // applicable to the locale was chosen.
1627 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); 1632 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale());
1628 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); 1633 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage());
1629 VerifyKeyboardLayoutMatchesLocale(); 1634 VerifyKeyboardLayoutMatchesLocale();
1630 } 1635 }
1631 1636
1632 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { 1637 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) {
1633 UploadAndInstallDeviceLocalAccountPolicy(); 1638 UploadAndInstallDeviceLocalAccountPolicy();
1634 AddPublicSessionToDevicePolicy(kAccountId1); 1639 AddPublicSessionToDevicePolicy(kAccountId1);
1635 1640
1636 WaitForPolicy(); 1641 WaitForPolicy();
1637 1642
1638 ExpandPublicSessionPod(false); 1643 ExpandPublicSessionPod(false);
1639 1644
1640 // Click the link that switches the pod to its advanced form. Verify that the 1645 // Click the link that switches the pod to its advanced form. Verify that the
1641 // pod switches from basic to advanced. 1646 // pod switches from basic to advanced.
1642 bool advanced = false; 1647 bool advanced = false;
1643 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 1648 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
1644 contents_, 1649 contents_,
1645 base::StringPrintf( 1650 base::StringPrintf(
1646 "var pod =" 1651 "var pod ="
1647 " document.getElementById('pod-row').getPodWithUsername_('%s');" 1652 " document.getElementById('pod-row').getPodWithUsername_('%s');"
1648 "pod.querySelector('.language-and-input').click();" 1653 "pod.querySelector('.language-and-input').click();"
1649 "domAutomationController.send(pod.classList.contains('advanced'));", 1654 "domAutomationController.send(pod.classList.contains('advanced'));",
1650 user_id_1_.c_str()), 1655 user_id_1_.GetUserEmail().c_str()),
1651 &advanced)); 1656 &advanced));
1652 EXPECT_FALSE(advanced); 1657 EXPECT_FALSE(advanced);
1653 1658
1654 // Manually select a different locale. 1659 // Manually select a different locale.
1655 ASSERT_TRUE(content::ExecuteScript( 1660 ASSERT_TRUE(content::ExecuteScript(
1656 contents_, 1661 contents_,
1657 base::StringPrintf( 1662 base::StringPrintf(
1658 "var languageSelect = document.getElementById('pod-row')" 1663 "var languageSelect = document.getElementById('pod-row')"
1659 " .getPodWithUsername_('%s').querySelector('.language-select');" 1664 " .getPodWithUsername_('%s').querySelector('.language-select');"
1660 "languageSelect.value = '%s';" 1665 "languageSelect.value = '%s';"
1661 "var event = document.createEvent('HTMLEvents');" 1666 "var event = document.createEvent('HTMLEvents');"
1662 "event.initEvent('change', false, true);" 1667 "event.initEvent('change', false, true);"
1663 "languageSelect.dispatchEvent(event);", 1668 "languageSelect.dispatchEvent(event);",
1664 user_id_1_.c_str(), 1669 user_id_1_.GetUserEmail().c_str(), kPublicSessionLocale)));
1665 kPublicSessionLocale)));
1666 1670
1667 // The UI will have requested an updated list of keyboard layouts at this 1671 // The UI will have requested an updated list of keyboard layouts at this
1668 // point. Wait for the constructions of this list to finish. 1672 // point. Wait for the constructions of this list to finish.
1669 WaitForGetKeyboardLayoutsForLocaleToFinish(); 1673 WaitForGetKeyboardLayoutsForLocaleToFinish();
1670 1674
1671 // Manually select a different keyboard layout and click the enter button to 1675 // Manually select a different keyboard layout and click the enter button to
1672 // start the session. 1676 // start the session.
1673 ASSERT_TRUE(content::ExecuteScript( 1677 ASSERT_TRUE(content::ExecuteScript(
1674 contents_, 1678 contents_,
1675 base::StringPrintf( 1679 base::StringPrintf(
1676 "var pod =" 1680 "var pod ="
1677 " document.getElementById('pod-row').getPodWithUsername_('%s');" 1681 " document.getElementById('pod-row').getPodWithUsername_('%s');"
1678 "pod.querySelector('.keyboard-select').value = '%s';" 1682 "pod.querySelector('.keyboard-select').value = '%s';"
1679 "pod.querySelector('.enter-button').click();", 1683 "pod.querySelector('.enter-button').click();",
1680 user_id_1_.c_str(), 1684 user_id_1_.GetUserEmail().c_str(),
1681 public_session_input_method_id_.c_str()))); 1685 public_session_input_method_id_.c_str())));
1682 1686
1683 WaitForSessionStart(); 1687 WaitForSessionStart();
1684 1688
1685 // Verify that the locale and keyboard layout have been applied. 1689 // Verify that the locale and keyboard layout have been applied.
1686 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); 1690 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale());
1687 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), 1691 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale),
1688 icu::Locale::getDefault().getLanguage()); 1692 icu::Locale::getDefault().getLanguage());
1689 EXPECT_EQ(public_session_input_method_id_, 1693 EXPECT_EQ(public_session_input_method_id_,
1690 chromeos::input_method::InputMethodManager::Get() 1694 chromeos::input_method::InputMethodManager::Get()
(...skipping 12 matching lines...) Expand all
1703 WaitForPolicy(); 1707 WaitForPolicy();
1704 1708
1705 ExpandPublicSessionPod(false); 1709 ExpandPublicSessionPod(false);
1706 1710
1707 // Click the enter button to start the session. 1711 // Click the enter button to start the session.
1708 ASSERT_TRUE(content::ExecuteScript( 1712 ASSERT_TRUE(content::ExecuteScript(
1709 contents_, 1713 contents_,
1710 base::StringPrintf( 1714 base::StringPrintf(
1711 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1715 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1712 " .querySelector('.enter-button').click();", 1716 " .querySelector('.enter-button').click();",
1713 user_id_1_.c_str()))); 1717 user_id_1_.GetUserEmail().c_str())));
1714 1718
1715 WaitForSessionStart(); 1719 WaitForSessionStart();
1716 1720
1717 // Verify that the recommended locale has been applied and the first keyboard 1721 // Verify that the recommended locale has been applied and the first keyboard
1718 // layout applicable to the locale was chosen. 1722 // layout applicable to the locale was chosen.
1719 EXPECT_EQ(kSingleRecommendedLocale[0], 1723 EXPECT_EQ(kSingleRecommendedLocale[0],
1720 g_browser_process->GetApplicationLocale()); 1724 g_browser_process->GetApplicationLocale());
1721 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), 1725 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]),
1722 icu::Locale::getDefault().getLanguage()); 1726 icu::Locale::getDefault().getLanguage());
1723 VerifyKeyboardLayoutMatchesLocale(); 1727 VerifyKeyboardLayoutMatchesLocale();
(...skipping 12 matching lines...) Expand all
1736 1740
1737 // Verify that the pod shows a list of locales beginning with the recommended 1741 // Verify that the pod shows a list of locales beginning with the recommended
1738 // ones, followed by others. 1742 // ones, followed by others.
1739 const std::string get_locale_list = base::StringPrintf( 1743 const std::string get_locale_list = base::StringPrintf(
1740 "var languageSelect = document.getElementById('pod-row')" 1744 "var languageSelect = document.getElementById('pod-row')"
1741 " .getPodWithUsername_('%s').querySelector('.language-select');" 1745 " .getPodWithUsername_('%s').querySelector('.language-select');"
1742 "var locales = [];" 1746 "var locales = [];"
1743 "for (var i = 0; i < languageSelect.length; ++i)" 1747 "for (var i = 0; i < languageSelect.length; ++i)"
1744 " locales.push(languageSelect.options[i].value);" 1748 " locales.push(languageSelect.options[i].value);"
1745 "domAutomationController.send(JSON.stringify(locales));", 1749 "domAutomationController.send(JSON.stringify(locales));",
1746 user_id_1_.c_str()); 1750 user_id_1_.GetUserEmail().c_str());
1747 std::string json; 1751 std::string json;
1748 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, 1752 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_,
1749 get_locale_list, 1753 get_locale_list,
1750 &json)); 1754 &json));
1751 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); 1755 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json);
1752 const base::ListValue* locales = NULL; 1756 const base::ListValue* locales = NULL;
1753 ASSERT_TRUE(value_ptr); 1757 ASSERT_TRUE(value_ptr);
1754 ASSERT_TRUE(value_ptr->GetAsList(&locales)); 1758 ASSERT_TRUE(value_ptr->GetAsList(&locales));
1755 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); 1759 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize());
1756 1760
(...skipping 10 matching lines...) Expand all
1767 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i) 1771 for (size_t i = 0; i < arraysize(kRecommendedLocales1); ++i)
1768 recommended_locales.insert(kRecommendedLocales1[i]); 1772 recommended_locales.insert(kRecommendedLocales1[i]);
1769 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); 1773 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize();
1770 ++i) { 1774 ++i) {
1771 std::string locale; 1775 std::string locale;
1772 EXPECT_TRUE(locales->GetString(i, &locale)); 1776 EXPECT_TRUE(locales->GetString(i, &locale));
1773 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); 1777 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale));
1774 } 1778 }
1775 1779
1776 // Verify that the first recommended locale is selected. 1780 // Verify that the first recommended locale is selected.
1777 const std::string get_selected_locale = 1781 const std::string get_selected_locale = base::StringPrintf(
1778 base::StringPrintf( 1782 "domAutomationController.send(document.getElementById('pod-row')"
1779 "domAutomationController.send(document.getElementById('pod-row')" 1783 " .getPodWithUsername_('%s').querySelector('.language-select')"
1780 " .getPodWithUsername_('%s').querySelector('.language-select')" 1784 " .value);",
1781 " .value);", 1785 user_id_1_.GetUserEmail().c_str());
1782 user_id_1_.c_str());
1783 std::string selected_locale; 1786 std::string selected_locale;
1784 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, 1787 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_,
1785 get_selected_locale, 1788 get_selected_locale,
1786 &selected_locale)); 1789 &selected_locale));
1787 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); 1790 EXPECT_EQ(kRecommendedLocales1[0], selected_locale);
1788 1791
1789 // Change the list of recommended locales. 1792 // Change the list of recommended locales.
1790 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); 1793 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2));
1791 1794
1792 // Also change the display name as it is easy to ensure that policy has been 1795 // Also change the display name as it is easy to ensure that policy has been
1793 // updated by waiting for a display name change. 1796 // updated by waiting for a display name change.
1794 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( 1797 device_local_account_policy_.payload().mutable_userdisplayname()->set_value(
1795 kDisplayName2); 1798 kDisplayName2);
1796 UploadAndInstallDeviceLocalAccountPolicy(); 1799 UploadAndInstallDeviceLocalAccountPolicy();
1797 policy::BrowserPolicyConnectorChromeOS* connector = 1800 policy::BrowserPolicyConnectorChromeOS* connector =
1798 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 1801 g_browser_process->platform_part()->browser_policy_connector_chromeos();
1799 DeviceLocalAccountPolicyBroker* broker = 1802 DeviceLocalAccountPolicyBroker* broker =
1800 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( 1803 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser(
1801 user_id_1_); 1804 user_id_1_.GetUserEmail());
1802 ASSERT_TRUE(broker); 1805 ASSERT_TRUE(broker);
1803 broker->core()->store()->Load(); 1806 broker->core()->store()->Load();
1804 WaitForDisplayName(user_id_1_, kDisplayName2); 1807 WaitForDisplayName(user_id_1_.GetUserEmail(), kDisplayName2);
1805 1808
1806 // Verify that the new list of locales is shown in the UI. 1809 // Verify that the new list of locales is shown in the UI.
1807 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, 1810 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_,
1808 get_locale_list, 1811 get_locale_list,
1809 &json)); 1812 &json));
1810 value_ptr = base::JSONReader::Read(json); 1813 value_ptr = base::JSONReader::Read(json);
1811 locales = NULL; 1814 locales = NULL;
1812 ASSERT_TRUE(value_ptr); 1815 ASSERT_TRUE(value_ptr);
1813 ASSERT_TRUE(value_ptr->GetAsList(&locales)); 1816 ASSERT_TRUE(value_ptr->GetAsList(&locales));
1814 EXPECT_LT(arraysize(kRecommendedLocales2), locales->GetSize()); 1817 EXPECT_LT(arraysize(kRecommendedLocales2), locales->GetSize());
(...skipping 12 matching lines...) Expand all
1827 // Manually select a different locale. 1830 // Manually select a different locale.
1828 ASSERT_TRUE(content::ExecuteScript( 1831 ASSERT_TRUE(content::ExecuteScript(
1829 contents_, 1832 contents_,
1830 base::StringPrintf( 1833 base::StringPrintf(
1831 "var languageSelect = document.getElementById('pod-row')" 1834 "var languageSelect = document.getElementById('pod-row')"
1832 " .getPodWithUsername_('%s').querySelector('.language-select');" 1835 " .getPodWithUsername_('%s').querySelector('.language-select');"
1833 "languageSelect.value = '%s';" 1836 "languageSelect.value = '%s';"
1834 "var event = document.createEvent('HTMLEvents');" 1837 "var event = document.createEvent('HTMLEvents');"
1835 "event.initEvent('change', false, true);" 1838 "event.initEvent('change', false, true);"
1836 "languageSelect.dispatchEvent(event);", 1839 "languageSelect.dispatchEvent(event);",
1837 user_id_1_.c_str(), 1840 user_id_1_.GetUserEmail().c_str(), kPublicSessionLocale)));
1838 kPublicSessionLocale)));
1839 1841
1840 // Change the list of recommended locales. 1842 // Change the list of recommended locales.
1841 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); 1843 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2));
1842 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( 1844 device_local_account_policy_.payload().mutable_userdisplayname()->set_value(
1843 kDisplayName1); 1845 kDisplayName1);
1844 UploadAndInstallDeviceLocalAccountPolicy(); 1846 UploadAndInstallDeviceLocalAccountPolicy();
1845 broker->core()->store()->Load(); 1847 broker->core()->store()->Load();
1846 WaitForDisplayName(user_id_1_, kDisplayName1); 1848 WaitForDisplayName(user_id_1_.GetUserEmail(), kDisplayName1);
1847 1849
1848 // Verify that the manually selected locale is still selected. 1850 // Verify that the manually selected locale is still selected.
1849 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, 1851 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_,
1850 get_selected_locale, 1852 get_selected_locale,
1851 &selected_locale)); 1853 &selected_locale));
1852 EXPECT_EQ(kPublicSessionLocale, selected_locale); 1854 EXPECT_EQ(kPublicSessionLocale, selected_locale);
1853 1855
1854 // The UI will request an updated list of keyboard layouts at this point. Wait 1856 // The UI will request an updated list of keyboard layouts at this point. Wait
1855 // for the constructions of this list to finish. 1857 // for the constructions of this list to finish.
1856 WaitForGetKeyboardLayoutsForLocaleToFinish(); 1858 WaitForGetKeyboardLayoutsForLocaleToFinish();
1857 1859
1858 // Manually select a different keyboard layout. 1860 // Manually select a different keyboard layout.
1859 ASSERT_TRUE(content::ExecuteScript( 1861 ASSERT_TRUE(content::ExecuteScript(
1860 contents_, 1862 contents_,
1861 base::StringPrintf( 1863 base::StringPrintf(
1862 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1864 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1863 " .querySelector('.keyboard-select').value = '%s';", 1865 " .querySelector('.keyboard-select').value = '%s';",
1864 user_id_1_.c_str(), 1866 user_id_1_.GetUserEmail().c_str(),
1865 public_session_input_method_id_.c_str()))); 1867 public_session_input_method_id_.c_str())));
1866 1868
1867 // Click on a different pod, causing focus to shift away and the pod to 1869 // Click on a different pod, causing focus to shift away and the pod to
1868 // contract. 1870 // contract.
1869 ASSERT_TRUE(content::ExecuteScript( 1871 ASSERT_TRUE(content::ExecuteScript(
1870 contents_, 1872 contents_,
1871 base::StringPrintf( 1873 base::StringPrintf(
1872 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1874 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1873 " .click();", 1875 " .click();",
1874 user_id_2_.c_str()))); 1876 user_id_2_.GetUserEmail().c_str())));
1875 1877
1876 // Click on the pod again, causing it to expand again. Verify that the pod has 1878 // 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 1879 // kept all its state (the advanced form is being shown, the manually selected
1878 // locale and keyboard layout are selected). 1880 // locale and keyboard layout are selected).
1879 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 1881 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
1880 contents_, 1882 contents_,
1881 base::StringPrintf( 1883 base::StringPrintf(
1882 "var pod =" 1884 "var pod ="
1883 " document.getElementById('pod-row').getPodWithUsername_('%s');" 1885 " document.getElementById('pod-row').getPodWithUsername_('%s');"
1884 "pod.click();" 1886 "pod.click();"
1885 "var state = {};" 1887 "var state = {};"
1886 "state.advanced = pod.classList.contains('advanced');" 1888 "state.advanced = pod.classList.contains('advanced');"
1887 "state.locale = pod.querySelector('.language-select').value;" 1889 "state.locale = pod.querySelector('.language-select').value;"
1888 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" 1890 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;"
1889 "console.log(JSON.stringify(state));" 1891 "console.log(JSON.stringify(state));"
1890 "domAutomationController.send(JSON.stringify(state));", 1892 "domAutomationController.send(JSON.stringify(state));",
1891 user_id_1_.c_str()), 1893 user_id_1_.GetUserEmail().c_str()),
1892 &json)); 1894 &json));
1893 LOG(ERROR) << json; 1895 LOG(ERROR) << json;
1894 value_ptr = base::JSONReader::Read(json); 1896 value_ptr = base::JSONReader::Read(json);
1895 const base::DictionaryValue* state = NULL; 1897 const base::DictionaryValue* state = NULL;
1896 ASSERT_TRUE(value_ptr); 1898 ASSERT_TRUE(value_ptr);
1897 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); 1899 ASSERT_TRUE(value_ptr->GetAsDictionary(&state));
1898 bool advanced = false; 1900 bool advanced = false;
1899 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); 1901 EXPECT_TRUE(state->GetBoolean("advanced", &advanced));
1900 EXPECT_TRUE(advanced); 1902 EXPECT_TRUE(advanced);
1901 EXPECT_TRUE(state->GetString("locale", &selected_locale)); 1903 EXPECT_TRUE(state->GetString("locale", &selected_locale));
1902 EXPECT_EQ(kPublicSessionLocale, selected_locale); 1904 EXPECT_EQ(kPublicSessionLocale, selected_locale);
1903 std::string selected_keyboard_layout; 1905 std::string selected_keyboard_layout;
1904 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); 1906 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout));
1905 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); 1907 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout);
1906 1908
1907 // Click the enter button to start the session. 1909 // Click the enter button to start the session.
1908 ASSERT_TRUE(content::ExecuteScript( 1910 ASSERT_TRUE(content::ExecuteScript(
1909 contents_, 1911 contents_,
1910 base::StringPrintf( 1912 base::StringPrintf(
1911 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1913 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1912 " .querySelector('.enter-button').click();", 1914 " .querySelector('.enter-button').click();",
1913 user_id_1_.c_str()))); 1915 user_id_1_.GetUserEmail().c_str())));
1914 1916
1915 WaitForSessionStart(); 1917 WaitForSessionStart();
1916 1918
1917 // Verify that the locale and keyboard layout have been applied. 1919 // Verify that the locale and keyboard layout have been applied.
1918 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); 1920 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale());
1919 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), 1921 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale),
1920 icu::Locale::getDefault().getLanguage()); 1922 icu::Locale::getDefault().getLanguage());
1921 EXPECT_EQ(public_session_input_method_id_, 1923 EXPECT_EQ(public_session_input_method_id_,
1922 chromeos::input_method::InputMethodManager::Get() 1924 chromeos::input_method::InputMethodManager::Get()
1923 ->GetActiveIMEState() 1925 ->GetActiveIMEState()
(...skipping 13 matching lines...) Expand all
1937 // Click on the pod to expand it. Verify that the pod expands to its basic 1939 // Click on the pod to expand it. Verify that the pod expands to its basic
1938 // form as there is only one recommended locale. 1940 // form as there is only one recommended locale.
1939 bool advanced = false; 1941 bool advanced = false;
1940 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 1942 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
1941 contents_, 1943 contents_,
1942 base::StringPrintf( 1944 base::StringPrintf(
1943 "var pod =" 1945 "var pod ="
1944 " document.getElementById('pod-row').getPodWithUsername_('%s');" 1946 " document.getElementById('pod-row').getPodWithUsername_('%s');"
1945 "pod.click();" 1947 "pod.click();"
1946 "domAutomationController.send(pod.classList.contains('advanced'));", 1948 "domAutomationController.send(pod.classList.contains('advanced'));",
1947 user_id_1_.c_str()), 1949 user_id_1_.GetUserEmail().c_str()),
1948 &advanced)); 1950 &advanced));
1949 EXPECT_FALSE(advanced); 1951 EXPECT_FALSE(advanced);
1950 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), 1952 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_),
1951 icu::Locale::getDefault().getLanguage()); 1953 icu::Locale::getDefault().getLanguage());
1952 1954
1953 // Click the enter button to start the session. 1955 // Click the enter button to start the session.
1954 ASSERT_TRUE(content::ExecuteScript( 1956 ASSERT_TRUE(content::ExecuteScript(
1955 contents_, 1957 contents_,
1956 base::StringPrintf( 1958 base::StringPrintf(
1957 "document.getElementById('pod-row').getPodWithUsername_('%s')" 1959 "document.getElementById('pod-row').getPodWithUsername_('%s')"
1958 " .querySelector('.enter-button').click();", 1960 " .querySelector('.enter-button').click();",
1959 user_id_1_.c_str()))); 1961 user_id_1_.GetUserEmail().c_str())));
1960 1962
1961 WaitForSessionStart(); 1963 WaitForSessionStart();
1962 1964
1963 // Verify that since the recommended locale was invalid, the locale has not 1965 // 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. 1966 // changed and the first keyboard layout applicable to the locale was chosen.
1965 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); 1967 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale());
1966 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), 1968 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_),
1967 icu::Locale::getDefault().getLanguage()); 1969 icu::Locale::getDefault().getLanguage());
1968 VerifyKeyboardLayoutMatchesLocale(); 1970 VerifyKeyboardLayoutMatchesLocale();
1969 } 1971 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 // Select a different locale. 2044 // Select a different locale.
2043 ASSERT_TRUE(content::ExecuteScript( 2045 ASSERT_TRUE(content::ExecuteScript(
2044 contents_, 2046 contents_,
2045 base::StringPrintf( 2047 base::StringPrintf(
2046 "var languageSelect = document.getElementById('pod-row')" 2048 "var languageSelect = document.getElementById('pod-row')"
2047 " .getPodWithUsername_('%s').querySelector('.language-select');" 2049 " .getPodWithUsername_('%s').querySelector('.language-select');"
2048 "languageSelect.value = '%s';" 2050 "languageSelect.value = '%s';"
2049 "var event = document.createEvent('HTMLEvents');" 2051 "var event = document.createEvent('HTMLEvents');"
2050 "event.initEvent('change', false, true);" 2052 "event.initEvent('change', false, true);"
2051 "languageSelect.dispatchEvent(event);", 2053 "languageSelect.dispatchEvent(event);",
2052 user_id_1_.c_str(), 2054 user_id_1_.GetUserEmail().c_str(), kPublicSessionLocale)));
2053 kPublicSessionLocale)));
2054 2055
2055 // The UI will have requested an updated list of keyboard layouts at this 2056 // The UI will have requested an updated list of keyboard layouts at this
2056 // point. Wait for the constructions of this list to finish. 2057 // point. Wait for the constructions of this list to finish.
2057 WaitForGetKeyboardLayoutsForLocaleToFinish(); 2058 WaitForGetKeyboardLayoutsForLocaleToFinish();
2058 2059
2059 // Set up an observer that will quit the message loop when login has succeeded 2060 // 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. 2061 // and the first wizard screen, if any, is being shown.
2061 base::RunLoop login_wait_run_loop; 2062 base::RunLoop login_wait_run_loop;
2062 chromeos::MockAuthStatusConsumer login_status_consumer; 2063 chromeos::MockAuthStatusConsumer login_status_consumer;
2063 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( 2064 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce(
2064 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); 2065 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit));
2065 chromeos::ExistingUserController* controller = 2066 chromeos::ExistingUserController* controller =
2066 chromeos::ExistingUserController::current_controller(); 2067 chromeos::ExistingUserController::current_controller();
2067 ASSERT_TRUE(controller); 2068 ASSERT_TRUE(controller);
2068 controller->set_login_status_consumer(&login_status_consumer); 2069 controller->set_login_status_consumer(&login_status_consumer);
2069 2070
2070 // Manually select a different keyboard layout and click the enter button to 2071 // Manually select a different keyboard layout and click the enter button to
2071 // start the session. 2072 // start the session.
2072 ASSERT_TRUE(content::ExecuteScript( 2073 ASSERT_TRUE(content::ExecuteScript(
2073 contents_, 2074 contents_,
2074 base::StringPrintf( 2075 base::StringPrintf(
2075 "var pod =" 2076 "var pod ="
2076 " document.getElementById('pod-row').getPodWithUsername_('%s');" 2077 " document.getElementById('pod-row').getPodWithUsername_('%s');"
2077 "pod.querySelector('.keyboard-select').value = '%s';" 2078 "pod.querySelector('.keyboard-select').value = '%s';"
2078 "pod.querySelector('.enter-button').click();", 2079 "pod.querySelector('.enter-button').click();",
2079 user_id_1_.c_str(), 2080 user_id_1_.GetUserEmail().c_str(),
2080 public_session_input_method_id_.c_str()))); 2081 public_session_input_method_id_.c_str())));
2081 2082
2082 // Spin the loop until the login observer fires. Then, unregister the 2083 // Spin the loop until the login observer fires. Then, unregister the
2083 // observer. 2084 // observer.
2084 login_wait_run_loop.Run(); 2085 login_wait_run_loop.Run();
2085 controller->set_login_status_consumer(NULL); 2086 controller->set_login_status_consumer(NULL);
2086 2087
2087 // Verify that the Terms of Service screen is being shown. 2088 // Verify that the Terms of Service screen is being shown.
2088 chromeos::WizardController* wizard_controller = 2089 chromeos::WizardController* wizard_controller =
2089 chromeos::WizardController::default_controller(); 2090 chromeos::WizardController::default_controller();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 ASSERT_TRUE(content::ExecuteScript(contents_, 2384 ASSERT_TRUE(content::ExecuteScript(contents_,
2384 "$('tos-accept-button').click();")); 2385 "$('tos-accept-button').click();"));
2385 2386
2386 WaitForSessionStart(); 2387 WaitForSessionStart();
2387 } 2388 }
2388 2389
2389 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, 2390 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance,
2390 TermsOfServiceDownloadTest, testing::Bool()); 2391 TermsOfServiceDownloadTest, testing::Bool());
2391 2392
2392 } // namespace policy 2393 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698