Index: ipc/mojo/ipc_channel_mojo_unittest.cc |
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc |
index 356d3b3acd110ab1835f89ca9849cd0ccdc8c4fa..662e75829694e0358e206cfaa01be2983c40321a 100644 |
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc |
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc |
@@ -18,7 +18,6 @@ |
#include "ipc/mojo/ipc_channel_mojo_host.h" |
#include "ipc/mojo/ipc_mojo_handle_attachment.h" |
#include "ipc/mojo/ipc_mojo_message_helper.h" |
-#include "ipc/mojo/ipc_mojo_param_traits.h" |
#include "ipc/mojo/scoped_ipc_support.h" |
#if defined(OS_POSIX) |
@@ -443,120 +442,6 @@ |
return 0; |
} |
-void ReadOK(mojo::MessagePipeHandle pipe) { |
- std::string should_be_ok("xx"); |
- uint32_t num_bytes = static_cast<uint32_t>(should_be_ok.size()); |
- CHECK_EQ(MOJO_RESULT_OK, |
- mojo::ReadMessageRaw(pipe, &should_be_ok[0], &num_bytes, nullptr, |
- nullptr, 0)); |
- EXPECT_EQ(should_be_ok, std::string("OK")); |
-} |
- |
-void WriteOK(mojo::MessagePipeHandle pipe) { |
- std::string ok("OK"); |
- CHECK_EQ(MOJO_RESULT_OK, |
- mojo::WriteMessageRaw(pipe, &ok[0], static_cast<uint32_t>(ok.size()), |
- nullptr, 0, 0)); |
-} |
- |
-class ListenerThatExpectsMessagePipeUsingParamTrait : public IPC::Listener { |
- public: |
- explicit ListenerThatExpectsMessagePipeUsingParamTrait(bool receiving_valid) |
- : sender_(NULL), receiving_valid_(receiving_valid) {} |
- |
- ~ListenerThatExpectsMessagePipeUsingParamTrait() override {} |
- |
- bool OnMessageReceived(const IPC::Message& message) override { |
- PickleIterator iter(message); |
- mojo::MessagePipeHandle handle; |
- EXPECT_TRUE(IPC::ParamTraits<mojo::MessagePipeHandle>::Read(&message, &iter, |
- &handle)); |
- EXPECT_EQ(handle.is_valid(), receiving_valid_); |
- if (receiving_valid_) { |
- ReadOK(handle); |
- MojoClose(handle.value()); |
- } |
- |
- base::MessageLoop::current()->Quit(); |
- ListenerThatExpectsOK::SendOK(sender_); |
- return true; |
- } |
- |
- void OnChannelError() override { NOTREACHED(); } |
- void set_sender(IPC::Sender* sender) { sender_ = sender; } |
- |
- private: |
- IPC::Sender* sender_; |
- bool receiving_valid_; |
-}; |
- |
-void ParamTraitMessagePipeClient(bool receiving_valid_handle, |
- const char* channel_name) { |
- ListenerThatExpectsMessagePipeUsingParamTrait listener( |
- receiving_valid_handle); |
- ChannelClient client(&listener, channel_name); |
- client.Connect(); |
- listener.set_sender(client.channel()); |
- |
- base::MessageLoop::current()->Run(); |
- |
- client.Close(); |
-} |
- |
-TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) { |
- InitWithMojo("ParamTraitValidMessagePipeClient"); |
- |
- ListenerThatExpectsOK listener; |
- CreateChannel(&listener); |
- ASSERT_TRUE(ConnectChannel()); |
- ASSERT_TRUE(StartClient()); |
- |
- TestingMessagePipe pipe; |
- |
- scoped_ptr<IPC::Message> message(new IPC::Message()); |
- IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
- pipe.peer.release()); |
- WriteOK(pipe.self.get()); |
- |
- this->channel()->Send(message.release()); |
- base::MessageLoop::current()->Run(); |
- this->channel()->Close(); |
- |
- EXPECT_TRUE(WaitForClientShutdown()); |
- DestroyChannel(); |
-} |
- |
-MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitValidMessagePipeClient) { |
- ParamTraitMessagePipeClient(true, "ParamTraitValidMessagePipeClient"); |
- return 0; |
-} |
- |
-TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) { |
- InitWithMojo("ParamTraitInvalidMessagePipeClient"); |
- |
- ListenerThatExpectsOK listener; |
- CreateChannel(&listener); |
- ASSERT_TRUE(ConnectChannel()); |
- ASSERT_TRUE(StartClient()); |
- |
- mojo::MessagePipeHandle invalid_handle; |
- scoped_ptr<IPC::Message> message(new IPC::Message()); |
- IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(), |
- invalid_handle); |
- |
- this->channel()->Send(message.release()); |
- base::MessageLoop::current()->Run(); |
- this->channel()->Close(); |
- |
- EXPECT_TRUE(WaitForClientShutdown()); |
- DestroyChannel(); |
-} |
- |
-MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ParamTraitInvalidMessagePipeClient) { |
- ParamTraitMessagePipeClient(false, "ParamTraitInvalidMessagePipeClient"); |
- return 0; |
-} |
- |
#if defined(OS_WIN) |
class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { |
protected: |