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

Unified Diff: chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc

Issue 973303002: [Extensions] Make chrome://extensions use developerPrivate for error calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 9 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/browser/extensions/api/developer_private/developer_private_api_unittest.cc
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
index b7d90d2bbe8c9bcbad8ca68c35c888ef20ce02c6..e4332946d99466144580895e07340e2972f470e4 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
@@ -372,4 +372,36 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateLoadUnpacked) {
current_ids).size());
}
+// Test developerPrivate.requestFileSource.
+TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateRequestFileSource) {
+ ResetThreadBundle(content::TestBrowserThreadBundle::DEFAULT);
+ // Testing of this function seems light, but that's because it basically just
+ // forwards to reading a file to a string, and highlighting it - both of which
+ // are already tested separately.
+ const Extension* extension = LoadUnpackedExtension();
+ const char kErrorMessage[] = "Something went wrong";
+ api::developer_private::RequestFileSourceProperties properties;
+ properties.extension_id = extension->id();
+ properties.path_suffix = "manifest.json";
+ properties.message = kErrorMessage;
+ properties.manifest_key.reset(new std::string("name"));
+
+ scoped_refptr<UIThreadExtensionFunction> function(
+ new api::DeveloperPrivateRequestFileSourceFunction());
+ base::ListValue file_source_args;
+ file_source_args.Append(properties.ToValue().release());
+ EXPECT_TRUE(RunFunction(function, file_source_args)) << function->GetError();
+
+ const base::Value* response_value = nullptr;
+ ASSERT_TRUE(function->GetResultList()->Get(0u, &response_value));
+ scoped_ptr<api::developer_private::RequestFileSourceResponse> response =
+ api::developer_private::RequestFileSourceResponse::FromValue(
+ *response_value);
+ EXPECT_FALSE(response->before_highlight.empty());
+ EXPECT_EQ("\"name\": \"foo\"", response->highlight);
+ EXPECT_FALSE(response->after_highlight.empty());
+ EXPECT_EQ("foo: manifest.json", response->title);
+ EXPECT_EQ(kErrorMessage, response->message);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698