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

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

Issue 7276014: DnsQuery: changed raw function pointer to callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Got rid of unnecessary include. Created 9 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 | « net/base/dns_query_unittest.cc ('k') | net/base/rand_callback.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/dns_response.h"
6
7 #include "base/bind.h"
5 #include "base/rand_util.h" 8 #include "base/rand_util.h"
6 #include "net/base/dns_response.h"
7 #include "net/base/dns_util.h" 9 #include "net/base/dns_util.h"
8 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 12
11 namespace net { 13 namespace net {
12 14
13 // DNS response consists of a header followed by a question followed by 15 // DNS response consists of a header followed by a question followed by
14 // answer. Header format, question format and response format are 16 // answer. Header format, question format and response format are
15 // described below. For the meaning of specific fields, please see RFC 17 // described below. For the meaning of specific fields, please see RFC
16 // 1035. 18 // 1035.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 65 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
64 // | RDLENGTH | 66 // | RDLENGTH |
65 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| 67 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
66 // / RDATA / 68 // / RDATA /
67 // / / 69 // / /
68 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 70 // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
69 71
70 // TODO(agayev): add more thorough tests. 72 // TODO(agayev): add more thorough tests.
71 TEST(DnsResponseTest, ResponseWithCnameA) { 73 TEST(DnsResponseTest, ResponseWithCnameA) {
72 const std::string kHostnameDns("\012codereview\010chromium\003org", 25); 74 const std::string kHostnameDns("\012codereview\010chromium\003org", 25);
75 RandIntCallback rand_int_cb = base::Bind(&base::RandInt);
73 76
74 DnsQuery q1(kHostnameDns, kDNS_A, base::RandUint64); 77 DnsQuery q1(kHostnameDns, kDNS_A, rand_int_cb);
75 uint8 id_hi = q1.id() >> 8, id_lo = q1.id() & 0xff; 78 uint8 id_hi = q1.id() >> 8, id_lo = q1.id() & 0xff;
76 79
77 uint8 ip[] = { // codereview.chromium.org resolves to 80 uint8 ip[] = { // codereview.chromium.org resolves to
78 0x4a, 0x7d, 0x5f, 0x79 // 74.125.95.121 81 0x4a, 0x7d, 0x5f, 0x79 // 74.125.95.121
79 }; 82 };
80 83
81 std::vector<IPAddressNumber> expected_ips; 84 std::vector<IPAddressNumber> expected_ips;
82 expected_ips.push_back(IPAddressNumber(ip, ip + arraysize(ip))); 85 expected_ips.push_back(IPAddressNumber(ip, ip + arraysize(ip)));
83 86
84 uint8 response_data[] = { 87 uint8 response_data[] = {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 r1.io_buffer()->size()); 133 r1.io_buffer()->size());
131 134
132 // Verify resolved IPs. 135 // Verify resolved IPs.
133 int response_size = arraysize(response_data); 136 int response_size = arraysize(response_data);
134 std::vector<IPAddressNumber> actual_ips; 137 std::vector<IPAddressNumber> actual_ips;
135 EXPECT_EQ(OK, r1.Parse(response_size, &actual_ips)); 138 EXPECT_EQ(OK, r1.Parse(response_size, &actual_ips));
136 EXPECT_EQ(expected_ips, actual_ips); 139 EXPECT_EQ(expected_ips, actual_ips);
137 } 140 }
138 141
139 } // namespace net 142 } // namespace net
OLDNEW
« no previous file with comments | « net/base/dns_query_unittest.cc ('k') | net/base/rand_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698