summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppapi_proxy_test.h
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.h
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.h')
-rw-r--r--ppapi/proxy/ppapi_proxy_test.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h
index 9c76b84..667a60f 100644
--- a/ppapi/proxy/ppapi_proxy_test.h
+++ b/ppapi/proxy/ppapi_proxy_test.h
@@ -83,14 +83,14 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); }
PluginResourceTracker& resource_tracker() {
- return *plugin_globals_.plugin_resource_tracker();
+ return *plugin_globals_->plugin_resource_tracker();
}
PluginVarTracker& var_tracker() {
- return *plugin_globals_.plugin_var_tracker();
+ return *plugin_globals_->plugin_var_tracker();
}
// ProxyTestHarnessBase implementation.
- virtual PpapiGlobals* GetGlobals() { return &plugin_globals_; }
+ virtual PpapiGlobals* GetGlobals();
virtual Dispatcher* GetDispatcher();
virtual void SetUpHarness();
virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
@@ -111,6 +111,10 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
shutdown_event_ = shutdown_event;
}
+ void set_browser_sender(IPC::Sender* browser_sender) {
+ browser_sender_ = browser_sender;
+ }
+
// ProxyChannel::Delegate implementation.
virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE;
virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE;
@@ -124,7 +128,7 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
virtual uint32 Register(PluginDispatcher* plugin_dispatcher) OVERRIDE;
virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;
- // PluginPepperDelegate implementation.
+ // PluginProxyDelegate implementation.
virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE;
virtual IPC::Sender* GetBrowserSender() OVERRIDE;
virtual std::string GetUILanguage() OVERRIDE;
@@ -135,12 +139,13 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
base::MessageLoopProxy* ipc_message_loop_; // Weak
base::WaitableEvent* shutdown_event_; // Weak
std::set<PP_Instance> instance_id_set_;
+ IPC::Sender* browser_sender_;
DISALLOW_COPY_AND_ASSIGN(PluginDelegateMock);
};
private:
- PluginGlobals plugin_globals_;
+ scoped_ptr<PluginGlobals> plugin_globals_;
scoped_ptr<PluginDispatcher> plugin_dispatcher_;
PluginDelegateMock plugin_delegate_mock_;
@@ -165,14 +170,14 @@ class HostProxyTestHarness : public ProxyTestHarnessBase {
HostDispatcher* host_dispatcher() { return host_dispatcher_.get(); }
ResourceTracker& resource_tracker() {
- return *host_globals_.GetResourceTracker();
+ return *host_globals_->GetResourceTracker();
}
VarTracker& var_tracker() {
- return *host_globals_.GetVarTracker();
+ return *host_globals_->GetVarTracker();
}
// ProxyTestBase implementation.
- virtual PpapiGlobals* GetGlobals() { return &host_globals_; }
+ virtual PpapiGlobals* GetGlobals();
virtual Dispatcher* GetDispatcher();
virtual void SetUpHarness();
virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
@@ -211,7 +216,7 @@ class HostProxyTestHarness : public ProxyTestHarnessBase {
private:
class MockSyncMessageStatusReceiver;
- ppapi::TestGlobals host_globals_;
+ scoped_ptr<ppapi::TestGlobals> host_globals_;
scoped_ptr<HostDispatcher> host_dispatcher_;
DelegateMock delegate_mock_;
@@ -250,6 +255,12 @@ class TwoWayTest : public testing::Test {
virtual void SetUp();
virtual void TearDown();
+ protected:
+ // Post a task to the thread where the remote harness lives. This
+ // is typically used to test the state of the var tracker on the plugin
+ // thread. This runs the task synchronously for convenience.
+ void PostTaskOnRemoteHarness(const base::Closure& task);
+
private:
TwoWayTestMode test_mode_;
HostProxyTestHarness host_;