Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3928)

Unified Diff: chrome/common/extensions/extension_l10n_util_unittest.cc

Issue 22801019: Provide i18n support for descriptions in commands API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_l10n_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_l10n_util_unittest.cc
diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc
index 31696753a7d654057bccc695cb96b22c476223b3..a1fe13d4b403291d5ce751c0ae26c23e250c5b96 100644
--- a/chrome/common/extensions/extension_l10n_util_unittest.cc
+++ b/chrome/common/extensions/extension_l10n_util_unittest.cc
@@ -249,6 +249,16 @@ MessageBundle* CreateManifestBundle() {
launch_web_url_tree->SetString("message", "http://www.google.com/");
catalog->Set("launch_web_url", launch_web_url_tree);
+ base::DictionaryValue* first_command_description_tree =
+ new base::DictionaryValue();
+ first_command_description_tree->SetString("message", "first command");
+ catalog->Set("first_command_description", first_command_description_tree);
+
+ base::DictionaryValue* second_command_description_tree =
+ new base::DictionaryValue();
+ second_command_description_tree->SetString("message", "second command");
+ catalog->Set("second_command_description", second_command_description_tree);
+
std::vector<linked_ptr<base::DictionaryValue> > catalogs;
catalogs.push_back(catalog);
@@ -443,6 +453,48 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionFileHandlerTitle) {
EXPECT_TRUE(error.empty());
}
+TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionCommandDescription) {
+ base::DictionaryValue manifest;
+ manifest.SetString(keys::kName, "__MSG_name__");
+ manifest.SetString(keys::kDescription, "__MSG_description__");
+ base::DictionaryValue* commands = new DictionaryValue();
+ std::string commands_title(keys::kCommands);
+ manifest.Set(commands_title, commands);
+
+ base::DictionaryValue* first_command = new DictionaryValue();
+ commands->Set("first_command", first_command);
+ first_command->SetString(keys::kDescription,
+ "__MSG_first_command_description__");
+
+ base::DictionaryValue* second_command = new DictionaryValue();
+ commands->Set("second_command", second_command);
+ second_command->SetString(keys::kDescription,
+ "__MSG_second_command_description__");
+
+ std::string error;
+ scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+
+ EXPECT_TRUE(
+ extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
+
+ std::string result;
+ ASSERT_TRUE(manifest.GetString(keys::kName, &result));
+ EXPECT_EQ("name", result);
+
+ ASSERT_TRUE(manifest.GetString(keys::kDescription, &result));
+ EXPECT_EQ("description", result);
+
+ ASSERT_TRUE(manifest.GetString("commands.first_command.description",
+ &result));
+ EXPECT_EQ("first command", result);
+
+ ASSERT_TRUE(manifest.GetString("commands.second_command.description",
+ &result));
+ EXPECT_EQ("second command", result);
+
+ EXPECT_TRUE(error.empty());
+}
+
// Try with NULL manifest.
TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) {
EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(NULL));
« no previous file with comments | « chrome/common/extensions/extension_l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698