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 "ppapi/proxy/ppapi_proxy_test.h" | 5 #include "ppapi/proxy/ppapi_proxy_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ipc/ipc_sync_channel.h" | 10 #include "ipc/ipc_sync_channel.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 PluginProxyTestHarness::~PluginProxyTestHarness() { | 145 PluginProxyTestHarness::~PluginProxyTestHarness() { |
146 } | 146 } |
147 | 147 |
148 Dispatcher* PluginProxyTestHarness::GetDispatcher() { | 148 Dispatcher* PluginProxyTestHarness::GetDispatcher() { |
149 return plugin_dispatcher_.get(); | 149 return plugin_dispatcher_.get(); |
150 } | 150 } |
151 | 151 |
152 void PluginProxyTestHarness::SetUpHarness() { | 152 void PluginProxyTestHarness::SetUpHarness() { |
153 // These must be first since the dispatcher set-up uses them. | 153 // These must be first since the dispatcher set-up uses them. |
154 resource_tracker().DidCreateInstance(pp_instance()); | 154 resource_tracker_.DidCreateInstance(pp_instance()); |
| 155 PluginResourceTracker::SetInstanceForTest(&resource_tracker_); |
| 156 resource_tracker_.set_var_tracker_test_override(&var_tracker_); |
155 | 157 |
156 plugin_dispatcher_.reset(new PluginDispatcher( | 158 plugin_dispatcher_.reset(new PluginDispatcher( |
157 base::Process::Current().handle(), | 159 base::Process::Current().handle(), |
158 &MockGetInterface)); | 160 &MockGetInterface)); |
159 plugin_dispatcher_->InitWithTestSink(&sink()); | 161 plugin_dispatcher_->InitWithTestSink(&sink()); |
160 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 162 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
161 } | 163 } |
162 | 164 |
163 void PluginProxyTestHarness::SetUpHarnessWithChannel( | 165 void PluginProxyTestHarness::SetUpHarnessWithChannel( |
164 const IPC::ChannelHandle& channel_handle, | 166 const IPC::ChannelHandle& channel_handle, |
165 base::MessageLoopProxy* ipc_message_loop, | 167 base::MessageLoopProxy* ipc_message_loop, |
166 base::WaitableEvent* shutdown_event, | 168 base::WaitableEvent* shutdown_event, |
167 bool is_client) { | 169 bool is_client) { |
168 // These must be first since the dispatcher set-up uses them. | 170 // These must be first since the dispatcher set-up uses them. |
169 resource_tracker().DidCreateInstance(pp_instance()); | 171 resource_tracker_.DidCreateInstance(pp_instance()); |
| 172 PluginResourceTracker::SetInstanceForTest(&resource_tracker_); |
| 173 resource_tracker_.set_var_tracker_test_override(&var_tracker_); |
170 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); | 174 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); |
171 | 175 |
172 plugin_dispatcher_.reset(new PluginDispatcher( | 176 plugin_dispatcher_.reset(new PluginDispatcher( |
173 base::Process::Current().handle(), | 177 base::Process::Current().handle(), |
174 &MockGetInterface)); | 178 &MockGetInterface)); |
175 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, | 179 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, |
176 channel_handle, | 180 channel_handle, |
177 is_client); | 181 is_client); |
178 plugin_dispatcher_->DidCreateInstance(pp_instance()); | 182 plugin_dispatcher_->DidCreateInstance(pp_instance()); |
179 } | 183 } |
180 | 184 |
181 void PluginProxyTestHarness::TearDownHarness() { | 185 void PluginProxyTestHarness::TearDownHarness() { |
182 plugin_dispatcher_->DidDestroyInstance(pp_instance()); | 186 plugin_dispatcher_->DidDestroyInstance(pp_instance()); |
183 plugin_dispatcher_.reset(); | 187 plugin_dispatcher_.reset(); |
184 | 188 |
185 resource_tracker().DidDeleteInstance(pp_instance()); | 189 resource_tracker_.DidDeleteInstance(pp_instance()); |
| 190 PluginResourceTracker::SetInstanceForTest(NULL); |
186 } | 191 } |
187 | 192 |
188 base::MessageLoopProxy* | 193 base::MessageLoopProxy* |
189 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { | 194 PluginProxyTestHarness::PluginDelegateMock::GetIPCMessageLoop() { |
190 return ipc_message_loop_; | 195 return ipc_message_loop_; |
191 } | 196 } |
192 | 197 |
193 base::WaitableEvent* | 198 base::WaitableEvent* |
194 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { | 199 PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() { |
195 return shutdown_event_; | 200 return shutdown_event_; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 remote_harness_torn_down.Wait(); | 373 remote_harness_torn_down.Wait(); |
369 | 374 |
370 local_harness_->TearDownHarness(); | 375 local_harness_->TearDownHarness(); |
371 | 376 |
372 io_thread_.Stop(); | 377 io_thread_.Stop(); |
373 } | 378 } |
374 | 379 |
375 | 380 |
376 } // namespace proxy | 381 } // namespace proxy |
377 } // namespace ppapi | 382 } // namespace ppapi |
OLD | NEW |