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

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

Issue 2094913002: Make base::Environment::Create() return unique_ptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit, rebase Created 4 years, 5 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
« no previous file with comments | « sandbox/win/src/address_sanitizer_test.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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 for (size_t i = 0; i < arraysize(filenames); ++i) { 129 for (size_t i = 0; i < arraysize(filenames); ++i) {
130 base::FilePath filename = new_locale_dir.AppendASCII( 130 base::FilePath filename = new_locale_dir.AppendASCII(
131 filenames[i] + ".pak"); 131 filenames[i] + ".pak");
132 base::WriteFile(filename, "", 0); 132 base::WriteFile(filename, "", 0);
133 } 133 }
134 134
135 // Keep a copy of ICU's default locale before we overwrite it. 135 // Keep a copy of ICU's default locale before we overwrite it.
136 const std::string original_locale = base::i18n::GetConfiguredLocale(); 136 const std::string original_locale = base::i18n::GetConfiguredLocale();
137 137
138 if (kPlatformHasDefaultLocale && kUseLocaleFromEnvironment) { 138 if (kPlatformHasDefaultLocale && kUseLocaleFromEnvironment) {
139 env.reset(base::Environment::Create()); 139 env = base::Environment::Create();
140 140
141 // Test the support of LANGUAGE environment variable. 141 // Test the support of LANGUAGE environment variable.
142 base::i18n::SetICUDefaultLocale("en-US"); 142 base::i18n::SetICUDefaultLocale("en-US");
143 env->SetVar("LANGUAGE", "xx:fr_CA"); 143 env->SetVar("LANGUAGE", "xx:fr_CA");
144 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(std::string())); 144 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(std::string()));
145 EXPECT_STREQ("fr", icu::Locale::getDefault().getLanguage()); 145 EXPECT_STREQ("fr", icu::Locale::getDefault().getLanguage());
146 146
147 env->SetVar("LANGUAGE", "xx:yy:en_gb.utf-8@quot"); 147 env->SetVar("LANGUAGE", "xx:yy:en_gb.utf-8@quot");
148 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(std::string())); 148 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(std::string()));
149 EXPECT_STREQ("en", icu::Locale::getDefault().getLanguage()); 149 EXPECT_STREQ("en", icu::Locale::getDefault().getLanguage());
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); 567 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin"));
568 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); 568 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German"));
569 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); 569 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR"));
570 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); 570 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia"));
571 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); 571 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@"));
572 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); 572 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@"));
573 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); 573 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x"));
574 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); 574 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x="));
575 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); 575 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y"));
576 } 576 }
OLDNEW
« no previous file with comments | « sandbox/win/src/address_sanitizer_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698