summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppapi_proxy_test.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 16:31:46 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 16:31:46 +0000
commit465faa29046328890a224677db522f1aece8cad0 (patch)
tree5cf23803cc13d27c71c05c4532a5fc434e6d7e4d /ppapi/proxy/ppapi_proxy_test.h
parenta313e51c562c3d3400d2bd14231f23e9ca699857 (diff)
downloadchromium_src-465faa29046328890a224677db522f1aece8cad0.zip
chromium_src-465faa29046328890a224677db522f1aece8cad0.tar.gz
chromium_src-465faa29046328890a224677db522f1aece8cad0.tar.bz2
Rent syncemove all uses of the global Dispatcher Get function.
This reqired reworking how plugin->host GetInterface works. Previously, interface requests were symmetric where each side would first do a SupportsInterface to see if the remote side supports the interface, then create the proxy. Since the plugin may talk to multiple renderers, we don't know where to send these requests. The solution is to make the assumption that the renderer always supports all PPB interfaces (which is possible since the proxy is compiled with the executable). This also adds some better lookup for interfaces to avoid having multiple lists of interfaces. We now have a list of interfaces and factory functions in dispatcher.cc. Add some additional testing infrastructure for the dispatchers with simple tests. Review URL: http://codereview.chromium.org/6286070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74121 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppapi_proxy_test.h')
-rw-r--r--ppapi/proxy/ppapi_proxy_test.h82
1 files changed, 69 insertions, 13 deletions
diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h
index a811080..d3c867a 100644
--- a/ppapi/proxy/ppapi_proxy_test.h
+++ b/ppapi/proxy/ppapi_proxy_test.h
@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <map>
+#include <string>
+
#include "base/scoped_ptr.h"
#include "ipc/ipc_test_sink.h"
#include "ppapi/c/pp_instance.h"
+#include "ppapi/proxy/host_dispatcher.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "ppapi/proxy/plugin_var_tracker.h"
@@ -13,33 +17,85 @@
namespace pp {
namespace proxy {
-// Test harness for the plugin side of the proxy.
-class PluginProxyTest : public testing::Test {
+// Base class for plugin and host tests. Tests will not use this directly.
+// Instead, use the Plugin or HostProxyTest.
+class ProxyTestBase : public testing::Test {
public:
- PluginProxyTest();
- ~PluginProxyTest();
-
- virtual void SetUp();
- virtual void TearDown();
+ ProxyTestBase();
+ virtual ~ProxyTestBase();
- // The instance ID associated with the plugin dispatcher.
+ PP_Module pp_module() const { return pp_module_; }
PP_Instance pp_instance() const { return pp_instance_; }
+ IPC::TestSink& sink() { return sink_; }
- PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); }
+ // Returns either the plugin or host dispatcher, depending on the test.
+ virtual Dispatcher* GetDispatcher() = 0;
+
+ // Implementation of GetInterface for the dispatcher. This will
+ // return NULL for all interfaces unless one is registered by calling
+ // RegisterTestInterface();
+ const void* GetInterface(const char* name);
+
+ // Allows the test to specify an interface implementation for a given
+ // interface name. This will be returned when any of the proxy logic
+ // requests a local interface.
+ void RegisterTestInterface(const char* name, const void* interface);
+ // Sends a "supports interface" message to the current dispatcher and returns
+ // true if it's supported. This is just for the convenience of tests.
+ bool SupportsInterface(const char* name);
+
+ private:
+ // Destination for IPC messages sent by the test.
+ IPC::TestSink sink_;
+
+ // The module and instance ID associated with the plugin dispatcher.
+ PP_Module pp_module_;
+ PP_Instance pp_instance_;
+
+ // Stores the data for GetInterface/RegisterTestInterface.
+ std::map<std::string, const void*> registered_interfaces_;
+};
+
+// Test harness for the plugin side of the proxy.
+class PluginProxyTest : public ProxyTestBase {
+ public:
+ PluginProxyTest();
+ virtual ~PluginProxyTest();
+
+ PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); }
PluginResourceTracker& resource_tracker() { return resource_tracker_; }
PluginVarTracker& var_tracker() { return var_tracker_; }
- IPC::TestSink& sink() { return sink_; }
+ // ProxyTestBase implementation.
+ virtual Dispatcher* GetDispatcher();
+
+ // testing::Test implementation.
+ virtual void SetUp();
+ virtual void TearDown();
private:
PluginResourceTracker resource_tracker_;
PluginVarTracker var_tracker_;
-
- PP_Instance pp_instance_;
scoped_ptr<PluginDispatcher> plugin_dispatcher_;
+};
- IPC::TestSink sink_;
+class HostProxyTest : public ProxyTestBase {
+ public:
+ HostProxyTest();
+ virtual ~HostProxyTest();
+
+ HostDispatcher* host_dispatcher() { return host_dispatcher_.get(); }
+
+ // ProxyTestBase implementation.
+ virtual Dispatcher* GetDispatcher();
+
+ // testing::Test implementation.
+ virtual void SetUp();
+ virtual void TearDown();
+
+ private:
+ scoped_ptr<HostDispatcher> host_dispatcher_;
};
} // namespace proxy