| OLD | NEW |
| 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/linked_ptr.h" | 8 #include "base/linked_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 scoped_ptr<ExtensionMessageBundle> message_bundle( | 207 scoped_ptr<ExtensionMessageBundle> message_bundle( |
| 208 extension_l10n_util::LoadMessageCatalogs(src_path, | 208 extension_l10n_util::LoadMessageCatalogs(src_path, |
| 209 "en", | 209 "en", |
| 210 "sr", | 210 "sr", |
| 211 valid_locales, | 211 valid_locales, |
| 212 &error)); | 212 &error)); |
| 213 EXPECT_TRUE(NULL != message_bundle.get()); | 213 EXPECT_TRUE(NULL != message_bundle.get()); |
| 214 EXPECT_TRUE(error.empty()); | 214 EXPECT_TRUE(error.empty()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST(ExtensionL10nUtil, GetParentLocales) { | |
| 218 std::vector<std::string> locales; | |
| 219 const std::string top_locale("sr_Cyrl_RS"); | |
| 220 extension_l10n_util::GetParentLocales(top_locale, &locales); | |
| 221 | |
| 222 ASSERT_EQ(3U, locales.size()); | |
| 223 EXPECT_EQ("sr_Cyrl_RS", locales[0]); | |
| 224 EXPECT_EQ("sr_Cyrl", locales[1]); | |
| 225 EXPECT_EQ("sr", locales[2]); | |
| 226 } | |
| 227 | |
| 228 // Caller owns the returned object. | 217 // Caller owns the returned object. |
| 229 ExtensionMessageBundle* CreateManifestBundle() { | 218 ExtensionMessageBundle* CreateManifestBundle() { |
| 230 linked_ptr<DictionaryValue> catalog(new DictionaryValue); | 219 linked_ptr<DictionaryValue> catalog(new DictionaryValue); |
| 231 | 220 |
| 232 DictionaryValue* name_tree = new DictionaryValue(); | 221 DictionaryValue* name_tree = new DictionaryValue(); |
| 233 name_tree->SetString("message", "name"); | 222 name_tree->SetString("message", "name"); |
| 234 catalog->Set("name", name_tree); | 223 catalog->Set("name", name_tree); |
| 235 | 224 |
| 236 DictionaryValue* description_tree = new DictionaryValue(); | 225 DictionaryValue* description_tree = new DictionaryValue(); |
| 237 description_tree->SetString("message", "description"); | 226 description_tree->SetString("message", "description"); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 DictionaryValue manifest; | 418 DictionaryValue manifest; |
| 430 manifest.SetString(keys::kDefaultLocale, "en_US"); | 419 manifest.SetString(keys::kDefaultLocale, "en_US"); |
| 431 manifest.SetString(keys::kCurrentLocale, "sr"); | 420 manifest.SetString(keys::kCurrentLocale, "sr"); |
| 432 | 421 |
| 433 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); | 422 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); |
| 434 | 423 |
| 435 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); | 424 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); |
| 436 } | 425 } |
| 437 | 426 |
| 438 } // namespace | 427 } // namespace |
| OLD | NEW |