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

Side by Side Diff: mojo/edk/embedder/embedder_unittest.cc

Issue 2504193005: Revert of Mojo EDK: Speculatively disable peer connection tests on Android (Closed)
Patch Set: Created 4 years, 1 month 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 "mojo/edk/embedder/embedder.h" 5 #include "mojo/edk/embedder/embedder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 #else 572 #else
573 return NamedPlatformHandle(GenerateRandomToken()); 573 return NamedPlatformHandle(GenerateRandomToken());
574 #endif 574 #endif
575 } 575 }
576 576
577 void CreateClientHandleOnIoThread(const NamedPlatformHandle& named_handle, 577 void CreateClientHandleOnIoThread(const NamedPlatformHandle& named_handle,
578 ScopedPlatformHandle* output) { 578 ScopedPlatformHandle* output) {
579 *output = CreateClientHandle(named_handle); 579 *output = CreateClientHandle(named_handle);
580 } 580 }
581 581
582 #if defined(OS_ANDROID) 582 TEST_F(EmbedderTest, ClosePendingPeerConnection) {
583 // Disabled on Android as suspected source of flake. https://crbug.com/666356.
584 #define MAYBE_ClosePendingPeerConnection DISABLED_ClosePendingPeerConnection
585 #else
586 #define MAYBE_ClosePendingPeerConnection ClosePendingPeerConnection
587 #endif
588 TEST_F(EmbedderTest, MAYBE_ClosePendingPeerConnection) {
589 NamedPlatformHandle named_handle = GenerateChannelName(); 583 NamedPlatformHandle named_handle = GenerateChannelName();
590 std::string peer_token = GenerateRandomToken(); 584 std::string peer_token = GenerateRandomToken();
591 ScopedMessagePipeHandle server_pipe = 585 ScopedMessagePipeHandle server_pipe =
592 ConnectToPeerProcess(CreateServerHandle(named_handle), peer_token); 586 ConnectToPeerProcess(CreateServerHandle(named_handle), peer_token);
593 ClosePeerConnection(peer_token); 587 ClosePeerConnection(peer_token);
594 EXPECT_EQ(MOJO_RESULT_OK, 588 EXPECT_EQ(MOJO_RESULT_OK,
595 Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, 589 Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED,
596 MOJO_DEADLINE_INDEFINITE, nullptr)); 590 MOJO_DEADLINE_INDEFINITE, nullptr));
597 base::MessageLoop message_loop; 591 base::MessageLoop message_loop;
598 base::RunLoop run_loop; 592 base::RunLoop run_loop;
599 ScopedPlatformHandle client_handle; 593 ScopedPlatformHandle client_handle;
600 // Closing the channel involves posting a task to the IO thread to do the 594 // Closing the channel involves posting a task to the IO thread to do the
601 // work. By the time the local message pipe has been observerd as closed, 595 // work. By the time the local message pipe has been observerd as closed,
602 // that task will have been posted. Therefore, a task to create the client 596 // that task will have been posted. Therefore, a task to create the client
603 // connection should be handled after the channel is closed. 597 // connection should be handled after the channel is closed.
604 test::GetIoTaskRunner()->PostTaskAndReply( 598 test::GetIoTaskRunner()->PostTaskAndReply(
605 FROM_HERE, 599 FROM_HERE,
606 base::Bind(&CreateClientHandleOnIoThread, named_handle, &client_handle), 600 base::Bind(&CreateClientHandleOnIoThread, named_handle, &client_handle),
607 run_loop.QuitClosure()); 601 run_loop.QuitClosure());
608 run_loop.Run(); 602 run_loop.Run();
609 EXPECT_FALSE(client_handle.is_valid()); 603 EXPECT_FALSE(client_handle.is_valid());
610 } 604 }
611 605
612 #if !defined(OS_IOS) 606 #if !defined(OS_IOS)
613 607
614 #if defined(OS_ANDROID) 608 TEST_F(EmbedderTest, ClosePipeToConnectedPeer) {
615 // Disabled on Android as suspected source of flake. https://crbug.com/666356.
616 #define MAYBE_ClosePipeToConnectedPeer DISABLED_ClosePipeToConnectedPeer
617 #else
618 #define MAYBE_ClosePipeToConnectedPeer ClosePipeToConnectedPeer
619 #endif
620 TEST_F(EmbedderTest, MAYBE_ClosePipeToConnectedPeer) {
621 set_launch_type(LaunchType::PEER); 609 set_launch_type(LaunchType::PEER);
622 auto& controller = StartClient("ClosePipeToConnectedPeerClient"); 610 auto& controller = StartClient("ClosePipeToConnectedPeerClient");
623 MojoHandle server_mp = controller.pipe(); 611 MojoHandle server_mp = controller.pipe();
624 // 1. Write a message to |server_mp| (attaching nothing). 612 // 1. Write a message to |server_mp| (attaching nothing).
625 WriteMessage(server_mp, "hello"); 613 WriteMessage(server_mp, "hello");
626 614
627 // 2. Read a message from |server_mp|. 615 // 2. Read a message from |server_mp|.
628 EXPECT_EQ("world!", ReadMessage(server_mp)); 616 EXPECT_EQ("world!", ReadMessage(server_mp));
629 617
630 controller.ClosePeerConnection(); 618 controller.ClosePeerConnection();
(...skipping 10 matching lines...) Expand all
641 EXPECT_EQ("hello", ReadMessage(client_mp)); 629 EXPECT_EQ("hello", ReadMessage(client_mp));
642 630
643 // 2. Write a message to |client_mp| (attaching nothing). 631 // 2. Write a message to |client_mp| (attaching nothing).
644 WriteMessage(client_mp, "world!"); 632 WriteMessage(client_mp, "world!");
645 633
646 ASSERT_EQ(MOJO_RESULT_OK, 634 ASSERT_EQ(MOJO_RESULT_OK,
647 MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, 635 MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED,
648 MOJO_DEADLINE_INDEFINITE, nullptr)); 636 MOJO_DEADLINE_INDEFINITE, nullptr));
649 } 637 }
650 638
651 #if defined(OS_ANDROID) 639 TEST_F(EmbedderTest, ClosePipeToConnectingPeer) {
652 // Disabled on Android as suspected source of flake. https://crbug.com/666356.
653 #define MAYBE_ClosePipeToConnectingPeer DISABLED_ClosePipeToConnectingPeer
654 #else
655 #define MAYBE_ClosePipeToConnectingPeer ClosePipeToConnectingPeer
656 #endif
657 TEST_F(EmbedderTest, MAYBE_ClosePipeToConnectingPeer) {
658 set_launch_type(LaunchType::PEER); 640 set_launch_type(LaunchType::PEER);
659 auto& controller = StartClient("ClosePipeToConnectingPeerClient"); 641 auto& controller = StartClient("ClosePipeToConnectingPeerClient");
660 controller.ClosePeerConnection(); 642 controller.ClosePeerConnection();
661 643
662 MojoHandle server_mp = controller.pipe(); 644 MojoHandle server_mp = controller.pipe();
663 645
664 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, 646 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED,
665 MOJO_DEADLINE_INDEFINITE, nullptr)); 647 MOJO_DEADLINE_INDEFINITE, nullptr));
666 648
667 EXPECT_EQ(0, controller.WaitForShutdown()); 649 EXPECT_EQ(0, controller.WaitForShutdown());
668 } 650 }
669 651
670 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ClosePipeToConnectingPeerClient, EmbedderTest, 652 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ClosePipeToConnectingPeerClient, EmbedderTest,
671 client_mp) { 653 client_mp) {
672 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, 654 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED,
673 MOJO_DEADLINE_INDEFINITE, nullptr)); 655 MOJO_DEADLINE_INDEFINITE, nullptr));
674 } 656 }
675 657
676 #endif // !defined(OS_IOS) 658 #endif // !defined(OS_IOS)
677 659
678 } // namespace 660 } // namespace
679 } // namespace edk 661 } // namespace edk
680 } // namespace mojo 662 } // namespace mojo
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