| 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_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/linked_ptr.h" | 7 #include "base/memory/linked_ptr.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 std::string data = "{ \"name\":"; | 203 std::string data = "{ \"name\":"; |
| 204 ASSERT_TRUE( | 204 ASSERT_TRUE( |
| 205 file_util::WriteFile(locale.Append(Extension::kMessagesFilename), | 205 file_util::WriteFile(locale.Append(Extension::kMessagesFilename), |
| 206 data.c_str(), data.length())); | 206 data.c_str(), data.length())); |
| 207 | 207 |
| 208 std::set<std::string> valid_locales; | 208 std::set<std::string> valid_locales; |
| 209 valid_locales.insert("sr"); | 209 valid_locales.insert("sr"); |
| 210 valid_locales.insert("en_US"); | 210 valid_locales.insert("en_US"); |
| 211 std::string error; | 211 std::string error; |
| 212 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, | 212 EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, |
| 213 "en_US", | 213 "en_US", |
| 214 "sr", | 214 "sr", |
| 215 valid_locales, | 215 valid_locales, |
| 216 &error)); | 216 &error)); |
| 217 EXPECT_EQ("Line: 1, column: 10, Syntax error.", error); | 217 EXPECT_EQ("Line: 1, column: 10, Unexpected token.", error); |
| 218 } | 218 } |
| 219 | 219 |
| 220 TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { | 220 TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { |
| 221 ScopedTempDir temp; | 221 ScopedTempDir temp; |
| 222 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 222 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 223 | 223 |
| 224 FilePath src_path = temp.path().Append(Extension::kLocaleFolder); | 224 FilePath src_path = temp.path().Append(Extension::kLocaleFolder); |
| 225 ASSERT_TRUE(file_util::CreateDirectory(src_path)); | 225 ASSERT_TRUE(file_util::CreateDirectory(src_path)); |
| 226 | 226 |
| 227 FilePath locale_1 = src_path.AppendASCII("en"); | 227 FilePath locale_1 = src_path.AppendASCII("en"); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 DictionaryValue manifest; | 609 DictionaryValue manifest; |
| 610 manifest.SetString(keys::kDefaultLocale, "en_US"); | 610 manifest.SetString(keys::kDefaultLocale, "en_US"); |
| 611 manifest.SetString(keys::kCurrentLocale, "sr"); | 611 manifest.SetString(keys::kCurrentLocale, "sr"); |
| 612 | 612 |
| 613 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); | 613 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); |
| 614 | 614 |
| 615 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); | 615 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); |
| 616 } | 616 } |
| 617 | 617 |
| 618 } // namespace | 618 } // namespace |
| OLD | NEW |