| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/udp/udp_client_socket.h" | 5 #include "net/udp/udp_client_socket.h" |
| 6 #include "net/udp/udp_server_socket.h" | 6 #include "net/udp/udp_server_socket.h" |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 *address = IPEndPoint(ip_number, port); | 125 *address = IPEndPoint(ip_number, port); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST_F(UDPSocketTest, Connect) { | 128 TEST_F(UDPSocketTest, Connect) { |
| 129 const int kPort = 9999; | 129 const int kPort = 9999; |
| 130 std::string simple_message("hello world!"); | 130 std::string simple_message("hello world!"); |
| 131 | 131 |
| 132 // Setup the server to listen. | 132 // Setup the server to listen. |
| 133 IPEndPoint bind_address; | 133 IPEndPoint bind_address; |
| 134 CreateUDPAddress("0.0.0.0", kPort, &bind_address); | 134 CreateUDPAddress("0.0.0.0", kPort, &bind_address); |
| 135 CapturingNetLog server_log(CapturingNetLog::kUnbounded); | 135 CapturingNetLog server_log; |
| 136 scoped_ptr<UDPServerSocket> server( | 136 scoped_ptr<UDPServerSocket> server( |
| 137 new UDPServerSocket(&server_log, NetLog::Source())); | 137 new UDPServerSocket(&server_log, NetLog::Source())); |
| 138 int rv = server->Listen(bind_address); | 138 int rv = server->Listen(bind_address); |
| 139 EXPECT_EQ(OK, rv); | 139 EXPECT_EQ(OK, rv); |
| 140 | 140 |
| 141 // Setup the client. | 141 // Setup the client. |
| 142 IPEndPoint server_address; | 142 IPEndPoint server_address; |
| 143 CreateUDPAddress("127.0.0.1", kPort, &server_address); | 143 CreateUDPAddress("127.0.0.1", kPort, &server_address); |
| 144 CapturingNetLog client_log(CapturingNetLog::kUnbounded); | 144 CapturingNetLog client_log; |
| 145 scoped_ptr<UDPClientSocket> client( | 145 scoped_ptr<UDPClientSocket> client( |
| 146 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, | 146 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, |
| 147 RandIntCallback(), | 147 RandIntCallback(), |
| 148 &client_log, | 148 &client_log, |
| 149 NetLog::Source())); | 149 NetLog::Source())); |
| 150 rv = client->Connect(server_address); | 150 rv = client->Connect(server_address); |
| 151 EXPECT_EQ(OK, rv); | 151 EXPECT_EQ(OK, rv); |
| 152 | 152 |
| 153 // Client sends to the server. | 153 // Client sends to the server. |
| 154 rv = WriteSocket(client.get(), simple_message); | 154 rv = WriteSocket(client.get(), simple_message); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 EXPECT_EQ(rv, ERR_IO_PENDING); | 439 EXPECT_EQ(rv, ERR_IO_PENDING); |
| 440 | 440 |
| 441 server.Close(); | 441 server.Close(); |
| 442 | 442 |
| 443 EXPECT_FALSE(callback.have_result()); | 443 EXPECT_FALSE(callback.have_result()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace | 446 } // namespace |
| 447 | 447 |
| 448 } // namespace net | 448 } // namespace net |
| OLD | NEW |