Index: ppapi/proxy/ppapi_proxy_test.cc |
diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc |
index eba0aedd4964cbeef54d7316f4c02bcd67fe4765..63cb82ed1750b34db3ed885efb3cf7bb074b92f5 100644 |
--- a/ppapi/proxy/ppapi_proxy_test.cc |
+++ b/ppapi/proxy/ppapi_proxy_test.cc |
@@ -93,6 +93,12 @@ void TearDownRemoteHarness(ProxyTestHarnessBase* harness, |
harness_torn_down->Signal(); |
} |
+void RunTaskOnRemoteHarness(const base::Closure& task, |
+ base::WaitableEvent* task_complete) { |
+ task.Run(); |
+ task_complete->Signal(); |
+} |
+ |
} // namespace |
// ProxyTestHarnessBase -------------------------------------------------------- |
@@ -140,13 +146,18 @@ bool ProxyTestHarnessBase::SupportsInterface(const char* name) { |
// PluginProxyTestHarness ------------------------------------------------------ |
-PluginProxyTestHarness::PluginProxyTestHarness() |
- : plugin_globals_(PpapiGlobals::ForTest()) { |
+PluginProxyTestHarness::PluginProxyTestHarness() { |
} |
PluginProxyTestHarness::~PluginProxyTestHarness() { |
} |
+PpapiGlobals* PluginProxyTestHarness::GetGlobals() { |
+ if (!plugin_globals_.get()) |
+ plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest())); |
+ return plugin_globals_.get(); |
dmichael (off chromium)
2012/09/17 15:27:29
What about explicitly setting it in SetUpHarness a
raymes
2012/09/18 21:29:15
Done.
|
+} |
+ |
Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
return plugin_dispatcher_.get(); |
} |
@@ -161,6 +172,13 @@ void PluginProxyTestHarness::SetUpHarness() { |
false)); |
plugin_dispatcher_->InitWithTestSink(&sink()); |
plugin_dispatcher_->DidCreateInstance(pp_instance()); |
+ // The plugin proxy delegate is needed for |
+ // |PluginPepperDelegate::GetBrowserSender| which is used |
dmichael (off chromium)
2012/09/17 15:27:29
PluginProxyDelegate
raymes
2012/09/18 21:29:15
Done.
|
+ // in |ResourceCreationProxy::GetConnection| to get the channel to the |
+ // browser. In this case we just use the |plugin_dispatcher_| as the channel |
+ // for test purposes. |
+ plugin_delegate_mock_.set_browser_sender(plugin_dispatcher_.get()); |
+ PluginGlobals::Get()->set_plugin_proxy_delegate(&plugin_delegate_mock_); |
} |
void PluginProxyTestHarness::SetUpHarnessWithChannel( |
@@ -187,6 +205,7 @@ void PluginProxyTestHarness::TearDownHarness() { |
plugin_dispatcher_.reset(); |
resource_tracker().DidDeleteInstance(pp_instance()); |
+ plugin_globals_.reset(); |
} |
base::MessageLoopProxy* |
@@ -230,8 +249,7 @@ bool PluginProxyTestHarness::PluginDelegateMock::SendToBrowser( |
} |
IPC::Sender* PluginProxyTestHarness::PluginDelegateMock::GetBrowserSender() { |
- NOTREACHED(); |
- return NULL; |
+ return browser_sender_; |
} |
std::string PluginProxyTestHarness::PluginDelegateMock::GetUILanguage() { |
@@ -272,13 +290,18 @@ class HostProxyTestHarness::MockSyncMessageStatusReceiver |
}; |
HostProxyTestHarness::HostProxyTestHarness() |
- : host_globals_(PpapiGlobals::ForTest()), |
- status_receiver_(new MockSyncMessageStatusReceiver) { |
+ : status_receiver_(new MockSyncMessageStatusReceiver) { |
} |
HostProxyTestHarness::~HostProxyTestHarness() { |
} |
+PpapiGlobals* HostProxyTestHarness::GetGlobals() { |
+ if (!host_globals_.get()) |
+ host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest())); |
+ return host_globals_.get(); |
+} |
+ |
Dispatcher* HostProxyTestHarness::GetDispatcher() { |
return host_dispatcher_.get(); |
} |
@@ -316,6 +339,7 @@ void HostProxyTestHarness::SetUpHarnessWithChannel( |
void HostProxyTestHarness::TearDownHarness() { |
HostDispatcher::RemoveForInstance(pp_instance()); |
host_dispatcher_.reset(); |
+ host_globals_.reset(); |
} |
base::MessageLoopProxy* |
@@ -415,5 +439,15 @@ void TwoWayTest::TearDown() { |
io_thread_.Stop(); |
} |
+void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) { |
+ base::WaitableEvent task_complete(true, false); |
+ plugin_thread_.message_loop_proxy()->PostTask(FROM_HERE, |
+ base::Bind(&RunTaskOnRemoteHarness, |
+ task, |
+ &task_complete)); |
+ task_complete.Wait(); |
+} |
+ |
+ |
} // namespace proxy |
} // namespace ppapi |