Index: mojo/shell/incoming_connection_listener_unittest.cc |
diff --git a/mojo/shell/incoming_connection_listener_unittest.cc b/mojo/shell/incoming_connection_listener_unittest.cc |
index c8b660a3ad627259344eb3e7d004c07139119db8..64f3622e6923a8bf0d9e2b8cd4b4c0a38544e14e 100644 |
--- a/mojo/shell/incoming_connection_listener_unittest.cc |
+++ b/mojo/shell/incoming_connection_listener_unittest.cc |
@@ -99,15 +99,40 @@ TEST_F(IncomingConnectionListenerTest, ConnectSuccess) { |
run_loop_.Run(); |
} |
-TEST_F(IncomingConnectionListenerTest, ConnectFails_SocketFileExists) { |
+TEST_F(IncomingConnectionListenerTest, ConnectSuccess_SocketFileExists) { |
+ TestDelegate delegate; |
+ IncomingConnectionListenerPosix listener(socket_path_, &delegate); |
+ |
+ ASSERT_EQ(1, base::WriteFile(socket_path_, "1", 1)); |
+ ASSERT_TRUE(base::PathExists(socket_path_)); |
+ listener.StartListening(); |
+ |
+ ExternalApplicationRegistrarConnection connection(socket_path_); |
+ connection.Connect(base::Bind(&OnConnect, run_loop_.QuitClosure())); |
+ |
+ run_loop_.Run(); |
+} |
+ |
+TEST_F(IncomingConnectionListenerTest, ConnectFails_SocketFileUndeletable) { |
ListeningFailsDelegate fail_delegate(net::ERR_FILE_EXISTS); |
IncomingConnectionListenerPosix listener(socket_path_, &fail_delegate); |
+ // Create the socket file. |
ASSERT_EQ(1, base::WriteFile(socket_path_, "1", 1)); |
ASSERT_TRUE(base::PathExists(socket_path_)); |
+ // Render it undeletable, but in a way that the test harness can recover |
+ // later. |
+ int temp_dir_perms = 0; |
+ ASSERT_TRUE(base::GetPosixFilePermissions(temp_dir_.path(), &temp_dir_perms)); |
+ ASSERT_TRUE( |
+ base::SetPosixFilePermissions(temp_dir_.path(), |
+ base::FILE_PERMISSION_READ_BY_USER | |
+ base::FILE_PERMISSION_WRITE_BY_USER)); |
// The listener should fail to start up. |
listener.StartListening(); |
+ |
+ ASSERT_TRUE(base::SetPosixFilePermissions(temp_dir_.path(), temp_dir_perms)); |
} |
TEST_F(IncomingConnectionListenerTest, ConnectFails_SocketDirNonexistent) { |