| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 void ExpandPublicSessionPod(bool expect_advanced) { | 686 void ExpandPublicSessionPod(bool expect_advanced) { |
| 687 bool advanced = false; | 687 bool advanced = false; |
| 688 // Click on the pod to expand it. | 688 // Click on the pod to expand it. |
| 689 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 689 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 690 contents_, | 690 contents_, |
| 691 base::StringPrintf( | 691 base::StringPrintf( |
| 692 "var pod =" | 692 "var pod =" |
| 693 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 693 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 694 "pod.click();" | 694 "pod.click();" |
| 695 "domAutomationController.send(pod.classList.contains('advanced'));", | 695 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 696 account_id_1_.GetUserEmail().c_str()), | 696 account_id_1_.Serialize().c_str()), |
| 697 &advanced)); | 697 &advanced)); |
| 698 // Verify that the pod expanded to its basic/advanced form, as expected. | 698 // Verify that the pod expanded to its basic/advanced form, as expected. |
| 699 EXPECT_EQ(expect_advanced, advanced); | 699 EXPECT_EQ(expect_advanced, advanced); |
| 700 | 700 |
| 701 // Verify that the construction of the pod's language list did not affect | 701 // Verify that the construction of the pod's language list did not affect |
| 702 // the current ICU locale. | 702 // the current ICU locale. |
| 703 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 703 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 704 } | 704 } |
| 705 | 705 |
| 706 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. | 706 // GetKeyboardLayoutsForLocale() posts a task to a background task runner. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { | 828 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) { |
| 829 UploadAndInstallDeviceLocalAccountPolicy(); | 829 UploadAndInstallDeviceLocalAccountPolicy(); |
| 830 AddPublicSessionToDevicePolicy(kAccountId1); | 830 AddPublicSessionToDevicePolicy(kAccountId1); |
| 831 | 831 |
| 832 WaitForPolicy(); | 832 WaitForPolicy(); |
| 833 | 833 |
| 834 // Verify that the display name is shown in the UI. | 834 // Verify that the display name is shown in the UI. |
| 835 const std::string get_compact_pod_display_name = base::StringPrintf( | 835 const std::string get_compact_pod_display_name = base::StringPrintf( |
| 836 "domAutomationController.send(document.getElementById('pod-row')" | 836 "domAutomationController.send(document.getElementById('pod-row')" |
| 837 " .getPodWithUsername_('%s').nameElement.textContent);", | 837 " .getPodWithUsername_('%s').nameElement.textContent);", |
| 838 account_id_1_.GetUserEmail().c_str()); | 838 account_id_1_.Serialize().c_str()); |
| 839 std::string display_name; | 839 std::string display_name; |
| 840 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 840 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 841 contents_, | 841 contents_, |
| 842 get_compact_pod_display_name, | 842 get_compact_pod_display_name, |
| 843 &display_name)); | 843 &display_name)); |
| 844 EXPECT_EQ(kDisplayName1, display_name); | 844 EXPECT_EQ(kDisplayName1, display_name); |
| 845 const std::string get_expanded_pod_display_name = base::StringPrintf( | 845 const std::string get_expanded_pod_display_name = base::StringPrintf( |
| 846 "domAutomationController.send(document.getElementById('pod-row')" | 846 "domAutomationController.send(document.getElementById('pod-row')" |
| 847 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" | 847 " .getPodWithUsername_('%s').querySelector('.expanded-pane-name')" |
| 848 " .textContent);", | 848 " .textContent);", |
| 849 account_id_1_.GetUserEmail().c_str()); | 849 account_id_1_.Serialize().c_str()); |
| 850 display_name.clear(); | 850 display_name.clear(); |
| 851 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 851 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 852 contents_, | 852 contents_, |
| 853 get_expanded_pod_display_name, | 853 get_expanded_pod_display_name, |
| 854 &display_name)); | 854 &display_name)); |
| 855 EXPECT_EQ(kDisplayName1, display_name); | 855 EXPECT_EQ(kDisplayName1, display_name); |
| 856 | 856 |
| 857 // Click on the pod to expand it. | 857 // Click on the pod to expand it. |
| 858 ASSERT_TRUE(content::ExecuteScript( | 858 ASSERT_TRUE(content::ExecuteScript( |
| 859 contents_, | 859 contents_, |
| 860 base::StringPrintf( | 860 base::StringPrintf( |
| 861 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 861 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 862 " .click();", | 862 " .click();", |
| 863 account_id_1_.GetUserEmail().c_str()))); | 863 account_id_1_.Serialize().c_str()))); |
| 864 | 864 |
| 865 // Change the display name. | 865 // Change the display name. |
| 866 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 866 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 867 kDisplayName2); | 867 kDisplayName2); |
| 868 UploadAndInstallDeviceLocalAccountPolicy(); | 868 UploadAndInstallDeviceLocalAccountPolicy(); |
| 869 policy::BrowserPolicyConnectorChromeOS* connector = | 869 policy::BrowserPolicyConnectorChromeOS* connector = |
| 870 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 870 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 871 DeviceLocalAccountPolicyBroker* broker = | 871 DeviceLocalAccountPolicyBroker* broker = |
| 872 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 872 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
| 873 account_id_1_.GetUserEmail()); | 873 account_id_1_.GetUserEmail()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 890 EXPECT_EQ(kDisplayName2, display_name); | 890 EXPECT_EQ(kDisplayName2, display_name); |
| 891 | 891 |
| 892 // 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 |
| 893 // without reloading and losing state. | 893 // without reloading and losing state. |
| 894 bool expanded = false; | 894 bool expanded = false; |
| 895 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 895 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 896 contents_, | 896 contents_, |
| 897 base::StringPrintf( | 897 base::StringPrintf( |
| 898 "domAutomationController.send(document.getElementById('pod-row')" | 898 "domAutomationController.send(document.getElementById('pod-row')" |
| 899 " .getPodWithUsername_('%s').expanded);", | 899 " .getPodWithUsername_('%s').expanded);", |
| 900 account_id_1_.GetUserEmail().c_str()), | 900 account_id_1_.Serialize().c_str()), |
| 901 &expanded)); | 901 &expanded)); |
| 902 EXPECT_TRUE(expanded); | 902 EXPECT_TRUE(expanded); |
| 903 } | 903 } |
| 904 | 904 |
| 905 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { | 905 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) { |
| 906 UploadDeviceLocalAccountPolicy(); | 906 UploadDeviceLocalAccountPolicy(); |
| 907 AddPublicSessionToDevicePolicy(kAccountId1); | 907 AddPublicSessionToDevicePolicy(kAccountId1); |
| 908 | 908 |
| 909 WaitForPolicy(); | 909 WaitForPolicy(); |
| 910 | 910 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 WaitForPolicy(); | 1617 WaitForPolicy(); |
| 1618 | 1618 |
| 1619 ExpandPublicSessionPod(false); | 1619 ExpandPublicSessionPod(false); |
| 1620 | 1620 |
| 1621 // Click the enter button to start the session. | 1621 // Click the enter button to start the session. |
| 1622 ASSERT_TRUE(content::ExecuteScript( | 1622 ASSERT_TRUE(content::ExecuteScript( |
| 1623 contents_, | 1623 contents_, |
| 1624 base::StringPrintf( | 1624 base::StringPrintf( |
| 1625 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1625 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1626 " .querySelector('.enter-button').click();", | 1626 " .querySelector('.enter-button').click();", |
| 1627 account_id_1_.GetUserEmail().c_str()))); | 1627 account_id_1_.Serialize().c_str()))); |
| 1628 | 1628 |
| 1629 WaitForSessionStart(); | 1629 WaitForSessionStart(); |
| 1630 | 1630 |
| 1631 // Verify that the locale has not changed and the first keyboard layout | 1631 // Verify that the locale has not changed and the first keyboard layout |
| 1632 // applicable to the locale was chosen. | 1632 // applicable to the locale was chosen. |
| 1633 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 1633 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1634 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); | 1634 EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
| 1635 VerifyKeyboardLayoutMatchesLocale(); | 1635 VerifyKeyboardLayoutMatchesLocale(); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { | 1638 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
| 1639 UploadAndInstallDeviceLocalAccountPolicy(); | 1639 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1640 AddPublicSessionToDevicePolicy(kAccountId1); | 1640 AddPublicSessionToDevicePolicy(kAccountId1); |
| 1641 | 1641 |
| 1642 WaitForPolicy(); | 1642 WaitForPolicy(); |
| 1643 | 1643 |
| 1644 ExpandPublicSessionPod(false); | 1644 ExpandPublicSessionPod(false); |
| 1645 | 1645 |
| 1646 // Click the link that switches the pod to its advanced form. Verify that the | 1646 // Click the link that switches the pod to its advanced form. Verify that the |
| 1647 // pod switches from basic to advanced. | 1647 // pod switches from basic to advanced. |
| 1648 bool advanced = false; | 1648 bool advanced = false; |
| 1649 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1649 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 1650 contents_, | 1650 contents_, |
| 1651 base::StringPrintf( | 1651 base::StringPrintf( |
| 1652 "var pod =" | 1652 "var pod =" |
| 1653 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1653 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1654 "pod.querySelector('.language-and-input').click();" | 1654 "pod.querySelector('.language-and-input').click();" |
| 1655 "domAutomationController.send(pod.classList.contains('advanced'));", | 1655 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1656 account_id_1_.GetUserEmail().c_str()), | 1656 account_id_1_.Serialize().c_str()), |
| 1657 &advanced)); | 1657 &advanced)); |
| 1658 EXPECT_FALSE(advanced); | 1658 EXPECT_FALSE(advanced); |
| 1659 | 1659 |
| 1660 // Manually select a different locale. | 1660 // Manually select a different locale. |
| 1661 ASSERT_TRUE(content::ExecuteScript( | 1661 ASSERT_TRUE(content::ExecuteScript( |
| 1662 contents_, | 1662 contents_, |
| 1663 base::StringPrintf( | 1663 base::StringPrintf( |
| 1664 "var languageSelect = document.getElementById('pod-row')" | 1664 "var languageSelect = document.getElementById('pod-row')" |
| 1665 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1665 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1666 "languageSelect.value = '%s';" | 1666 "languageSelect.value = '%s';" |
| 1667 "var event = document.createEvent('HTMLEvents');" | 1667 "var event = document.createEvent('HTMLEvents');" |
| 1668 "event.initEvent('change', false, true);" | 1668 "event.initEvent('change', false, true);" |
| 1669 "languageSelect.dispatchEvent(event);", | 1669 "languageSelect.dispatchEvent(event);", |
| 1670 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 1670 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 1671 | 1671 |
| 1672 // The UI will have requested an updated list of keyboard layouts at this | 1672 // The UI will have requested an updated list of keyboard layouts at this |
| 1673 // point. Wait for the constructions of this list to finish. | 1673 // point. Wait for the constructions of this list to finish. |
| 1674 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1674 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1675 | 1675 |
| 1676 // Manually select a different keyboard layout and click the enter button to | 1676 // Manually select a different keyboard layout and click the enter button to |
| 1677 // start the session. | 1677 // start the session. |
| 1678 ASSERT_TRUE(content::ExecuteScript( | 1678 ASSERT_TRUE(content::ExecuteScript( |
| 1679 contents_, | 1679 contents_, |
| 1680 base::StringPrintf( | 1680 base::StringPrintf( |
| 1681 "var pod =" | 1681 "var pod =" |
| 1682 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1682 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1683 "pod.querySelector('.keyboard-select').value = '%s';" | 1683 "pod.querySelector('.keyboard-select').value = '%s';" |
| 1684 "pod.querySelector('.enter-button').click();", | 1684 "pod.querySelector('.enter-button').click();", |
| 1685 account_id_1_.GetUserEmail().c_str(), | 1685 account_id_1_.Serialize().c_str(), |
| 1686 public_session_input_method_id_.c_str()))); | 1686 public_session_input_method_id_.c_str()))); |
| 1687 | 1687 |
| 1688 WaitForSessionStart(); | 1688 WaitForSessionStart(); |
| 1689 | 1689 |
| 1690 // Verify that the locale and keyboard layout have been applied. | 1690 // Verify that the locale and keyboard layout have been applied. |
| 1691 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1691 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1692 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1692 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1693 icu::Locale::getDefault().getLanguage()); | 1693 icu::Locale::getDefault().getLanguage()); |
| 1694 EXPECT_EQ(public_session_input_method_id_, | 1694 EXPECT_EQ(public_session_input_method_id_, |
| 1695 chromeos::input_method::InputMethodManager::Get() | 1695 chromeos::input_method::InputMethodManager::Get() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1708 WaitForPolicy(); | 1708 WaitForPolicy(); |
| 1709 | 1709 |
| 1710 ExpandPublicSessionPod(false); | 1710 ExpandPublicSessionPod(false); |
| 1711 | 1711 |
| 1712 // Click the enter button to start the session. | 1712 // Click the enter button to start the session. |
| 1713 ASSERT_TRUE(content::ExecuteScript( | 1713 ASSERT_TRUE(content::ExecuteScript( |
| 1714 contents_, | 1714 contents_, |
| 1715 base::StringPrintf( | 1715 base::StringPrintf( |
| 1716 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1716 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1717 " .querySelector('.enter-button').click();", | 1717 " .querySelector('.enter-button').click();", |
| 1718 account_id_1_.GetUserEmail().c_str()))); | 1718 account_id_1_.Serialize().c_str()))); |
| 1719 | 1719 |
| 1720 WaitForSessionStart(); | 1720 WaitForSessionStart(); |
| 1721 | 1721 |
| 1722 // Verify that the recommended locale has been applied and the first keyboard | 1722 // Verify that the recommended locale has been applied and the first keyboard |
| 1723 // layout applicable to the locale was chosen. | 1723 // layout applicable to the locale was chosen. |
| 1724 EXPECT_EQ(kSingleRecommendedLocale[0], | 1724 EXPECT_EQ(kSingleRecommendedLocale[0], |
| 1725 g_browser_process->GetApplicationLocale()); | 1725 g_browser_process->GetApplicationLocale()); |
| 1726 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), | 1726 EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
| 1727 icu::Locale::getDefault().getLanguage()); | 1727 icu::Locale::getDefault().getLanguage()); |
| 1728 VerifyKeyboardLayoutMatchesLocale(); | 1728 VerifyKeyboardLayoutMatchesLocale(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1741 | 1741 |
| 1742 // Verify that the pod shows a list of locales beginning with the recommended | 1742 // Verify that the pod shows a list of locales beginning with the recommended |
| 1743 // ones, followed by others. | 1743 // ones, followed by others. |
| 1744 const std::string get_locale_list = base::StringPrintf( | 1744 const std::string get_locale_list = base::StringPrintf( |
| 1745 "var languageSelect = document.getElementById('pod-row')" | 1745 "var languageSelect = document.getElementById('pod-row')" |
| 1746 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1746 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1747 "var locales = [];" | 1747 "var locales = [];" |
| 1748 "for (var i = 0; i < languageSelect.length; ++i)" | 1748 "for (var i = 0; i < languageSelect.length; ++i)" |
| 1749 " locales.push(languageSelect.options[i].value);" | 1749 " locales.push(languageSelect.options[i].value);" |
| 1750 "domAutomationController.send(JSON.stringify(locales));", | 1750 "domAutomationController.send(JSON.stringify(locales));", |
| 1751 account_id_1_.GetUserEmail().c_str()); | 1751 account_id_1_.Serialize().c_str()); |
| 1752 std::string json; | 1752 std::string json; |
| 1753 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1753 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1754 get_locale_list, | 1754 get_locale_list, |
| 1755 &json)); | 1755 &json)); |
| 1756 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); | 1756 scoped_ptr<base::Value> value_ptr = base::JSONReader::Read(json); |
| 1757 const base::ListValue* locales = NULL; | 1757 const base::ListValue* locales = NULL; |
| 1758 ASSERT_TRUE(value_ptr); | 1758 ASSERT_TRUE(value_ptr); |
| 1759 ASSERT_TRUE(value_ptr->GetAsList(&locales)); | 1759 ASSERT_TRUE(value_ptr->GetAsList(&locales)); |
| 1760 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); | 1760 EXPECT_LT(arraysize(kRecommendedLocales1), locales->GetSize()); |
| 1761 | 1761 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1776 std::string locale; | 1776 std::string locale; |
| 1777 EXPECT_TRUE(locales->GetString(i, &locale)); | 1777 EXPECT_TRUE(locales->GetString(i, &locale)); |
| 1778 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); | 1778 EXPECT_EQ(recommended_locales.end(), recommended_locales.find(locale)); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 // Verify that the first recommended locale is selected. | 1781 // Verify that the first recommended locale is selected. |
| 1782 const std::string get_selected_locale = base::StringPrintf( | 1782 const std::string get_selected_locale = base::StringPrintf( |
| 1783 "domAutomationController.send(document.getElementById('pod-row')" | 1783 "domAutomationController.send(document.getElementById('pod-row')" |
| 1784 " .getPodWithUsername_('%s').querySelector('.language-select')" | 1784 " .getPodWithUsername_('%s').querySelector('.language-select')" |
| 1785 " .value);", | 1785 " .value);", |
| 1786 account_id_1_.GetUserEmail().c_str()); | 1786 account_id_1_.Serialize().c_str()); |
| 1787 std::string selected_locale; | 1787 std::string selected_locale; |
| 1788 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1788 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1789 get_selected_locale, | 1789 get_selected_locale, |
| 1790 &selected_locale)); | 1790 &selected_locale)); |
| 1791 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); | 1791 EXPECT_EQ(kRecommendedLocales1[0], selected_locale); |
| 1792 | 1792 |
| 1793 // Change the list of recommended locales. | 1793 // Change the list of recommended locales. |
| 1794 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1794 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| 1795 | 1795 |
| 1796 // Also change the display name as it is easy to ensure that policy has been | 1796 // Also change the display name as it is easy to ensure that policy has been |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 // Manually select a different locale. | 1831 // Manually select a different locale. |
| 1832 ASSERT_TRUE(content::ExecuteScript( | 1832 ASSERT_TRUE(content::ExecuteScript( |
| 1833 contents_, | 1833 contents_, |
| 1834 base::StringPrintf( | 1834 base::StringPrintf( |
| 1835 "var languageSelect = document.getElementById('pod-row')" | 1835 "var languageSelect = document.getElementById('pod-row')" |
| 1836 " .getPodWithUsername_('%s').querySelector('.language-select');" | 1836 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 1837 "languageSelect.value = '%s';" | 1837 "languageSelect.value = '%s';" |
| 1838 "var event = document.createEvent('HTMLEvents');" | 1838 "var event = document.createEvent('HTMLEvents');" |
| 1839 "event.initEvent('change', false, true);" | 1839 "event.initEvent('change', false, true);" |
| 1840 "languageSelect.dispatchEvent(event);", | 1840 "languageSelect.dispatchEvent(event);", |
| 1841 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 1841 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 1842 | 1842 |
| 1843 // Change the list of recommended locales. | 1843 // Change the list of recommended locales. |
| 1844 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); | 1844 SetRecommendedLocales(kRecommendedLocales2, arraysize(kRecommendedLocales2)); |
| 1845 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( | 1845 device_local_account_policy_.payload().mutable_userdisplayname()->set_value( |
| 1846 kDisplayName1); | 1846 kDisplayName1); |
| 1847 UploadAndInstallDeviceLocalAccountPolicy(); | 1847 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1848 broker->core()->store()->Load(); | 1848 broker->core()->store()->Load(); |
| 1849 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); | 1849 WaitForDisplayName(account_id_1_.GetUserEmail(), kDisplayName1); |
| 1850 | 1850 |
| 1851 // Verify that the manually selected locale is still selected. | 1851 // Verify that the manually selected locale is still selected. |
| 1852 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, | 1852 ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents_, |
| 1853 get_selected_locale, | 1853 get_selected_locale, |
| 1854 &selected_locale)); | 1854 &selected_locale)); |
| 1855 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1855 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1856 | 1856 |
| 1857 // The UI will request an updated list of keyboard layouts at this point. Wait | 1857 // The UI will request an updated list of keyboard layouts at this point. Wait |
| 1858 // for the constructions of this list to finish. | 1858 // for the constructions of this list to finish. |
| 1859 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 1859 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 1860 | 1860 |
| 1861 // Manually select a different keyboard layout. | 1861 // Manually select a different keyboard layout. |
| 1862 ASSERT_TRUE(content::ExecuteScript( | 1862 ASSERT_TRUE(content::ExecuteScript( |
| 1863 contents_, | 1863 contents_, |
| 1864 base::StringPrintf( | 1864 base::StringPrintf( |
| 1865 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1865 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1866 " .querySelector('.keyboard-select').value = '%s';", | 1866 " .querySelector('.keyboard-select').value = '%s';", |
| 1867 account_id_1_.GetUserEmail().c_str(), | 1867 account_id_1_.Serialize().c_str(), |
| 1868 public_session_input_method_id_.c_str()))); | 1868 public_session_input_method_id_.c_str()))); |
| 1869 | 1869 |
| 1870 // Click on a different pod, causing focus to shift away and the pod to | 1870 // Click on a different pod, causing focus to shift away and the pod to |
| 1871 // contract. | 1871 // contract. |
| 1872 ASSERT_TRUE(content::ExecuteScript( | 1872 ASSERT_TRUE(content::ExecuteScript( |
| 1873 contents_, | 1873 contents_, |
| 1874 base::StringPrintf( | 1874 base::StringPrintf( |
| 1875 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1875 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1876 " .click();", | 1876 " .click();", |
| 1877 account_id_2_.GetUserEmail().c_str()))); | 1877 account_id_2_.Serialize().c_str()))); |
| 1878 | 1878 |
| 1879 // Click on the pod again, causing it to expand again. Verify that the pod has | 1879 // Click on the pod again, causing it to expand again. Verify that the pod has |
| 1880 // kept all its state (the advanced form is being shown, the manually selected | 1880 // kept all its state (the advanced form is being shown, the manually selected |
| 1881 // locale and keyboard layout are selected). | 1881 // locale and keyboard layout are selected). |
| 1882 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 1882 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 1883 contents_, | 1883 contents_, |
| 1884 base::StringPrintf( | 1884 base::StringPrintf( |
| 1885 "var pod =" | 1885 "var pod =" |
| 1886 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 1886 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 1887 "pod.click();" | 1887 "pod.click();" |
| 1888 "var state = {};" | 1888 "var state = {};" |
| 1889 "state.advanced = pod.classList.contains('advanced');" | 1889 "state.advanced = pod.classList.contains('advanced');" |
| 1890 "state.locale = pod.querySelector('.language-select').value;" | 1890 "state.locale = pod.querySelector('.language-select').value;" |
| 1891 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" | 1891 "state.keyboardLayout = pod.querySelector('.keyboard-select').value;" |
| 1892 "console.log(JSON.stringify(state));" | 1892 "console.log(JSON.stringify(state));" |
| 1893 "domAutomationController.send(JSON.stringify(state));", | 1893 "domAutomationController.send(JSON.stringify(state));", |
| 1894 account_id_1_.GetUserEmail().c_str()), | 1894 account_id_1_.Serialize().c_str()), |
| 1895 &json)); | 1895 &json)); |
| 1896 LOG(ERROR) << json; | 1896 LOG(ERROR) << json; |
| 1897 value_ptr = base::JSONReader::Read(json); | 1897 value_ptr = base::JSONReader::Read(json); |
| 1898 const base::DictionaryValue* state = NULL; | 1898 const base::DictionaryValue* state = NULL; |
| 1899 ASSERT_TRUE(value_ptr); | 1899 ASSERT_TRUE(value_ptr); |
| 1900 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); | 1900 ASSERT_TRUE(value_ptr->GetAsDictionary(&state)); |
| 1901 bool advanced = false; | 1901 bool advanced = false; |
| 1902 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); | 1902 EXPECT_TRUE(state->GetBoolean("advanced", &advanced)); |
| 1903 EXPECT_TRUE(advanced); | 1903 EXPECT_TRUE(advanced); |
| 1904 EXPECT_TRUE(state->GetString("locale", &selected_locale)); | 1904 EXPECT_TRUE(state->GetString("locale", &selected_locale)); |
| 1905 EXPECT_EQ(kPublicSessionLocale, selected_locale); | 1905 EXPECT_EQ(kPublicSessionLocale, selected_locale); |
| 1906 std::string selected_keyboard_layout; | 1906 std::string selected_keyboard_layout; |
| 1907 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); | 1907 EXPECT_TRUE(state->GetString("keyboardLayout", &selected_keyboard_layout)); |
| 1908 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); | 1908 EXPECT_EQ(public_session_input_method_id_, selected_keyboard_layout); |
| 1909 | 1909 |
| 1910 // Click the enter button to start the session. | 1910 // Click the enter button to start the session. |
| 1911 ASSERT_TRUE(content::ExecuteScript( | 1911 ASSERT_TRUE(content::ExecuteScript( |
| 1912 contents_, | 1912 contents_, |
| 1913 base::StringPrintf( | 1913 base::StringPrintf( |
| 1914 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1914 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1915 " .querySelector('.enter-button').click();", | 1915 " .querySelector('.enter-button').click();", |
| 1916 account_id_1_.GetUserEmail().c_str()))); | 1916 account_id_1_.Serialize().c_str()))); |
| 1917 | 1917 |
| 1918 WaitForSessionStart(); | 1918 WaitForSessionStart(); |
| 1919 | 1919 |
| 1920 // Verify that the locale and keyboard layout have been applied. | 1920 // Verify that the locale and keyboard layout have been applied. |
| 1921 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); | 1921 EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
| 1922 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), | 1922 EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
| 1923 icu::Locale::getDefault().getLanguage()); | 1923 icu::Locale::getDefault().getLanguage()); |
| 1924 EXPECT_EQ(public_session_input_method_id_, | 1924 EXPECT_EQ(public_session_input_method_id_, |
| 1925 chromeos::input_method::InputMethodManager::Get() | 1925 chromeos::input_method::InputMethodManager::Get() |
| 1926 ->GetActiveIMEState() | 1926 ->GetActiveIMEState() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1940 // Click on the pod to expand it. Verify that the pod expands to its basic | 1940 // Click on the pod to expand it. Verify that the pod expands to its basic |
| 1941 // form as there is only one recommended locale. | 1941 // form as there is only one recommended locale. |
| 1942 bool advanced = false; | 1942 bool advanced = false; |
| 1943 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 1943 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 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 "domAutomationController.send(pod.classList.contains('advanced'));", | 1949 "domAutomationController.send(pod.classList.contains('advanced'));", |
| 1950 account_id_1_.GetUserEmail().c_str()), | 1950 account_id_1_.Serialize().c_str()), |
| 1951 &advanced)); | 1951 &advanced)); |
| 1952 EXPECT_FALSE(advanced); | 1952 EXPECT_FALSE(advanced); |
| 1953 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 1953 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
| 1954 icu::Locale::getDefault().getLanguage()); | 1954 icu::Locale::getDefault().getLanguage()); |
| 1955 | 1955 |
| 1956 // Click the enter button to start the session. | 1956 // Click the enter button to start the session. |
| 1957 ASSERT_TRUE(content::ExecuteScript( | 1957 ASSERT_TRUE(content::ExecuteScript( |
| 1958 contents_, | 1958 contents_, |
| 1959 base::StringPrintf( | 1959 base::StringPrintf( |
| 1960 "document.getElementById('pod-row').getPodWithUsername_('%s')" | 1960 "document.getElementById('pod-row').getPodWithUsername_('%s')" |
| 1961 " .querySelector('.enter-button').click();", | 1961 " .querySelector('.enter-button').click();", |
| 1962 account_id_1_.GetUserEmail().c_str()))); | 1962 account_id_1_.Serialize().c_str()))); |
| 1963 | 1963 |
| 1964 WaitForSessionStart(); | 1964 WaitForSessionStart(); |
| 1965 | 1965 |
| 1966 // Verify that since the recommended locale was invalid, the locale has not | 1966 // Verify that since the recommended locale was invalid, the locale has not |
| 1967 // changed and the first keyboard layout applicable to the locale was chosen. | 1967 // changed and the first keyboard layout applicable to the locale was chosen. |
| 1968 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); | 1968 EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
| 1969 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), | 1969 EXPECT_EQ(l10n_util::GetLanguage(initial_locale_), |
| 1970 icu::Locale::getDefault().getLanguage()); | 1970 icu::Locale::getDefault().getLanguage()); |
| 1971 VerifyKeyboardLayoutMatchesLocale(); | 1971 VerifyKeyboardLayoutMatchesLocale(); |
| 1972 } | 1972 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 // Select a different locale. | 2045 // Select a different locale. |
| 2046 ASSERT_TRUE(content::ExecuteScript( | 2046 ASSERT_TRUE(content::ExecuteScript( |
| 2047 contents_, | 2047 contents_, |
| 2048 base::StringPrintf( | 2048 base::StringPrintf( |
| 2049 "var languageSelect = document.getElementById('pod-row')" | 2049 "var languageSelect = document.getElementById('pod-row')" |
| 2050 " .getPodWithUsername_('%s').querySelector('.language-select');" | 2050 " .getPodWithUsername_('%s').querySelector('.language-select');" |
| 2051 "languageSelect.value = '%s';" | 2051 "languageSelect.value = '%s';" |
| 2052 "var event = document.createEvent('HTMLEvents');" | 2052 "var event = document.createEvent('HTMLEvents');" |
| 2053 "event.initEvent('change', false, true);" | 2053 "event.initEvent('change', false, true);" |
| 2054 "languageSelect.dispatchEvent(event);", | 2054 "languageSelect.dispatchEvent(event);", |
| 2055 account_id_1_.GetUserEmail().c_str(), kPublicSessionLocale))); | 2055 account_id_1_.Serialize().c_str(), kPublicSessionLocale))); |
| 2056 | 2056 |
| 2057 // The UI will have requested an updated list of keyboard layouts at this | 2057 // The UI will have requested an updated list of keyboard layouts at this |
| 2058 // point. Wait for the constructions of this list to finish. | 2058 // point. Wait for the constructions of this list to finish. |
| 2059 WaitForGetKeyboardLayoutsForLocaleToFinish(); | 2059 WaitForGetKeyboardLayoutsForLocaleToFinish(); |
| 2060 | 2060 |
| 2061 // Set up an observer that will quit the message loop when login has succeeded | 2061 // Set up an observer that will quit the message loop when login has succeeded |
| 2062 // and the first wizard screen, if any, is being shown. | 2062 // and the first wizard screen, if any, is being shown. |
| 2063 base::RunLoop login_wait_run_loop; | 2063 base::RunLoop login_wait_run_loop; |
| 2064 chromeos::MockAuthStatusConsumer login_status_consumer; | 2064 chromeos::MockAuthStatusConsumer login_status_consumer; |
| 2065 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( | 2065 EXPECT_CALL(login_status_consumer, OnAuthSuccess(_)).Times(1).WillOnce( |
| 2066 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); | 2066 InvokeWithoutArgs(&login_wait_run_loop, &base::RunLoop::Quit)); |
| 2067 chromeos::ExistingUserController* controller = | 2067 chromeos::ExistingUserController* controller = |
| 2068 chromeos::ExistingUserController::current_controller(); | 2068 chromeos::ExistingUserController::current_controller(); |
| 2069 ASSERT_TRUE(controller); | 2069 ASSERT_TRUE(controller); |
| 2070 controller->set_login_status_consumer(&login_status_consumer); | 2070 controller->set_login_status_consumer(&login_status_consumer); |
| 2071 | 2071 |
| 2072 // Manually select a different keyboard layout and click the enter button to | 2072 // Manually select a different keyboard layout and click the enter button to |
| 2073 // start the session. | 2073 // start the session. |
| 2074 ASSERT_TRUE(content::ExecuteScript( | 2074 ASSERT_TRUE(content::ExecuteScript( |
| 2075 contents_, | 2075 contents_, |
| 2076 base::StringPrintf( | 2076 base::StringPrintf( |
| 2077 "var pod =" | 2077 "var pod =" |
| 2078 " document.getElementById('pod-row').getPodWithUsername_('%s');" | 2078 " document.getElementById('pod-row').getPodWithUsername_('%s');" |
| 2079 "pod.querySelector('.keyboard-select').value = '%s';" | 2079 "pod.querySelector('.keyboard-select').value = '%s';" |
| 2080 "pod.querySelector('.enter-button').click();", | 2080 "pod.querySelector('.enter-button').click();", |
| 2081 account_id_1_.GetUserEmail().c_str(), | 2081 account_id_1_.Serialize().c_str(), |
| 2082 public_session_input_method_id_.c_str()))); | 2082 public_session_input_method_id_.c_str()))); |
| 2083 | 2083 |
| 2084 // Spin the loop until the login observer fires. Then, unregister the | 2084 // Spin the loop until the login observer fires. Then, unregister the |
| 2085 // observer. | 2085 // observer. |
| 2086 login_wait_run_loop.Run(); | 2086 login_wait_run_loop.Run(); |
| 2087 controller->set_login_status_consumer(NULL); | 2087 controller->set_login_status_consumer(NULL); |
| 2088 | 2088 |
| 2089 // Verify that the Terms of Service screen is being shown. | 2089 // Verify that the Terms of Service screen is being shown. |
| 2090 chromeos::WizardController* wizard_controller = | 2090 chromeos::WizardController* wizard_controller = |
| 2091 chromeos::WizardController::default_controller(); | 2091 chromeos::WizardController::default_controller(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2385 ASSERT_TRUE(content::ExecuteScript(contents_, | 2385 ASSERT_TRUE(content::ExecuteScript(contents_, |
| 2386 "$('tos-accept-button').click();")); | 2386 "$('tos-accept-button').click();")); |
| 2387 | 2387 |
| 2388 WaitForSessionStart(); | 2388 WaitForSessionStart(); |
| 2389 } | 2389 } |
| 2390 | 2390 |
| 2391 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, | 2391 INSTANTIATE_TEST_CASE_P(TermsOfServiceDownloadTestInstance, |
| 2392 TermsOfServiceDownloadTest, testing::Bool()); | 2392 TermsOfServiceDownloadTest, testing::Bool()); |
| 2393 | 2393 |
| 2394 } // namespace policy | 2394 } // namespace policy |
| OLD | NEW |