| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 void SetDefaultLocaleForTest(const std::string& tag, base::Environment* env) { | 98 void SetDefaultLocaleForTest(const std::string& tag, base::Environment* env) { |
| 99 if (kUseLocaleFromEnvironment) | 99 if (kUseLocaleFromEnvironment) |
| 100 env->SetVar("LANGUAGE", tag); | 100 env->SetVar("LANGUAGE", tag); |
| 101 else | 101 else |
| 102 base::i18n::SetICUDefaultLocale(tag); | 102 base::i18n::SetICUDefaultLocale(tag); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(L10nUtilTest, GetAppLocale) { | 105 TEST_F(L10nUtilTest, GetAppLocale) { |
| 106 scoped_ptr<base::Environment> env; | 106 std::unique_ptr<base::Environment> env; |
| 107 // Use a temporary locale dir so we don't have to actually build the locale | 107 // Use a temporary locale dir so we don't have to actually build the locale |
| 108 // pak files for this test. | 108 // pak files for this test. |
| 109 base::ScopedPathOverride locale_dir_override(ui::DIR_LOCALES); | 109 base::ScopedPathOverride locale_dir_override(ui::DIR_LOCALES); |
| 110 base::FilePath new_locale_dir; | 110 base::FilePath new_locale_dir; |
| 111 ASSERT_TRUE(PathService::Get(ui::DIR_LOCALES, &new_locale_dir)); | 111 ASSERT_TRUE(PathService::Get(ui::DIR_LOCALES, &new_locale_dir)); |
| 112 // Make fake locale files. | 112 // Make fake locale files. |
| 113 std::string filenames[] = { | 113 std::string filenames[] = { |
| 114 "en-US", | 114 "en-US", |
| 115 "en-GB", | 115 "en-GB", |
| 116 "fr", | 116 "fr", |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |