OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/chromeos/login/l10n_util.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 TEST_F(L10nUtilTest, GetUILanguageList) { | 123 TEST_F(L10nUtilTest, GetUILanguageList) { |
124 SetInputMethods1(); | 124 SetInputMethods1(); |
125 | 125 |
126 // This requires initialized StatisticsProvider (see L10nUtilTest()). | 126 // This requires initialized StatisticsProvider (see L10nUtilTest()). |
127 scoped_ptr<base::ListValue> list(GetUILanguageList(NULL, std::string())); | 127 scoped_ptr<base::ListValue> list(GetUILanguageList(NULL, std::string())); |
128 | 128 |
129 VerifyOnlyUILanguages(*list); | 129 VerifyOnlyUILanguages(*list); |
130 } | 130 } |
131 | 131 |
| 132 TEST_F(L10nUtilTest, FindMostRelevantLocale) { |
| 133 base::ListValue available_locales; |
| 134 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 135 dict->SetString("value", "de"); |
| 136 available_locales.Append(dict.release()); |
| 137 dict.reset(new base::DictionaryValue); |
| 138 dict->SetString("value", "fr"); |
| 139 available_locales.Append(dict.release()); |
| 140 dict.reset(new base::DictionaryValue); |
| 141 dict->SetString("value", "en-GB"); |
| 142 available_locales.Append(dict.release()); |
| 143 |
| 144 std::vector<std::string> most_relevant_language_codes; |
| 145 EXPECT_EQ("en-US", FindMostRelevantLocale(most_relevant_language_codes, |
| 146 available_locales, |
| 147 "en-US")); |
| 148 |
| 149 most_relevant_language_codes.push_back("xx"); |
| 150 EXPECT_EQ("en-US", FindMostRelevantLocale(most_relevant_language_codes, |
| 151 available_locales, |
| 152 "en-US")); |
| 153 |
| 154 most_relevant_language_codes.push_back("fr"); |
| 155 EXPECT_EQ("fr", FindMostRelevantLocale(most_relevant_language_codes, |
| 156 available_locales, |
| 157 "en-US")); |
| 158 |
| 159 most_relevant_language_codes.push_back("de"); |
| 160 EXPECT_EQ("fr", FindMostRelevantLocale(most_relevant_language_codes, |
| 161 available_locales, |
| 162 "en-US")); |
| 163 } |
| 164 |
132 void InitStartupCustomizationDocumentForTesting(const std::string& manifest) { | 165 void InitStartupCustomizationDocumentForTesting(const std::string& manifest) { |
133 StartupCustomizationDocument::GetInstance()->LoadManifestFromString(manifest); | 166 StartupCustomizationDocument::GetInstance()->LoadManifestFromString(manifest); |
134 StartupCustomizationDocument::GetInstance()->Init( | 167 StartupCustomizationDocument::GetInstance()->Init( |
135 chromeos::system::StatisticsProvider::GetInstance()); | 168 chromeos::system::StatisticsProvider::GetInstance()); |
136 } | 169 } |
137 | 170 |
138 const char kStartupManifest[] = | 171 const char kStartupManifest[] = |
139 "{\n" | 172 "{\n" |
140 " \"version\": \"1.0\",\n" | 173 " \"version\": \"1.0\",\n" |
141 " \"initial_locale\" : \"fr,en-US,de,is,it\",\n" | 174 " \"initial_locale\" : \"fr,en-US,de,is,it\",\n" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 VerifyOnlyUILanguages(*list); | 215 VerifyOnlyUILanguages(*list); |
183 | 216 |
184 ASSERT_LE(3u, list->GetSize()); | 217 ASSERT_LE(3u, list->GetSize()); |
185 | 218 |
186 VerifyLanguageCode(*list, 0, "it"); | 219 VerifyLanguageCode(*list, 0, "it"); |
187 VerifyLanguageCode(*list, 1, "de"); | 220 VerifyLanguageCode(*list, 1, "de"); |
188 VerifyLanguageCode(*list, 2, kMostRelevantLanguagesDivider); | 221 VerifyLanguageCode(*list, 2, kMostRelevantLanguagesDivider); |
189 } | 222 } |
190 | 223 |
191 } // namespace chromeos | 224 } // namespace chromeos |
OLD | NEW |