| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // These tests are POSIX only. | 5 // These tests are POSIX only. |
| 6 | 6 |
| 7 #include "ipc/ipc_channel_posix.h" | 7 #include "ipc/ipc_channel_posix.h" |
| 8 | 8 |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds)); | 212 ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds)); |
| 213 std::string socket_name("/var/tmp/IPCChannelPosixTest_BasicConnected"); | 213 std::string socket_name("/var/tmp/IPCChannelPosixTest_BasicConnected"); |
| 214 ASSERT_GE(fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK), 0); | 214 ASSERT_GE(fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK), 0); |
| 215 | 215 |
| 216 base::FileDescriptor fd(pipe_fds[0], false); | 216 base::FileDescriptor fd(pipe_fds[0], false); |
| 217 IPC::ChannelHandle handle(socket_name, fd); | 217 IPC::ChannelHandle handle(socket_name, fd); |
| 218 IPC::Channel channel(handle, IPC::Channel::MODE_SERVER, NULL); | 218 IPC::Channel channel(handle, IPC::Channel::MODE_SERVER, NULL); |
| 219 ASSERT_TRUE(channel.Connect()); | 219 ASSERT_TRUE(channel.Connect()); |
| 220 ASSERT_FALSE(channel.AcceptsConnections()); | 220 ASSERT_FALSE(channel.AcceptsConnections()); |
| 221 channel.Close(); | 221 channel.Close(); |
| 222 ASSERT_TRUE(HANDLE_EINTR(close(pipe_fds[1])) == 0); | 222 ASSERT_TRUE(IGNORE_EINTR(close(pipe_fds[1])) == 0); |
| 223 | 223 |
| 224 // Make sure that we can use the socket that is created for us by | 224 // Make sure that we can use the socket that is created for us by |
| 225 // a standard channel. | 225 // a standard channel. |
| 226 IPC::Channel channel2(socket_name, IPC::Channel::MODE_SERVER, NULL); | 226 IPC::Channel channel2(socket_name, IPC::Channel::MODE_SERVER, NULL); |
| 227 ASSERT_TRUE(channel2.Connect()); | 227 ASSERT_TRUE(channel2.Connect()); |
| 228 ASSERT_FALSE(channel2.AcceptsConnections()); | 228 ASSERT_FALSE(channel2.AcceptsConnections()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 TEST_F(IPCChannelPosixTest, AdvancedConnected) { | 231 TEST_F(IPCChannelPosixTest, AdvancedConnected) { |
| 232 // Test creating a connection to an external process. | 232 // Test creating a connection to an external process. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (connected) { | 417 if (connected) { |
| 418 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); | 418 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); |
| 419 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 419 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
| 420 } else { | 420 } else { |
| 421 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 421 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
| 422 } | 422 } |
| 423 return 0; | 423 return 0; |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace | 426 } // namespace |
| OLD | NEW |