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

Side by Side Diff: net/base/address_list_unittest.cc

Issue 149511: Refactorings surrounding HostResolver:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Merge in socks5_client_socket_unittest.cc Created 11 years, 5 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 | « chrome/test/unit/chrome_test_suite.h ('k') | net/base/host_resolver.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/address_list.h" 5 #include "net/base/address_list.h"
6 6
7 #if defined(OS_WIN)
8 #include <ws2tcpip.h>
9 #include <wspiapi.h> // Needed for Win2k compat.
10 #elif defined(OS_POSIX)
11 #include <netdb.h>
12 #include <sys/socket.h>
13 #endif
14
15 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "net/base/host_resolver_proc.h"
16 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
17 #if defined(OS_WIN) 10 #if defined(OS_WIN)
18 #include "net/base/winsock_init.h" 11 #include "net/base/winsock_init.h"
19 #endif 12 #endif
20 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
21 14
22 namespace { 15 namespace {
23 16
24 // Use getaddrinfo() to allocate an addrinfo structure. 17 // Use getaddrinfo() to allocate an addrinfo structure.
25 void CreateAddressList(net::AddressList* addrlist, int port) { 18 void CreateAddressList(net::AddressList* addrlist, int port) {
26 #if defined(OS_WIN) 19 #if defined(OS_WIN)
27 net::EnsureWinsockInit(); 20 net::EnsureWinsockInit();
28 #endif 21 #endif
29 std::string portstr = IntToString(port); 22 int rv = SystemHostResolverProc("192.168.1.1", addrlist);
30 23 EXPECT_EQ(0, rv);
31 struct addrinfo* result = NULL; 24 addrlist->SetPort(port);
32 struct addrinfo hints = {0};
33 hints.ai_family = AF_UNSPEC;
34 hints.ai_flags = AI_NUMERICHOST;
35 hints.ai_socktype = SOCK_STREAM;
36
37 int err = getaddrinfo("192.168.1.1", portstr.c_str(), &hints, &result);
38 EXPECT_EQ(0, err);
39 addrlist->Adopt(result);
40 } 25 }
41 26
42 TEST(AddressListTest, GetPort) { 27 TEST(AddressListTest, GetPort) {
43 net::AddressList addrlist; 28 net::AddressList addrlist;
44 CreateAddressList(&addrlist, 81); 29 CreateAddressList(&addrlist, 81);
45 EXPECT_EQ(81, addrlist.GetPort()); 30 EXPECT_EQ(81, addrlist.GetPort());
46 31
47 addrlist.SetPort(83); 32 addrlist.SetPort(83);
48 EXPECT_EQ(83, addrlist.GetPort()); 33 EXPECT_EQ(83, addrlist.GetPort());
49 } 34 }
(...skipping 27 matching lines...) Expand all
77 62
78 // Changes to addrlist1 are not reflected in addrlist2. 63 // Changes to addrlist1 are not reflected in addrlist2.
79 addrlist1.SetPort(70); 64 addrlist1.SetPort(70);
80 addrlist2.SetPort(90); 65 addrlist2.SetPort(90);
81 66
82 EXPECT_EQ(70, addrlist1.GetPort()); 67 EXPECT_EQ(70, addrlist1.GetPort());
83 EXPECT_EQ(90, addrlist2.GetPort()); 68 EXPECT_EQ(90, addrlist2.GetPort());
84 } 69 }
85 70
86 } // namespace 71 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/unit/chrome_test_suite.h ('k') | net/base/host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698