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

Side by Side Diff: ui/base/l10n/l10n_util_unittest.cc

Issue 834183005: Move two locale functions from rtl.h into l10n_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« base/i18n/rtl.h ('K') | « ui/base/l10n/l10n_util.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <cstdlib> 8 #include <cstdlib>
9 #endif 9 #endif
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 "ca@valencia", 125 "ca@valencia",
126 }; 126 };
127 127
128 for (size_t i = 0; i < arraysize(filenames); ++i) { 128 for (size_t i = 0; i < arraysize(filenames); ++i) {
129 base::FilePath filename = new_locale_dir.AppendASCII( 129 base::FilePath filename = new_locale_dir.AppendASCII(
130 filenames[i] + ".pak"); 130 filenames[i] + ".pak");
131 base::WriteFile(filename, "", 0); 131 base::WriteFile(filename, "", 0);
132 } 132 }
133 133
134 // Keep a copy of ICU's default locale before we overwrite it. 134 // Keep a copy of ICU's default locale before we overwrite it.
135 const std::string original_locale = base::i18n::GetConfiguredLocale(); 135 const std::string original_locale = l10n_util::GetConfiguredLocale();
136 136
137 if (kPlatformHasDefaultLocale && kUseLocaleFromEnvironment) { 137 if (kPlatformHasDefaultLocale && kUseLocaleFromEnvironment) {
138 env.reset(base::Environment::Create()); 138 env.reset(base::Environment::Create());
139 139
140 // Test the support of LANGUAGE environment variable. 140 // Test the support of LANGUAGE environment variable.
141 base::i18n::SetICUDefaultLocale("en-US"); 141 base::i18n::SetICUDefaultLocale("en-US");
142 env->SetVar("LANGUAGE", "xx:fr_CA"); 142 env->SetVar("LANGUAGE", "xx:fr_CA");
143 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(std::string())); 143 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(std::string()));
144 EXPECT_STREQ("fr", icu::Locale::getDefault().getLanguage()); 144 EXPECT_STREQ("fr", icu::Locale::getDefault().getLanguage());
145 145
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 result = l10n_util::GetDisplayNameForLocale("-BR", "en", false); 456 result = l10n_util::GetDisplayNameForLocale("-BR", "en", false);
457 EXPECT_EQ(ASCIIToUTF16("Brazil"), result); 457 EXPECT_EQ(ASCIIToUTF16("Brazil"), result);
458 458
459 result = l10n_util::GetDisplayNameForLocale("xyz-xyz", "en", false); 459 result = l10n_util::GetDisplayNameForLocale("xyz-xyz", "en", false);
460 EXPECT_EQ(ASCIIToUTF16("xyz (XYZ)"), result); 460 EXPECT_EQ(ASCIIToUTF16("xyz (XYZ)"), result);
461 461
462 // Check for directional markers when using RTL languages to ensure that 462 // Check for directional markers when using RTL languages to ensure that
463 // direction neutral characters such as parentheses are properly formatted. 463 // direction neutral characters such as parentheses are properly formatted.
464 464
465 // Keep a copy of ICU's default locale before we overwrite it. 465 // Keep a copy of ICU's default locale before we overwrite it.
466 const std::string original_locale = base::i18n::GetConfiguredLocale(); 466 const std::string original_locale = l10n_util::GetConfiguredLocale();
467 467
468 base::i18n::SetICUDefaultLocale("he"); 468 base::i18n::SetICUDefaultLocale("he");
469 CheckUiDisplayNameForLocale("en-US", "en", false); 469 CheckUiDisplayNameForLocale("en-US", "en", false);
470 CheckUiDisplayNameForLocale("en-US", "he", true); 470 CheckUiDisplayNameForLocale("en-US", "he", true);
471 471
472 // Clean up. 472 // Clean up.
473 base::i18n::SetICUDefaultLocale(original_locale); 473 base::i18n::SetICUDefaultLocale(original_locale);
474 474
475 // ToUpper and ToLower should work with embedded NULLs. 475 // ToUpper and ToLower should work with embedded NULLs.
476 const size_t length_with_null = 4; 476 const size_t length_with_null = 4;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); 557 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin"));
558 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); 558 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German"));
559 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); 559 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR"));
560 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); 560 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia"));
561 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); 561 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@"));
562 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); 562 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@"));
563 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); 563 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x"));
564 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); 564 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x="));
565 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); 565 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y"));
566 } 566 }
OLDNEW
« base/i18n/rtl.h ('K') | « ui/base/l10n/l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698