| OLD | NEW |
| 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> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "ipc/ipc_test_sink.h" | 12 #include "ipc/ipc_test_sink.h" |
| 13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/proxy/host_dispatcher.h" | 14 #include "ppapi/proxy/host_dispatcher.h" |
| 15 #include "ppapi/proxy/plugin_dispatcher.h" | 15 #include "ppapi/proxy/plugin_dispatcher.h" |
| 16 #include "ppapi/proxy/plugin_globals.h" | |
| 17 #include "ppapi/proxy/plugin_resource_tracker.h" | 16 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 18 #include "ppapi/proxy/plugin_var_tracker.h" | 17 #include "ppapi/proxy/plugin_var_tracker.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 namespace ppapi { | 20 namespace ppapi { |
| 22 namespace proxy { | 21 namespace proxy { |
| 23 | 22 |
| 24 // Base class for plugin and host test harnesses. Tests will not use this | 23 // Base class for plugin and host test harnesses. Tests will not use this |
| 25 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest. | 24 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest. |
| 26 class ProxyTestHarnessBase { | 25 class ProxyTestHarnessBase { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 std::map<std::string, const void*> registered_interfaces_; | 71 std::map<std::string, const void*> registered_interfaces_; |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 // Test harness for the plugin side of the proxy. | 74 // Test harness for the plugin side of the proxy. |
| 76 class PluginProxyTestHarness : public ProxyTestHarnessBase { | 75 class PluginProxyTestHarness : public ProxyTestHarnessBase { |
| 77 public: | 76 public: |
| 78 PluginProxyTestHarness(); | 77 PluginProxyTestHarness(); |
| 79 virtual ~PluginProxyTestHarness(); | 78 virtual ~PluginProxyTestHarness(); |
| 80 | 79 |
| 81 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); } | 80 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); } |
| 82 PluginResourceTracker& resource_tracker() { | 81 PluginResourceTracker& resource_tracker() { return resource_tracker_; } |
| 83 return *plugin_globals_.plugin_resource_tracker(); | 82 PluginVarTracker& var_tracker() { return var_tracker_; } |
| 84 } | |
| 85 PluginVarTracker& var_tracker() { | |
| 86 return *plugin_globals_.plugin_var_tracker(); | |
| 87 } | |
| 88 | 83 |
| 89 // ProxyTestHarnessBase implementation. | 84 // ProxyTestHarnessBase implementation. |
| 90 virtual Dispatcher* GetDispatcher(); | 85 virtual Dispatcher* GetDispatcher(); |
| 91 virtual void SetUpHarness(); | 86 virtual void SetUpHarness(); |
| 92 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, | 87 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, |
| 93 base::MessageLoopProxy* ipc_message_loop, | 88 base::MessageLoopProxy* ipc_message_loop, |
| 94 base::WaitableEvent* shutdown_event, | 89 base::WaitableEvent* shutdown_event, |
| 95 bool is_client); | 90 bool is_client); |
| 96 virtual void TearDownHarness(); | 91 virtual void TearDownHarness(); |
| 97 | 92 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 121 | 116 |
| 122 private: | 117 private: |
| 123 base::MessageLoopProxy* ipc_message_loop_; // Weak | 118 base::MessageLoopProxy* ipc_message_loop_; // Weak |
| 124 base::WaitableEvent* shutdown_event_; // Weak | 119 base::WaitableEvent* shutdown_event_; // Weak |
| 125 std::set<PP_Instance> instance_id_set_; | 120 std::set<PP_Instance> instance_id_set_; |
| 126 | 121 |
| 127 DISALLOW_COPY_AND_ASSIGN(PluginDelegateMock); | 122 DISALLOW_COPY_AND_ASSIGN(PluginDelegateMock); |
| 128 }; | 123 }; |
| 129 | 124 |
| 130 private: | 125 private: |
| 131 PluginGlobals plugin_globals_; | 126 PluginResourceTracker resource_tracker_; |
| 132 | 127 PluginVarTracker var_tracker_; |
| 133 scoped_ptr<PluginDispatcher> plugin_dispatcher_; | 128 scoped_ptr<PluginDispatcher> plugin_dispatcher_; |
| 134 PluginDelegateMock plugin_delegate_mock_; | 129 PluginDelegateMock plugin_delegate_mock_; |
| 135 }; | 130 }; |
| 136 | 131 |
| 137 class PluginProxyTest : public PluginProxyTestHarness, public testing::Test { | 132 class PluginProxyTest : public PluginProxyTestHarness, public testing::Test { |
| 138 public: | 133 public: |
| 139 PluginProxyTest(); | 134 PluginProxyTest(); |
| 140 virtual ~PluginProxyTest(); | 135 virtual ~PluginProxyTest(); |
| 141 | 136 |
| 142 // testing::Test implementation. | 137 // testing::Test implementation. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // stopping the harnesses. | 234 // stopping the harnesses. |
| 240 ProxyTestHarnessBase* remote_harness_; | 235 ProxyTestHarnessBase* remote_harness_; |
| 241 ProxyTestHarnessBase* local_harness_; | 236 ProxyTestHarnessBase* local_harness_; |
| 242 | 237 |
| 243 base::WaitableEvent channel_created_; | 238 base::WaitableEvent channel_created_; |
| 244 base::WaitableEvent shutdown_event_; | 239 base::WaitableEvent shutdown_event_; |
| 245 }; | 240 }; |
| 246 | 241 |
| 247 } // namespace proxy | 242 } // namespace proxy |
| 248 } // namespace ppapi | 243 } // namespace ppapi |
| OLD | NEW |