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

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

Issue 1910233003: Implement a new child test helper for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inject main(). Created 4 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXPECT_TRUE(base::kNullProcessId != peer_pid); 163 EXPECT_TRUE(base::kNullProcessId != peer_pid);
164 is_connected_called_ = true; 164 is_connected_called_ = true;
165 } 165 }
166 166
167 bool is_connected_called() const { return is_connected_called_; } 167 bool is_connected_called() const { return is_connected_called_; }
168 168
169 private: 169 private:
170 bool is_connected_called_; 170 bool is_connected_called_;
171 }; 171 };
172 172
173 // Times out on Android; see http://crbug.com/502290 173 TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
174 #if defined(OS_ANDROID)
175 #define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient
176 #else
177 #define MAYBE_ConnectedFromClient ConnectedFromClient
178 #endif
179 TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) {
180 InitWithMojo("IPCChannelMojoTestClient"); 174 InitWithMojo("IPCChannelMojoTestClient");
181 175
182 // Set up IPC channel and start client. 176 // Set up IPC channel and start client.
183 TestChannelListenerWithExtraExpectations listener; 177 TestChannelListenerWithExtraExpectations listener;
184 CreateChannel(&listener); 178 CreateChannel(&listener);
185 listener.Init(sender()); 179 listener.Init(sender());
186 ASSERT_TRUE(ConnectChannel()); 180 ASSERT_TRUE(ConnectChannel());
187 181
188 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); 182 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
189 183
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient, 242 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient,
249 ChannelClient) { 243 ChannelClient) {
250 ListenerThatQuits listener; 244 ListenerThatQuits listener;
251 Connect(&listener); 245 Connect(&listener);
252 246
253 base::MessageLoop::current()->Run(); 247 base::MessageLoop::current()->Run();
254 248
255 Close(); 249 Close();
256 } 250 }
257 251
258 // Times out on Android; see http://crbug.com/502290 252 TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) {
259 #if defined(OS_ANDROID)
260 #define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages
261 #else
262 #define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages
263 #endif
264 TEST_F(IPCChannelMojoTest, MAYBE_SendFailWithPendingMessages) {
265 InitWithMojo("IPCChannelMojoErraticTestClient"); 253 InitWithMojo("IPCChannelMojoErraticTestClient");
266 254
267 // Set up IPC channel and start client. 255 // Set up IPC channel and start client.
268 ListenerExpectingErrors listener; 256 ListenerExpectingErrors listener;
269 CreateChannel(&listener); 257 CreateChannel(&listener);
270 ASSERT_TRUE(ConnectChannel()); 258 ASSERT_TRUE(ConnectChannel());
271 259
272 // This matches a value in mojo/edk/system/constants.h 260 // This matches a value in mojo/edk/system/constants.h
273 const int kMaxMessageNumBytes = 4 * 1024 * 1024; 261 const int kMaxMessageNumBytes = 4 * 1024 * 1024;
274 std::string overly_large_data(kMaxMessageNumBytes, '*'); 262 std::string overly_large_data(kMaxMessageNumBytes, '*');
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 385 }
398 386
399 void OnChannelError() override { NOTREACHED(); } 387 void OnChannelError() override { NOTREACHED(); }
400 388
401 void set_sender(IPC::Sender* sender) { sender_ = sender; } 389 void set_sender(IPC::Sender* sender) { sender_ = sender; }
402 390
403 private: 391 private:
404 IPC::Sender* sender_; 392 IPC::Sender* sender_;
405 }; 393 };
406 394
407 // Times out on Android; see http://crbug.com/502290 395 TEST_F(IPCChannelMojoTest, SendMessagePipe) {
408 #if defined(OS_ANDROID)
409 #define MAYBE_SendMessagePipe DISABLED_SendMessagePipe
410 #else
411 #define MAYBE_SendMessagePipe SendMessagePipe
412 #endif
413 TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) {
414 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); 396 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient");
415 397
416 ListenerThatExpectsOK listener; 398 ListenerThatExpectsOK listener;
417 CreateChannel(&listener); 399 CreateChannel(&listener);
418 ASSERT_TRUE(ConnectChannel()); 400 ASSERT_TRUE(ConnectChannel());
419 401
420 TestingMessagePipe pipe; 402 TestingMessagePipe pipe;
421 HandleSendingHelper::WritePipeThenSend(channel(), &pipe); 403 HandleSendingHelper::WritePipeThenSend(channel(), &pipe);
422 404
423 base::MessageLoop::current()->Run(); 405 base::MessageLoop::current()->Run();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 receiving_valid_handle); 476 receiving_valid_handle);
495 Connect(&listener); 477 Connect(&listener);
496 listener.set_sender(channel()); 478 listener.set_sender(channel());
497 479
498 base::MessageLoop::current()->Run(); 480 base::MessageLoop::current()->Run();
499 481
500 Close(); 482 Close();
501 } 483 }
502 }; 484 };
503 485
504 // Times out on Android; see http://crbug.com/502290 486 TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) {
505 #if defined(OS_ANDROID)
506 #define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe
507 #else
508 #define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe
509 #endif
510 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) {
511 InitWithMojo("ParamTraitValidMessagePipeClient"); 487 InitWithMojo("ParamTraitValidMessagePipeClient");
512 488
513 ListenerThatExpectsOK listener; 489 ListenerThatExpectsOK listener;
514 CreateChannel(&listener); 490 CreateChannel(&listener);
515 ASSERT_TRUE(ConnectChannel()); 491 ASSERT_TRUE(ConnectChannel());
516 492
517 TestingMessagePipe pipe; 493 TestingMessagePipe pipe;
518 494
519 scoped_ptr<IPC::Message> message(new IPC::Message()); 495 scoped_ptr<IPC::Message> message(new IPC::Message());
520 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), 496 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
521 pipe.peer.release()); 497 pipe.peer.release());
522 WriteOK(pipe.self.get()); 498 WriteOK(pipe.self.get());
523 499
524 channel()->Send(message.release()); 500 channel()->Send(message.release());
525 base::MessageLoop::current()->Run(); 501 base::MessageLoop::current()->Run();
526 channel()->Close(); 502 channel()->Close();
527 503
528 EXPECT_TRUE(WaitForClientShutdown()); 504 EXPECT_TRUE(WaitForClientShutdown());
529 DestroyChannel(); 505 DestroyChannel();
530 } 506 }
531 507
532 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitValidMessagePipeClient, 508 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitValidMessagePipeClient,
533 ParamTraitMessagePipeClient) { 509 ParamTraitMessagePipeClient) {
534 RunTest(true); 510 RunTest(true);
535 } 511 }
536 512
537 // Times out on Android; see http://crbug.com/502290 513 TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) {
538 #if defined(OS_ANDROID)
539 #define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe
540 #else
541 #define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe
542 #endif
543 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) {
544 InitWithMojo("ParamTraitInvalidMessagePipeClient"); 514 InitWithMojo("ParamTraitInvalidMessagePipeClient");
545 515
546 ListenerThatExpectsOK listener; 516 ListenerThatExpectsOK listener;
547 CreateChannel(&listener); 517 CreateChannel(&listener);
548 ASSERT_TRUE(ConnectChannel()); 518 ASSERT_TRUE(ConnectChannel());
549 519
550 mojo::MessagePipeHandle invalid_handle; 520 mojo::MessagePipeHandle invalid_handle;
551 scoped_ptr<IPC::Message> message(new IPC::Message()); 521 scoped_ptr<IPC::Message> message(new IPC::Message());
552 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), 522 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
553 invalid_handle); 523 invalid_handle);
554 524
555 channel()->Send(message.release()); 525 channel()->Send(message.release());
556 base::MessageLoop::current()->Run(); 526 base::MessageLoop::current()->Run();
557 channel()->Close(); 527 channel()->Close();
558 528
559 EXPECT_TRUE(WaitForClientShutdown()); 529 EXPECT_TRUE(WaitForClientShutdown());
560 DestroyChannel(); 530 DestroyChannel();
561 } 531 }
562 532
563 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitInvalidMessagePipeClient, 533 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitInvalidMessagePipeClient,
564 ParamTraitMessagePipeClient) { 534 ParamTraitMessagePipeClient) {
565 RunTest(false); 535 RunTest(false);
566 } 536 }
567 537
568 // Times out on Android. crbug.com/593790 538 TEST_F(IPCChannelMojoTest, SendFailAfterClose) {
569 #if defined(OS_ANDROID)
570 #define MAYBE_SendFailAfterClose DISABLED_SendFailAfterClose
571 #else
572 #define MAYBE_SendFailAfterClose SendFailAfterClose
573 #endif
574 TEST_F(IPCChannelMojoTest, MAYBE_SendFailAfterClose) {
575 InitWithMojo("IPCChannelMojoTestSendOkClient"); 539 InitWithMojo("IPCChannelMojoTestSendOkClient");
576 540
577 ListenerThatExpectsOK listener; 541 ListenerThatExpectsOK listener;
578 CreateChannel(&listener); 542 CreateChannel(&listener);
579 ASSERT_TRUE(ConnectChannel()); 543 ASSERT_TRUE(ConnectChannel());
580 544
581 base::MessageLoop::current()->Run(); 545 base::MessageLoop::current()->Run();
582 channel()->Close(); 546 channel()->Close();
583 ASSERT_FALSE(channel()->Send(new IPC::Message())); 547 ASSERT_FALSE(channel()->Send(new IPC::Message()));
584 548
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 594 }
631 595
632 void OnChannelError() override { NOTREACHED(); } 596 void OnChannelError() override { NOTREACHED(); }
633 597
634 void set_sender(IPC::Sender* sender) { sender_ = sender; } 598 void set_sender(IPC::Sender* sender) { sender_ = sender; }
635 599
636 private: 600 private:
637 IPC::Sender* sender_; 601 IPC::Sender* sender_;
638 }; 602 };
639 603
640 // Times out on Android; see http://crbug.com/502290 604 TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
641 #if defined(OS_ANDROID)
642 #define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle
643 #else
644 #define MAYBE_SendPlatformHandle SendPlatformHandle
645 #endif
646 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) {
647 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); 605 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient");
648 606
649 ListenerThatExpectsOK listener; 607 ListenerThatExpectsOK listener;
650 CreateChannel(&listener); 608 CreateChannel(&listener);
651 ASSERT_TRUE(ConnectChannel()); 609 ASSERT_TRUE(ConnectChannel());
652 610
653 base::File file(HandleSendingHelper::GetSendingFilePath(), 611 base::File file(HandleSendingHelper::GetSendingFilePath(),
654 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | 612 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
655 base::File::FLAG_READ); 613 base::File::FLAG_READ);
656 HandleSendingHelper::WriteFileThenSend(channel(), file); 614 HandleSendingHelper::WriteFileThenSend(channel(), file);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 647 }
690 648
691 void OnChannelError() override { NOTREACHED(); } 649 void OnChannelError() override { NOTREACHED(); }
692 650
693 void set_sender(IPC::Sender* sender) { sender_ = sender; } 651 void set_sender(IPC::Sender* sender) { sender_ = sender; }
694 652
695 private: 653 private:
696 IPC::Sender* sender_; 654 IPC::Sender* sender_;
697 }; 655 };
698 656
699 // Times out on Android; see http://crbug.com/502290 657 TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) {
700 #if defined(OS_ANDROID)
701 #define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe
702 #else
703 #define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe
704 #endif
705 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) {
706 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); 658 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient");
707 659
708 ListenerThatExpectsOK listener; 660 ListenerThatExpectsOK listener;
709 CreateChannel(&listener); 661 CreateChannel(&listener);
710 ASSERT_TRUE(ConnectChannel()); 662 ASSERT_TRUE(ConnectChannel());
711 663
712 base::File file(HandleSendingHelper::GetSendingFilePath(), 664 base::File file(HandleSendingHelper::GetSendingFilePath(),
713 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | 665 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
714 base::File::FLAG_READ); 666 base::File::FLAG_READ);
715 TestingMessagePipe pipe; 667 TestingMessagePipe pipe;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 Connect(&listener); 726 Connect(&listener);
775 727
776 base::MessageLoop::current()->Run(); 728 base::MessageLoop::current()->Run();
777 729
778 Close(); 730 Close();
779 } 731 }
780 732
781 #endif // OS_LINUX 733 #endif // OS_LINUX
782 734
783 } // namespace 735 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698