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

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: Rebase. 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
« no previous file with comments | « base/test/multiprocess_test_android.cc ('k') | ipc/mojo/run_all_unittests.cc » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 EXPECT_TRUE(base::kNullProcessId != peer_pid); 164 EXPECT_TRUE(base::kNullProcessId != peer_pid);
165 is_connected_called_ = true; 165 is_connected_called_ = true;
166 } 166 }
167 167
168 bool is_connected_called() const { return is_connected_called_; } 168 bool is_connected_called() const { return is_connected_called_; }
169 169
170 private: 170 private:
171 bool is_connected_called_; 171 bool is_connected_called_;
172 }; 172 };
173 173
174 // Times out on Android; see http://crbug.com/502290 174 TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
175 #if defined(OS_ANDROID)
176 #define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient
177 #else
178 #define MAYBE_ConnectedFromClient ConnectedFromClient
179 #endif
180 TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) {
181 InitWithMojo("IPCChannelMojoTestClient"); 175 InitWithMojo("IPCChannelMojoTestClient");
182 176
183 // Set up IPC channel and start client. 177 // Set up IPC channel and start client.
184 TestChannelListenerWithExtraExpectations listener; 178 TestChannelListenerWithExtraExpectations listener;
185 CreateChannel(&listener); 179 CreateChannel(&listener);
186 listener.Init(sender()); 180 listener.Init(sender());
187 ASSERT_TRUE(ConnectChannel()); 181 ASSERT_TRUE(ConnectChannel());
188 182
189 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent"); 183 IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
190 184
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient, 243 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient,
250 ChannelClient) { 244 ChannelClient) {
251 ListenerThatQuits listener; 245 ListenerThatQuits listener;
252 Connect(&listener); 246 Connect(&listener);
253 247
254 base::MessageLoop::current()->Run(); 248 base::MessageLoop::current()->Run();
255 249
256 Close(); 250 Close();
257 } 251 }
258 252
259 // Times out on Android; see http://crbug.com/502290 253 TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) {
260 #if defined(OS_ANDROID)
261 #define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages
262 #else
263 #define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages
264 #endif
265 TEST_F(IPCChannelMojoTest, MAYBE_SendFailWithPendingMessages) {
266 InitWithMojo("IPCChannelMojoErraticTestClient"); 254 InitWithMojo("IPCChannelMojoErraticTestClient");
267 255
268 // Set up IPC channel and start client. 256 // Set up IPC channel and start client.
269 ListenerExpectingErrors listener; 257 ListenerExpectingErrors listener;
270 CreateChannel(&listener); 258 CreateChannel(&listener);
271 ASSERT_TRUE(ConnectChannel()); 259 ASSERT_TRUE(ConnectChannel());
272 260
273 // This matches a value in mojo/edk/system/constants.h 261 // This matches a value in mojo/edk/system/constants.h
274 const int kMaxMessageNumBytes = 4 * 1024 * 1024; 262 const int kMaxMessageNumBytes = 4 * 1024 * 1024;
275 std::string overly_large_data(kMaxMessageNumBytes, '*'); 263 std::string overly_large_data(kMaxMessageNumBytes, '*');
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 386 }
399 387
400 void OnChannelError() override { NOTREACHED(); } 388 void OnChannelError() override { NOTREACHED(); }
401 389
402 void set_sender(IPC::Sender* sender) { sender_ = sender; } 390 void set_sender(IPC::Sender* sender) { sender_ = sender; }
403 391
404 private: 392 private:
405 IPC::Sender* sender_; 393 IPC::Sender* sender_;
406 }; 394 };
407 395
408 // Times out on Android; see http://crbug.com/502290 396 TEST_F(IPCChannelMojoTest, SendMessagePipe) {
409 #if defined(OS_ANDROID)
410 #define MAYBE_SendMessagePipe DISABLED_SendMessagePipe
411 #else
412 #define MAYBE_SendMessagePipe SendMessagePipe
413 #endif
414 TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) {
415 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient"); 397 InitWithMojo("IPCChannelMojoTestSendMessagePipeClient");
416 398
417 ListenerThatExpectsOK listener; 399 ListenerThatExpectsOK listener;
418 CreateChannel(&listener); 400 CreateChannel(&listener);
419 ASSERT_TRUE(ConnectChannel()); 401 ASSERT_TRUE(ConnectChannel());
420 402
421 TestingMessagePipe pipe; 403 TestingMessagePipe pipe;
422 HandleSendingHelper::WritePipeThenSend(channel(), &pipe); 404 HandleSendingHelper::WritePipeThenSend(channel(), &pipe);
423 405
424 base::MessageLoop::current()->Run(); 406 base::MessageLoop::current()->Run();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 receiving_valid_handle); 477 receiving_valid_handle);
496 Connect(&listener); 478 Connect(&listener);
497 listener.set_sender(channel()); 479 listener.set_sender(channel());
498 480
499 base::MessageLoop::current()->Run(); 481 base::MessageLoop::current()->Run();
500 482
501 Close(); 483 Close();
502 } 484 }
503 }; 485 };
504 486
505 // Times out on Android; see http://crbug.com/502290 487 TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) {
506 #if defined(OS_ANDROID)
507 #define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe
508 #else
509 #define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe
510 #endif
511 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) {
512 InitWithMojo("ParamTraitValidMessagePipeClient"); 488 InitWithMojo("ParamTraitValidMessagePipeClient");
513 489
514 ListenerThatExpectsOK listener; 490 ListenerThatExpectsOK listener;
515 CreateChannel(&listener); 491 CreateChannel(&listener);
516 ASSERT_TRUE(ConnectChannel()); 492 ASSERT_TRUE(ConnectChannel());
517 493
518 TestingMessagePipe pipe; 494 TestingMessagePipe pipe;
519 495
520 std::unique_ptr<IPC::Message> message(new IPC::Message()); 496 std::unique_ptr<IPC::Message> message(new IPC::Message());
521 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), 497 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
522 pipe.peer.release()); 498 pipe.peer.release());
523 WriteOK(pipe.self.get()); 499 WriteOK(pipe.self.get());
524 500
525 channel()->Send(message.release()); 501 channel()->Send(message.release());
526 base::MessageLoop::current()->Run(); 502 base::MessageLoop::current()->Run();
527 channel()->Close(); 503 channel()->Close();
528 504
529 EXPECT_TRUE(WaitForClientShutdown()); 505 EXPECT_TRUE(WaitForClientShutdown());
530 DestroyChannel(); 506 DestroyChannel();
531 } 507 }
532 508
533 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitValidMessagePipeClient, 509 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitValidMessagePipeClient,
534 ParamTraitMessagePipeClient) { 510 ParamTraitMessagePipeClient) {
535 RunTest(true); 511 RunTest(true);
536 } 512 }
537 513
538 // Times out on Android; see http://crbug.com/502290 514 TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) {
539 #if defined(OS_ANDROID)
540 #define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe
541 #else
542 #define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe
543 #endif
544 TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) {
545 InitWithMojo("ParamTraitInvalidMessagePipeClient"); 515 InitWithMojo("ParamTraitInvalidMessagePipeClient");
546 516
547 ListenerThatExpectsOK listener; 517 ListenerThatExpectsOK listener;
548 CreateChannel(&listener); 518 CreateChannel(&listener);
549 ASSERT_TRUE(ConnectChannel()); 519 ASSERT_TRUE(ConnectChannel());
550 520
551 mojo::MessagePipeHandle invalid_handle; 521 mojo::MessagePipeHandle invalid_handle;
552 std::unique_ptr<IPC::Message> message(new IPC::Message()); 522 std::unique_ptr<IPC::Message> message(new IPC::Message());
553 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), 523 IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
554 invalid_handle); 524 invalid_handle);
555 525
556 channel()->Send(message.release()); 526 channel()->Send(message.release());
557 base::MessageLoop::current()->Run(); 527 base::MessageLoop::current()->Run();
558 channel()->Close(); 528 channel()->Close();
559 529
560 EXPECT_TRUE(WaitForClientShutdown()); 530 EXPECT_TRUE(WaitForClientShutdown());
561 DestroyChannel(); 531 DestroyChannel();
562 } 532 }
563 533
564 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitInvalidMessagePipeClient, 534 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitInvalidMessagePipeClient,
565 ParamTraitMessagePipeClient) { 535 ParamTraitMessagePipeClient) {
566 RunTest(false); 536 RunTest(false);
567 } 537 }
568 538
569 // Times out on Android. crbug.com/593790 539 TEST_F(IPCChannelMojoTest, SendFailAfterClose) {
570 #if defined(OS_ANDROID)
571 #define MAYBE_SendFailAfterClose DISABLED_SendFailAfterClose
572 #else
573 #define MAYBE_SendFailAfterClose SendFailAfterClose
574 #endif
575 TEST_F(IPCChannelMojoTest, MAYBE_SendFailAfterClose) {
576 InitWithMojo("IPCChannelMojoTestSendOkClient"); 540 InitWithMojo("IPCChannelMojoTestSendOkClient");
577 541
578 ListenerThatExpectsOK listener; 542 ListenerThatExpectsOK listener;
579 CreateChannel(&listener); 543 CreateChannel(&listener);
580 ASSERT_TRUE(ConnectChannel()); 544 ASSERT_TRUE(ConnectChannel());
581 545
582 base::MessageLoop::current()->Run(); 546 base::MessageLoop::current()->Run();
583 channel()->Close(); 547 channel()->Close();
584 ASSERT_FALSE(channel()->Send(new IPC::Message())); 548 ASSERT_FALSE(channel()->Send(new IPC::Message()));
585 549
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 595 }
632 596
633 void OnChannelError() override { NOTREACHED(); } 597 void OnChannelError() override { NOTREACHED(); }
634 598
635 void set_sender(IPC::Sender* sender) { sender_ = sender; } 599 void set_sender(IPC::Sender* sender) { sender_ = sender; }
636 600
637 private: 601 private:
638 IPC::Sender* sender_; 602 IPC::Sender* sender_;
639 }; 603 };
640 604
641 // Times out on Android; see http://crbug.com/502290 605 TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
642 #if defined(OS_ANDROID)
643 #define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle
644 #else
645 #define MAYBE_SendPlatformHandle SendPlatformHandle
646 #endif
647 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) {
648 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient"); 606 InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient");
649 607
650 ListenerThatExpectsOK listener; 608 ListenerThatExpectsOK listener;
651 CreateChannel(&listener); 609 CreateChannel(&listener);
652 ASSERT_TRUE(ConnectChannel()); 610 ASSERT_TRUE(ConnectChannel());
653 611
654 base::File file(HandleSendingHelper::GetSendingFilePath(), 612 base::File file(HandleSendingHelper::GetSendingFilePath(),
655 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | 613 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
656 base::File::FLAG_READ); 614 base::File::FLAG_READ);
657 HandleSendingHelper::WriteFileThenSend(channel(), file); 615 HandleSendingHelper::WriteFileThenSend(channel(), file);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 648 }
691 649
692 void OnChannelError() override { NOTREACHED(); } 650 void OnChannelError() override { NOTREACHED(); }
693 651
694 void set_sender(IPC::Sender* sender) { sender_ = sender; } 652 void set_sender(IPC::Sender* sender) { sender_ = sender; }
695 653
696 private: 654 private:
697 IPC::Sender* sender_; 655 IPC::Sender* sender_;
698 }; 656 };
699 657
700 // Times out on Android; see http://crbug.com/502290 658 TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) {
701 #if defined(OS_ANDROID)
702 #define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe
703 #else
704 #define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe
705 #endif
706 TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) {
707 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient"); 659 InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient");
708 660
709 ListenerThatExpectsOK listener; 661 ListenerThatExpectsOK listener;
710 CreateChannel(&listener); 662 CreateChannel(&listener);
711 ASSERT_TRUE(ConnectChannel()); 663 ASSERT_TRUE(ConnectChannel());
712 664
713 base::File file(HandleSendingHelper::GetSendingFilePath(), 665 base::File file(HandleSendingHelper::GetSendingFilePath(),
714 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | 666 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
715 base::File::FLAG_READ); 667 base::File::FLAG_READ);
716 TestingMessagePipe pipe; 668 TestingMessagePipe pipe;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 735
784 // This test always passes; it ensures that there is at least one test on all 736 // This test always passes; it ensures that there is at least one test on all
785 // targets. Otherwise, Android bots will fail because there is a test target 737 // targets. Otherwise, Android bots will fail because there is a test target
786 // that runs 0 tests. 738 // that runs 0 tests.
787 // TODO(amistry): Remove this once at least one other test has been enabled. 739 // TODO(amistry): Remove this once at least one other test has been enabled.
788 // https://crbug.com/606624. 740 // https://crbug.com/606624.
789 TEST_F(IPCChannelMojoTest, DummyAlwaysPasses) { 741 TEST_F(IPCChannelMojoTest, DummyAlwaysPasses) {
790 } 742 }
791 743
792 } // namespace 744 } // namespace
OLDNEW
« no previous file with comments | « base/test/multiprocess_test_android.cc ('k') | ipc/mojo/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698