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

Side by Side Diff: chrome/installer/util/language_selector_unittest.cc

Issue 8488006: Add some language aliases to track changes to base/ui/l10n_util.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed bad macau alias Created 9 years 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
« no previous file with comments | « chrome/installer/util/language_selector.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "chrome/installer/util/language_selector.h" 8 #include "chrome/installer/util/language_selector.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 const wchar_t* const kExactMatchCandidates[] = { 13 const wchar_t* const kExactMatchCandidates[] = {
14 #if defined(GOOGLE_CHROME_BUILD) 14 #if defined(GOOGLE_CHROME_BUILD)
15 L"am", L"ar", L"bg", L"bn", L"ca", L"cs", L"da", L"de", L"el", L"en-gb", 15 L"am", L"ar", L"bg", L"bn", L"ca", L"cs", L"da", L"de", L"el", L"en-gb",
16 L"en-us", L"es", L"es-419", L"et", L"fa", L"fi", L"fil", L"fr", L"gu", L"hi", 16 L"en-us", L"es", L"es-419", L"et", L"fa", L"fi", L"fil", L"fr", L"gu", L"hi",
17 L"hr", L"hu", L"id", L"it", L"iw", L"ja", L"kn", L"ko", L"lt", L"lv", L"ml", 17 L"hr", L"hu", L"id", L"it", L"iw", L"ja", L"kn", L"ko", L"lt", L"lv", L"ml",
18 L"mr", L"nl", L"no", L"pl", L"pt-br", L"pt-pt", L"ro", L"ru", L"sk", L"sl", 18 L"mr", L"nl", L"no", L"pl", L"pt-br", L"pt-pt", L"ro", L"ru", L"sk", L"sl",
19 L"sr", L"sv", L"sw", L"ta", L"te", L"th", L"tr", L"uk", L"vi", L"zh-cn", 19 L"sr", L"sv", L"sw", L"ta", L"te", L"th", L"tr", L"uk", L"vi", L"zh-cn",
20 L"zh-tw" 20 L"zh-tw"
21 #else 21 #else
22 L"en-us" 22 L"en-us"
23 #endif 23 #endif
24 }; 24 };
25 25
26 const wchar_t* const kAliasMatchCandidates[] = { 26 const wchar_t* const kAliasMatchCandidates[] = {
27 #if defined(GOOGLE_CHROME_BUILD) 27 #if defined(GOOGLE_CHROME_BUILD)
28 L"he", L"nb", L"tl", L"zh-chs", L"zh-cht", L"zh-hans", L"zh-hant", L"zh-hk", 28 L"he", L"nb", L"tl", L"zh-chs", L"zh-cht", L"zh-hans", L"zh-hant", L"zh-hk",
29 L"zh-mk", L"zh-mo" 29 L"zh-mo"
30 #else 30 #else
31 // There is only en-us. 31 // There is only en-us.
32 L"en-us" 32 L"en-us"
33 #endif 33 #endif
34 }; 34 };
35 35
36 const wchar_t* const kWildcardMatchCandidates[] = { 36 const wchar_t* const kWildcardMatchCandidates[] = {
37 L"en-AU", 37 L"en-AU",
38 #if defined(GOOGLE_CHROME_BUILD) 38 #if defined(GOOGLE_CHROME_BUILD)
39 L"es-CO", L"pt-AB", L"zh-SG" 39 L"es-CO", L"pt-AB", L"zh-SG"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 &kAliasMatchCandidates[0], 119 &kAliasMatchCandidates[0],
120 &kAliasMatchCandidates[arraysize(kAliasMatchCandidates)])); 120 &kAliasMatchCandidates[arraysize(kAliasMatchCandidates)]));
121 121
122 // Test a few wildcard matches. 122 // Test a few wildcard matches.
123 INSTANTIATE_TEST_CASE_P( 123 INSTANTIATE_TEST_CASE_P(
124 TestWildcardMatches, 124 TestWildcardMatches,
125 LanguageSelectorMatchCandidateTest, 125 LanguageSelectorMatchCandidateTest,
126 ::testing::ValuesIn( 126 ::testing::ValuesIn(
127 &kWildcardMatchCandidates[0], 127 &kWildcardMatchCandidates[0],
128 &kWildcardMatchCandidates[arraysize(kWildcardMatchCandidates)])); 128 &kWildcardMatchCandidates[arraysize(kWildcardMatchCandidates)]));
129
130 #if defined(GOOGLE_CHROME_BUILD)
131
132 // A fixture for testing aliases that match to an expected translation. The
133 // first member of the tuple is the expected translation, the second is a
134 // candidate that should be aliased to the expectation.
135 class LanguageSelectorAliasTest
136 : public ::testing::TestWithParam< std::tr1::tuple<const wchar_t*,
137 const wchar_t*> > {
138 };
139
140 // Test that the candidate language maps to the aliased translation.
141 TEST_P(LanguageSelectorAliasTest, AliasesMatch) {
142 installer::LanguageSelector instance(
143 std::vector<std::wstring>(1, std::tr1::get<1>(GetParam())));
144 EXPECT_EQ(std::tr1::get<0>(GetParam()), instance.selected_translation());
145 }
146
147 INSTANTIATE_TEST_CASE_P(
148 EnGbAliases,
149 LanguageSelectorAliasTest,
150 ::testing::Combine(
151 ::testing::Values(L"en-gb"),
152 ::testing::Values(L"en-au", L"en-ca", L"en-nz", L"en-za")));
153
154 INSTANTIATE_TEST_CASE_P(
155 IwAliases,
156 LanguageSelectorAliasTest,
157 ::testing::Combine(
158 ::testing::Values(L"iw"),
159 ::testing::Values(L"he")));
160
161 INSTANTIATE_TEST_CASE_P(
162 NoAliases,
163 LanguageSelectorAliasTest,
164 ::testing::Combine(
165 ::testing::Values(L"no"),
166 ::testing::Values(L"nb")));
167
168 INSTANTIATE_TEST_CASE_P(
169 FilAliases,
170 LanguageSelectorAliasTest,
171 ::testing::Combine(
172 ::testing::Values(L"fil"),
173 ::testing::Values(L"tl")));
174
175 INSTANTIATE_TEST_CASE_P(
176 ZhCnAliases,
177 LanguageSelectorAliasTest,
178 ::testing::Combine(
179 ::testing::Values(L"zh-cn"),
180 ::testing::Values(L"zh-chs", L"zh-hans", L"zh-sg")));
181
182 INSTANTIATE_TEST_CASE_P(
183 ZhTwAliases,
184 LanguageSelectorAliasTest,
185 ::testing::Combine(
186 ::testing::Values(L"zh-tw"),
187 ::testing::Values(L"zh-cht", L"zh-hant", L"zh-hk", L"zh-mo")));
188
189 #endif // GOOGLE_CHROME_BUILD
OLDNEW
« no previous file with comments | « chrome/installer/util/language_selector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698