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

Side by Side Diff: chrome/common/extensions/extension_l10n_util_unittest.cc

Issue 9421010: Allow app launch URLs to be localized. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 catalog->Set("title", action_title_tree); 274 catalog->Set("title", action_title_tree);
275 275
276 DictionaryValue* omnibox_keyword_tree = new DictionaryValue(); 276 DictionaryValue* omnibox_keyword_tree = new DictionaryValue();
277 omnibox_keyword_tree->SetString("message", "omnibox keyword"); 277 omnibox_keyword_tree->SetString("message", "omnibox keyword");
278 catalog->Set("omnibox_keyword", omnibox_keyword_tree); 278 catalog->Set("omnibox_keyword", omnibox_keyword_tree);
279 279
280 DictionaryValue* file_handler_title_tree = new DictionaryValue(); 280 DictionaryValue* file_handler_title_tree = new DictionaryValue();
281 file_handler_title_tree->SetString("message", "file handler title"); 281 file_handler_title_tree->SetString("message", "file handler title");
282 catalog->Set("file_handler_title", file_handler_title_tree); 282 catalog->Set("file_handler_title", file_handler_title_tree);
283 283
284 DictionaryValue* launch_local_path_tree = new DictionaryValue();
285 launch_local_path_tree->SetString("message", "main.html");
286 catalog->Set("launch_local_path", launch_local_path_tree);
287
288 DictionaryValue* launch_web_url_tree = new DictionaryValue();
289 launch_web_url_tree->SetString("message", "http://www.google.com/");
290 catalog->Set("launch_web_url", launch_web_url_tree);
291
284 std::vector<linked_ptr<DictionaryValue> > catalogs; 292 std::vector<linked_ptr<DictionaryValue> > catalogs;
285 catalogs.push_back(catalog); 293 catalogs.push_back(catalog);
286 294
287 std::string error; 295 std::string error;
288 ExtensionMessageBundle* bundle = 296 ExtensionMessageBundle* bundle =
289 ExtensionMessageBundle::Create(catalogs, &error); 297 ExtensionMessageBundle::Create(catalogs, &error);
290 EXPECT_TRUE(bundle); 298 EXPECT_TRUE(bundle);
291 EXPECT_TRUE(error.empty()); 299 EXPECT_TRUE(error.empty());
292 300
293 return bundle; 301 return bundle;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 340
333 std::string result; 341 std::string result;
334 ASSERT_TRUE(manifest.GetString(keys::kName, &result)); 342 ASSERT_TRUE(manifest.GetString(keys::kName, &result));
335 EXPECT_EQ("name", result); 343 EXPECT_EQ("name", result);
336 344
337 EXPECT_FALSE(manifest.HasKey(keys::kDescription)); 345 EXPECT_FALSE(manifest.HasKey(keys::kDescription));
338 346
339 EXPECT_TRUE(error.empty()); 347 EXPECT_TRUE(error.empty());
340 } 348 }
341 349
350 TEST(ExtensionL10nUtil, LocalizeManifestWithLocalLaunchURL) {
351 DictionaryValue manifest;
352 manifest.SetString(keys::kName, "name");
353 manifest.SetString(keys::kLaunchLocalPath, "__MSG_launch_local_path__");
354 std::string error;
355 scoped_ptr<ExtensionMessageBundle> messages(CreateManifestBundle());
356
357 EXPECT_TRUE(
358 extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
359
360 std::string result;
361 ASSERT_TRUE(manifest.GetString(keys::kLaunchLocalPath, &result));
362 EXPECT_EQ("main.html", result);
363
364 EXPECT_TRUE(error.empty());
365 }
366
367 TEST(ExtensionL10nUtil, LocalizeManifestWithHostedLaunchURL) {
368 DictionaryValue manifest;
369 manifest.SetString(keys::kName, "name");
370 manifest.SetString(keys::kLaunchWebURL, "__MSG_launch_web_url__");
371 std::string error;
372 scoped_ptr<ExtensionMessageBundle> messages(CreateManifestBundle());
373
374 EXPECT_TRUE(
375 extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
376
377 std::string result;
378 ASSERT_TRUE(manifest.GetString(keys::kLaunchWebURL, &result));
379 EXPECT_EQ("http://www.google.com/", result);
380
381 EXPECT_TRUE(error.empty());
382 }
383
342 TEST(ExtensionL10nUtil, LocalizeManifestWithBadNameMsg) { 384 TEST(ExtensionL10nUtil, LocalizeManifestWithBadNameMsg) {
343 DictionaryValue manifest; 385 DictionaryValue manifest;
344 manifest.SetString(keys::kName, "__MSG_name_is_bad__"); 386 manifest.SetString(keys::kName, "__MSG_name_is_bad__");
345 manifest.SetString(keys::kDescription, "__MSG_description__"); 387 manifest.SetString(keys::kDescription, "__MSG_description__");
346 std::string error; 388 std::string error;
347 scoped_ptr<ExtensionMessageBundle> messages(CreateManifestBundle()); 389 scoped_ptr<ExtensionMessageBundle> messages(CreateManifestBundle());
348 390
349 EXPECT_FALSE( 391 EXPECT_FALSE(
350 extension_l10n_util::LocalizeManifest(*messages, &manifest, &error)); 392 extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
351 393
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 DictionaryValue manifest; 537 DictionaryValue manifest;
496 manifest.SetString(keys::kDefaultLocale, "en_US"); 538 manifest.SetString(keys::kDefaultLocale, "en_US");
497 manifest.SetString(keys::kCurrentLocale, "sr"); 539 manifest.SetString(keys::kCurrentLocale, "sr");
498 540
499 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD); 541 ExtensionInfo info(&manifest, "", FilePath(), Extension::LOAD);
500 542
501 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); 543 EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info));
502 } 544 }
503 545
504 } // namespace 546 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_l10n_util.cc ('k') | chrome/common/extensions/extension_manifests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698