Index: mojo/edk/embedder/embedder_unittest.cc |
diff --git a/mojo/edk/embedder/embedder_unittest.cc b/mojo/edk/embedder/embedder_unittest.cc |
index d5a87e54f99b96e238ac97de39be7944f6928ae2..388b45c3651c807887cf5b6ecdcaf6499e1f9711 100644 |
--- a/mojo/edk/embedder/embedder_unittest.cc |
+++ b/mojo/edk/embedder/embedder_unittest.cc |
@@ -35,19 +35,13 @@ |
#include "mojo/public/c/system/core.h" |
#include "mojo/public/cpp/system/handle.h" |
#include "mojo/public/cpp/system/message_pipe.h" |
+#include "mojo/public/cpp/system/wait.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace mojo { |
namespace edk { |
namespace { |
-const MojoHandleSignals kSignalReadadableWritable = |
- MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE; |
- |
-const MojoHandleSignals kSignalAll = MOJO_HANDLE_SIGNAL_READABLE | |
- MOJO_HANDLE_SIGNAL_WRITABLE | |
- MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
- |
// The multiprocess tests that use these don't compile on iOS. |
#if !defined(OS_IOS) |
const char kHelloWorld[] = "hello world"; |
@@ -70,50 +64,6 @@ TEST_F(EmbedderTest, ChannelBasic) { |
ASSERT_EQ(MOJO_RESULT_OK, MojoClose(client_mp)); |
} |
-// Test sending a MP which has read messages out of the OS pipe but which have |
-// not been consumed using MojoReadMessage yet. |
-TEST_F(EmbedderTest, SendReadableMessagePipe) { |
- MojoHandle server_mp, client_mp; |
- CreateMessagePipe(&server_mp, &client_mp); |
- |
- MojoHandle server_mp2, client_mp2; |
- CreateMessagePipe(&server_mp2, &client_mp2); |
- |
- // Write to server2 and wait for client2 to be readable before sending it. |
- // client2's MessagePipeDispatcher will have the message below in its |
- // message_queue_. For extra measures, also verify that this pending message |
- // can contain a message pipe. |
- MojoHandle server_mp3, client_mp3; |
- CreateMessagePipe(&server_mp3, &client_mp3); |
- |
- const std::string kHello = "hello"; |
- WriteMessageWithHandles(server_mp2, kHello, &client_mp3, 1); |
- |
- MojoHandleSignalsState state; |
- ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp2, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, &state)); |
- ASSERT_EQ(kSignalReadadableWritable, state.satisfied_signals); |
- ASSERT_EQ(kSignalAll, state.satisfiable_signals); |
- |
- // Now send client2 |
- WriteMessageWithHandles(server_mp, kHello, &client_mp2, 1); |
- |
- MojoHandle port; |
- std::string message = ReadMessageWithHandles(client_mp, &port, 1); |
- EXPECT_EQ(kHello, message); |
- |
- client_mp2 = port; |
- message = ReadMessageWithHandles(client_mp2, &client_mp3, 1); |
- EXPECT_EQ(kHello, message); |
- |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(server_mp3)); |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(client_mp3)); |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(server_mp2)); |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(client_mp2)); |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(server_mp)); |
- ASSERT_EQ(MOJO_RESULT_OK, MojoClose(client_mp)); |
-} |
- |
// Verifies that a MP with pending messages to be written can be sent and the |
// pending messages aren't dropped. |
TEST_F(EmbedderTest, SendMessagePipeWithWriteQueue) { |
@@ -217,10 +167,8 @@ TEST_F(EmbedderTest, PipeSetup_LaunchDeath) { |
// the reserved port. |
ignore_result(pair.PassClientHandle()); |
- EXPECT_EQ(MOJO_RESULT_OK, MojoWait(parent_mp.get().value(), |
- MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, |
- nullptr)); |
+ EXPECT_EQ(MOJO_RESULT_OK, WaitForSignals(parent_mp.get().value(), |
+ MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
} |
TEST_F(EmbedderTest, PipeSetup_LaunchFailure) { |
@@ -234,10 +182,8 @@ TEST_F(EmbedderTest, PipeSetup_LaunchFailure) { |
// called, any message pipes associated with it detect peer closure. |
process.reset(); |
- EXPECT_EQ(MOJO_RESULT_OK, MojoWait(parent_mp.get().value(), |
- MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, |
- nullptr)); |
+ EXPECT_EQ(MOJO_RESULT_OK, WaitForSignals(parent_mp.get().value(), |
+ MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
} |
// The sequence of messages sent is: |
@@ -292,9 +238,7 @@ TEST_F(EmbedderTest, MultiprocessChannels) { |
// 10. Wait on |mp2| (which should eventually fail) and then close it. |
MojoHandleSignalsState state; |
ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
- MojoWait(mp2, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, |
- &state)); |
+ WaitForSignals(mp2, MOJO_HANDLE_SIGNAL_READABLE, &state)); |
ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfied_signals); |
ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals); |
@@ -336,8 +280,7 @@ DEFINE_TEST_CLIENT_TEST_WITH_PIPE(MultiprocessChannelsClient, EmbedderTest, |
// 10. Wait on |mp1| (which should eventually fail) and then close it. |
MojoHandleSignalsState state; |
ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
- MojoWait(mp1, MOJO_HANDLE_SIGNAL_READABLE, |
- MOJO_DEADLINE_INDEFINITE, &state)); |
+ WaitForSignals(mp1, MOJO_HANDLE_SIGNAL_READABLE, &state)); |
ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfied_signals); |
ASSERT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfiable_signals); |
ASSERT_EQ(MOJO_RESULT_OK, MojoClose(mp1)); |
@@ -586,8 +529,7 @@ TEST_F(EmbedderTest, ClosePendingPeerConnection) { |
ConnectToPeerProcess(CreateServerHandle(named_handle), peer_token); |
ClosePeerConnection(peer_token); |
EXPECT_EQ(MOJO_RESULT_OK, |
- Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, nullptr)); |
+ Wait(server_pipe.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
base::MessageLoop message_loop; |
base::RunLoop run_loop; |
ScopedPlatformHandle client_handle; |
@@ -617,8 +559,8 @@ TEST_F(EmbedderTest, ClosePipeToConnectedPeer) { |
controller.ClosePeerConnection(); |
- EXPECT_EQ(MOJO_RESULT_OK, MojoWait(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, nullptr)); |
+ EXPECT_EQ(MOJO_RESULT_OK, |
+ WaitForSignals(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
EXPECT_EQ(0, controller.WaitForShutdown()); |
} |
@@ -632,8 +574,7 @@ DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ClosePipeToConnectedPeerClient, EmbedderTest, |
WriteMessage(client_mp, "world!"); |
ASSERT_EQ(MOJO_RESULT_OK, |
- MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, nullptr)); |
+ WaitForSignals(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
} |
TEST_F(EmbedderTest, ClosePipeToConnectingPeer) { |
@@ -643,16 +584,16 @@ TEST_F(EmbedderTest, ClosePipeToConnectingPeer) { |
MojoHandle server_mp = controller.pipe(); |
- EXPECT_EQ(MOJO_RESULT_OK, MojoWait(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, nullptr)); |
+ EXPECT_EQ(MOJO_RESULT_OK, |
+ WaitForSignals(server_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
EXPECT_EQ(0, controller.WaitForShutdown()); |
} |
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ClosePipeToConnectingPeerClient, EmbedderTest, |
client_mp) { |
- ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
- MOJO_DEADLINE_INDEFINITE, nullptr)); |
+ ASSERT_EQ(MOJO_RESULT_OK, |
+ WaitForSignals(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED)); |
} |
#endif // !defined(OS_IOS) |