| Index: content/browser/plugin_service_browsertest.cc
|
| diff --git a/content/browser/plugin_service_browsertest.cc b/content/browser/plugin_service_browsertest.cc
|
| index e1e15b72983c78f3c3a439db8feecb25453e7823..b436ab2b656689be8bf5164e788870a065868b2b 100644
|
| --- a/content/browser/plugin_service_browsertest.cc
|
| +++ b/content/browser/plugin_service_browsertest.cc
|
| @@ -9,6 +9,7 @@
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "content/browser/browser_thread.h"
|
| +#include "content/browser/resource_context.h"
|
| #include "content/common/content_switches.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "webkit/plugins/npapi/plugin_list.h"
|
| @@ -17,6 +18,15 @@ namespace {
|
|
|
| const char* kNPAPITestPluginMimeType = "application/vnd.npapi-test";
|
|
|
| +class MockResourceContext : public content::ResourceContext {
|
| + public:
|
| + MockResourceContext() {}
|
| + virtual ~MockResourceContext() {}
|
| +
|
| + private:
|
| + virtual void EnsureInitialized() const OVERRIDE {}
|
| +};
|
| +
|
| // Mock up of the Client and the Listener classes that would supply the
|
| // communication channel with the plugin.
|
| class MockPluginProcessHostClient : public PluginProcessHost::Client,
|
| @@ -33,8 +43,11 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
|
| }
|
|
|
| // Client implementation.
|
| - int ID() { return 42; }
|
| - bool OffTheRecord() { return false; }
|
| + virtual int ID() OVERRIDE { return 42; }
|
| + virtual bool OffTheRecord() OVERRIDE { return false; }
|
| + virtual const content::ResourceContext* GetResourceContext() OVERRIDE {
|
| + return &context_;
|
| + }
|
|
|
| void OnChannelOpened(const IPC::ChannelHandle& handle) {
|
| ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| @@ -63,6 +76,7 @@ class MockPluginProcessHostClient : public PluginProcessHost::Client,
|
| MOCK_METHOD0(OnChannelListenError, void());
|
|
|
| private:
|
| + MockResourceContext context_;
|
| IPC::Channel* channel_;
|
| bool set_plugin_info_called_;
|
| DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
|
| @@ -82,13 +96,20 @@ class PluginServiceTest : public InProcessBrowserTest {
|
| browser_directory.AppendASCII("plugins"));
|
| #endif
|
| }
|
| +
|
| + static void OpenChannelOnIOThread(PluginProcessHost::Client* client) {
|
| + PluginService::GetInstance()->OpenChannelToNpapiPlugin(
|
| + 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client);
|
| + }
|
| };
|
|
|
| // 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;
|
| - PluginService::GetInstance()->OpenChannelToNpapiPlugin(
|
| - 0, 0, GURL(), kNPAPITestPluginMimeType, &mock_client);
|
| + ::testing::StrictMock<MockPluginProcessHostClient> mock_client;
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + NewRunnableFunction(&PluginServiceTest::OpenChannelOnIOThread,
|
| + &mock_client));
|
| ui_test_utils::RunMessageLoop();
|
| }
|
|
|