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

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

Issue 9139054: Revert 117399 - Make it possible to have 1 PpapiGlobals per thread. Update unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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_proxy_test.h ('k') | ppapi/proxy/ppb_var_unittest.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) 2012 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"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 TupleTypes<PpapiMsg_SupportsInterface::ReplyParam>::ValueTuple reply_data; 132 TupleTypes<PpapiMsg_SupportsInterface::ReplyParam>::ValueTuple reply_data;
133 EXPECT_TRUE(PpapiMsg_SupportsInterface::ReadReplyParam( 133 EXPECT_TRUE(PpapiMsg_SupportsInterface::ReadReplyParam(
134 reply_msg, &reply_data)); 134 reply_msg, &reply_data));
135 135
136 sink().ClearMessages(); 136 sink().ClearMessages();
137 return reply_data.a; 137 return reply_data.a;
138 } 138 }
139 139
140 // PluginProxyTestHarness ------------------------------------------------------ 140 // PluginProxyTestHarness ------------------------------------------------------
141 141
142 PluginProxyTestHarness::PluginProxyTestHarness() 142 PluginProxyTestHarness::PluginProxyTestHarness() {
143 : plugin_globals_(PpapiGlobals::ForTest()) {
144 } 143 }
145 144
146 PluginProxyTestHarness::~PluginProxyTestHarness() { 145 PluginProxyTestHarness::~PluginProxyTestHarness() {
147 } 146 }
148 147
149 Dispatcher* PluginProxyTestHarness::GetDispatcher() { 148 Dispatcher* PluginProxyTestHarness::GetDispatcher() {
150 return plugin_dispatcher_.get(); 149 return plugin_dispatcher_.get();
151 } 150 }
152 151
153 void PluginProxyTestHarness::SetUpHarness() { 152 void PluginProxyTestHarness::SetUpHarness() {
154 // These must be first since the dispatcher set-up uses them. 153 // These must be first since the dispatcher set-up uses them.
155 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
156 resource_tracker().DidCreateInstance(pp_instance()); 154 resource_tracker().DidCreateInstance(pp_instance());
157 155
158 plugin_dispatcher_.reset(new PluginDispatcher( 156 plugin_dispatcher_.reset(new PluginDispatcher(
159 base::Process::Current().handle(), 157 base::Process::Current().handle(),
160 &MockGetInterface)); 158 &MockGetInterface));
161 plugin_dispatcher_->InitWithTestSink(&sink()); 159 plugin_dispatcher_->InitWithTestSink(&sink());
162 plugin_dispatcher_->DidCreateInstance(pp_instance()); 160 plugin_dispatcher_->DidCreateInstance(pp_instance());
163 } 161 }
164 162
165 void PluginProxyTestHarness::SetUpHarnessWithChannel( 163 void PluginProxyTestHarness::SetUpHarnessWithChannel(
166 const IPC::ChannelHandle& channel_handle, 164 const IPC::ChannelHandle& channel_handle,
167 base::MessageLoopProxy* ipc_message_loop, 165 base::MessageLoopProxy* ipc_message_loop,
168 base::WaitableEvent* shutdown_event, 166 base::WaitableEvent* shutdown_event,
169 bool is_client) { 167 bool is_client) {
170 // These must be first since the dispatcher set-up uses them. 168 // These must be first since the dispatcher set-up uses them.
171 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
172 resource_tracker().DidCreateInstance(pp_instance()); 169 resource_tracker().DidCreateInstance(pp_instance());
173 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event); 170 plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event);
174 171
175 plugin_dispatcher_.reset(new PluginDispatcher( 172 plugin_dispatcher_.reset(new PluginDispatcher(
176 base::Process::Current().handle(), 173 base::Process::Current().handle(),
177 &MockGetInterface)); 174 &MockGetInterface));
178 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, 175 plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_,
179 channel_handle, 176 channel_handle,
180 is_client); 177 is_client);
181 plugin_dispatcher_->DidCreateInstance(pp_instance()); 178 plugin_dispatcher_->DidCreateInstance(pp_instance());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void PluginProxyTest::SetUp() { 241 void PluginProxyTest::SetUp() {
245 SetUpHarness(); 242 SetUpHarness();
246 } 243 }
247 244
248 void PluginProxyTest::TearDown() { 245 void PluginProxyTest::TearDown() {
249 TearDownHarness(); 246 TearDownHarness();
250 } 247 }
251 248
252 // HostProxyTestHarness -------------------------------------------------------- 249 // HostProxyTestHarness --------------------------------------------------------
253 250
254 HostProxyTestHarness::HostProxyTestHarness() 251 HostProxyTestHarness::HostProxyTestHarness() {
255 : host_globals_(PpapiGlobals::ForTest()) {
256 } 252 }
257 253
258 HostProxyTestHarness::~HostProxyTestHarness() { 254 HostProxyTestHarness::~HostProxyTestHarness() {
259 } 255 }
260 256
261 Dispatcher* HostProxyTestHarness::GetDispatcher() { 257 Dispatcher* HostProxyTestHarness::GetDispatcher() {
262 return host_dispatcher_.get(); 258 return host_dispatcher_.get();
263 } 259 }
264 260
265 void HostProxyTestHarness::SetUpHarness() { 261 void HostProxyTestHarness::SetUpHarness() {
266 // These must be first since the dispatcher set-up uses them.
267 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
268 host_dispatcher_.reset(new HostDispatcher( 262 host_dispatcher_.reset(new HostDispatcher(
269 base::Process::Current().handle(), 263 base::Process::Current().handle(),
270 pp_module(), 264 pp_module(),
271 &MockGetInterface)); 265 &MockGetInterface));
272 host_dispatcher_->InitWithTestSink(&sink()); 266 host_dispatcher_->InitWithTestSink(&sink());
273 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); 267 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get());
274 } 268 }
275 269
276 void HostProxyTestHarness::SetUpHarnessWithChannel( 270 void HostProxyTestHarness::SetUpHarnessWithChannel(
277 const IPC::ChannelHandle& channel_handle, 271 const IPC::ChannelHandle& channel_handle,
278 base::MessageLoopProxy* ipc_message_loop, 272 base::MessageLoopProxy* ipc_message_loop,
279 base::WaitableEvent* shutdown_event, 273 base::WaitableEvent* shutdown_event,
280 bool is_client) { 274 bool is_client) {
281 // These must be first since the dispatcher set-up uses them.
282 PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
283 delegate_mock_.Init(ipc_message_loop, shutdown_event); 275 delegate_mock_.Init(ipc_message_loop, shutdown_event);
284
285 host_dispatcher_.reset(new HostDispatcher( 276 host_dispatcher_.reset(new HostDispatcher(
286 base::Process::Current().handle(), 277 base::Process::Current().handle(),
287 pp_module(), 278 pp_module(),
288 &MockGetInterface)); 279 &MockGetInterface));
289 ppapi::Preferences preferences; 280 ppapi::Preferences preferences;
290 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle, 281 host_dispatcher_->InitHostWithChannel(&delegate_mock_, channel_handle,
291 is_client, preferences); 282 is_client, preferences);
292 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); 283 HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get());
293 } 284 }
294 285
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 338 }
348 339
349 void TwoWayTest::SetUp() { 340 void TwoWayTest::SetUp() {
350 base::Thread::Options options; 341 base::Thread::Options options;
351 options.message_loop_type = MessageLoop::TYPE_IO; 342 options.message_loop_type = MessageLoop::TYPE_IO;
352 io_thread_.StartWithOptions(options); 343 io_thread_.StartWithOptions(options);
353 plugin_thread_.Start(); 344 plugin_thread_.Start();
354 345
355 IPC::ChannelHandle handle; 346 IPC::ChannelHandle handle;
356 handle.name = "TwoWayTestChannel"; 347 handle.name = "TwoWayTestChannel";
348
357 base::WaitableEvent remote_harness_set_up(true, false); 349 base::WaitableEvent remote_harness_set_up(true, false);
358 plugin_thread_.message_loop_proxy()->PostTask( 350 plugin_thread_.message_loop_proxy()->PostTask(
359 FROM_HERE, 351 FROM_HERE,
360 base::Bind(&SetUpRemoteHarness, 352 base::Bind(&SetUpRemoteHarness,
361 remote_harness_, 353 remote_harness_,
362 handle, 354 handle,
363 io_thread_.message_loop_proxy(), 355 io_thread_.message_loop_proxy(),
364 &shutdown_event_, 356 &shutdown_event_,
365 &remote_harness_set_up)); 357 &remote_harness_set_up));
366 remote_harness_set_up.Wait(); 358 remote_harness_set_up.Wait();
(...skipping 13 matching lines...) Expand all
380 remote_harness_torn_down.Wait(); 372 remote_harness_torn_down.Wait();
381 373
382 local_harness_->TearDownHarness(); 374 local_harness_->TearDownHarness();
383 375
384 io_thread_.Stop(); 376 io_thread_.Stop();
385 } 377 }
386 378
387 379
388 } // namespace proxy 380 } // namespace proxy
389 } // namespace ppapi 381 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_proxy_test.h ('k') | ppapi/proxy/ppb_var_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698