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 "chrome/common/extensions/message_bundle.h" | 5 #include "chrome/common/extensions/message_bundle.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/common/extensions/extension_l10n_util.h" |
16 #include "chrome/common/extensions/extension_manifest_constants.h" | 17 #include "chrome/common/extensions/extension_manifest_constants.h" |
17 #include "chrome/common/extensions/extension_error_utils.h" | 18 #include "extensions/common/error_utils.h" |
18 #include "chrome/common/extensions/extension_l10n_util.h" | |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace errors = extension_manifest_errors; | 21 namespace errors = extension_manifest_errors; |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 class MessageBundleTest : public testing::Test { | 25 class MessageBundleTest : public testing::Test { |
26 protected: | 26 protected: |
27 enum BadDictionary { | 27 enum BadDictionary { |
28 INVALID_NAME, | 28 INVALID_NAME, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 TEST_F(MessageBundleTest, ReservedMessagesOverrideDeveloperMessages) { | 259 TEST_F(MessageBundleTest, ReservedMessagesOverrideDeveloperMessages) { |
260 catalogs_.push_back(linked_ptr<DictionaryValue>(CreateGoodDictionary())); | 260 catalogs_.push_back(linked_ptr<DictionaryValue>(CreateGoodDictionary())); |
261 | 261 |
262 DictionaryValue* dict = catalogs_[0].get(); | 262 DictionaryValue* dict = catalogs_[0].get(); |
263 CreateMessageTree(MessageBundle::kUILocaleKey, "x", false, dict); | 263 CreateMessageTree(MessageBundle::kUILocaleKey, "x", false, dict); |
264 | 264 |
265 std::string error = CreateMessageBundle(); | 265 std::string error = CreateMessageBundle(); |
266 | 266 |
267 EXPECT_TRUE(handler_.get() == NULL); | 267 EXPECT_TRUE(handler_.get() == NULL); |
268 std::string expected_error = ExtensionErrorUtils::FormatErrorMessage( | 268 std::string expected_error = ErrorUtils::FormatErrorMessage( |
269 errors::kReservedMessageFound, MessageBundle::kUILocaleKey); | 269 errors::kReservedMessageFound, MessageBundle::kUILocaleKey); |
270 EXPECT_EQ(expected_error, error); | 270 EXPECT_EQ(expected_error, error); |
271 } | 271 } |
272 | 272 |
273 TEST_F(MessageBundleTest, AppendReservedMessagesForLTR) { | 273 TEST_F(MessageBundleTest, AppendReservedMessagesForLTR) { |
274 CreateMessageBundle(); | 274 CreateMessageBundle(); |
275 | 275 |
276 ASSERT_TRUE(handler_.get() != NULL); | 276 ASSERT_TRUE(handler_.get() != NULL); |
277 ClearDictionary(); | 277 ClearDictionary(); |
278 ASSERT_TRUE(AppendReservedMessages("en_US")); | 278 ASSERT_TRUE(AppendReservedMessages("en_US")); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 messages.insert(std::make_pair("message_name", "message_value")); | 420 messages.insert(std::make_pair("message_name", "message_value")); |
421 (*GetExtensionToL10nMessagesMap())[extension_id] = messages; | 421 (*GetExtensionToL10nMessagesMap())[extension_id] = messages; |
422 | 422 |
423 L10nMessagesMap* map = GetL10nMessagesMap(extension_id); | 423 L10nMessagesMap* map = GetL10nMessagesMap(extension_id); |
424 ASSERT_TRUE(NULL != map); | 424 ASSERT_TRUE(NULL != map); |
425 EXPECT_EQ(1U, map->size()); | 425 EXPECT_EQ(1U, map->size()); |
426 EXPECT_EQ("message_value", (*map)["message_name"]); | 426 EXPECT_EQ("message_value", (*map)["message_name"]); |
427 } | 427 } |
428 | 428 |
429 } // namespace extensions | 429 } // namespace extensions |
OLD | NEW |