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

Unified Diff: content/browser/plugin_service_impl_browsertest.cc

Issue 12315023: Merge 180159 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 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
« no previous file with comments | « content/browser/plugin_service_impl.cc ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/plugin_service_impl_browsertest.cc
===================================================================
--- content/browser/plugin_service_impl_browsertest.cc (revision 183671)
+++ content/browser/plugin_service_impl_browsertest.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/plugin_service_filter.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
@@ -35,10 +36,11 @@
class MockPluginProcessHostClient : public PluginProcessHost::Client,
public IPC::Listener {
public:
- MockPluginProcessHostClient(ResourceContext* context)
+ MockPluginProcessHostClient(ResourceContext* context, bool expect_fail)
: context_(context),
channel_(NULL),
- set_plugin_info_called_(false) {
+ set_plugin_info_called_(false),
+ expect_fail_(expect_fail) {
}
virtual ~MockPluginProcessHostClient() {
@@ -79,6 +81,8 @@
return false;
}
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
+ if (expect_fail_)
+ FAIL();
QuitMessageLoop();
}
virtual void OnChannelError() OVERRIDE {
@@ -95,7 +99,8 @@
private:
void Fail() {
- FAIL();
+ if (!expect_fail_)
+ FAIL();
QuitMessageLoop();
}
@@ -107,9 +112,27 @@
ResourceContext* context_;
IPC::Channel* channel_;
bool set_plugin_info_called_;
+ bool expect_fail_;
DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
};
+class MockPluginServiceFilter : public content::PluginServiceFilter {
+ public:
+ MockPluginServiceFilter() {}
+
+ virtual bool IsPluginEnabled(
+ int render_process_id,
+ int render_view_id,
+ const void* context,
+ const GURL& url,
+ const GURL& policy_url,
+ webkit::WebPluginInfo* plugin) OVERRIDE { return true; }
+
+ virtual bool CanLoadPlugin(
+ int render_process_id,
+ const FilePath& path) OVERRIDE { return false; }
+};
+
class PluginServiceTest : public ContentBrowserTest {
public:
PluginServiceTest() {}
@@ -137,13 +160,23 @@
// Try to open a channel to the test plugin. Minimal plugin process spawning
// test for the PluginService interface.
IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) {
- MockPluginProcessHostClient mock_client(GetResourceContext());
+ MockPluginProcessHostClient mock_client(GetResourceContext(), false);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&OpenChannel, &mock_client));
RunMessageLoop();
}
+IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) {
+ MockPluginServiceFilter filter;
+ PluginServiceImpl::GetInstance()->SetFilter(&filter);
+ MockPluginProcessHostClient mock_client(GetResourceContext(), true);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&OpenChannel, &mock_client));
+ RunMessageLoop();
+}
+
// A strict mock that fails if any of the methods are called. They shouldn't be
// called since the request should get canceled before then.
class MockCanceledPluginServiceClient : public PluginProcessHost::Client {
« no previous file with comments | « content/browser/plugin_service_impl.cc ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698