| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/socket/unix_domain_server_socket_posix.h" | 5 #include "net/socket/unix_domain_server_socket_posix.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 kUseAbstractNamespace); | 64 kUseAbstractNamespace); |
| 65 #if defined(OS_ANDROID) || defined(OS_LINUX) | 65 #if defined(OS_ANDROID) || defined(OS_LINUX) |
| 66 EXPECT_EQ(OK, | 66 EXPECT_EQ(OK, |
| 67 server_socket.ListenWithAddressAndPort(kInvalidSocketPath, 0, 1)); | 67 server_socket.ListenWithAddressAndPort(kInvalidSocketPath, 0, 1)); |
| 68 #else | 68 #else |
| 69 EXPECT_EQ(ERR_ADDRESS_INVALID, | 69 EXPECT_EQ(ERR_ADDRESS_INVALID, |
| 70 server_socket.ListenWithAddressAndPort(kInvalidSocketPath, 0, 1)); | 70 server_socket.ListenWithAddressAndPort(kInvalidSocketPath, 0, 1)); |
| 71 #endif | 71 #endif |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST_F(UnixDomainServerSocketTest, ListenAgainAfterFailureWithInvalidPath) { |
| 75 const bool kUseAbstractNamespace = false; |
| 76 UnixDomainServerSocket server_socket(CreateAuthCallback(true), |
| 77 kUseAbstractNamespace); |
| 78 EXPECT_EQ(ERR_FILE_NOT_FOUND, |
| 79 server_socket.ListenWithAddressAndPort(kInvalidSocketPath, 0, 1)); |
| 80 EXPECT_EQ(OK, server_socket.ListenWithAddressAndPort(socket_path_, 0, 1)); |
| 81 } |
| 82 |
| 74 TEST_F(UnixDomainServerSocketTest, AcceptWithForbiddenUser) { | 83 TEST_F(UnixDomainServerSocketTest, AcceptWithForbiddenUser) { |
| 75 const bool kUseAbstractNamespace = false; | 84 const bool kUseAbstractNamespace = false; |
| 76 | 85 |
| 77 UnixDomainServerSocket server_socket(CreateAuthCallback(false), | 86 UnixDomainServerSocket server_socket(CreateAuthCallback(false), |
| 78 kUseAbstractNamespace); | 87 kUseAbstractNamespace); |
| 79 EXPECT_EQ(OK, server_socket.ListenWithAddressAndPort(socket_path_, 0, 1)); | 88 EXPECT_EQ(OK, server_socket.ListenWithAddressAndPort(socket_path_, 0, 1)); |
| 80 | 89 |
| 81 scoped_ptr<StreamSocket> accepted_socket; | 90 scoped_ptr<StreamSocket> accepted_socket; |
| 82 TestCompletionCallback accept_callback; | 91 TestCompletionCallback accept_callback; |
| 83 EXPECT_EQ(ERR_IO_PENDING, | 92 EXPECT_EQ(ERR_IO_PENDING, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 107 // The server socket should not have called |accept_callback| or modified | 116 // The server socket should not have called |accept_callback| or modified |
| 108 // |accepted_socket|. | 117 // |accepted_socket|. |
| 109 EXPECT_FALSE(accept_callback.have_result()); | 118 EXPECT_FALSE(accept_callback.have_result()); |
| 110 EXPECT_FALSE(accepted_socket); | 119 EXPECT_FALSE(accepted_socket); |
| 111 } | 120 } |
| 112 | 121 |
| 113 // Normal cases including read/write are tested by UnixDomainClientSocketTest. | 122 // Normal cases including read/write are tested by UnixDomainClientSocketTest. |
| 114 | 123 |
| 115 } // namespace | 124 } // namespace |
| 116 } // namespace net | 125 } // namespace net |
| OLD | NEW |