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

Side by Side Diff: chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc

Issue 310853003: Add IPC::ChannelProxy::Create() and IPC::SyncChannel::Create() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landing Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Create a service process that uses a Mock to respond to the browser in order 5 // Create a service process that uses a Mock to respond to the browser in order
6 // to test launching the browser using the cloud print policy check command 6 // to test launching the browser using the cloud print policy check command
7 // line switch. 7 // line switch.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // Connect up the parent/child IPC channel to signal that the test can 260 // Connect up the parent/child IPC channel to signal that the test can
261 // continue. 261 // continue.
262 TestStartupClientChannelListener listener; 262 TestStartupClientChannelListener listener;
263 EXPECT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( 263 EXPECT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
264 switches::kProcessChannelID)); 264 switches::kProcessChannelID));
265 std::string startup_channel_name = 265 std::string startup_channel_name =
266 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 266 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
267 switches::kProcessChannelID); 267 switches::kProcessChannelID);
268 scoped_ptr<IPC::ChannelProxy> startup_channel; 268 scoped_ptr<IPC::ChannelProxy> startup_channel;
269 startup_channel.reset( 269 startup_channel =
270 new IPC::ChannelProxy(startup_channel_name, 270 IPC::ChannelProxy::Create(startup_channel_name,
271 IPC::Channel::MODE_CLIENT, 271 IPC::Channel::MODE_CLIENT,
272 &listener, 272 &listener,
273 service_process.IOMessageLoopProxy())); 273 service_process.IOMessageLoopProxy());
274 274
275 main_message_loop.Run(); 275 main_message_loop.Run();
276 if (!Mock::VerifyAndClearExpectations(&server)) 276 if (!Mock::VerifyAndClearExpectations(&server))
277 return kExpectationsNotMet; 277 return kExpectationsNotMet;
278 if (!g_good_shutdown) 278 if (!g_good_shutdown)
279 return kShutdownNotGood; 279 return kShutdownNotGood;
280 return 0; 280 return 0;
281 } 281 }
282 282
283 void SetServiceEnabledExpectations(MockServiceIPCServer* server) { 283 void SetServiceEnabledExpectations(MockServiceIPCServer* server) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 436
437 base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch( 437 base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch(
438 const std::string& name) { 438 const std::string& name) {
439 EXPECT_FALSE(CheckServiceProcessReady()); 439 EXPECT_FALSE(CheckServiceProcessReady());
440 440
441 startup_channel_id_ = 441 startup_channel_id_ =
442 base::StringPrintf("%d.%p.%d", 442 base::StringPrintf("%d.%p.%d",
443 base::GetCurrentProcId(), this, 443 base::GetCurrentProcId(), this,
444 base::RandInt(0, std::numeric_limits<int>::max())); 444 base::RandInt(0, std::numeric_limits<int>::max()));
445 startup_channel_.reset(new IPC::ChannelProxy( 445 startup_channel_ = IPC::ChannelProxy::Create(startup_channel_id_,
446 startup_channel_id_, IPC::Channel::MODE_SERVER, 446 IPC::Channel::MODE_SERVER,
447 this, IOMessageLoopProxy())); 447 this,
448 IOMessageLoopProxy());
448 449
449 #if defined(OS_POSIX) 450 #if defined(OS_POSIX)
450 base::FileHandleMappingVector ipc_file_list; 451 base::FileHandleMappingVector ipc_file_list;
451 ipc_file_list.push_back(std::make_pair( 452 ipc_file_list.push_back(std::make_pair(
452 startup_channel_->TakeClientFileDescriptor(), 453 startup_channel_->TakeClientFileDescriptor(),
453 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); 454 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
454 base::LaunchOptions options; 455 base::LaunchOptions options;
455 options.fds_to_remap = &ipc_file_list; 456 options.fds_to_remap = &ipc_file_list;
456 base::ProcessHandle handle = SpawnChildWithOptions(name, options); 457 base::ProcessHandle handle = SpawnChildWithOptions(name, options);
457 #else 458 #else
458 base::ProcessHandle handle = SpawnChild(name); 459 base::ProcessHandle handle = SpawnChild(name);
459 #endif 460 #endif
460 EXPECT_TRUE(handle); 461 EXPECT_TRUE(handle);
461 return handle; 462 return handle;
462 } 463 }
463 464
464 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { 465 void CloudPrintProxyPolicyStartupTest::WaitForConnect() {
465 observer_.Wait(); 466 observer_.Wait();
466 EXPECT_TRUE(CheckServiceProcessReady()); 467 EXPECT_TRUE(CheckServiceProcessReady());
467 EXPECT_TRUE(base::MessageLoopProxy::current().get()); 468 EXPECT_TRUE(base::MessageLoopProxy::current().get());
468 ServiceProcessControl::GetInstance()->SetChannel( 469 ServiceProcessControl::GetInstance()->SetChannel(
469 new IPC::ChannelProxy(GetServiceProcessChannel(), 470 IPC::ChannelProxy::Create(GetServiceProcessChannel(),
470 IPC::Channel::MODE_NAMED_CLIENT, 471 IPC::Channel::MODE_NAMED_CLIENT,
471 ServiceProcessControl::GetInstance(), 472 ServiceProcessControl::GetInstance(),
472 IOMessageLoopProxy())); 473 IOMessageLoopProxy()));
473 } 474 }
474 475
475 bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) { 476 bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) {
476 return ServiceProcessControl::GetInstance()->Send(message); 477 return ServiceProcessControl::GetInstance()->Send(message);
477 } 478 }
478 479
479 void CloudPrintProxyPolicyStartupTest::ShutdownAndWaitForExitWithTimeout( 480 void CloudPrintProxyPolicyStartupTest::ShutdownAndWaitForExitWithTimeout(
480 base::ProcessHandle handle) { 481 base::ProcessHandle handle) {
481 ASSERT_TRUE(Send(new ServiceMsg_Shutdown())); 482 ASSERT_TRUE(Send(new ServiceMsg_Shutdown()));
482 483
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // condition. 623 // condition.
623 if (should_run_loop) 624 if (should_run_loop)
624 run_loop.Run(); 625 run_loop.Run();
625 626
626 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); 627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail));
627 628
628 ShutdownAndWaitForExitWithTimeout(handle); 629 ShutdownAndWaitForExitWithTimeout(handle);
629 content::RunAllPendingInMessageLoop(); 630 content::RunAllPendingInMessageLoop();
630 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); 631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy");
631 } 632 }
OLDNEW
« no previous file with comments | « apps/app_shim/chrome_main_app_mode_mac.mm ('k') | chrome/browser/service_process/service_process_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698