Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: ppapi/proxy/ppapi_proxy_test.h

Issue 6286070: Remove all uses of the global Dispatcher Get function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppapi_messages_internal.h ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map>
6 #include <string>
7
5 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
6 #include "ipc/ipc_test_sink.h" 9 #include "ipc/ipc_test_sink.h"
7 #include "ppapi/c/pp_instance.h" 10 #include "ppapi/c/pp_instance.h"
11 #include "ppapi/proxy/host_dispatcher.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 12 #include "ppapi/proxy/plugin_dispatcher.h"
9 #include "ppapi/proxy/plugin_resource_tracker.h" 13 #include "ppapi/proxy/plugin_resource_tracker.h"
10 #include "ppapi/proxy/plugin_var_tracker.h" 14 #include "ppapi/proxy/plugin_var_tracker.h"
11 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
12 16
13 namespace pp { 17 namespace pp {
14 namespace proxy { 18 namespace proxy {
15 19
20 // Base class for plugin and host tests. Tests will not use this directly.
21 // Instead, use the Plugin or HostProxyTest.
22 class ProxyTestBase : public testing::Test {
23 public:
24 ProxyTestBase();
25 virtual ~ProxyTestBase();
26
27 PP_Module pp_module() const { return pp_module_; }
28 PP_Instance pp_instance() const { return pp_instance_; }
29 IPC::TestSink& sink() { return sink_; }
30
31 // Returns either the plugin or host dispatcher, depending on the test.
32 virtual Dispatcher* GetDispatcher() = 0;
33
34 // Implementation of GetInterface for the dispatcher. This will
35 // return NULL for all interfaces unless one is registered by calling
36 // RegisterTestInterface();
37 const void* GetInterface(const char* name);
38
39 // Allows the test to specify an interface implementation for a given
40 // interface name. This will be returned when any of the proxy logic
41 // requests a local interface.
42 void RegisterTestInterface(const char* name, const void* interface);
43
44 // Sends a "supports interface" message to the current dispatcher and returns
45 // true if it's supported. This is just for the convenience of tests.
46 bool SupportsInterface(const char* name);
47
48 private:
49 // Destination for IPC messages sent by the test.
50 IPC::TestSink sink_;
51
52 // The module and instance ID associated with the plugin dispatcher.
53 PP_Module pp_module_;
54 PP_Instance pp_instance_;
55
56 // Stores the data for GetInterface/RegisterTestInterface.
57 std::map<std::string, const void*> registered_interfaces_;
58 };
59
16 // Test harness for the plugin side of the proxy. 60 // Test harness for the plugin side of the proxy.
17 class PluginProxyTest : public testing::Test { 61 class PluginProxyTest : public ProxyTestBase {
18 public: 62 public:
19 PluginProxyTest(); 63 PluginProxyTest();
20 ~PluginProxyTest(); 64 virtual ~PluginProxyTest();
21
22 virtual void SetUp();
23 virtual void TearDown();
24
25 // The instance ID associated with the plugin dispatcher.
26 PP_Instance pp_instance() const { return pp_instance_; }
27 65
28 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); } 66 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); }
29
30 PluginResourceTracker& resource_tracker() { return resource_tracker_; } 67 PluginResourceTracker& resource_tracker() { return resource_tracker_; }
31 PluginVarTracker& var_tracker() { return var_tracker_; } 68 PluginVarTracker& var_tracker() { return var_tracker_; }
32 69
33 IPC::TestSink& sink() { return sink_; } 70 // ProxyTestBase implementation.
71 virtual Dispatcher* GetDispatcher();
72
73 // testing::Test implementation.
74 virtual void SetUp();
75 virtual void TearDown();
34 76
35 private: 77 private:
36 PluginResourceTracker resource_tracker_; 78 PluginResourceTracker resource_tracker_;
37 PluginVarTracker var_tracker_; 79 PluginVarTracker var_tracker_;
80 scoped_ptr<PluginDispatcher> plugin_dispatcher_;
81 };
38 82
39 PP_Instance pp_instance_; 83 class HostProxyTest : public ProxyTestBase {
40 scoped_ptr<PluginDispatcher> plugin_dispatcher_; 84 public:
85 HostProxyTest();
86 virtual ~HostProxyTest();
41 87
42 IPC::TestSink sink_; 88 HostDispatcher* host_dispatcher() { return host_dispatcher_.get(); }
89
90 // ProxyTestBase implementation.
91 virtual Dispatcher* GetDispatcher();
92
93 // testing::Test implementation.
94 virtual void SetUp();
95 virtual void TearDown();
96
97 private:
98 scoped_ptr<HostDispatcher> host_dispatcher_;
43 }; 99 };
44 100
45 } // namespace proxy 101 } // namespace proxy
46 } // namespace pp 102 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_messages_internal.h ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698