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

Side by Side Diff: src/net/base/host_resolver_impl_unittest.cc

Issue 7046011: Merge 84251, 85083, 85188, 85375, 77501. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/696/
Patch Set: Created 9 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 | « src/net/base/address_list.cc ('k') | src/net/base/mock_host_resolver.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 } 1658 }
1659 1659
1660 TEST_F(HostResolverImplTest, DisallowNonCachedResponses) { 1660 TEST_F(HostResolverImplTest, DisallowNonCachedResponses) {
1661 AddressList addrlist; 1661 AddressList addrlist;
1662 const int kPortnum = 80; 1662 const int kPortnum = 80;
1663 1663
1664 scoped_refptr<RuleBasedHostResolverProc> resolver_proc( 1664 scoped_refptr<RuleBasedHostResolverProc> resolver_proc(
1665 new RuleBasedHostResolverProc(NULL)); 1665 new RuleBasedHostResolverProc(NULL));
1666 resolver_proc->AddRule("just.testing", "192.168.1.42"); 1666 resolver_proc->AddRule("just.testing", "192.168.1.42");
1667 1667
1668 scoped_ptr<HostResolver> host_resolver( 1668 scoped_ptr<HostResolver> host_resolver(
1669 CreateHostResolverImpl(resolver_proc)); 1669 CreateHostResolverImpl(resolver_proc));
1670 1670
1671 // First hit will miss the cache. 1671 // First hit will miss the cache.
1672 HostResolver::RequestInfo info(HostPortPair("just.testing", kPortnum)); 1672 HostResolver::RequestInfo info(HostPortPair("just.testing", kPortnum));
1673 info.set_only_use_cached_response(true); 1673 info.set_only_use_cached_response(true);
1674 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); 1674 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
1675 int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); 1675 int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound());
1676 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, err); 1676 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, err);
1677 1677
1678 // This time, we fetch normally. 1678 // This time, we fetch normally.
1679 info.set_only_use_cached_response(false); 1679 info.set_only_use_cached_response(false);
1680 err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); 1680 err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound());
1681 EXPECT_EQ(OK, err); 1681 EXPECT_EQ(OK, err);
(...skipping 10 matching lines...) Expand all
1692 const struct sockaddr* sa = ainfo->ai_addr; 1692 const struct sockaddr* sa = ainfo->ai_addr;
1693 const struct sockaddr_in* sa_in = reinterpret_cast<const sockaddr_in*>(sa); 1693 const struct sockaddr_in* sa_in = reinterpret_cast<const sockaddr_in*>(sa);
1694 EXPECT_TRUE(htons(kPortnum) == sa_in->sin_port); 1694 EXPECT_TRUE(htons(kPortnum) == sa_in->sin_port);
1695 EXPECT_TRUE(htonl(0xc0a8012a) == sa_in->sin_addr.s_addr); 1695 EXPECT_TRUE(htonl(0xc0a8012a) == sa_in->sin_addr.s_addr);
1696 } 1696 }
1697 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. 1697 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags.
1698 1698
1699 } // namespace 1699 } // namespace
1700 1700
1701 } // namespace net 1701 } // namespace net
OLDNEW
« no previous file with comments | « src/net/base/address_list.cc ('k') | src/net/base/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698