| 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 "chrome/browser/chromeos/policy/device_local_account.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); | 679 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void ExpandPublicSessionPod(bool expect_advanced) { | 682 void ExpandPublicSessionPod(bool expect_advanced) { |
| 683 bool advanced = false; | 683 bool advanced = false; |
| 684 // Click on the pod to expand it. | 684 // Click on the pod to expand it. |
| 685 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 685 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 686 contents_, | 686 contents_, |
| 687 base::StringPrintf( | 687 base::StringPrintf( |
| 688 "var pod =" | 688 "var pod =" |
| 689 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 689 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 690 "pod.click();" | 690 "pod.click();" |
| 691 "domAutomationController.send(pod.classList.contains('advanced'));", | 691 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 692 account_id_1_.Serialize().c_str()), | 692 account_id_1_.Serialize().c_str()), |
| 693 &advanced)); | 693 &advanced)); |
| 694 // Verify that the pod expanded to its basic/advanced form, as expected. | 694 // Verify that the pod expanded to its basic/advanced form, as expected. |
| 695 EXPECT_EQ(expect_advanced, advanced); | 695 EXPECT_EQ(expect_advanced, advanced); |
| 696 | 696 |
| 697 // Verify that the construction of the pod's language list did not affect | 697 // Verify that the construction of the pod's language list did not affect |
| 698 // the current ICU locale. | 698 // the current ICU locale. |
| 699 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 699 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 // Flaky: http://crbug.com/512670. | 896 // Flaky: http://crbug.com/512670. |
| 897 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { | 897 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { |
| 898 UploadAndInstallDeviceLocalAccountPolicy(); | 898 UploadAndInstallDeviceLocalAccountPolicy(); |
| 899 AddPublicSessionToDevicePolicy(kAccountId1); | 899 AddPublicSessionToDevicePolicy(kAccountId1); |
| 900 | 900 |
| 901 WaitForPolicy(); | 901 WaitForPolicy(); |
| 902 | 902 |
| 903 // Verify that the display name is shown in the UI. | 903 // Verify that the display name is shown in the UI. |
| 904 const std::string get_compact_pod_display_name = base::StringPrintf( | 904 const std::string get_compact_pod_display_name = base::StringPrintf( |
| 905 "domAutomationController.send(document.getElementById('pod-row')" | 905 "domAutomationController.send(document.getElementById('pod-row')" |
| 906 " .getPodWithUsername_('%s').nameElement.textContent);", | 906 " .getPodWithUsername('%s').nameElement.textContent);", |
| 907 account_id_1_.Serialize().c_str()); | 907 account_id_1_.Serialize().c_str()); |
| 908 std::string display_name; | 908 std::string display_name; |
| 909 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 909 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 910 contents_, | 910 contents_, |
| 911 get_compact_pod_display_name, | 911 get_compact_pod_display_name, |
| 912 &display_name)); | 912 &display_name)); |
| 913 EXPECT_EQ(kDisplayName1, display_name); | 913 EXPECT_EQ(kDisplayName1, display_name); |
| 914 const std::string get_expanded_pod_display_name = base::StringPrintf( | 914 const std::string get_expanded_pod_display_name = base::StringPrintf( |
| 915 "domAutomationController.send(document.getElementById('pod-row')" | 915 "domAutomationController.send(document.getElementById('pod-row')" |
| 916 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" | 916 " .getPodWithUsername('%s').querySelector('.expanded-pane-name')" |
| 917 " .textContent);", | 917 " .textContent);", |
| 918 account_id_1_.Serialize().c_str()); | 918 account_id_1_.Serialize().c_str()); |
| 919 display_name.clear(); | 919 display_name.clear(); |
| 920 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 920 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 921 contents_, | 921 contents_, |
| 922 get_expanded_pod_display_name, | 922 get_expanded_pod_display_name, |
| 923 &display_name)); | 923 &display_name)); |
| 924 EXPECT_EQ(kDisplayName1, display_name); | 924 EXPECT_EQ(kDisplayName1, display_name); |
| 925 | 925 |
| 926 // Click on the pod to expand it. | 926 // Click on the pod to expand it. |
| 927 ASSERT_TRUE(content::ExecuteScript( | 927 ASSERT_TRUE(content::ExecuteScript( |
| 928 contents_, | 928 contents_, |
| 929 base::StringPrintf( | 929 base::StringPrintf( |
| 930 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 930 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 931 " .click();", | 931 " .click();", |
| 932 account_id_1_.Serialize().c_str()))); | 932 account_id_1_.Serialize().c_str()))); |
| 933 | 933 |
| 934 // Change the display name. | 934 // Change the display name. |
| 935 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 935 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 936 kDisplayName2); | 936 kDisplayName2); |
| 937 UploadAndInstallDeviceLocalAccountPolicy(); | 937 UploadAndInstallDeviceLocalAccountPolicy(); |
| 938 policy::BrowserPolicyConnectorChromeOS* connector = | 938 policy::BrowserPolicyConnectorChromeOS* connector = |
| 939 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 939 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 940 DeviceLocalAccountPolicyBroker* broker = | 940 DeviceLocalAccountPolicyBroker* broker = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 958 &display_name)); | 958 &display_name)); |
| 959 EXPECT_EQ(kDisplayName2, display_name); | 959 EXPECT_EQ(kDisplayName2, display_name); |
| 960 | 960 |
| 961 // Verify that the pod is still expanded. This indicates that the UI updated | 961 // Verify that the pod is still expanded. This indicates that the UI updated |
| 962 // without reloading and losing state. | 962 // without reloading and losing state. |
| 963 bool expanded = false; | 963 bool expanded = false; |
| 964 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 964 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 965 contents_, | 965 contents_, |
| 966 base::StringPrintf( | 966 base::StringPrintf( |
| 967 "domAutomationController.send(document.getElementById('pod-row')" | 967 "domAutomationController.send(document.getElementById('pod-row')" |
| 968 " .getPodWithUsername_('%s').expanded);", | 968 " .getPodWithUsername('%s').expanded);", |
| 969 account_id_1_.Serialize().c_str()), | 969 account_id_1_.Serialize().c_str()), |
| 970 &expanded)); | 970 &expanded)); |
| 971 EXPECT_TRUE(expanded); | 971 EXPECT_TRUE(expanded); |
| 972 } | 972 } |
| 973 | 973 |
| 974 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { | 974 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { |
| 975 UploadDeviceLocalAccountPolicy(); | 975 UploadDeviceLocalAccountPolicy(); |
| 976 AddPublicSessionToDevicePolicy(kAccountId1); | 976 AddPublicSessionToDevicePolicy(kAccountId1); |
| 977 | 977 |
| 978 WaitForPolicy(); | 978 WaitForPolicy(); |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 AddPublicSessionToDevicePolicy(kAccountId1); | 1676 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1677 | 1677 |
| 1678 WaitForPolicy(); | 1678 WaitForPolicy(); |
| 1679 | 1679 |
| 1680 ExpandPublicSessionPod(false); | 1680 ExpandPublicSessionPod(false); |
| 1681 | 1681 |
| 1682 // Click the enter button to start the session. | 1682 // Click the enter button to start the session. |
| 1683 ASSERT_TRUE(content::ExecuteScript( | 1683 ASSERT_TRUE(content::ExecuteScript( |
| 1684 contents_, | 1684 contents_, |
| 1685 base::StringPrintf( | 1685 base::StringPrintf( |
| 1686 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1686 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 1687 " .querySelector('.enter-button').click();", | 1687 " .querySelector('.enter-button').click();", |
| 1688 account_id_1_.Serialize().c_str()))); | 1688 account_id_1_.Serialize().c_str()))); |
| 1689 | 1689 |
| 1690 WaitForSessionStart(); | 1690 WaitForSessionStart(); |
| 1691 | 1691 |
| 1692 // Verify that the locale has not changed and the first keyboard layout | 1692 // Verify that the locale has not changed and the first keyboard layout |
| 1693 // applicable to the locale was chosen. | 1693 // applicable to the locale was chosen. |
| 1694 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 1694 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1695 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 1695 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1696 VerifyKeyboardLayoutMatchesLocale(); | 1696 VerifyKeyboardLayoutMatchesLocale(); |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1699 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
| 1700 UploadAndInstallDeviceLocalAccountPolicy(); | 1700 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1701 AddPublicSessionToDevicePolicy(kAccountId1); | 1701 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1702 | 1702 |
| 1703 WaitForPolicy(); | 1703 WaitForPolicy(); |
| 1704 | 1704 |
| 1705 ExpandPublicSessionPod(false); | 1705 ExpandPublicSessionPod(false); |
| 1706 | 1706 |
| 1707 // Click the link that switches the pod to its advanced form. Verify that the | 1707 // Click the link that switches the pod to its advanced form. Verify that the |
| 1708 // pod switches from basic to advanced. | 1708 // pod switches from basic to advanced. |
| 1709 bool advanced = false; | 1709 bool advanced = false; |
| 1710 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1710 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1711 contents_, | 1711 contents_, |
| 1712 base::StringPrintf( | 1712 base::StringPrintf( |
| 1713 "var pod =" | 1713 "var pod =" |
| 1714 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1714 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 1715 "pod.querySelector('.language-and-input').click();" | 1715 "pod.querySelector('.language-and-input').click();" |
| 1716 "domAutomationController.send(pod.classList.contains('advanced'));", | 1716 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1717 account_id_1_.Serialize().c_str()), | 1717 account_id_1_.Serialize().c_str()), |
| 1718 &advanced)); | 1718 &advanced)); |
| 1719 EXPECT_FALSE(advanced); | 1719 EXPECT_FALSE(advanced); |
| 1720 | 1720 |
| 1721 // Manually select a different locale. | 1721 // Manually select a different locale. |
| 1722 ASSERT_TRUE(content::ExecuteScript( | 1722 ASSERT_TRUE(content::ExecuteScript( |
| 1723 contents_, | 1723 contents_, |
| 1724 base::StringPrintf( | 1724 base::StringPrintf( |
| 1725 "var languageSelect = document.getElementById('pod-row')" | 1725 "var languageSelect = document.getElementById('pod-row')" |
| 1726 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1726 " .getPodWithUsername('%s').querySelector('.language-select');" |
| 1727 "languageSelect.value = '%s';" | 1727 "languageSelect.value = '%s';" |
| 1728 "var event = document.createEvent('HTMLEvents');" | 1728 "var event = document.createEvent('HTMLEvents');" |
| 1729 "event.initEvent('change', false, true);" | 1729 "event.initEvent('change', false, true);" |
| 1730 "languageSelect.dispatchEvent(event);", | 1730 "languageSelect.dispatchEvent(event);", |
| 1731 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); | 1731 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 1732 | 1732 |
| 1733 // The UI will have requested an updated list of keyboard layouts at this | 1733 // The UI will have requested an updated list of keyboard layouts at this |
| 1734 // point. Wait for the constructions of this list to finish. | 1734 // point. Wait for the constructions of this list to finish. |
| 1735 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1735 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1736 | 1736 |
| 1737 // Manually select a different keyboard layout and click the enter button to | 1737 // Manually select a different keyboard layout and click the enter button to |
| 1738 // start the session. | 1738 // start the session. |
| 1739 ASSERT_TRUE(content::ExecuteScript( | 1739 ASSERT_TRUE(content::ExecuteScript( |
| 1740 contents_, | 1740 contents_, |
| 1741 base::StringPrintf( | 1741 base::StringPrintf( |
| 1742 "var pod =" | 1742 "var pod =" |
| 1743 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1743 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 1744 "pod.querySelector('.keyboard-select').value = '%s';" | 1744 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1745 "pod.querySelector('.enter-button').click();", | 1745 "pod.querySelector('.enter-button').click();", |
| 1746 account_id_1_.Serialize().c_str(), | 1746 account_id_1_.Serialize().c_str(), |
| 1747 public_session_input_method_id_.c_str()))); | 1747 public_session_input_method_id_.c_str()))); |
| 1748 | 1748 |
| 1749 WaitForSessionStart(); | 1749 WaitForSessionStart(); |
| 1750 | 1750 |
| 1751 // Verify that the locale and keyboard layout have been applied. | 1751 // Verify that the locale and keyboard layout have been applied. |
| 1752 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1752 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1753 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1753 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1767 AddPublicSessionToDevicePolicy(kAccountId1); | 1767 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1768 | 1768 |
| 1769 WaitForPolicy(); | 1769 WaitForPolicy(); |
| 1770 | 1770 |
| 1771 ExpandPublicSessionPod(false); | 1771 ExpandPublicSessionPod(false); |
| 1772 | 1772 |
| 1773 // Click the enter button to start the session. | 1773 // Click the enter button to start the session. |
| 1774 ASSERT_TRUE(content::ExecuteScript( | 1774 ASSERT_TRUE(content::ExecuteScript( |
| 1775 contents_, | 1775 contents_, |
| 1776 base::StringPrintf( | 1776 base::StringPrintf( |
| 1777 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1777 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 1778 " .querySelector('.enter-button').click();", | 1778 " .querySelector('.enter-button').click();", |
| 1779 account_id_1_.Serialize().c_str()))); | 1779 account_id_1_.Serialize().c_str()))); |
| 1780 | 1780 |
| 1781 WaitForSessionStart(); | 1781 WaitForSessionStart(); |
| 1782 | 1782 |
| 1783 // Verify that the recommended locale has been applied and the first keyboard | 1783 // Verify that the recommended locale has been applied and the first keyboard |
| 1784 // layout applicable to the locale was chosen. | 1784 // layout applicable to the locale was chosen. |
| 1785 EXPECT_EQ(kSingleRecommendedLocale[0], | 1785 EXPECT_EQ(kSingleRecommendedLocale[0], |
| 1786 g_browser_process->GetApplicationLocale()); | 1786 g_browser_process->GetApplicationLocale()); |
| 1787 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), | 1787 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
| 1788 icu::Locale::getDefault().getLanguage()); | 1788 icu::Locale::getDefault().getLanguage()); |
| 1789 VerifyKeyboardLayoutMatchesLocale(); | 1789 VerifyKeyboardLayoutMatchesLocale(); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { | 1792 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
| 1793 // Specify recommended locales. | 1793 // Specify recommended locales. |
| 1794 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); | 1794 SetRecommendedLocales(kRecommendedLocales1, arraysize(kRecommendedLocales1)); |
| 1795 UploadAndInstallDeviceLocalAccountPolicy(); | 1795 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1796 AddPublicSessionToDevicePolicy(kAccountId1); | 1796 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1797 AddPublicSessionToDevicePolicy(kAccountId2); | 1797 AddPublicSessionToDevicePolicy(kAccountId2); |
| 1798 | 1798 |
| 1799 WaitForPolicy(); | 1799 WaitForPolicy(); |
| 1800 | 1800 |
| 1801 ExpandPublicSessionPod(true); | 1801 ExpandPublicSessionPod(true); |
| 1802 | 1802 |
| 1803 // Verify that the pod shows a list of locales beginning with the recommended | 1803 // Verify that the pod shows a list of locales beginning with the recommended |
| 1804 // ones, followed by others. | 1804 // ones, followed by others. |
| 1805 const std::string get_locale_list = base::StringPrintf( | 1805 const std::string get_locale_list = base::StringPrintf( |
| 1806 "var languageSelect = document.getElementById('pod-row')" | 1806 "var languageSelect = document.getElementById('pod-row')" |
| 1807 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1807 " .getPodWithUsername('%s').querySelector('.language-select');" |
| 1808 "var locales = [];" | 1808 "var locales = [];" |
| 1809 "for (var i = 0; i < languageSelect.length; ++i)" | 1809 "for (var i = 0; i < languageSelect.length; ++i)" |
| 1810 " locales.push(languageSelect.options[i].value);" | 1810 " locales.push(languageSelect.options[i].value);" |
| 1811 "domAutomationController.send(JSON.stringify(locales));", | 1811 "domAutomationController.send(JSON.stringify(locales));", |
| 1812 account_id_1_.Serialize().c_str()); | 1812 account_id_1_.Serialize().c_str()); |
| 1813 std::string json; | 1813 std::string json; |
| 1814 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1814 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1815 get_locale_list, | 1815 get_locale_list, |
| 1816 &json)); | 1816 &json)); |
| 1817 std::unique_ptr<base::Value> value_ptr = base::JSONReader::Read(json); | 1817 std::unique_ptr<base::Value> value_ptr = base::JSONReader::Read(json); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1835 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); | 1835 for (size_t i = arraysize(kRecommendedLocales1); i < locales->GetSize(); |
| 1836 ++i) { | 1836 ++i) { |
| 1837 std::string locale; | 1837 std::string locale; |
| 1838 EXPECT_TRUE(locales->GetString(i, &locale)); | 1838 EXPECT_TRUE(locales->GetString(i, &locale)); |
| 1839 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); | 1839 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 // Verify that the first recommended locale is selected. | 1842 // Verify that the first recommended locale is selected. |
| 1843 const std::string get_selected_locale = base::StringPrintf( | 1843 const std::string get_selected_locale = base::StringPrintf( |
| 1844 "domAutomationController.send(document.getElementById('pod-row')" | 1844 "domAutomationController.send(document.getElementById('pod-row')" |
| 1845 " .getPodWithUsername_('%s').querySelector('.language-select')" | 1845 " .getPodWithUsername('%s').querySelector('.language-select')" |
| 1846 " .value);", | 1846 " .value);", |
| 1847 account_id_1_.Serialize().c_str()); | 1847 account_id_1_.Serialize().c_str()); |
| 1848 std::string selected_locale; | 1848 std::string selected_locale; |
| 1849 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1849 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1850 get_selected_locale, | 1850 get_selected_locale, |
| 1851 &selected_locale)); | 1851 &selected_locale)); |
| 1852 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); | 1852 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); |
| 1853 | 1853 |
| 1854 // Change the list of recommended locales. | 1854 // Change the list of recommended locales. |
| 1855 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1855 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1887 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1888 get_selected_locale, | 1888 get_selected_locale, |
| 1889 &selected_locale)); | 1889 &selected_locale)); |
| 1890 EXPECT_EQ(kRecommendedLocales2[0], selected_locale); | 1890 EXPECT_EQ(kRecommendedLocales2[0], selected_locale); |
| 1891 | 1891 |
| 1892 // Manually select a different locale. | 1892 // Manually select a different locale. |
| 1893 ASSERT_TRUE(content::ExecuteScript( | 1893 ASSERT_TRUE(content::ExecuteScript( |
| 1894 contents_, | 1894 contents_, |
| 1895 base::StringPrintf( | 1895 base::StringPrintf( |
| 1896 "var languageSelect = document.getElementById('pod-row')" | 1896 "var languageSelect = document.getElementById('pod-row')" |
| 1897 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1897 " .getPodWithUsername('%s').querySelector('.language-select');" |
| 1898 "languageSelect.value = '%s';" | 1898 "languageSelect.value = '%s';" |
| 1899 "var event = document.createEvent('HTMLEvents');" | 1899 "var event = document.createEvent('HTMLEvents');" |
| 1900 "event.initEvent('change', false, true);" | 1900 "event.initEvent('change', false, true);" |
| 1901 "languageSelect.dispatchEvent(event);", | 1901 "languageSelect.dispatchEvent(event);", |
| 1902 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); | 1902 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 1903 | 1903 |
| 1904 // Change the list of recommended locales. | 1904 // Change the list of recommended locales. |
| 1905 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1905 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| 1906 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 1906 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 1907 kDisplayName1); | 1907 kDisplayName1); |
| 1908 UploadAndInstallDeviceLocalAccountPolicy(); | 1908 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1909 broker->core()->store()->Load(); | 1909 broker->core()->store()->Load(); |
| 1910 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); | 1910 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); |
| 1911 | 1911 |
| 1912 // Verify that the manually selected locale is still selected. | 1912 // Verify that the manually selected locale is still selected. |
| 1913 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1913 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1914 get_selected_locale, | 1914 get_selected_locale, |
| 1915 &selected_locale)); | 1915 &selected_locale)); |
| 1916 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1916 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1917 | 1917 |
| 1918 // The UI will request an updated list of keyboard layouts at this point. Wait | 1918 // The UI will request an updated list of keyboard layouts at this point. Wait |
| 1919 // for the constructions of this list to finish. | 1919 // for the constructions of this list to finish. |
| 1920 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1920 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1921 | 1921 |
| 1922 // Manually select a different keyboard layout. | 1922 // Manually select a different keyboard layout. |
| 1923 ASSERT_TRUE(content::ExecuteScript( | 1923 ASSERT_TRUE(content::ExecuteScript( |
| 1924 contents_, | 1924 contents_, |
| 1925 base::StringPrintf( | 1925 base::StringPrintf( |
| 1926 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1926 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 1927 " .querySelector('.keyboard-select').value = '%s';", | 1927 " .querySelector('.keyboard-select').value = '%s';", |
| 1928 account_id_1_.Serialize().c_str(), | 1928 account_id_1_.Serialize().c_str(), |
| 1929 public_session_input_method_id_.c_str()))); | 1929 public_session_input_method_id_.c_str()))); |
| 1930 | 1930 |
| 1931 // Click on a different pod, causing focus to shift away and the pod to | 1931 // Click on a different pod, causing focus to shift away and the pod to |
| 1932 // contract. | 1932 // contract. |
| 1933 ASSERT_TRUE(content::ExecuteScript( | 1933 ASSERT_TRUE(content::ExecuteScript( |
| 1934 contents_, | 1934 contents_, |
| 1935 base::StringPrintf( | 1935 base::StringPrintf( |
| 1936 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1936 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 1937 " .click();", | 1937 " .click();", |
| 1938 account_id_2_.Serialize().c_str()))); | 1938 account_id_2_.Serialize().c_str()))); |
| 1939 | 1939 |
| 1940 // Click on the pod again, causing it to expand again. Verify that the pod has | 1940 // Click on the pod again, causing it to expand again. Verify that the pod has |
| 1941 // kept all its state (the advanced form is being shown, the manually selected | 1941 // kept all its state (the advanced form is being shown, the manually selected |
| 1942 // locale and keyboard layout are selected). | 1942 // locale and keyboard layout are selected). |
| 1943 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 1943 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 1944 contents_, | 1944 contents_, |
| 1945 base::StringPrintf( | 1945 base::StringPrintf( |
| 1946 "var pod =" | 1946 "var pod =" |
| 1947 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1947 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 1948 "pod.click();" | 1948 "pod.click();" |
| 1949 "var state = {};" | 1949 "var state = {};" |
| 1950 "state.advanced = pod.classList.contains('advanced');" | 1950 "state.advanced = pod.classList.contains('advanced');" |
| 1951 "state.locale = pod.querySelector('.language-select').value;" | 1951 "state.locale = pod.querySelector('.language-select').value;" |
| 1952 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" | 1952 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" |
| 1953 "console.log(JSON.stringify(state));" | 1953 "console.log(JSON.stringify(state));" |
| 1954 "domAutomationController.send(JSON.stringify(state));", | 1954 "domAutomationController.send(JSON.stringify(state));", |
| 1955 account_id_1_.Serialize().c_str()), | 1955 account_id_1_.Serialize().c_str()), |
| 1956 &json)); | 1956 &json)); |
| 1957 LOG(ERROR) << json; | 1957 LOG(ERROR) << json; |
| 1958 value_ptr = base::JSONReader::Read(json); | 1958 value_ptr = base::JSONReader::Read(json); |
| 1959 const base::DictionaryValue* state = NULL; | 1959 const base::DictionaryValue* state = NULL; |
| 1960 ASSERT_TRUE(value_ptr); | 1960 ASSERT_TRUE(value_ptr); |
| 1961 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); | 1961 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); |
| 1962 bool advanced = false; | 1962 bool advanced = false; |
| 1963 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); | 1963 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); |
| 1964 EXPECT_TRUE(advanced); | 1964 EXPECT_TRUE(advanced); |
| 1965 EXPECT_TRUE(state->GetString("locale", &selected_locale)); | 1965 EXPECT_TRUE(state->GetString("locale", &selected_locale)); |
| 1966 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1966 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1967 std::string selected_keyboard_layout; | 1967 std::string selected_keyboard_layout; |
| 1968 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); | 1968 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); |
| 1969 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); | 1969 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); |
| 1970 | 1970 |
| 1971 // Click the enter button to start the session. | 1971 // Click the enter button to start the session. |
| 1972 ASSERT_TRUE(content::ExecuteScript( | 1972 ASSERT_TRUE(content::ExecuteScript( |
| 1973 contents_, | 1973 contents_, |
| 1974 base::StringPrintf( | 1974 base::StringPrintf( |
| 1975 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1975 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 1976 " .querySelector('.enter-button').click();", | 1976 " .querySelector('.enter-button').click();", |
| 1977 account_id_1_.Serialize().c_str()))); | 1977 account_id_1_.Serialize().c_str()))); |
| 1978 | 1978 |
| 1979 WaitForSessionStart(); | 1979 WaitForSessionStart(); |
| 1980 | 1980 |
| 1981 // Verify that the locale and keyboard layout have been applied. | 1981 // Verify that the locale and keyboard layout have been applied. |
| 1982 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1982 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1983 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1983 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1984 icu::Locale::getDefault().getLanguage()); | 1984 icu::Locale::getDefault().getLanguage()); |
| 1985 EXPECT_EQ(public_session_input_method_id_, | 1985 EXPECT_EQ(public_session_input_method_id_, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1998 | 1998 |
| 1999 WaitForPolicy(); | 1999 WaitForPolicy(); |
| 2000 | 2000 |
| 2001 // Click on the pod to expand it. Verify that the pod expands to its basic | 2001 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 2002 // form as there is only one recommended locale. | 2002 // form as there is only one recommended locale. |
| 2003 bool advanced = false; | 2003 bool advanced = false; |
| 2004 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 2004 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 2005 contents_, | 2005 contents_, |
| 2006 base::StringPrintf( | 2006 base::StringPrintf( |
| 2007 "var pod =" | 2007 "var pod =" |
| 2008 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 2008 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 2009 "pod.click();" | 2009 "pod.click();" |
| 2010 "domAutomationController.send(pod.classList.contains('advanced'));", | 2010 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 2011 account_id_1_.Serialize().c_str()), | 2011 account_id_1_.Serialize().c_str()), |
| 2012 &advanced)); | 2012 &advanced)); |
| 2013 EXPECT_FALSE(advanced); | 2013 EXPECT_FALSE(advanced); |
| 2014 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 2014 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
| 2015 icu::Locale::getDefault().getLanguage()); | 2015 icu::Locale::getDefault().getLanguage()); |
| 2016 | 2016 |
| 2017 // Click the enter button to start the session. | 2017 // Click the enter button to start the session. |
| 2018 ASSERT_TRUE(content::ExecuteScript( | 2018 ASSERT_TRUE(content::ExecuteScript( |
| 2019 contents_, | 2019 contents_, |
| 2020 base::StringPrintf( | 2020 base::StringPrintf( |
| 2021 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 2021 "document.getElementById('pod-row').getPodWithUsername('%s')" |
| 2022 " .querySelector('.enter-button').click();", | 2022 " .querySelector('.enter-button').click();", |
| 2023 account_id_1_.Serialize().c_str()))); | 2023 account_id_1_.Serialize().c_str()))); |
| 2024 | 2024 |
| 2025 WaitForSessionStart(); | 2025 WaitForSessionStart(); |
| 2026 | 2026 |
| 2027 // Verify that since the recommended locale was invalid, the locale has not | 2027 // Verify that since the recommended locale was invalid, the locale has not |
| 2028 // changed and the first keyboard layout applicable to the locale was chosen. | 2028 // changed and the first keyboard layout applicable to the locale was chosen. |
| 2029 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 2029 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 2030 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 2030 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
| 2031 icu::Locale::getDefault().getLanguage()); | 2031 icu::Locale::getDefault().getLanguage()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 UploadAndInstallDeviceLocalAccountPolicy(); | 2101 UploadAndInstallDeviceLocalAccountPolicy(); |
| 2102 AddPublicSessionToDevicePolicy(kAccountId1); | 2102 AddPublicSessionToDevicePolicy(kAccountId1); |
| 2103 | 2103 |
| 2104 WaitForPolicy(); | 2104 WaitForPolicy(); |
| 2105 | 2105 |
| 2106 // Select a different locale. | 2106 // Select a different locale. |
| 2107 ASSERT_TRUE(content::ExecuteScript( | 2107 ASSERT_TRUE(content::ExecuteScript( |
| 2108 contents_, | 2108 contents_, |
| 2109 base::StringPrintf( | 2109 base::StringPrintf( |
| 2110 "var languageSelect = document.getElementById('pod-row')" | 2110 "var languageSelect = document.getElementById('pod-row')" |
| 2111 " .getPodWithUsername_('%s').querySelector('.language-select');" | 2111 " .getPodWithUsername('%s').querySelector('.language-select');" |
| 2112 "languageSelect.value = '%s';" | 2112 "languageSelect.value = '%s';" |
| 2113 "var event = document.createEvent('HTMLEvents');" | 2113 "var event = document.createEvent('HTMLEvents');" |
| 2114 "event.initEvent('change', false, true);" | 2114 "event.initEvent('change', false, true);" |
| 2115 "languageSelect.dispatchEvent(event);", | 2115 "languageSelect.dispatchEvent(event);", |
| 2116 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); | 2116 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 2117 | 2117 |
| 2118 // The UI will have requested an updated list of keyboard layouts at this | 2118 // The UI will have requested an updated list of keyboard layouts at this |
| 2119 // point. Wait for the constructions of this list to finish. | 2119 // point. Wait for the constructions of this list to finish. |
| 2120 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 2120 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 2121 | 2121 |
| 2122 // Set up an observer that will quit the message loop when login has succeeded | 2122 // Set up an observer that will quit the message loop when login has succeeded |
| 2123 // and the first wizard screen, if any, is being shown. | 2123 // and the first wizard screen, if any, is being shown. |
| 2124 base::RunLoop login_wait_run_loop; | 2124 base::RunLoop login_wait_run_loop; |
| 2125 chromeos::MockAuthStatusConsumer login_status_consumer; | 2125 chromeos::MockAuthStatusConsumer login_status_consumer; |
| 2126 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 2126 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
| 2127 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 2127 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
| 2128 chromeos::ExistingUserController* controller = | 2128 chromeos::ExistingUserController* controller = |
| 2129 chromeos::ExistingUserController::current_controller(); | 2129 chromeos::ExistingUserController::current_controller(); |
| 2130 ASSERT_TRUE(controller); | 2130 ASSERT_TRUE(controller); |
| 2131 controller->set_login_status_consumer(&login_status_consumer); | 2131 controller->set_login_status_consumer(&login_status_consumer); |
| 2132 | 2132 |
| 2133 // Manually select a different keyboard layout and click the enter button to | 2133 // Manually select a different keyboard layout and click the enter button to |
| 2134 // start the session. | 2134 // start the session. |
| 2135 ASSERT_TRUE(content::ExecuteScript( | 2135 ASSERT_TRUE(content::ExecuteScript( |
| 2136 contents_, | 2136 contents_, |
| 2137 base::StringPrintf( | 2137 base::StringPrintf( |
| 2138 "var pod =" | 2138 "var pod =" |
| 2139 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 2139 " document.getElementById('pod-row').getPodWithUsername('%s');" |
| 2140 "pod.querySelector('.keyboard-select').value = '%s';" | 2140 "pod.querySelector('.keyboard-select').value = '%s';" |
| 2141 "pod.querySelector('.enter-button').click();", | 2141 "pod.querySelector('.enter-button').click();", |
| 2142 account_id_1_.Serialize().c_str(), | 2142 account_id_1_.Serialize().c_str(), |
| 2143 public_session_input_method_id_.c_str()))); | 2143 public_session_input_method_id_.c_str()))); |
| 2144 | 2144 |
| 2145 // Spin the loop until the login observer fires. Then, unregister the | 2145 // Spin the loop until the login observer fires. Then, unregister the |
| 2146 // observer. | 2146 // observer. |
| 2147 login_wait_run_loop.Run(); | 2147 login_wait_run_loop.Run(); |
| 2148 controller->set_login_status_consumer(NULL); | 2148 controller->set_login_status_consumer(NULL); |
| 2149 | 2149 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 ASSERT_TRUE(content::ExecuteScript(contents_, | 2444 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 2445 "$('tos-accept-button').click();")); | 2445 "$('tos-accept-button').click();")); |
| 2446 | 2446 |
| 2447 WaitForSessionStart(); | 2447 WaitForSessionStart(); |
| 2448 } | 2448 } |
| 2449 | 2449 |
| 2450 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2450 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
| 2451 TermsOfServiceDownloadTest, testing::Bool()); | 2451 TermsOfServiceDownloadTest, testing::Bool()); |
| 2452 | 2452 |
| 2453 } // namespace policy | 2453 } // namespace policy |
| OLD | NEW |