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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
13 #include "chrome/common/extensions/extension.h" | |
14 #include "chrome/common/extensions/extension_l10n_util.h" | 13 #include "chrome/common/extensions/extension_l10n_util.h" |
15 #include "chrome/common/extensions/extension_manifest_constants.h" | 14 #include "chrome/common/extensions/extension_manifest_constants.h" |
16 #include "chrome/common/extensions/message_bundle.h" | 15 #include "chrome/common/extensions/message_bundle.h" |
16 #include "extensions/common/constants.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 | 19 |
20 using extensions::Extension; | |
21 using extensions::ExtensionInfo; | |
22 using extensions::Manifest; | |
23 using extensions::MessageBundle; | 20 using extensions::MessageBundle; |
24 | 21 |
25 namespace errors = extension_manifest_errors; | 22 namespace errors = extension_manifest_errors; |
26 namespace keys = extension_manifest_keys; | 23 namespace keys = extension_manifest_keys; |
27 | 24 |
28 namespace { | 25 namespace { |
29 | 26 |
30 TEST(ExtensionL10nUtil, GetValidLocalesEmptyLocaleFolder) { | 27 TEST(ExtensionL10nUtil, GetValidLocalesEmptyLocaleFolder) { |
31 base::ScopedTempDir temp; | 28 base::ScopedTempDir temp; |
32 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 29 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
33 | 30 |
34 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 31 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
Jeffrey Yasskin
2013/03/22 20:26:50
Maybe add "using extensions::kLocaleFolder;"
Yoyo Zhou
2013/03/22 21:33:32
Done.
| |
35 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 32 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
36 | 33 |
37 std::string error; | 34 std::string error; |
38 std::set<std::string> locales; | 35 std::set<std::string> locales; |
39 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, | 36 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, |
40 &locales, | 37 &locales, |
41 &error)); | 38 &error)); |
42 | 39 |
43 EXPECT_TRUE(locales.empty()); | 40 EXPECT_TRUE(locales.empty()); |
44 } | 41 } |
45 | 42 |
46 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocaleNoMessagesFile) { | 43 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocaleNoMessagesFile) { |
47 base::ScopedTempDir temp; | 44 base::ScopedTempDir temp; |
48 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 45 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
49 | 46 |
50 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 47 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
51 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 48 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
52 ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("sr"))); | 49 ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("sr"))); |
53 | 50 |
54 std::string error; | 51 std::string error; |
55 std::set<std::string> locales; | 52 std::set<std::string> locales; |
56 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, | 53 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, |
57 &locales, | 54 &locales, |
58 &error)); | 55 &error)); |
59 | 56 |
60 EXPECT_TRUE(locales.empty()); | 57 EXPECT_TRUE(locales.empty()); |
61 } | 58 } |
62 | 59 |
63 TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { | 60 TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { |
64 base::ScopedTempDir temp; | 61 base::ScopedTempDir temp; |
65 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 62 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
66 | 63 |
67 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 64 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
68 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 65 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
69 // Supported locale. | 66 // Supported locale. |
70 base::FilePath locale_1 = src_path.AppendASCII("sr"); | 67 base::FilePath locale_1 = src_path.AppendASCII("sr"); |
71 ASSERT_TRUE(file_util::CreateDirectory(locale_1)); | 68 ASSERT_TRUE(file_util::CreateDirectory(locale_1)); |
72 std::string data("whatever"); | 69 std::string data("whatever"); |
73 ASSERT_TRUE(file_util::WriteFile( | 70 ASSERT_TRUE(file_util::WriteFile( |
74 locale_1.Append(Extension::kMessagesFilename), | 71 locale_1.Append(extensions::kMessagesFilename), |
75 data.c_str(), data.length())); | 72 data.c_str(), data.length())); |
76 // Unsupported locale. | 73 // Unsupported locale. |
77 ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("xxx_yyy"))); | 74 ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("xxx_yyy"))); |
78 | 75 |
79 std::string error; | 76 std::string error; |
80 std::set<std::string> locales; | 77 std::set<std::string> locales; |
81 EXPECT_TRUE(extension_l10n_util::GetValidLocales(src_path, | 78 EXPECT_TRUE(extension_l10n_util::GetValidLocales(src_path, |
82 &locales, | 79 &locales, |
83 &error)); | 80 &error)); |
84 | 81 |
85 EXPECT_FALSE(locales.empty()); | 82 EXPECT_FALSE(locales.empty()); |
86 EXPECT_TRUE(locales.find("sr") != locales.end()); | 83 EXPECT_TRUE(locales.find("sr") != locales.end()); |
87 EXPECT_FALSE(locales.find("xxx_yyy") != locales.end()); | 84 EXPECT_FALSE(locales.find("xxx_yyy") != locales.end()); |
88 } | 85 } |
89 | 86 |
90 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { | 87 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { |
91 base::FilePath install_dir; | 88 base::FilePath install_dir; |
92 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); | 89 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); |
93 install_dir = install_dir.AppendASCII("extensions") | 90 install_dir = install_dir.AppendASCII("extensions") |
94 .AppendASCII("good") | 91 .AppendASCII("good") |
95 .AppendASCII("Extensions") | 92 .AppendASCII("Extensions") |
96 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 93 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
97 .AppendASCII("1.0.0.0") | 94 .AppendASCII("1.0.0.0") |
98 .Append(Extension::kLocaleFolder); | 95 .Append(extensions::kLocaleFolder); |
99 | 96 |
100 std::string error; | 97 std::string error; |
101 std::set<std::string> locales; | 98 std::set<std::string> locales; |
102 EXPECT_TRUE(extension_l10n_util::GetValidLocales(install_dir, | 99 EXPECT_TRUE(extension_l10n_util::GetValidLocales(install_dir, |
103 &locales, | 100 &locales, |
104 &error)); | 101 &error)); |
105 EXPECT_EQ(3U, locales.size()); | 102 EXPECT_EQ(3U, locales.size()); |
106 EXPECT_TRUE(locales.find("sr") != locales.end()); | 103 EXPECT_TRUE(locales.find("sr") != locales.end()); |
107 EXPECT_TRUE(locales.find("en") != locales.end()); | 104 EXPECT_TRUE(locales.find("en") != locales.end()); |
108 EXPECT_TRUE(locales.find("en_US") != locales.end()); | 105 EXPECT_TRUE(locales.find("en_US") != locales.end()); |
109 } | 106 } |
110 | 107 |
111 TEST(ExtensionL10nUtil, LoadMessageCatalogsValidFallback) { | 108 TEST(ExtensionL10nUtil, LoadMessageCatalogsValidFallback) { |
112 base::FilePath install_dir; | 109 base::FilePath install_dir; |
113 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); | 110 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); |
114 install_dir = install_dir.AppendASCII("extensions") | 111 install_dir = install_dir.AppendASCII("extensions") |
115 .AppendASCII("good") | 112 .AppendASCII("good") |
116 .AppendASCII("Extensions") | 113 .AppendASCII("Extensions") |
117 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 114 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
118 .AppendASCII("1.0.0.0") | 115 .AppendASCII("1.0.0.0") |
119 .Append(Extension::kLocaleFolder); | 116 .Append(extensions::kLocaleFolder); |
120 | 117 |
121 std::string error; | 118 std::string error; |
122 std::set<std::string> locales; | 119 std::set<std::string> locales; |
123 EXPECT_TRUE(extension_l10n_util::GetValidLocales(install_dir, | 120 EXPECT_TRUE(extension_l10n_util::GetValidLocales(install_dir, |
124 &locales, | 121 &locales, |
125 &error)); | 122 &error)); |
126 | 123 |
127 scoped_ptr<MessageBundle> bundle(extension_l10n_util::LoadMessageCatalogs( | 124 scoped_ptr<MessageBundle> bundle(extension_l10n_util::LoadMessageCatalogs( |
128 install_dir, "sr", "en_US", locales, &error)); | 125 install_dir, "sr", "en_US", locales, &error)); |
129 ASSERT_FALSE(NULL == bundle.get()); | 126 ASSERT_FALSE(NULL == bundle.get()); |
130 EXPECT_TRUE(error.empty()); | 127 EXPECT_TRUE(error.empty()); |
131 EXPECT_EQ("Color", bundle->GetL10nMessage("color")); | 128 EXPECT_EQ("Color", bundle->GetL10nMessage("color")); |
132 EXPECT_EQ("Not in the US or GB.", bundle->GetL10nMessage("not_in_US_or_GB")); | 129 EXPECT_EQ("Not in the US or GB.", bundle->GetL10nMessage("not_in_US_or_GB")); |
133 } | 130 } |
134 | 131 |
135 TEST(ExtensionL10nUtil, LoadMessageCatalogsMissingFiles) { | 132 TEST(ExtensionL10nUtil, LoadMessageCatalogsMissingFiles) { |
136 base::ScopedTempDir temp; | 133 base::ScopedTempDir temp; |
137 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 134 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
138 | 135 |
139 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 136 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
140 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 137 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
141 | 138 |
142 std::set<std::string> valid_locales; | 139 std::set<std::string> valid_locales; |
143 valid_locales.insert("sr"); | 140 valid_locales.insert("sr"); |
144 valid_locales.insert("en"); | 141 valid_locales.insert("en"); |
145 std::string error; | 142 std::string error; |
146 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, | 143 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, |
147 "en", | 144 "en", |
148 "sr", | 145 "sr", |
149 valid_locales, | 146 valid_locales, |
150 &error)); | 147 &error)); |
151 EXPECT_FALSE(error.empty()); | 148 EXPECT_FALSE(error.empty()); |
152 } | 149 } |
153 | 150 |
154 TEST(ExtensionL10nUtil, LoadMessageCatalogsBadJSONFormat) { | 151 TEST(ExtensionL10nUtil, LoadMessageCatalogsBadJSONFormat) { |
155 base::ScopedTempDir temp; | 152 base::ScopedTempDir temp; |
156 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 153 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
157 | 154 |
158 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 155 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
159 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 156 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
160 | 157 |
161 base::FilePath locale = src_path.AppendASCII("sr"); | 158 base::FilePath locale = src_path.AppendASCII("sr"); |
162 ASSERT_TRUE(file_util::CreateDirectory(locale)); | 159 ASSERT_TRUE(file_util::CreateDirectory(locale)); |
163 | 160 |
164 std::string data = "{ \"name\":"; | 161 std::string data = "{ \"name\":"; |
165 ASSERT_TRUE( | 162 ASSERT_TRUE( |
166 file_util::WriteFile(locale.Append(Extension::kMessagesFilename), | 163 file_util::WriteFile(locale.Append(extensions::kMessagesFilename), |
167 data.c_str(), data.length())); | 164 data.c_str(), data.length())); |
168 | 165 |
169 std::set<std::string> valid_locales; | 166 std::set<std::string> valid_locales; |
170 valid_locales.insert("sr"); | 167 valid_locales.insert("sr"); |
171 valid_locales.insert("en_US"); | 168 valid_locales.insert("en_US"); |
172 std::string error; | 169 std::string error; |
173 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, | 170 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, |
174 "en_US", | 171 "en_US", |
175 "sr", | 172 "sr", |
176 valid_locales, | 173 valid_locales, |
177 &error)); | 174 &error)); |
178 EXPECT_EQ("Line: 1, column: 10, Unexpected token.", error); | 175 EXPECT_EQ("Line: 1, column: 10, Unexpected token.", error); |
179 } | 176 } |
180 | 177 |
181 TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { | 178 TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { |
182 base::ScopedTempDir temp; | 179 base::ScopedTempDir temp; |
183 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 180 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
184 | 181 |
185 base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 182 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); |
186 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 183 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
187 | 184 |
188 base::FilePath locale_1 = src_path.AppendASCII("en"); | 185 base::FilePath locale_1 = src_path.AppendASCII("en"); |
189 ASSERT_TRUE(file_util::CreateDirectory(locale_1)); | 186 ASSERT_TRUE(file_util::CreateDirectory(locale_1)); |
190 | 187 |
191 std::string data = | 188 std::string data = |
192 "{ \"name\": { \"message\": \"something\" }, " | 189 "{ \"name\": { \"message\": \"something\" }, " |
193 "\"name\": { \"message\": \"something else\" } }"; | 190 "\"name\": { \"message\": \"something else\" } }"; |
194 ASSERT_TRUE( | 191 ASSERT_TRUE( |
195 file_util::WriteFile(locale_1.Append(Extension::kMessagesFilename), | 192 file_util::WriteFile(locale_1.Append(extensions::kMessagesFilename), |
196 data.c_str(), data.length())); | 193 data.c_str(), data.length())); |
197 | 194 |
198 base::FilePath locale_2 = src_path.AppendASCII("sr"); | 195 base::FilePath locale_2 = src_path.AppendASCII("sr"); |
199 ASSERT_TRUE(file_util::CreateDirectory(locale_2)); | 196 ASSERT_TRUE(file_util::CreateDirectory(locale_2)); |
200 | 197 |
201 ASSERT_TRUE( | 198 ASSERT_TRUE( |
202 file_util::WriteFile(locale_2.Append(Extension::kMessagesFilename), | 199 file_util::WriteFile(locale_2.Append(extensions::kMessagesFilename), |
203 data.c_str(), data.length())); | 200 data.c_str(), data.length())); |
204 | 201 |
205 std::set<std::string> valid_locales; | 202 std::set<std::string> valid_locales; |
206 valid_locales.insert("sr"); | 203 valid_locales.insert("sr"); |
207 valid_locales.insert("en"); | 204 valid_locales.insert("en"); |
208 std::string error; | 205 std::string error; |
209 // JSON parser hides duplicates. We are going to get only one key/value | 206 // JSON parser hides duplicates. We are going to get only one key/value |
210 // pair at the end. | 207 // pair at the end. |
211 scoped_ptr<MessageBundle> message_bundle( | 208 scoped_ptr<MessageBundle> message_bundle( |
212 extension_l10n_util::LoadMessageCatalogs(src_path, | 209 extension_l10n_util::LoadMessageCatalogs(src_path, |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 EXPECT_EQ("description", result); | 508 EXPECT_EQ("description", result); |
512 | 509 |
513 ASSERT_TRUE(handler->GetString(keys::kPageActionDefaultTitle, &result)); | 510 ASSERT_TRUE(handler->GetString(keys::kPageActionDefaultTitle, &result)); |
514 EXPECT_EQ("file handler title", result); | 511 EXPECT_EQ("file handler title", result); |
515 | 512 |
516 EXPECT_TRUE(error.empty()); | 513 EXPECT_TRUE(error.empty()); |
517 } | 514 } |
518 | 515 |
519 // Try with NULL manifest. | 516 // Try with NULL manifest. |
520 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) { | 517 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) { |
521 ExtensionInfo info(NULL, "", base::FilePath(), Manifest::UNPACKED); | 518 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(NULL)); |
522 | |
523 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
524 } | 519 } |
525 | 520 |
526 // Try with default and current locales missing. | 521 // Try with default and current locales missing. |
527 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestEmptyManifest) { | 522 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestEmptyManifest) { |
528 DictionaryValue manifest; | 523 DictionaryValue manifest; |
529 ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::UNPACKED); | 524 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(&manifest)); |
530 | |
531 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
532 } | 525 } |
533 | 526 |
534 // Try with missing current_locale. | 527 // Try with missing current_locale. |
535 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithDefaultLocale) { | 528 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithDefaultLocale) { |
536 DictionaryValue manifest; | 529 DictionaryValue manifest; |
537 manifest.SetString(keys::kDefaultLocale, "en_US"); | 530 manifest.SetString(keys::kDefaultLocale, "en_US"); |
538 | 531 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(&manifest)); |
539 ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::UNPACKED); | |
540 | |
541 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
542 } | 532 } |
543 | 533 |
544 // Try with missing default_locale. | 534 // Try with missing default_locale. |
545 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithCurrentLocale) { | 535 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithCurrentLocale) { |
546 DictionaryValue manifest; | 536 DictionaryValue manifest; |
547 manifest.SetString(keys::kCurrentLocale, | 537 manifest.SetString(keys::kCurrentLocale, |
548 extension_l10n_util::CurrentLocaleOrDefault()); | 538 extension_l10n_util::CurrentLocaleOrDefault()); |
549 | 539 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(&manifest)); |
550 ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::UNPACKED); | |
551 | |
552 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
553 } | 540 } |
554 | 541 |
555 // Try with all data present, but with same current_locale as system locale. | 542 // Try with all data present, but with same current_locale as system locale. |
556 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestSameCurrentLocale) { | 543 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestSameCurrentLocale) { |
557 DictionaryValue manifest; | 544 DictionaryValue manifest; |
558 manifest.SetString(keys::kDefaultLocale, "en_US"); | 545 manifest.SetString(keys::kDefaultLocale, "en_US"); |
559 manifest.SetString(keys::kCurrentLocale, | 546 manifest.SetString(keys::kCurrentLocale, |
560 extension_l10n_util::CurrentLocaleOrDefault()); | 547 extension_l10n_util::CurrentLocaleOrDefault()); |
561 | 548 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(&manifest)); |
562 ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::UNPACKED); | |
563 | |
564 EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
565 } | 549 } |
566 | 550 |
567 // Try with all data present, but with different current_locale. | 551 // Try with all data present, but with different current_locale. |
568 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestDifferentCurrentLocale) { | 552 TEST(ExtensionL10nUtil, ShouldRelocalizeManifestDifferentCurrentLocale) { |
569 DictionaryValue manifest; | 553 DictionaryValue manifest; |
570 manifest.SetString(keys::kDefaultLocale, "en_US"); | 554 manifest.SetString(keys::kDefaultLocale, "en_US"); |
571 manifest.SetString(keys::kCurrentLocale, "sr"); | 555 manifest.SetString(keys::kCurrentLocale, "sr"); |
572 | 556 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(&manifest)); |
573 ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::UNPACKED); | |
574 | |
575 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); | |
576 } | 557 } |
577 | 558 |
578 TEST(ExtensionL10nUtil, GetAllFallbackLocales) { | 559 TEST(ExtensionL10nUtil, GetAllFallbackLocales) { |
579 std::vector<std::string> fallback_locales; | 560 std::vector<std::string> fallback_locales; |
580 extension_l10n_util::GetAllFallbackLocales("en_US", "all", &fallback_locales); | 561 extension_l10n_util::GetAllFallbackLocales("en_US", "all", &fallback_locales); |
581 ASSERT_EQ(3U, fallback_locales.size()); | 562 ASSERT_EQ(3U, fallback_locales.size()); |
582 | 563 |
583 CHECK_EQ("en_US", fallback_locales[0]); | 564 CHECK_EQ("en_US", fallback_locales[0]); |
584 CHECK_EQ("en", fallback_locales[1]); | 565 CHECK_EQ("en", fallback_locales[1]); |
585 CHECK_EQ("all", fallback_locales[2]); | 566 CHECK_EQ("all", fallback_locales[2]); |
586 } | 567 } |
587 | 568 |
588 } // namespace | 569 } // namespace |
OLD | NEW |