| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 is_connected_called_ = true; | 143 is_connected_called_ = true; |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool is_connected_called() const { return is_connected_called_; } | 146 bool is_connected_called() const { return is_connected_called_; } |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 bool is_connected_called_; | 149 bool is_connected_called_; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 // Times out on Android; see http://crbug.com/502290 | 152 // Times out on Android; see http://crbug.com/502290 |
| 153 #if defined(OS_ANDROID) | 153 // Times out on Linux. crbug.com/585784 |
| 154 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 154 #define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient | 155 #define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient |
| 155 #else | 156 #else |
| 156 #define MAYBE_ConnectedFromClient ConnectedFromClient | 157 #define MAYBE_ConnectedFromClient ConnectedFromClient |
| 157 #endif | 158 #endif |
| 158 TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) { | 159 TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) { |
| 159 InitWithMojo("IPCChannelMojoTestClient"); | 160 InitWithMojo("IPCChannelMojoTestClient"); |
| 160 | 161 |
| 161 // Set up IPC channel and start client. | 162 // Set up IPC channel and start client. |
| 162 TestChannelListenerWithExtraExpectations listener; | 163 TestChannelListenerWithExtraExpectations listener; |
| 163 CreateChannel(&listener); | 164 CreateChannel(&listener); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 client.Connect(); | 259 client.Connect(); |
| 259 | 260 |
| 260 base::MessageLoop::current()->Run(); | 261 base::MessageLoop::current()->Run(); |
| 261 | 262 |
| 262 client.Close(); | 263 client.Close(); |
| 263 | 264 |
| 264 return 0; | 265 return 0; |
| 265 } | 266 } |
| 266 | 267 |
| 267 // Times out on Android; see http://crbug.com/502290 | 268 // Times out on Android; see http://crbug.com/502290 |
| 268 #if defined(OS_ANDROID) | 269 // Times out on Linux. crbug.com/585784 |
| 270 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 269 #define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages | 271 #define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages |
| 270 #else | 272 #else |
| 271 #define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages | 273 #define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages |
| 272 #endif | 274 #endif |
| 273 TEST_F(IPCChannelMojoErrorTest, MAYBE_SendFailWithPendingMessages) { | 275 TEST_F(IPCChannelMojoErrorTest, MAYBE_SendFailWithPendingMessages) { |
| 274 InitWithMojo("IPCChannelMojoErraticTestClient"); | 276 InitWithMojo("IPCChannelMojoErraticTestClient"); |
| 275 | 277 |
| 276 // Set up IPC channel and start client. | 278 // Set up IPC channel and start client. |
| 277 ListenerExpectingErrors listener; | 279 ListenerExpectingErrors listener; |
| 278 CreateChannel(&listener); | 280 CreateChannel(&listener); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 407 |
| 406 void OnChannelError() override { NOTREACHED(); } | 408 void OnChannelError() override { NOTREACHED(); } |
| 407 | 409 |
| 408 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 410 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 409 | 411 |
| 410 private: | 412 private: |
| 411 IPC::Sender* sender_; | 413 IPC::Sender* sender_; |
| 412 }; | 414 }; |
| 413 | 415 |
| 414 // Times out on Android; see http://crbug.com/502290 | 416 // Times out on Android; see http://crbug.com/502290 |
| 415 #if defined(OS_ANDROID) | 417 // Times out on Linux. crbug.com/585784 |
| 418 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 416 #define MAYBE_SendMessagePipe DISABLED_SendMessagePipe | 419 #define MAYBE_SendMessagePipe DISABLED_SendMessagePipe |
| 417 #else | 420 #else |
| 418 #define MAYBE_SendMessagePipe SendMessagePipe | 421 #define MAYBE_SendMessagePipe SendMessagePipe |
| 419 #endif | 422 #endif |
| 420 TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) { | 423 TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) { |
| 421 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); | 424 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); |
| 422 | 425 |
| 423 ListenerThatExpectsOK listener; | 426 ListenerThatExpectsOK listener; |
| 424 CreateChannel(&listener); | 427 CreateChannel(&listener); |
| 425 ASSERT_TRUE(ConnectChannel()); | 428 ASSERT_TRUE(ConnectChannel()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 ChannelClient client(&listener, channel_name); | 505 ChannelClient client(&listener, channel_name); |
| 503 client.Connect(); | 506 client.Connect(); |
| 504 listener.set_sender(client.channel()); | 507 listener.set_sender(client.channel()); |
| 505 | 508 |
| 506 base::MessageLoop::current()->Run(); | 509 base::MessageLoop::current()->Run(); |
| 507 | 510 |
| 508 client.Close(); | 511 client.Close(); |
| 509 } | 512 } |
| 510 | 513 |
| 511 // Times out on Android; see http://crbug.com/502290 | 514 // Times out on Android; see http://crbug.com/502290 |
| 512 #if defined(OS_ANDROID) | 515 // Times out on Linux. crbug.com/585784 |
| 516 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 513 #define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe | 517 #define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe |
| 514 #else | 518 #else |
| 515 #define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe | 519 #define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe |
| 516 #endif | 520 #endif |
| 517 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) { | 521 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) { |
| 518 InitWithMojo("ParamTraitValidMessagePipeClient"); | 522 InitWithMojo("ParamTraitValidMessagePipeClient"); |
| 519 | 523 |
| 520 ListenerThatExpectsOK listener; | 524 ListenerThatExpectsOK listener; |
| 521 CreateChannel(&listener); | 525 CreateChannel(&listener); |
| 522 ASSERT_TRUE(ConnectChannel()); | 526 ASSERT_TRUE(ConnectChannel()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 536 EXPECT_TRUE(WaitForClientShutdown()); | 540 EXPECT_TRUE(WaitForClientShutdown()); |
| 537 DestroyChannel(); | 541 DestroyChannel(); |
| 538 } | 542 } |
| 539 | 543 |
| 540 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { | 544 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { |
| 541 ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); | 545 ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); |
| 542 return 0; | 546 return 0; |
| 543 } | 547 } |
| 544 | 548 |
| 545 // Times out on Android; see http://crbug.com/502290 | 549 // Times out on Android; see http://crbug.com/502290 |
| 546 #if defined(OS_ANDROID) | 550 // Times out on Linux. crbug.com/585784 |
| 551 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 547 #define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe | 552 #define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe |
| 548 #else | 553 #else |
| 549 #define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe | 554 #define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe |
| 550 #endif | 555 #endif |
| 551 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) { | 556 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) { |
| 552 InitWithMojo("ParamTraitInvalidMessagePipeClient"); | 557 InitWithMojo("ParamTraitInvalidMessagePipeClient"); |
| 553 | 558 |
| 554 ListenerThatExpectsOK listener; | 559 ListenerThatExpectsOK listener; |
| 555 CreateChannel(&listener); | 560 CreateChannel(&listener); |
| 556 ASSERT_TRUE(ConnectChannel()); | 561 ASSERT_TRUE(ConnectChannel()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 567 | 572 |
| 568 EXPECT_TRUE(WaitForClientShutdown()); | 573 EXPECT_TRUE(WaitForClientShutdown()); |
| 569 DestroyChannel(); | 574 DestroyChannel(); |
| 570 } | 575 } |
| 571 | 576 |
| 572 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitInvalidMessagePipeClient) { | 577 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitInvalidMessagePipeClient) { |
| 573 ParamTraitMessagePipeClient(false, "ParamTraitInvalidMessagePipeClient"); | 578 ParamTraitMessagePipeClient(false, "ParamTraitInvalidMessagePipeClient"); |
| 574 return 0; | 579 return 0; |
| 575 } | 580 } |
| 576 | 581 |
| 577 TEST_F(IPCChannelMojoTest, SendFailAfterClose) { | 582 // Times out on Linux. crbug.com/585784 |
| 583 #if defined(OS_LINUX) |
| 584 #define MAYBE_SendFailAfterClose DISABLED_SendFailAfterClose |
| 585 #else |
| 586 #define MAYBE_SendFailAfterClose SendFailAfterClose |
| 587 #endif |
| 588 TEST_F(IPCChannelMojoTest, MAYBE_SendFailAfterClose) { |
| 578 InitWithMojo("IPCChannelMojoTestSendOkClient"); | 589 InitWithMojo("IPCChannelMojoTestSendOkClient"); |
| 579 | 590 |
| 580 ListenerThatExpectsOK listener; | 591 ListenerThatExpectsOK listener; |
| 581 CreateChannel(&listener); | 592 CreateChannel(&listener); |
| 582 ASSERT_TRUE(ConnectChannel()); | 593 ASSERT_TRUE(ConnectChannel()); |
| 583 ASSERT_TRUE(StartClient()); | 594 ASSERT_TRUE(StartClient()); |
| 584 | 595 |
| 585 base::MessageLoop::current()->Run(); | 596 base::MessageLoop::current()->Run(); |
| 586 this->channel()->Close(); | 597 this->channel()->Close(); |
| 587 ASSERT_FALSE(this->channel()->Send(new IPC::Message())); | 598 ASSERT_FALSE(this->channel()->Send(new IPC::Message())); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 IPCTestBase::DidStartClient(); | 647 IPCTestBase::DidStartClient(); |
| 637 // const base::ProcessHandle client = client_process().Handle(); | 648 // const base::ProcessHandle client = client_process().Handle(); |
| 638 // Forces GetFileHandleForProcess() fail. It happens occasionally | 649 // Forces GetFileHandleForProcess() fail. It happens occasionally |
| 639 // in production, so we should exercise it somehow. | 650 // in production, so we should exercise it somehow. |
| 640 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. | 651 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. |
| 641 // ::CloseHandle(client); | 652 // ::CloseHandle(client); |
| 642 return true; | 653 return true; |
| 643 } | 654 } |
| 644 }; | 655 }; |
| 645 | 656 |
| 646 TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) { | 657 // Times out on Linux. crbug.com/585784 |
| 658 #if defined(OS_LINUX) |
| 659 #define MAYBE_InvalidClientHandle DISABLED_InvalidClientHandle |
| 660 #else |
| 661 #define MAYBE_InvalidClientHandle InvalidClientHandle |
| 662 #endif |
| 663 TEST_F(IPCChannelMojoDeadHandleTest, MAYBE_InvalidClientHandle) { |
| 647 // Any client type is fine as it is going to be killed anyway. | 664 // Any client type is fine as it is going to be killed anyway. |
| 648 InitWithMojo("IPCChannelMojoTestDoNothingClient"); | 665 InitWithMojo("IPCChannelMojoTestDoNothingClient"); |
| 649 | 666 |
| 650 // Set up IPC channel and start client. | 667 // Set up IPC channel and start client. |
| 651 ListenerExpectingErrors listener; | 668 ListenerExpectingErrors listener; |
| 652 CreateChannel(&listener); | 669 CreateChannel(&listener); |
| 653 ASSERT_TRUE(ConnectChannel()); | 670 ASSERT_TRUE(ConnectChannel()); |
| 654 | 671 |
| 655 ASSERT_TRUE(StartClient()); | 672 ASSERT_TRUE(StartClient()); |
| 656 base::MessageLoop::current()->Run(); | 673 base::MessageLoop::current()->Run(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 NOTREACHED(); | 716 NOTREACHED(); |
| 700 } | 717 } |
| 701 | 718 |
| 702 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 719 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 703 | 720 |
| 704 private: | 721 private: |
| 705 IPC::Sender* sender_; | 722 IPC::Sender* sender_; |
| 706 }; | 723 }; |
| 707 | 724 |
| 708 // Times out on Android; see http://crbug.com/502290 | 725 // Times out on Android; see http://crbug.com/502290 |
| 709 #if defined(OS_ANDROID) | 726 // Times out on Linux. crbug.com/585784 |
| 727 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 710 #define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle | 728 #define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle |
| 711 #else | 729 #else |
| 712 #define MAYBE_SendPlatformHandle SendPlatformHandle | 730 #define MAYBE_SendPlatformHandle SendPlatformHandle |
| 713 #endif | 731 #endif |
| 714 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) { | 732 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) { |
| 715 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); | 733 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); |
| 716 | 734 |
| 717 ListenerThatExpectsOK listener; | 735 ListenerThatExpectsOK listener; |
| 718 CreateChannel(&listener); | 736 CreateChannel(&listener); |
| 719 ASSERT_TRUE(ConnectChannel()); | 737 ASSERT_TRUE(ConnectChannel()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 780 |
| 763 void OnChannelError() override { NOTREACHED(); } | 781 void OnChannelError() override { NOTREACHED(); } |
| 764 | 782 |
| 765 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 783 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
| 766 | 784 |
| 767 private: | 785 private: |
| 768 IPC::Sender* sender_; | 786 IPC::Sender* sender_; |
| 769 }; | 787 }; |
| 770 | 788 |
| 771 // Times out on Android; see http://crbug.com/502290 | 789 // Times out on Android; see http://crbug.com/502290 |
| 772 #if defined(OS_ANDROID) | 790 // Times out on Linux. crbug.com/585784 |
| 791 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 773 #define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe | 792 #define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe |
| 774 #else | 793 #else |
| 775 #define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe | 794 #define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe |
| 776 #endif | 795 #endif |
| 777 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) { | 796 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) { |
| 778 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); | 797 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); |
| 779 | 798 |
| 780 ListenerThatExpectsOK listener; | 799 ListenerThatExpectsOK listener; |
| 781 CreateChannel(&listener); | 800 CreateChannel(&listener); |
| 782 ASSERT_TRUE(ConnectChannel()); | 801 ASSERT_TRUE(ConnectChannel()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 EXPECT_EQ(peer_pid, kMagicChildId); | 841 EXPECT_EQ(peer_pid, kMagicChildId); |
| 823 base::MessageLoop::current()->QuitWhenIdle(); | 842 base::MessageLoop::current()->QuitWhenIdle(); |
| 824 } | 843 } |
| 825 | 844 |
| 826 bool OnMessageReceived(const IPC::Message& message) override { | 845 bool OnMessageReceived(const IPC::Message& message) override { |
| 827 NOTREACHED(); | 846 NOTREACHED(); |
| 828 return true; | 847 return true; |
| 829 } | 848 } |
| 830 }; | 849 }; |
| 831 | 850 |
| 832 TEST_F(IPCChannelMojoTest, VerifyGlobalPid) { | 851 // Times out on Linux. crbug.com/585784 |
| 852 #if defined(OS_LINUX) |
| 853 #define MAYBE_VerifyGlobalPid DISABLED_VerifyGlobalPid |
| 854 #else |
| 855 #define MAYBE_VerifyGlobalPid VerifyGlobalPid |
| 856 #endif |
| 857 TEST_F(IPCChannelMojoTest, MAYBE_VerifyGlobalPid) { |
| 833 InitWithMojo("IPCChannelMojoTestVerifyGlobalPidClient"); | 858 InitWithMojo("IPCChannelMojoTestVerifyGlobalPidClient"); |
| 834 | 859 |
| 835 ListenerThatVerifiesPeerPid listener; | 860 ListenerThatVerifiesPeerPid listener; |
| 836 CreateChannel(&listener); | 861 CreateChannel(&listener); |
| 837 ASSERT_TRUE(ConnectChannel()); | 862 ASSERT_TRUE(ConnectChannel()); |
| 838 ASSERT_TRUE(StartClient()); | 863 ASSERT_TRUE(StartClient()); |
| 839 | 864 |
| 840 base::MessageLoop::current()->Run(); | 865 base::MessageLoop::current()->Run(); |
| 841 channel()->Close(); | 866 channel()->Close(); |
| 842 | 867 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 854 base::MessageLoop::current()->Run(); | 879 base::MessageLoop::current()->Run(); |
| 855 | 880 |
| 856 client.Close(); | 881 client.Close(); |
| 857 | 882 |
| 858 return 0; | 883 return 0; |
| 859 } | 884 } |
| 860 | 885 |
| 861 #endif // OS_LINUX | 886 #endif // OS_LINUX |
| 862 | 887 |
| 863 } // namespace | 888 } // namespace |
| OLD | NEW |