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

Side by Side Diff: net/socket/tcp_server_socket_unittest.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/tcp_server_socket_libevent.cc ('k') | net/socket/tcp_server_socket_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/socket/tcp_server_socket.h" 5 #include "net/socket/tcp_server_socket.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "net/base/address_list.h" 13 #include "net/base/address_list.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/ip_endpoint.h" 15 #include "net/base/ip_endpoint.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/sys_addrinfo.h"
18 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
19 #include "net/socket/tcp_client_socket.h" 18 #include "net/socket/tcp_client_socket.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
22 21
23 namespace net { 22 namespace net {
24 23
25 namespace { 24 namespace {
26 const int kListenBacklog = 5; 25 const int kListenBacklog = 5;
27 26
(...skipping 27 matching lines...) Expand all
55 IPAddressNumber ip_number; 54 IPAddressNumber ip_number;
56 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); 55 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number);
57 if (!rv) 56 if (!rv)
58 return; 57 return;
59 *address = IPEndPoint(ip_number, port); 58 *address = IPEndPoint(ip_number, port);
60 } 59 }
61 60
62 static IPEndPoint GetPeerAddress(StreamSocket* socket) { 61 static IPEndPoint GetPeerAddress(StreamSocket* socket) {
63 AddressList address; 62 AddressList address;
64 EXPECT_EQ(OK, socket->GetPeerAddress(&address)); 63 EXPECT_EQ(OK, socket->GetPeerAddress(&address));
65 IPEndPoint endpoint; 64 return address.front();
66 EXPECT_TRUE(endpoint.FromSockAddr(
67 address.head()->ai_addr, address.head()->ai_addrlen));
68 return endpoint;
69 } 65 }
70 66
71 AddressList local_address_list() const { 67 AddressList local_address_list() const {
72 return AddressList::CreateFromIPAddress( 68 return AddressList(local_address_);
73 local_address_.address(), local_address_.port());
74 } 69 }
75 70
76 TCPServerSocket socket_; 71 TCPServerSocket socket_;
77 IPEndPoint local_address_; 72 IPEndPoint local_address_;
78 }; 73 };
79 74
80 TEST_F(TCPServerSocketTest, Accept) { 75 TEST_F(TCPServerSocketTest, Accept) {
81 ASSERT_NO_FATAL_FAILURE(SetUpIPv4()); 76 ASSERT_NO_FATAL_FAILURE(SetUpIPv4());
82 77
83 TestCompletionCallback connect_callback; 78 TestCompletionCallback connect_callback;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bytes_read += read_result; 244 bytes_read += read_result;
250 } 245 }
251 246
252 std::string received_message(buffer.begin(), buffer.end()); 247 std::string received_message(buffer.begin(), buffer.end());
253 ASSERT_EQ(message, received_message); 248 ASSERT_EQ(message, received_message);
254 } 249 }
255 250
256 } // namespace 251 } // namespace
257 252
258 } // namespace net 253 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_server_socket_libevent.cc ('k') | net/socket/tcp_server_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698