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

Side by Side Diff: ipc/mojo/ipc_channel_mojo_unittest.cc

Issue 976043003: Fix a couple of ipc_channel_mojo_unittest failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a crbug.com link Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ipc/mojo/ipc_channel_mojo.h" 5 #include "ipc/mojo/ipc_channel_mojo.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 base::MessageLoop::current()->Run(); 425 base::MessageLoop::current()->Run();
426 this->channel()->Close(); 426 this->channel()->Close();
427 427
428 EXPECT_TRUE(WaitForClientShutdown()); 428 EXPECT_TRUE(WaitForClientShutdown());
429 DestroyChannel(); 429 DestroyChannel();
430 } 430 }
431 431
432 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestSendMessagePipeClient) { 432 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestSendMessagePipeClient) {
433 ListenerThatExpectsMessagePipe listener; 433 ListenerThatExpectsMessagePipe listener;
434 ChannelClient client(&listener, "IPCChannelMojoTestSendPlatformHandleClient"); 434 ChannelClient client(&listener, "IPCChannelMojoTestSendMessagePipeClient");
435 client.Connect(); 435 client.Connect();
436 listener.set_sender(client.channel()); 436 listener.set_sender(client.channel());
437 437
438 base::MessageLoop::current()->Run(); 438 base::MessageLoop::current()->Run();
439 439
440 client.Close(); 440 client.Close();
441 441
442 return 0; 442 return 0;
443 } 443 }
444 444
445 #if defined(OS_WIN) 445 #if defined(OS_WIN)
446 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { 446 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase {
447 protected: 447 protected:
448 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( 448 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
449 const IPC::ChannelHandle& handle, 449 const IPC::ChannelHandle& handle,
450 base::TaskRunner* runner) override { 450 base::TaskRunner* runner) override {
451 host_.reset(new IPC::ChannelMojoHost(task_runner())); 451 host_.reset(new IPC::ChannelMojoHost(task_runner()));
452 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), 452 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
453 handle); 453 handle);
454 } 454 }
455 455
456 virtual bool DidStartClient() override { 456 virtual bool DidStartClient() override {
457 IPCTestBase::DidStartClient(); 457 IPCTestBase::DidStartClient();
458 const base::ProcessHandle client = client_process().Handle(); 458 const base::ProcessHandle client = client_process().Handle();
459 // Forces GetFileHandleForProcess() fail. It happens occasionally 459 // Forces GetFileHandleForProcess() fail. It happens occasionally
460 // in production, so we should exercise it somehow. 460 // in production, so we should exercise it somehow.
461 // TODO(morrita): figure out how to safely test this. 461 // TODO(morrita): figure out how to safely test this. See crbug.com/464109.
462 // ::CloseHandle(client); 462 // ::CloseHandle(client);
463 host_->OnClientLaunched(client); 463 host_->OnClientLaunched(client);
464 return true; 464 return true;
465 } 465 }
466 466
467 private: 467 private:
468 scoped_ptr<IPC::ChannelMojoHost> host_; 468 scoped_ptr<IPC::ChannelMojoHost> host_;
469 }; 469 };
470 470
471 TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) { 471 TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) {
472 // Any client type is fine as it is going to be killed anyway. 472 // Any client type is fine as it is going to be killed anyway.
473 InitWithMojo("IPCChannelMojoTestDoNothingClient"); 473 InitWithMojo("IPCChannelMojoTestDoNothingClient");
474 474
475 // Set up IPC channel and start client. 475 // Set up IPC channel and start client.
476 ListenerExpectingErrors listener; 476 ListenerExpectingErrors listener;
477 CreateChannel(&listener); 477 CreateChannel(&listener);
478 ASSERT_TRUE(ConnectChannel()); 478 ASSERT_TRUE(ConnectChannel());
479 479
480 ASSERT_TRUE(StartClient()); 480 ASSERT_TRUE(StartClient());
481 base::MessageLoop::current()->Run(); 481 base::MessageLoop::current()->Run();
482 482
483 this->channel()->Close(); 483 this->channel()->Close();
484 484
485 // WaitForClientShutdown() fails as client_hanadle() is already 485 // TODO(morrita): We need CloseHandle() call in DidStartClient(),
486 // closed. 486 // which has been disabled since crrev.com/843113003, to
487 EXPECT_FALSE(WaitForClientShutdown()); 487 // make this fail. See crbug.com/464109.
488 // EXPECT_FALSE(WaitForClientShutdown());
489 WaitForClientShutdown();
488 EXPECT_TRUE(listener.has_error()); 490 EXPECT_TRUE(listener.has_error());
489 491
490 DestroyChannel(); 492 DestroyChannel();
491 } 493 }
492 494
493 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestDoNothingClient) { 495 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestDoNothingClient) {
494 ListenerThatQuits listener; 496 ListenerThatQuits listener;
495 ChannelClient client(&listener, "IPCChannelMojoTestDoNothingClient"); 497 ChannelClient client(&listener, "IPCChannelMojoTestDoNothingClient");
496 client.Connect(); 498 client.Connect();
497 499
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 base::MessageLoop::current()->Run(); 668 base::MessageLoop::current()->Run();
667 669
668 client.Close(); 670 client.Close();
669 671
670 return 0; 672 return 0;
671 } 673 }
672 674
673 #endif // OS_LINUX 675 #endif // OS_LINUX
674 676
675 } // namespace 677 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698