| OLD | NEW |
| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 static const int kT3TTL = 0x00000015; | 173 static const int kT3TTL = 0x00000015; |
| 174 // +2 for the CNAME records, +1 for TXT record. | 174 // +2 for the CNAME records, +1 for TXT record. |
| 175 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3; | 175 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3; |
| 176 | 176 |
| 177 class DnsClient; | 177 class DnsClient; |
| 178 | 178 |
| 179 struct MockDnsClientRule { | 179 struct MockDnsClientRule { |
| 180 enum Result { | 180 enum Result { |
| 181 FAIL_SYNC, // Fail synchronously with ERR_NAME_NOT_RESOLVED. | 181 FAIL_SYNC, // Fail synchronously with ERR_NAME_NOT_RESOLVED. |
| 182 FAIL_ASYNC, // Fail asynchronously with ERR_NAME_NOT_RESOLVED. | 182 FAIL_ASYNC, // Fail asynchronously with ERR_NAME_NOT_RESOLVED. |
| 183 TIMEOUT, // Fail asynchronously with ERR_DNS_TIMEOUT. |
| 183 EMPTY, // Return an empty response. | 184 EMPTY, // Return an empty response. |
| 184 OK, // Return a response with loopback address. | 185 OK, // Return a response with loopback address. |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 MockDnsClientRule(const std::string& prefix_arg, | 188 MockDnsClientRule(const std::string& prefix_arg, |
| 188 uint16 qtype_arg, | 189 uint16 qtype_arg, |
| 189 Result result_arg) | 190 Result result_arg) |
| 190 : result(result_arg), prefix(prefix_arg), qtype(qtype_arg) { } | 191 : result(result_arg), prefix(prefix_arg), qtype(qtype_arg) { } |
| 191 | 192 |
| 192 Result result; | 193 Result result; |
| 193 std::string prefix; | 194 std::string prefix; |
| 194 uint16 qtype; | 195 uint16 qtype; |
| 195 }; | 196 }; |
| 196 | 197 |
| 197 typedef std::vector<MockDnsClientRule> MockDnsClientRuleList; | 198 typedef std::vector<MockDnsClientRule> MockDnsClientRuleList; |
| 198 | 199 |
| 199 // Creates mock DnsClient for testing HostResolverImpl. | 200 // Creates mock DnsClient for testing HostResolverImpl. |
| 200 scoped_ptr<DnsClient> CreateMockDnsClient(const DnsConfig& config, | 201 scoped_ptr<DnsClient> CreateMockDnsClient(const DnsConfig& config, |
| 201 const MockDnsClientRuleList& rules); | 202 const MockDnsClientRuleList& rules); |
| 202 | 203 |
| 203 } // namespace net | 204 } // namespace net |
| 204 | 205 |
| 205 #endif // NET_DNS_DNS_TEST_UTIL_H_ | 206 #endif // NET_DNS_DNS_TEST_UTIL_H_ |
| OLD | NEW |