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 556e65accf59f03ac867f8cd4d11dcc6bc41da12..2cdb70afe705d6cd031ab46845e278b21482e31d 100644 |
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc |
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc |
@@ -9,6 +9,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/path_service.h" |
#include "base/pickle.h" |
+#include "base/test/test_timeouts.h" |
#include "base/threading/thread.h" |
#include "ipc/ipc_message.h" |
#include "ipc/ipc_test_base.h" |
@@ -578,4 +579,54 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN( |
#endif |
+#if defined(OS_LINUX) |
+ |
+const base::ProcessId kMagicChildId = 54321; |
+ |
+class ListenerThatVerifiesPeerPid : public IPC::Listener { |
+ public: |
+ ListenerThatVerifiesPeerPid() {} |
agl
2015/02/25 02:45:29
Won't the compiler synthesise the empty constructo
Hajime Morrita
2015/02/25 19:13:06
It should. removed.
|
+ ~ListenerThatVerifiesPeerPid() override {} |
+ |
+ void OnChannelConnected(int32 peer_pid) override { |
+ EXPECT_EQ(peer_pid, kMagicChildId); |
+ base::MessageLoop::current()->Quit(); |
+ } |
+ |
+ bool OnMessageReceived(const IPC::Message& message) override { |
+ NOTREACHED(); |
+ return true; |
+ } |
+ |
agl
2015/02/25 02:45:29
remove blank line.
Hajime Morrita
2015/02/25 19:13:05
Done.
|
+}; |
+ |
+TEST_F(IPCChannelMojoTest, VerifyGlobalPid) { |
+ Init("IPCChannelMojoTestVerifyGlobalPidClient"); |
+ |
+ ListenerThatVerifiesPeerPid listener; |
+ CreateChannel(&listener); |
+ ASSERT_TRUE(ConnectChannel()); |
+ ASSERT_TRUE(StartClient()); |
+ |
+ base::MessageLoop::current()->Run(); |
+ this->channel()->Close(); |
+ |
+ EXPECT_TRUE(WaitForClientShutdown()); |
+ DestroyChannel(); |
+} |
+ |
+MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestVerifyGlobalPidClient) { |
+ IPC::Channel::SetGlobalPid(kMagicChildId); |
+ ListenerThatQuits listener; |
+ ChannelClient client(&listener, |
+ "IPCChannelMojoTestVerifyGlobalPidClient"); |
+ client.Connect(); |
+ |
+ base::MessageLoop::current()->Run(); |
+ |
+ return 0; |
+} |
+ |
+#endif |
agl
2015/02/25 02:45:29
" // OS_LINUX" at the end of the line.
Hajime Morrita
2015/02/25 19:13:06
Done.
|
+ |
} // namespace |