Index: chrome/browser/chromeos/policy/device_local_account_browsertest.cc |
diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc |
index 17071d6ee28fe368b10e27633e937aaec4f08ad9..c087b660e613cbde8c8175b2d08ee76fb7717c13 100644 |
--- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc |
+++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc |
@@ -128,12 +128,12 @@ |
#include "net/url_request/url_request_status.h" |
#include "policy/policy_constants.h" |
#include "testing/gmock/include/gmock/gmock.h" |
+#include "third_party/icu/source/common/unicode/locid.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/window_open_disposition.h" |
#include "ui/gfx/image/image_skia.h" |
#include "ui/views/widget/widget.h" |
#include "url/gurl.h" |
-//#include "third_party/cros_system_api/dbus/service_constants.h" |
namespace em = enterprise_management; |
@@ -460,6 +460,9 @@ class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, |
virtual void SetUpOnMainThread() OVERRIDE { |
DevicePolicyCrosBrowserTest::SetUpOnMainThread(); |
+ initial_locale_ = g_browser_process->GetApplicationLocale(); |
+ initial_language_ = l10n_util::GetLanguage(initial_locale_); |
+ |
content::WindowedNotificationObserver( |
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
content::NotificationService::AllSources()).Wait(); |
@@ -701,6 +704,9 @@ class DeviceLocalAccountTest : public DevicePolicyCrosBrowserTest, |
const std::string user_id_2_; |
const std::string public_session_input_method_id_; |
+ std::string initial_locale_; |
+ std::string initial_language_; |
+ |
scoped_ptr<base::RunLoop> run_loop_; |
UserPolicyBuilder device_local_account_policy_; |
@@ -1397,8 +1403,6 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LastWindowClosedLogoutReminder) { |
}; |
IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
- const std::string initial_locale = g_browser_process->GetApplicationLocale(); |
- |
UploadAndInstallDeviceLocalAccountPolicy(); |
AddPublicSessionToDevicePolicy(kAccountId1); |
@@ -1418,6 +1422,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
&advanced)); |
EXPECT_FALSE(advanced); |
+ // Verify that the construction of the pod's language list did not affect the |
+ // current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Click the enter button to start the session. |
ASSERT_TRUE(content::ExecuteScript( |
contents_, |
@@ -1430,7 +1438,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleNoSwitch) { |
// Verify that the locale has not changed and the first keyboard layout |
// applicable to the locale was chosen. |
- EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
VerifyKeyboardLayoutMatchesLocale(); |
} |
@@ -1454,6 +1463,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
&advanced)); |
EXPECT_FALSE(advanced); |
+ // Verify that the construction of the pod's language list did not affect the |
+ // current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Click the link that switches the pod to its advanced form. Verify that the |
// pod switches from basic to advanced. |
ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
@@ -1484,6 +1497,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
// point. Wait for the constructions of this list to finish. |
WaitForGetKeyboardLayoutsForLocaleToFinish(); |
+ // Verify that the construction of the updated keyboard layout list did not |
+ // affect the current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Manually select a different keyboard layout and click the enter button to |
// start the session. |
ASSERT_TRUE(content::ExecuteScript( |
@@ -1500,6 +1517,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, NoRecommendedLocaleSwitch) { |
// Verify that the locale and keyboard layout have been applied. |
EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
+ icu::Locale::getDefault().getLanguage()); |
EXPECT_EQ(public_session_input_method_id_, |
chromeos::input_method::InputMethodManager::Get() |
->GetActiveIMEState() |
@@ -1530,6 +1549,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
&advanced)); |
EXPECT_FALSE(advanced); |
+ // Verify that the construction of the pod's language list did not affect the |
+ // current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Click the enter button to start the session. |
ASSERT_TRUE(content::ExecuteScript( |
contents_, |
@@ -1544,6 +1567,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, OneRecommendedLocale) { |
// layout applicable to the locale was chosen. |
EXPECT_EQ(kSingleRecommendedLocale[0], |
g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kSingleRecommendedLocale[0]), |
+ icu::Locale::getDefault().getLanguage()); |
VerifyKeyboardLayoutMatchesLocale(); |
} |
@@ -1570,6 +1595,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
&advanced)); |
EXPECT_TRUE(advanced); |
+ // Verify that the construction of the pod's language list did not affect the |
+ // current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Verify that the pod shows a list of locales beginning with the recommended |
// ones, followed by others. |
const std::string get_locale_list = base::StringPrintf( |
@@ -1691,6 +1720,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
// for the constructions of this list to finish. |
WaitForGetKeyboardLayoutsForLocaleToFinish(); |
+ // Verify that the construction of the updated keyboard layout list did not |
+ // affect the current ICU locale. |
+ EXPECT_EQ(initial_locale_, icu::Locale::getDefault().getLanguage()); |
+ |
// Manually select a different keyboard layout. |
ASSERT_TRUE(content::ExecuteScript( |
contents_, |
@@ -1751,6 +1784,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
// Verify that the locale and keyboard layout have been applied. |
EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
+ icu::Locale::getDefault().getLanguage()); |
EXPECT_EQ(public_session_input_method_id_, |
chromeos::input_method::InputMethodManager::Get() |
->GetActiveIMEState() |
@@ -1760,8 +1795,6 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, MultipleRecommendedLocales) { |
IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
AutoLoginWithoutRecommendedLocales) { |
- const std::string initial_locale = g_browser_process->GetApplicationLocale(); |
- |
UploadAndInstallDeviceLocalAccountPolicy(); |
AddPublicSessionToDevicePolicy(kAccountId1); |
EnableAutoLogin(); |
@@ -1772,7 +1805,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
// Verify that the locale has not changed and the first keyboard layout |
// applicable to the locale was chosen. |
- EXPECT_EQ(initial_locale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(initial_locale_, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
VerifyKeyboardLayoutMatchesLocale(); |
} |
@@ -1791,6 +1825,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, |
// Verify that the first recommended locale has been applied and the first |
// keyboard layout applicable to the locale was chosen. |
EXPECT_EQ(kRecommendedLocales1[0], g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kRecommendedLocales1[0]), |
+ icu::Locale::getDefault().getLanguage()); |
VerifyKeyboardLayoutMatchesLocale(); |
} |
@@ -1822,6 +1858,10 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
// point. Wait for the constructions of this list to finish. |
WaitForGetKeyboardLayoutsForLocaleToFinish(); |
+ // Verify that the construction of the updated keyboard layout list did not |
+ // affect the current ICU locale. |
+ EXPECT_EQ(initial_language_, icu::Locale::getDefault().getLanguage()); |
+ |
// Set up an observer that will quit the message loop when login has succeeded |
// and the first wizard screen, if any, is being shown. |
base::RunLoop login_wait_run_loop; |
@@ -1878,6 +1918,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
// Verify that the locale and keyboard layout have been applied. |
EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
+ icu::Locale::getDefault().getLanguage()); |
EXPECT_EQ(public_session_input_method_id_, |
chromeos::input_method::InputMethodManager::Get() |
->GetActiveIMEState() |
@@ -1892,6 +1934,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, TermsOfServiceWithLocaleSwitch) { |
// Verify that the locale and keyboard layout are still in force. |
EXPECT_EQ(kPublicSessionLocale, g_browser_process->GetApplicationLocale()); |
+ EXPECT_EQ(l10n_util::GetLanguage(kPublicSessionLocale), |
+ icu::Locale::getDefault().getLanguage()); |
EXPECT_EQ(public_session_input_method_id_, |
chromeos::input_method::InputMethodManager::Get() |
->GetActiveIMEState() |