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 "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/location.h" | 9 #include "base/location.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 EXPECT_TRUE(base::kNullProcessId != peer_pid); | 145 EXPECT_TRUE(base::kNullProcessId != peer_pid); |
146 is_connected_called_ = true; | 146 is_connected_called_ = true; |
147 } | 147 } |
148 | 148 |
149 bool is_connected_called() const { return is_connected_called_; } | 149 bool is_connected_called() const { return is_connected_called_; } |
150 | 150 |
151 private: | 151 private: |
152 bool is_connected_called_; | 152 bool is_connected_called_; |
153 }; | 153 }; |
154 | 154 |
155 TEST_F(IPCChannelMojoTest, ConnectedFromClient) { | 155 // Times out on Android; see http://crbug.com/502290 |
| 156 #if defined(OS_ANDROID) |
| 157 #define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient |
| 158 #else |
| 159 #define MAYBE_ConnectedFromClient ConnectedFromClient |
| 160 #endif |
| 161 TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) { |
156 InitWithMojo("IPCChannelMojoTestClient"); | 162 InitWithMojo("IPCChannelMojoTestClient"); |
157 | 163 |
158 // Set up IPC channel and start client. | 164 // Set up IPC channel and start client. |
159 TestChannelListenerWithExtraExpectations listener; | 165 TestChannelListenerWithExtraExpectations listener; |
160 CreateChannel(&listener); | 166 CreateChannel(&listener); |
161 listener.Init(sender()); | 167 listener.Init(sender()); |
162 ASSERT_TRUE(ConnectChannel()); | 168 ASSERT_TRUE(ConnectChannel()); |
163 ASSERT_TRUE(StartClient()); | 169 ASSERT_TRUE(StartClient()); |
164 | 170 |
165 IPC::TestChannelListener::SendOneMessage( | 171 IPC::TestChannelListener::SendOneMessage( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 ChannelClient client(&listener, "IPCChannelMojoErraticTestClient"); | 266 ChannelClient client(&listener, "IPCChannelMojoErraticTestClient"); |
261 client.Connect(); | 267 client.Connect(); |
262 | 268 |
263 base::MessageLoop::current()->Run(); | 269 base::MessageLoop::current()->Run(); |
264 | 270 |
265 client.Close(); | 271 client.Close(); |
266 | 272 |
267 return 0; | 273 return 0; |
268 } | 274 } |
269 | 275 |
270 TEST_F(IPCChannelMojoErrorTest, SendFailWithPendingMessages) { | 276 // Times out on Android; see http://crbug.com/502290 |
| 277 #if defined(OS_ANDROID) |
| 278 #define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages |
| 279 #else |
| 280 #define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages |
| 281 #endif |
| 282 TEST_F(IPCChannelMojoErrorTest, MAYBE_SendFailWithPendingMessages) { |
271 InitWithMojo("IPCChannelMojoErraticTestClient"); | 283 InitWithMojo("IPCChannelMojoErraticTestClient"); |
272 | 284 |
273 // Set up IPC channel and start client. | 285 // Set up IPC channel and start client. |
274 ListenerExpectingErrors listener; | 286 ListenerExpectingErrors listener; |
275 CreateChannel(&listener); | 287 CreateChannel(&listener); |
276 ASSERT_TRUE(ConnectChannel()); | 288 ASSERT_TRUE(ConnectChannel()); |
277 | 289 |
278 // This matches a value in mojo/edk/system/constants.h | 290 // This matches a value in mojo/edk/system/constants.h |
279 const int kMaxMessageNumBytes = 4 * 1024 * 1024; | 291 const int kMaxMessageNumBytes = 4 * 1024 * 1024; |
280 std::string overly_large_data(kMaxMessageNumBytes, '*'); | 292 std::string overly_large_data(kMaxMessageNumBytes, '*'); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 412 } |
401 | 413 |
402 void OnChannelError() override { NOTREACHED(); } | 414 void OnChannelError() override { NOTREACHED(); } |
403 | 415 |
404 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 416 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
405 | 417 |
406 private: | 418 private: |
407 IPC::Sender* sender_; | 419 IPC::Sender* sender_; |
408 }; | 420 }; |
409 | 421 |
410 TEST_F(IPCChannelMojoTest, SendMessagePipe) { | 422 // Times out on Android; see http://crbug.com/502290 |
| 423 #if defined(OS_ANDROID) |
| 424 #define MAYBE_SendMessagePipe DISABLED_SendMessagePipe |
| 425 #else |
| 426 #define MAYBE_SendMessagePipe SendMessagePipe |
| 427 #endif |
| 428 TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) { |
411 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); | 429 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); |
412 | 430 |
413 ListenerThatExpectsOK listener; | 431 ListenerThatExpectsOK listener; |
414 CreateChannel(&listener); | 432 CreateChannel(&listener); |
415 ASSERT_TRUE(ConnectChannel()); | 433 ASSERT_TRUE(ConnectChannel()); |
416 ASSERT_TRUE(StartClient()); | 434 ASSERT_TRUE(StartClient()); |
417 | 435 |
418 TestingMessagePipe pipe; | 436 TestingMessagePipe pipe; |
419 HandleSendingHelper::WritePipeThenSend(channel(), &pipe); | 437 HandleSendingHelper::WritePipeThenSend(channel(), &pipe); |
420 | 438 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 receiving_valid_handle); | 509 receiving_valid_handle); |
492 ChannelClient client(&listener, channel_name); | 510 ChannelClient client(&listener, channel_name); |
493 client.Connect(); | 511 client.Connect(); |
494 listener.set_sender(client.channel()); | 512 listener.set_sender(client.channel()); |
495 | 513 |
496 base::MessageLoop::current()->Run(); | 514 base::MessageLoop::current()->Run(); |
497 | 515 |
498 client.Close(); | 516 client.Close(); |
499 } | 517 } |
500 | 518 |
501 TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) { | 519 // Times out on Android; see http://crbug.com/502290 |
| 520 #if defined(OS_ANDROID) |
| 521 #define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe |
| 522 #else |
| 523 #define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe |
| 524 #endif |
| 525 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) { |
502 InitWithMojo("ParamTraitValidMessagePipeClient"); | 526 InitWithMojo("ParamTraitValidMessagePipeClient"); |
503 | 527 |
504 ListenerThatExpectsOK listener; | 528 ListenerThatExpectsOK listener; |
505 CreateChannel(&listener); | 529 CreateChannel(&listener); |
506 ASSERT_TRUE(ConnectChannel()); | 530 ASSERT_TRUE(ConnectChannel()); |
507 ASSERT_TRUE(StartClient()); | 531 ASSERT_TRUE(StartClient()); |
508 | 532 |
509 TestingMessagePipe pipe; | 533 TestingMessagePipe pipe; |
510 | 534 |
511 scoped_ptr<IPC::Message> message(new IPC::Message()); | 535 scoped_ptr<IPC::Message> message(new IPC::Message()); |
512 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), | 536 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
513 pipe.peer.release()); | 537 pipe.peer.release()); |
514 WriteOK(pipe.self.get()); | 538 WriteOK(pipe.self.get()); |
515 | 539 |
516 this->channel()->Send(message.release()); | 540 this->channel()->Send(message.release()); |
517 base::MessageLoop::current()->Run(); | 541 base::MessageLoop::current()->Run(); |
518 this->channel()->Close(); | 542 this->channel()->Close(); |
519 | 543 |
520 EXPECT_TRUE(WaitForClientShutdown()); | 544 EXPECT_TRUE(WaitForClientShutdown()); |
521 DestroyChannel(); | 545 DestroyChannel(); |
522 } | 546 } |
523 | 547 |
524 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { | 548 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { |
525 ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); | 549 ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); |
526 return 0; | 550 return 0; |
527 } | 551 } |
528 | 552 |
529 TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) { | 553 // Times out on Android; see http://crbug.com/502290 |
| 554 #if defined(OS_ANDROID) |
| 555 #define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe |
| 556 #else |
| 557 #define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe |
| 558 #endif |
| 559 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) { |
530 InitWithMojo("ParamTraitInvalidMessagePipeClient"); | 560 InitWithMojo("ParamTraitInvalidMessagePipeClient"); |
531 | 561 |
532 ListenerThatExpectsOK listener; | 562 ListenerThatExpectsOK listener; |
533 CreateChannel(&listener); | 563 CreateChannel(&listener); |
534 ASSERT_TRUE(ConnectChannel()); | 564 ASSERT_TRUE(ConnectChannel()); |
535 ASSERT_TRUE(StartClient()); | 565 ASSERT_TRUE(StartClient()); |
536 | 566 |
537 mojo::MessagePipeHandle invalid_handle; | 567 mojo::MessagePipeHandle invalid_handle; |
538 scoped_ptr<IPC::Message> message(new IPC::Message()); | 568 scoped_ptr<IPC::Message> message(new IPC::Message()); |
539 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), | 569 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 void OnChannelError() override { | 663 void OnChannelError() override { |
634 NOTREACHED(); | 664 NOTREACHED(); |
635 } | 665 } |
636 | 666 |
637 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 667 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
638 | 668 |
639 private: | 669 private: |
640 IPC::Sender* sender_; | 670 IPC::Sender* sender_; |
641 }; | 671 }; |
642 | 672 |
643 | 673 // Times out on Android; see http://crbug.com/502290 |
644 TEST_F(IPCChannelMojoTest, SendPlatformHandle) { | 674 #if defined(OS_ANDROID) |
| 675 #define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle |
| 676 #else |
| 677 #define MAYBE_SendPlatformHandle SendPlatformHandle |
| 678 #endif |
| 679 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) { |
645 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); | 680 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); |
646 | 681 |
647 ListenerThatExpectsOK listener; | 682 ListenerThatExpectsOK listener; |
648 CreateChannel(&listener); | 683 CreateChannel(&listener); |
649 ASSERT_TRUE(ConnectChannel()); | 684 ASSERT_TRUE(ConnectChannel()); |
650 ASSERT_TRUE(StartClient()); | 685 ASSERT_TRUE(StartClient()); |
651 | 686 |
652 base::File file(HandleSendingHelper::GetSendingFilePath(), | 687 base::File file(HandleSendingHelper::GetSendingFilePath(), |
653 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | | 688 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | |
654 base::File::FLAG_READ); | 689 base::File::FLAG_READ); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 } | 726 } |
692 | 727 |
693 void OnChannelError() override { NOTREACHED(); } | 728 void OnChannelError() override { NOTREACHED(); } |
694 | 729 |
695 void set_sender(IPC::Sender* sender) { sender_ = sender; } | 730 void set_sender(IPC::Sender* sender) { sender_ = sender; } |
696 | 731 |
697 private: | 732 private: |
698 IPC::Sender* sender_; | 733 IPC::Sender* sender_; |
699 }; | 734 }; |
700 | 735 |
701 TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) { | 736 // Times out on Android; see http://crbug.com/502290 |
| 737 #if defined(OS_ANDROID) |
| 738 #define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe |
| 739 #else |
| 740 #define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe |
| 741 #endif |
| 742 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) { |
702 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); | 743 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); |
703 | 744 |
704 ListenerThatExpectsOK listener; | 745 ListenerThatExpectsOK listener; |
705 CreateChannel(&listener); | 746 CreateChannel(&listener); |
706 ASSERT_TRUE(ConnectChannel()); | 747 ASSERT_TRUE(ConnectChannel()); |
707 ASSERT_TRUE(StartClient()); | 748 ASSERT_TRUE(StartClient()); |
708 | 749 |
709 base::File file(HandleSendingHelper::GetSendingFilePath(), | 750 base::File file(HandleSendingHelper::GetSendingFilePath(), |
710 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | | 751 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | |
711 base::File::FLAG_READ); | 752 base::File::FLAG_READ); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 base::MessageLoop::current()->Run(); | 819 base::MessageLoop::current()->Run(); |
779 | 820 |
780 client.Close(); | 821 client.Close(); |
781 | 822 |
782 return 0; | 823 return 0; |
783 } | 824 } |
784 | 825 |
785 #endif // OS_LINUX | 826 #endif // OS_LINUX |
786 | 827 |
787 } // namespace | 828 } // namespace |
OLD | NEW |