| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/listen_socket_unittest.h" | 5 #include "net/base/listen_socket_unittest.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/eintr_wrapper.h" | 9 #include "base/eintr_wrapper.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 loop_->PostTask(FROM_HERE, NewRunnableMethod( | 47 loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 48 this, &ListenSocketTester::Listen)); | 48 this, &ListenSocketTester::Listen)); |
| 49 | 49 |
| 50 // verify Listen succeeded | 50 // verify Listen succeeded |
| 51 ASSERT_TRUE(NextAction(kDefaultTimeoutMs)); | 51 ASSERT_TRUE(NextAction(kDefaultTimeoutMs)); |
| 52 ASSERT_FALSE(server_ == NULL); | 52 ASSERT_FALSE(server_ == NULL); |
| 53 ASSERT_EQ(ACTION_LISTEN, last_action_.type()); | 53 ASSERT_EQ(ACTION_LISTEN, last_action_.type()); |
| 54 | 54 |
| 55 // verify the connect/accept and setup test_socket_ | 55 // verify the connect/accept and setup test_socket_ |
| 56 test_socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | 56 test_socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
| 57 ASSERT_NE(INVALID_SOCKET, test_socket_); | 57 ASSERT_NE(-1, test_socket_); |
| 58 struct sockaddr_in client; | 58 struct sockaddr_in client; |
| 59 client.sin_family = AF_INET; | 59 client.sin_family = AF_INET; |
| 60 client.sin_addr.s_addr = inet_addr(kLoopback); | 60 client.sin_addr.s_addr = inet_addr(kLoopback); |
| 61 client.sin_port = htons(kTestPort); | 61 client.sin_port = htons(kTestPort); |
| 62 int ret = | 62 int ret = |
| 63 HANDLE_EINTR(connect(test_socket_, reinterpret_cast<sockaddr*>(&client), | 63 HANDLE_EINTR(connect(test_socket_, reinterpret_cast<sockaddr*>(&client), |
| 64 sizeof(client))); | 64 sizeof(client))); |
| 65 ASSERT_NE(ret, SOCKET_ERROR); | 65 ASSERT_NE(ret, SOCKET_ERROR); |
| 66 | 66 |
| 67 net::SetNonBlocking(test_socket_); | 67 net::SetNonBlocking(test_socket_); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 tester_->TestClientSend(); | 313 tester_->TestClientSend(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 TEST_F(ListenSocketTest, ClientSendLong) { | 316 TEST_F(ListenSocketTest, ClientSendLong) { |
| 317 tester_->TestClientSendLong(); | 317 tester_->TestClientSendLong(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 TEST_F(ListenSocketTest, ServerSend) { | 320 TEST_F(ListenSocketTest, ServerSend) { |
| 321 tester_->TestServerSend(); | 321 tester_->TestServerSend(); |
| 322 } | 322 } |
| OLD | NEW |