summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppapi_proxy_test.cc
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-19 00:55:42 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-19 00:55:42 +0000
commitd57fd38fb40a6bb65af7ab40cacd90c350c0aba1 (patch)
tree5533995be16ce702a45347690fbf20b14c1805e1 /ppapi/proxy/ppapi_proxy_test.cc
parentf6a55b8c655441988f72fb61863fbe16d122ce69 (diff)
downloadchromium_src-d57fd38fb40a6bb65af7ab40cacd90c350c0aba1.zip
chromium_src-d57fd38fb40a6bb65af7ab40cacd90c350c0aba1.tar.gz
chromium_src-d57fd38fb40a6bb65af7ab40cacd90c350c0aba1.tar.bz2
Various fixes to make ppapi_unittests pass again.
The following fixes are contained in this patch: -Construction/destruction of ppapi globals has been moved to the thread on which those globals are used (to prevent thread-safety CHECKs firing). -Some tests for the state of the var tracker in the plugin have been moved onto the plugin thread (to prevent thread-safety CHECKs firing). -Fixed a crash in ppp_instance_private_proxy_unittest.cc which was due to not passing a |PPP_Class_Deprecated| to |PPB_Var_Deprecated->CreateObject| which is required when deleting a var on the plugin side. -Set up a |PluginProxyDelegate| in |PluginGlobals| so that a channel to the browser can be correctly obtained for unittests. BUG=none TEST=Ran ppapi_unittests Review URL: https://chromiumcodereview.appspot.com/10913258 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppapi_proxy_test.cc')
-rw-r--r--ppapi/proxy/ppapi_proxy_test.cc50
1 files changed, 44 insertions, 6 deletions
diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc
index eba0aed..be75083 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,18 +146,23 @@ bool ProxyTestHarnessBase::SupportsInterface(const char* name) {
// PluginProxyTestHarness ------------------------------------------------------
-PluginProxyTestHarness::PluginProxyTestHarness()
- : plugin_globals_(PpapiGlobals::ForTest()) {
+PluginProxyTestHarness::PluginProxyTestHarness() {
}
PluginProxyTestHarness::~PluginProxyTestHarness() {
}
+PpapiGlobals* PluginProxyTestHarness::GetGlobals() {
+ return plugin_globals_.get();
+}
+
Dispatcher* PluginProxyTestHarness::GetDispatcher() {
return plugin_dispatcher_.get();
}
void PluginProxyTestHarness::SetUpHarness() {
+ plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest()));
+
// These must be first since the dispatcher set-up uses them.
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
resource_tracker().DidCreateInstance(pp_instance());
@@ -161,6 +172,13 @@ void PluginProxyTestHarness::SetUpHarness() {
false));
plugin_dispatcher_->InitWithTestSink(&sink());
plugin_dispatcher_->DidCreateInstance(pp_instance());
+ // The plugin proxy delegate is needed for
+ // |PluginProxyDelegate::GetBrowserSender| which is used
+ // 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(
@@ -168,6 +186,8 @@ void PluginProxyTestHarness::SetUpHarnessWithChannel(
base::MessageLoopProxy* ipc_message_loop,
base::WaitableEvent* shutdown_event,
bool is_client) {
+ plugin_globals_.reset(new PluginGlobals(PpapiGlobals::ForTest()));
+
// These must be first since the dispatcher set-up uses them.
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
resource_tracker().DidCreateInstance(pp_instance());
@@ -187,6 +207,7 @@ void PluginProxyTestHarness::TearDownHarness() {
plugin_dispatcher_.reset();
resource_tracker().DidDeleteInstance(pp_instance());
+ plugin_globals_.reset();
}
base::MessageLoopProxy*
@@ -230,8 +251,7 @@ bool PluginProxyTestHarness::PluginDelegateMock::SendToBrowser(
}
IPC::Sender* PluginProxyTestHarness::PluginDelegateMock::GetBrowserSender() {
- NOTREACHED();
- return NULL;
+ return browser_sender_;
}
std::string PluginProxyTestHarness::PluginDelegateMock::GetUILanguage() {
@@ -272,18 +292,23 @@ class HostProxyTestHarness::MockSyncMessageStatusReceiver
};
HostProxyTestHarness::HostProxyTestHarness()
- : host_globals_(PpapiGlobals::ForTest()),
- status_receiver_(new MockSyncMessageStatusReceiver) {
+ : status_receiver_(new MockSyncMessageStatusReceiver) {
}
HostProxyTestHarness::~HostProxyTestHarness() {
}
+PpapiGlobals* HostProxyTestHarness::GetGlobals() {
+ return host_globals_.get();
+}
+
Dispatcher* HostProxyTestHarness::GetDispatcher() {
return host_dispatcher_.get();
}
void HostProxyTestHarness::SetUpHarness() {
+ host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest()));
+
// These must be first since the dispatcher set-up uses them.
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
host_dispatcher_.reset(new HostDispatcher(
@@ -299,6 +324,8 @@ void HostProxyTestHarness::SetUpHarnessWithChannel(
base::MessageLoopProxy* ipc_message_loop,
base::WaitableEvent* shutdown_event,
bool is_client) {
+ host_globals_.reset(new ppapi::TestGlobals(PpapiGlobals::ForTest()));
+
// These must be first since the dispatcher set-up uses them.
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
delegate_mock_.Init(ipc_message_loop, shutdown_event);
@@ -316,6 +343,7 @@ void HostProxyTestHarness::SetUpHarnessWithChannel(
void HostProxyTestHarness::TearDownHarness() {
HostDispatcher::RemoveForInstance(pp_instance());
host_dispatcher_.reset();
+ host_globals_.reset();
}
base::MessageLoopProxy*
@@ -415,5 +443,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