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