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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc

Issue 483523005: Default to current UI locale when recommended locales are invalid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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
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 available_locales.AppendString("de");
135 available_locales.AppendString("fr");
136 available_locales.AppendString("en-GB");
137
138 EXPECT_EQ("en-US", FindMostRelevantLocale(NULL,
139 available_locales,
140 "en-US"));
141
142 std::vector<std::string> most_relevant_language_codes;
143 EXPECT_EQ("en-US", FindMostRelevantLocale(&most_relevant_language_codes,
144 available_locales,
145 "en-US"));
146
147 most_relevant_language_codes.push_back("xx");
148 EXPECT_EQ("en-US", FindMostRelevantLocale(&most_relevant_language_codes,
149 available_locales,
150 "en-US"));
151
152 most_relevant_language_codes.push_back("fr");
153 EXPECT_EQ("fr", FindMostRelevantLocale(&most_relevant_language_codes,
154 available_locales,
155 "en-US"));
156
157 most_relevant_language_codes.push_back("de");
158 EXPECT_EQ("fr", FindMostRelevantLocale(&most_relevant_language_codes,
159 available_locales,
160 "en-US"));
161 }
162
132 void InitStartupCustomizationDocumentForTesting(const std::string& manifest) { 163 void InitStartupCustomizationDocumentForTesting(const std::string& manifest) {
133 StartupCustomizationDocument::GetInstance()->LoadManifestFromString(manifest); 164 StartupCustomizationDocument::GetInstance()->LoadManifestFromString(manifest);
134 StartupCustomizationDocument::GetInstance()->Init( 165 StartupCustomizationDocument::GetInstance()->Init(
135 chromeos::system::StatisticsProvider::GetInstance()); 166 chromeos::system::StatisticsProvider::GetInstance());
136 } 167 }
137 168
138 const char kStartupManifest[] = 169 const char kStartupManifest[] =
139 "{\n" 170 "{\n"
140 " \"version\": \"1.0\",\n" 171 " \"version\": \"1.0\",\n"
141 " \"initial_locale\" : \"fr,en-US,de,is,it\",\n" 172 " \"initial_locale\" : \"fr,en-US,de,is,it\",\n"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 VerifyOnlyUILanguages(*list); 213 VerifyOnlyUILanguages(*list);
183 214
184 ASSERT_LE(3u, list->GetSize()); 215 ASSERT_LE(3u, list->GetSize());
185 216
186 VerifyLanguageCode(*list, 0, "it"); 217 VerifyLanguageCode(*list, 0, "it");
187 VerifyLanguageCode(*list, 1, "de"); 218 VerifyLanguageCode(*list, 1, "de");
188 VerifyLanguageCode(*list, 2, kMostRelevantLanguagesDivider); 219 VerifyLanguageCode(*list, 2, kMostRelevantLanguagesDivider);
189 } 220 }
190 221
191 } // namespace chromeos 222 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698