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

Side by Side Diff: net/dns/dns_test_util.h

Issue 2567623003: Make ERR_ICANN_NAME_COLLISION work for async DNS resolver. (Closed)
Patch Set: one more Created 4 years 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
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 #ifndef NET_DNS_DNS_TEST_UTIL_H_ 5 #ifndef NET_DNS_DNS_TEST_UTIL_H_
6 #define NET_DNS_DNS_TEST_UTIL_H_ 6 #define NET_DNS_DNS_TEST_UTIL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 static const char kT3CanonName[] = "www.l.google.com"; 151 static const char kT3CanonName[] = "www.l.google.com";
152 static const int kT3TTL = 0x00000015; 152 static const int kT3TTL = 0x00000015;
153 // +2 for the CNAME records, +1 for TXT record. 153 // +2 for the CNAME records, +1 for TXT record.
154 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3; 154 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3;
155 155
156 class AddressSorter; 156 class AddressSorter;
157 class DnsClient; 157 class DnsClient;
158 class MockTransactionFactory; 158 class MockTransactionFactory;
159 159
160 struct MockDnsClientRule { 160 struct MockDnsClientRule {
161 enum Result { 161 enum ResultType {
162 FAIL, // Fail asynchronously with ERR_NAME_NOT_RESOLVED. 162 FAIL, // Fail asynchronously with ERR_NAME_NOT_RESOLVED.
163 TIMEOUT, // Fail asynchronously with ERR_DNS_TIMEOUT. 163 TIMEOUT, // Fail asynchronously with ERR_DNS_TIMEOUT.
164 EMPTY, // Return an empty response. 164 EMPTY, // Return an empty response.
165 OK, // Return a response with loopback address. 165 OK, // Return an IP address (the accompanying IP is an argument in the
166 // Result structure, or understood as localhost when unspecified).
167 };
168
169 struct Result {
170 explicit Result(const IPAddress& ip) : type(OK), ip(ip) {}
171 explicit Result(ResultType type) : type(type) {}
172
173 ResultType type;
174 IPAddress ip;
166 }; 175 };
167 176
168 // If |delay| is true, matching transactions will be delayed until triggered 177 // If |delay| is true, matching transactions will be delayed until triggered
169 // by the consumer. 178 // by the consumer.
170 MockDnsClientRule(const std::string& prefix_arg, 179 MockDnsClientRule(const std::string& prefix_arg,
171 uint16_t qtype_arg, 180 uint16_t qtype_arg,
172 Result result_arg, 181 const Result& result_arg,
173 bool delay) 182 bool delay)
174 : result(result_arg), 183 : result(result_arg),
175 prefix(prefix_arg), 184 prefix(prefix_arg),
176 qtype(qtype_arg), 185 qtype(qtype_arg),
177 delay(delay) {} 186 delay(delay) {}
178 187
179 Result result; 188 Result result;
180 std::string prefix; 189 std::string prefix;
181 uint16_t qtype; 190 uint16_t qtype;
182 bool delay; 191 bool delay;
(...skipping 20 matching lines...) Expand all
203 212
204 private: 213 private:
205 DnsConfig config_; 214 DnsConfig config_;
206 std::unique_ptr<MockTransactionFactory> factory_; 215 std::unique_ptr<MockTransactionFactory> factory_;
207 std::unique_ptr<AddressSorter> address_sorter_; 216 std::unique_ptr<AddressSorter> address_sorter_;
208 }; 217 };
209 218
210 } // namespace net 219 } // namespace net
211 220
212 #endif // NET_DNS_DNS_TEST_UTIL_H_ 221 #endif // NET_DNS_DNS_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698