Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Unified Diff: mojo/shell/incoming_connection_listener_unittest.cc

Issue 611833005: Force creation of application listening socket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flag
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/incoming_connection_listener_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « mojo/shell/incoming_connection_listener_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698