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

Unified Diff: chrome/common/extensions/extension_manifests_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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension_manifests_unittest.cc
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index 01bcacf77ab991c53c608d8bc914037fc8279769..60763a098082b1e3dfeba193a1c434f97cc1ddef 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -25,6 +25,7 @@
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_error_utils.h"
+#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/extensions/url_pattern.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -50,16 +51,28 @@ class ExtensionManifestTest : public testing::Test {
protected:
static DictionaryValue* LoadManifestFile(const std::string& filename,
std::string* error) {
- FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII("extensions")
- .AppendASCII("manifest_tests")
- .AppendASCII(filename.c_str());
- EXPECT_TRUE(file_util::PathExists(path)) <<
- "Couldn't find " << path.value();
-
- JSONFileValueSerializer serializer(path);
- return static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
+ FilePath extension_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &extension_path);
+ extension_path = extension_path.AppendASCII("extensions")
+ .AppendASCII("manifest_tests");
+
+ FilePath manifest_path = extension_path.AppendASCII(filename.c_str());
+ EXPECT_TRUE(file_util::PathExists(manifest_path)) <<
+ "Couldn't find " << manifest_path.value();
+
+ JSONFileValueSerializer serializer(manifest_path);
+ DictionaryValue* manifest =
+ static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
+
+ // Most unit tests don't need localization, and they'll fail if we try to
+ // localize them, since their manifests don't have a default_locale key.
+ // Only localize manifests that indicate they want to be localized.
+ // Calling LocalizeExtension at this point mirrors
+ // extension_file_util::LoadExtension.
+ if (manifest && filename.find("localized") != std::string::npos)
+ extension_l10n_util::LocalizeExtension(extension_path, manifest, error);
+
+ return manifest;
}
// Helper class that simplifies creating methods that take either a filename
@@ -433,24 +446,35 @@ TEST_F(ExtensionManifestTest, AppLaunchURL) {
errors::kInvalidLaunchLocalPath);
LoadAndExpectError("launch_path_invalid_value.json",
errors::kInvalidLaunchLocalPath);
+ LoadAndExpectError("launch_path_invalid_localized.json",
+ errors::kInvalidLaunchLocalPath);
LoadAndExpectError("launch_url_invalid_type_1.json",
errors::kInvalidLaunchWebURL);
LoadAndExpectError("launch_url_invalid_type_2.json",
errors::kInvalidLaunchWebURL);
LoadAndExpectError("launch_url_invalid_type_3.json",
errors::kInvalidLaunchWebURL);
+ LoadAndExpectError("launch_url_invalid_localized.json",
+ errors::kInvalidLaunchWebURL);
scoped_refptr<Extension> extension;
extension = LoadAndExpectSuccess("launch_local_path.json");
EXPECT_EQ(extension->url().spec() + "launch.html",
extension->GetFullLaunchURL().spec());
+ extension = LoadAndExpectSuccess("launch_local_path_localized.json");
+ EXPECT_EQ(extension->url().spec() + "launch.html",
+ extension->GetFullLaunchURL().spec());
+
LoadAndExpectError("launch_web_url_relative.json",
errors::kInvalidLaunchWebURL);
extension = LoadAndExpectSuccess("launch_web_url_absolute.json");
EXPECT_EQ(GURL("http://www.google.com/launch.html"),
extension->GetFullLaunchURL());
+ extension = LoadAndExpectSuccess("launch_web_url_localized.json");
+ EXPECT_EQ(GURL("http://www.google.com/launch.html"),
+ extension->GetFullLaunchURL());
}
TEST_F(ExtensionManifestTest, Override) {

Powered by Google App Engine
This is Rietveld 408576698