| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 std::string error; | 50 std::string error; |
| 51 std::set<std::string> locales; | 51 std::set<std::string> locales; |
| 52 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, | 52 EXPECT_FALSE(extension_l10n_util::GetValidLocales(src_path, |
| 53 &locales, | 53 &locales, |
| 54 &error)); | 54 &error)); |
| 55 | 55 |
| 56 EXPECT_TRUE(locales.empty()); | 56 EXPECT_TRUE(locales.empty()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { |
| 60 ScopedTempDir temp; |
| 61 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 62 |
| 63 FilePath src_path = temp.path().Append(Extension::kLocaleFolder); |
| 64 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
| 65 // Supported locale. |
| 66 FilePath locale_1 = src_path.AppendASCII("sr"); |
| 67 ASSERT_TRUE(file_util::CreateDirectory(locale_1)); |
| 68 std::string data("whatever"); |
| 69 ASSERT_TRUE(file_util::WriteFile( |
| 70 locale_1.Append(Extension::kMessagesFilename), |
| 71 data.c_str(), data.length())); |
| 72 // Unsupported locale. |
| 73 ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("xxx_yyy"))); |
| 74 |
| 75 std::string error; |
| 76 std::set<std::string> locales; |
| 77 EXPECT_TRUE(extension_l10n_util::GetValidLocales(src_path, |
| 78 &locales, |
| 79 &error)); |
| 80 |
| 81 EXPECT_FALSE(locales.empty()); |
| 82 EXPECT_TRUE(locales.find("sr") != locales.end()); |
| 83 EXPECT_FALSE(locales.find("xxx_yyy") != locales.end()); |
| 84 } |
| 85 |
| 59 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { | 86 TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { |
| 60 FilePath install_dir; | 87 FilePath install_dir; |
| 61 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); | 88 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); |
| 62 install_dir = install_dir.AppendASCII("extensions") | 89 install_dir = install_dir.AppendASCII("extensions") |
| 63 .AppendASCII("good") | 90 .AppendASCII("good") |
| 64 .AppendASCII("Extensions") | 91 .AppendASCII("Extensions") |
| 65 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 92 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 66 .AppendASCII("1.0.0.0") | 93 .AppendASCII("1.0.0.0") |
| 67 .Append(Extension::kLocaleFolder); | 94 .Append(Extension::kLocaleFolder); |
| 68 | 95 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 DictionaryValue manifest; | 401 DictionaryValue manifest; |
| 375 manifest.SetString(keys::kDefaultLocale, "en_US"); | 402 manifest.SetString(keys::kDefaultLocale, "en_US"); |
| 376 manifest.SetString(keys::kCurrentLocale, "sr"); | 403 manifest.SetString(keys::kCurrentLocale, "sr"); |
| 377 | 404 |
| 378 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); | 405 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); |
| 379 | 406 |
| 380 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); | 407 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); |
| 381 } | 408 } |
| 382 | 409 |
| 383 } // namespace | 410 } // namespace |
| OLD | NEW |