summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_posix_unittest.cc
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 06:15:53 +0000
committermorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 06:15:53 +0000
commit5210d592110f837ea556551f4bf480a1c0ba97ef (patch)
tree65d85019008680d3e188774f4e1a0b7035a01653 /ipc/ipc_channel_posix_unittest.cc
parent231f7a25d46e825262d843203c2208aa888bf612 (diff)
downloadchromium_src-5210d592110f837ea556551f4bf480a1c0ba97ef.zip
chromium_src-5210d592110f837ea556551f4bf480a1c0ba97ef.tar.gz
chromium_src-5210d592110f837ea556551f4bf480a1c0ba97ef.tar.bz2
IPC::Channel: Reduce POSIX specific API surface
This change is a simple cleanup: It removes some Channel API that is only used only in POSIX specific tests. These funtions still live in ChannelPosix. POSIX speicific tests now touch ChannelPosix instead of its superclass Channel. TEST=none R=darin@chromium.org, jam@chromium.org BUG=377980 Review URL: https://codereview.chromium.org/320433002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_posix_unittest.cc')
-rw-r--r--ipc/ipc_channel_posix_unittest.cc69
1 files changed, 35 insertions, 34 deletions
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index be43b2a..a4b4f8d 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -204,8 +204,8 @@ TEST_F(IPCChannelPosixTest, BasicListen) {
IPC::ChannelHandle handle(kChannelName);
SetUpSocket(&handle, IPC::Channel::MODE_NAMED_SERVER);
unlink(handle.name.c_str());
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(handle, NULL));
+ scoped_ptr<IPC::ChannelPosix> channel(
+ new IPC::ChannelPosix(handle, IPC::Channel::MODE_NAMED_SERVER, NULL));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -222,7 +222,8 @@ TEST_F(IPCChannelPosixTest, BasicConnected) {
base::FileDescriptor fd(pipe_fds[0], false);
IPC::ChannelHandle handle(socket_name, fd);
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateServer(handle, NULL));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ handle, IPC::Channel::MODE_SERVER, NULL));
ASSERT_TRUE(channel->Connect());
ASSERT_FALSE(channel->AcceptsConnections());
channel->Close();
@@ -230,8 +231,8 @@ TEST_F(IPCChannelPosixTest, BasicConnected) {
// Make sure that we can use the socket that is created for us by
// a standard channel.
- scoped_ptr<IPC::Channel> channel2(
- IPC::Channel::CreateServer(socket_name, NULL));
+ scoped_ptr<IPC::ChannelPosix> channel2(new IPC::ChannelPosix(
+ socket_name, IPC::Channel::MODE_SERVER, NULL));
ASSERT_TRUE(channel2->Connect());
ASSERT_FALSE(channel2->AcceptsConnections());
}
@@ -243,13 +244,13 @@ TEST_F(IPCChannelPosixTest, SendHangTest) {
IPCChannelPosixTestListener out_listener(true);
IPCChannelPosixTestListener in_listener(true);
IPC::ChannelHandle in_handle("IN");
- scoped_ptr<IPC::Channel> in_chan(
- IPC::Channel::CreateServer(in_handle, &in_listener));
+ scoped_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
+ in_handle, IPC::Channel::MODE_SERVER, &in_listener));
base::FileDescriptor out_fd(
in_chan->TakeClientFileDescriptor(), false);
IPC::ChannelHandle out_handle("OUT", out_fd);
- scoped_ptr<IPC::Channel> out_chan(
- IPC::Channel::CreateClient(out_handle, &out_listener));
+ scoped_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
+ out_handle, IPC::Channel::MODE_CLIENT, &out_listener));
ASSERT_TRUE(in_chan->Connect());
ASSERT_TRUE(out_chan->Connect());
in_chan->Close(); // simulate remote process dying at an unfortunate time.
@@ -269,13 +270,13 @@ TEST_F(IPCChannelPosixTest, AcceptHangTest) {
IPCChannelPosixTestListener out_listener(true);
IPCChannelPosixTestListener in_listener(true);
IPC::ChannelHandle in_handle("IN");
- scoped_ptr<IPC::Channel> in_chan(
- IPC::Channel::CreateServer(in_handle, &in_listener));
+ scoped_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
+ in_handle, IPC::Channel::MODE_SERVER, &in_listener));
base::FileDescriptor out_fd(
in_chan->TakeClientFileDescriptor(), false);
IPC::ChannelHandle out_handle("OUT", out_fd);
- scoped_ptr<IPC::Channel> out_chan(
- IPC::Channel::CreateClient(out_handle, &out_listener));
+ scoped_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
+ out_handle, IPC::Channel::MODE_CLIENT, &out_listener));
ASSERT_TRUE(in_chan->Connect());
in_chan->Close(); // simulate remote process dying at an unfortunate time.
ASSERT_FALSE(out_chan->Connect());
@@ -288,8 +289,8 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) {
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(chan_handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -318,8 +319,8 @@ TEST_F(IPCChannelPosixTest, ResetState) {
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(chan_handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -353,8 +354,8 @@ TEST_F(IPCChannelPosixTest, ResetState) {
TEST_F(IPCChannelPosixTest, BadChannelName) {
// Test empty name
IPC::ChannelHandle handle("");
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(handle, NULL));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ handle, IPC::Channel::MODE_NAMED_SERVER, NULL));
ASSERT_FALSE(channel->Connect());
// Test name that is too long.
@@ -367,8 +368,8 @@ TEST_F(IPCChannelPosixTest, BadChannelName) {
"leading-edge_processes";
EXPECT_GE(strlen(kTooLongName), IPC::kMaxSocketNameLength);
IPC::ChannelHandle handle2(kTooLongName);
- scoped_ptr<IPC::Channel> channel2(
- IPC::Channel::CreateNamedServer(handle2, NULL));
+ scoped_ptr<IPC::ChannelPosix> channel2(new IPC::ChannelPosix(
+ handle2, IPC::Channel::MODE_NAMED_SERVER, NULL));
EXPECT_FALSE(channel2->Connect());
}
@@ -378,8 +379,8 @@ TEST_F(IPCChannelPosixTest, MultiConnection) {
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(chan_handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -413,10 +414,10 @@ TEST_F(IPCChannelPosixTest, DoubleServer) {
IPCChannelPosixTestListener listener(false);
IPCChannelPosixTestListener listener2(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateServer(chan_handle, &listener));
- scoped_ptr<IPC::Channel> channel2(
- IPC::Channel::CreateServer(chan_handle, &listener2));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_SERVER, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel2(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_SERVER, &listener2));
ASSERT_TRUE(channel->Connect());
ASSERT_FALSE(channel2->Connect());
}
@@ -425,7 +426,7 @@ TEST_F(IPCChannelPosixTest, BadMode) {
// Test setting up two servers with a bad mode.
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
- scoped_ptr<IPC::Channel> channel(IPC::Channel::Create(
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_NONE, &listener));
ASSERT_FALSE(channel->Connect());
}
@@ -437,8 +438,8 @@ TEST_F(IPCChannelPosixTest, IsNamedServerInitialized) {
ASSERT_TRUE(base::DeleteFile(base::FilePath(connection_socket_name), false));
ASSERT_FALSE(IPC::Channel::IsNamedServerInitialized(
connection_socket_name));
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedServer(chan_handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(
connection_socket_name));
channel->Close();
@@ -452,8 +453,8 @@ MULTIPROCESS_TEST_MAIN(IPCChannelPosixTestConnectionProc) {
IPCChannelPosixTestListener listener(true);
IPC::ChannelHandle handle(IPCChannelPosixTest::GetConnectionSocketName());
IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT);
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedClient(handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ handle, IPC::Channel::MODE_NAMED_CLIENT, &listener));
EXPECT_TRUE(channel->Connect());
IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout());
EXPECT_EQ(IPCChannelPosixTestListener::MESSAGE_RECEIVED, listener.status());
@@ -466,8 +467,8 @@ MULTIPROCESS_TEST_MAIN(IPCChannelPosixFailConnectionProc) {
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle handle(IPCChannelPosixTest::GetConnectionSocketName());
IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT);
- scoped_ptr<IPC::Channel> channel(
- IPC::Channel::CreateNamedClient(handle, &listener));
+ scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ handle, IPC::Channel::MODE_NAMED_CLIENT, &listener));
// In this case connect may succeed or fail depending on if the packet
// actually gets sent at sendmsg. Since we never delay on send, we may not