There are times on the Mac when pipe names of 0 length may occur. Let the caller handle
the error instead of aborting here.

BUG=75518
TEST=BUILD

Review URL: http://codereview.chromium.org/7743001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98225 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 3c52425b21e996264a0302e45fc75e623a029e12
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index 14ecc60..9d9c70a 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -281,6 +281,26 @@
   ASSERT_FALSE(channel.HasAcceptedConnection());
 }
 
+TEST_F(IPCChannelPosixTest, BadChannelName) {
+  // Test empty name
+  IPC::ChannelHandle handle("");
+  IPC::Channel channel(handle, IPC::Channel::MODE_NAMED_SERVER, NULL);
+  ASSERT_FALSE(channel.Connect());
+
+  // Test name that is too long.
+  const char *kTooLongName = "This_is_a_very_long_name_to_proactively_implement"
+                             "client-centered_synergy_through_top-line"
+                             "platforms_Phosfluorescently_disintermediate_"
+                             "clicks-and-mortar_best_practices_without_"
+                             "future-proof_growth_strategies_Continually"
+                             "pontificate_proactive_potentialities_before"
+                             "leading-edge_processes";
+  EXPECT_GE(strlen(kTooLongName), IPC::kMaxPipeNameLength);
+  IPC::ChannelHandle handle2(kTooLongName);
+  IPC::Channel channel2(handle2, IPC::Channel::MODE_NAMED_SERVER, NULL);
+  EXPECT_FALSE(channel2.Connect());
+}
+
 TEST_F(IPCChannelPosixTest, MultiConnection) {
   // Test setting up a connection to an external process, and then have
   // another external process attempt to connect to us.