| 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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <string> | 11 #include <string> |
| 9 #include <vector> | 12 #include <vector> |
| 10 | 13 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/dns/dns_client.h" | 15 #include "net/dns/dns_client.h" |
| 14 #include "net/dns/dns_config_service.h" | 16 #include "net/dns/dns_config_service.h" |
| 15 #include "net/dns/dns_protocol.h" | 17 #include "net/dns/dns_protocol.h" |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| 18 | 20 |
| 19 //----------------------------------------------------------------------------- | 21 //----------------------------------------------------------------------------- |
| 20 // Query/response set for www.google.com, ID is fixed to 0. | 22 // Query/response set for www.google.com, ID is fixed to 0. |
| 21 static const char kT0HostName[] = "www.google.com"; | 23 static const char kT0HostName[] = "www.google.com"; |
| 22 static const uint16 kT0Qtype = dns_protocol::kTypeA; | 24 static const uint16_t kT0Qtype = dns_protocol::kTypeA; |
| 23 static const char kT0DnsName[] = { | 25 static const char kT0DnsName[] = { |
| 24 0x03, 'w', 'w', 'w', | 26 0x03, 'w', 'w', 'w', |
| 25 0x06, 'g', 'o', 'o', 'g', 'l', 'e', | 27 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
| 26 0x03, 'c', 'o', 'm', | 28 0x03, 'c', 'o', 'm', |
| 27 0x00 | 29 0x00 |
| 28 }; | 30 }; |
| 29 static const size_t kT0QuerySize = 32; | 31 static const size_t kT0QuerySize = 32; |
| 30 static const uint8 kT0ResponseDatagram[] = { | 32 static const uint8_t kT0ResponseDatagram[] = { |
| 31 // response contains one CNAME for www.l.google.com and the following | 33 // response contains one CNAME for www.l.google.com and the following |
| 32 // IP addresses: 74.125.226.{179,180,176,177,178} | 34 // IP addresses: 74.125.226.{179,180,176,177,178} |
| 33 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x06, | 35 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, |
| 34 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, | 36 0x03, 0x77, 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, |
| 35 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, | 37 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05, |
| 36 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, | 38 0x00, 0x01, 0x00, 0x01, 0x4d, 0x13, 0x00, 0x08, 0x03, 0x77, 0x77, 0x77, |
| 37 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, | 39 0x01, 0x6c, 0xc0, 0x10, 0xc0, 0x2c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, |
| 38 0x4d, 0x13, 0x00, 0x08, 0x03, 0x77, 0x77, 0x77, | 40 0x00, 0xe4, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb3, 0xc0, 0x2c, 0x00, 0x01, |
| 39 0x01, 0x6c, 0xc0, 0x10, 0xc0, 0x2c, 0x00, 0x01, | 41 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb4, |
| 40 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, | 42 0xc0, 0x2c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, |
| 41 0x4a, 0x7d, 0xe2, 0xb3, 0xc0, 0x2c, 0x00, 0x01, | 43 0x4a, 0x7d, 0xe2, 0xb0, 0xc0, 0x2c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, |
| 42 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, | 44 0x00, 0xe4, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb1, 0xc0, 0x2c, 0x00, 0x01, |
| 43 0x4a, 0x7d, 0xe2, 0xb4, 0xc0, 0x2c, 0x00, 0x01, | 45 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb2}; |
| 44 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, | |
| 45 0x4a, 0x7d, 0xe2, 0xb0, 0xc0, 0x2c, 0x00, 0x01, | |
| 46 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, | |
| 47 0x4a, 0x7d, 0xe2, 0xb1, 0xc0, 0x2c, 0x00, 0x01, | |
| 48 0x00, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x04, | |
| 49 0x4a, 0x7d, 0xe2, 0xb2 | |
| 50 }; | |
| 51 static const char* const kT0IpAddresses[] = { | 46 static const char* const kT0IpAddresses[] = { |
| 52 "74.125.226.179", "74.125.226.180", "74.125.226.176", | 47 "74.125.226.179", "74.125.226.180", "74.125.226.176", |
| 53 "74.125.226.177", "74.125.226.178" | 48 "74.125.226.177", "74.125.226.178" |
| 54 }; | 49 }; |
| 55 static const char kT0CanonName[] = "www.l.google.com"; | 50 static const char kT0CanonName[] = "www.l.google.com"; |
| 56 static const int kT0TTL = 0x000000e4; | 51 static const int kT0TTL = 0x000000e4; |
| 57 // +1 for the CNAME record. | 52 // +1 for the CNAME record. |
| 58 static const unsigned kT0RecordCount = arraysize(kT0IpAddresses) + 1; | 53 static const unsigned kT0RecordCount = arraysize(kT0IpAddresses) + 1; |
| 59 | 54 |
| 60 //----------------------------------------------------------------------------- | 55 //----------------------------------------------------------------------------- |
| 61 // Query/response set for codereview.chromium.org, ID is fixed to 1. | 56 // Query/response set for codereview.chromium.org, ID is fixed to 1. |
| 62 static const char kT1HostName[] = "codereview.chromium.org"; | 57 static const char kT1HostName[] = "codereview.chromium.org"; |
| 63 static const uint16 kT1Qtype = dns_protocol::kTypeA; | 58 static const uint16_t kT1Qtype = dns_protocol::kTypeA; |
| 64 static const char kT1DnsName[] = { | 59 static const char kT1DnsName[] = { |
| 65 0x0a, 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w', | 60 0x0a, 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w', |
| 66 0x08, 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm', | 61 0x08, 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm', |
| 67 0x03, 'o', 'r', 'g', | 62 0x03, 'o', 'r', 'g', |
| 68 0x00 | 63 0x00 |
| 69 }; | 64 }; |
| 70 static const size_t kT1QuerySize = 41; | 65 static const size_t kT1QuerySize = 41; |
| 71 static const uint8 kT1ResponseDatagram[] = { | 66 static const uint8_t kT1ResponseDatagram[] = { |
| 72 // response contains one CNAME for ghs.l.google.com and the following | 67 // response contains one CNAME for ghs.l.google.com and the following |
| 73 // IP address: 64.233.169.121 | 68 // IP address: 64.233.169.121 |
| 74 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x02, | 69 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 75 0x00, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f, 0x64, | 70 0x00, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x65, 0x76, 0x69, 0x65, |
| 76 0x65, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x08, | 71 0x77, 0x08, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x69, 0x75, 0x6d, 0x03, |
| 77 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x69, 0x75, 0x6d, | 72 0x6f, 0x72, 0x67, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, |
| 78 0x03, 0x6f, 0x72, 0x67, 0x00, 0x00, 0x01, 0x00, | 73 0x05, 0x00, 0x01, 0x00, 0x01, 0x41, 0x75, 0x00, 0x12, 0x03, 0x67, |
| 79 0x01, 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, | 74 0x68, 0x73, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, |
| 80 0x01, 0x41, 0x75, 0x00, 0x12, 0x03, 0x67, 0x68, | 75 0x03, 0x63, 0x6f, 0x6d, 0x00, 0xc0, 0x35, 0x00, 0x01, 0x00, 0x01, |
| 81 0x73, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f, 0x67, | 76 0x00, 0x00, 0x01, 0x0b, 0x00, 0x04, 0x40, 0xe9, 0xa9, 0x79}; |
| 82 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0xc0, | |
| 83 0x35, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, | |
| 84 0x0b, 0x00, 0x04, 0x40, 0xe9, 0xa9, 0x79 | |
| 85 }; | |
| 86 static const char* const kT1IpAddresses[] = { | 77 static const char* const kT1IpAddresses[] = { |
| 87 "64.233.169.121" | 78 "64.233.169.121" |
| 88 }; | 79 }; |
| 89 static const char kT1CanonName[] = "ghs.l.google.com"; | 80 static const char kT1CanonName[] = "ghs.l.google.com"; |
| 90 static const int kT1TTL = 0x0000010b; | 81 static const int kT1TTL = 0x0000010b; |
| 91 // +1 for the CNAME record. | 82 // +1 for the CNAME record. |
| 92 static const unsigned kT1RecordCount = arraysize(kT1IpAddresses) + 1; | 83 static const unsigned kT1RecordCount = arraysize(kT1IpAddresses) + 1; |
| 93 | 84 |
| 94 //----------------------------------------------------------------------------- | 85 //----------------------------------------------------------------------------- |
| 95 // Query/response set for www.ccs.neu.edu, ID is fixed to 2. | 86 // Query/response set for www.ccs.neu.edu, ID is fixed to 2. |
| 96 static const char kT2HostName[] = "www.ccs.neu.edu"; | 87 static const char kT2HostName[] = "www.ccs.neu.edu"; |
| 97 static const uint16 kT2Qtype = dns_protocol::kTypeA; | 88 static const uint16_t kT2Qtype = dns_protocol::kTypeA; |
| 98 static const char kT2DnsName[] = { | 89 static const char kT2DnsName[] = { |
| 99 0x03, 'w', 'w', 'w', | 90 0x03, 'w', 'w', 'w', |
| 100 0x03, 'c', 'c', 's', | 91 0x03, 'c', 'c', 's', |
| 101 0x03, 'n', 'e', 'u', | 92 0x03, 'n', 'e', 'u', |
| 102 0x03, 'e', 'd', 'u', | 93 0x03, 'e', 'd', 'u', |
| 103 0x00 | 94 0x00 |
| 104 }; | 95 }; |
| 105 static const size_t kT2QuerySize = 33; | 96 static const size_t kT2QuerySize = 33; |
| 106 static const uint8 kT2ResponseDatagram[] = { | 97 static const uint8_t kT2ResponseDatagram[] = { |
| 107 // response contains one CNAME for vulcan.ccs.neu.edu and the following | 98 // response contains one CNAME for vulcan.ccs.neu.edu and the following |
| 108 // IP address: 129.10.116.81 | 99 // IP address: 129.10.116.81 |
| 109 0x00, 0x02, 0x81, 0x80, 0x00, 0x01, 0x00, 0x02, | 100 0x00, 0x02, 0x81, 0x80, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, |
| 110 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, | 101 0x03, 0x77, 0x77, 0x77, 0x03, 0x63, 0x63, 0x73, 0x03, 0x6e, 0x65, 0x75, |
| 111 0x03, 0x63, 0x63, 0x73, 0x03, 0x6e, 0x65, 0x75, | 102 0x03, 0x65, 0x64, 0x75, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, |
| 112 0x03, 0x65, 0x64, 0x75, 0x00, 0x00, 0x01, 0x00, | 103 0x05, 0x00, 0x01, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x09, 0x06, 0x76, 0x75, |
| 113 0x01, 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, | 104 0x6c, 0x63, 0x61, 0x6e, 0xc0, 0x10, 0xc0, 0x2d, 0x00, 0x01, 0x00, 0x01, |
| 114 0x00, 0x01, 0x2c, 0x00, 0x09, 0x06, 0x76, 0x75, | 105 0x00, 0x00, 0x01, 0x2c, 0x00, 0x04, 0x81, 0x0a, 0x74, 0x51}; |
| 115 0x6c, 0x63, 0x61, 0x6e, 0xc0, 0x10, 0xc0, 0x2d, | |
| 116 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x2c, | |
| 117 0x00, 0x04, 0x81, 0x0a, 0x74, 0x51 | |
| 118 }; | |
| 119 static const char* const kT2IpAddresses[] = { | 106 static const char* const kT2IpAddresses[] = { |
| 120 "129.10.116.81" | 107 "129.10.116.81" |
| 121 }; | 108 }; |
| 122 static const char kT2CanonName[] = "vulcan.ccs.neu.edu"; | 109 static const char kT2CanonName[] = "vulcan.ccs.neu.edu"; |
| 123 static const int kT2TTL = 0x0000012c; | 110 static const int kT2TTL = 0x0000012c; |
| 124 // +1 for the CNAME record. | 111 // +1 for the CNAME record. |
| 125 static const unsigned kT2RecordCount = arraysize(kT2IpAddresses) + 1; | 112 static const unsigned kT2RecordCount = arraysize(kT2IpAddresses) + 1; |
| 126 | 113 |
| 127 //----------------------------------------------------------------------------- | 114 //----------------------------------------------------------------------------- |
| 128 // Query/response set for www.google.az, ID is fixed to 3. | 115 // Query/response set for www.google.az, ID is fixed to 3. |
| 129 static const char kT3HostName[] = "www.google.az"; | 116 static const char kT3HostName[] = "www.google.az"; |
| 130 static const uint16 kT3Qtype = dns_protocol::kTypeA; | 117 static const uint16_t kT3Qtype = dns_protocol::kTypeA; |
| 131 static const char kT3DnsName[] = { | 118 static const char kT3DnsName[] = { |
| 132 0x03, 'w', 'w', 'w', | 119 0x03, 'w', 'w', 'w', |
| 133 0x06, 'g', 'o', 'o', 'g', 'l', 'e', | 120 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
| 134 0x02, 'a', 'z', | 121 0x02, 'a', 'z', |
| 135 0x00 | 122 0x00 |
| 136 }; | 123 }; |
| 137 static const size_t kT3QuerySize = 31; | 124 static const size_t kT3QuerySize = 31; |
| 138 static const uint8 kT3ResponseDatagram[] = { | 125 static const uint8_t kT3ResponseDatagram[] = { |
| 139 // response contains www.google.com as CNAME for www.google.az and | 126 // response contains www.google.com as CNAME for www.google.az and |
| 140 // www.l.google.com as CNAME for www.google.com and the following | 127 // www.l.google.com as CNAME for www.google.com and the following |
| 141 // IP addresses: 74.125.226.{178,179,180,176,177} | 128 // IP addresses: 74.125.226.{178,179,180,176,177} |
| 142 // The TTLs on the records are: 0x00015099, 0x00025099, 0x00000415, | 129 // The TTLs on the records are: 0x00015099, 0x00025099, 0x00000415, |
| 143 // 0x00003015, 0x00002015, 0x00000015, 0x00001015. | 130 // 0x00003015, 0x00002015, 0x00000015, 0x00001015. |
| 144 // The last record is an imaginary TXT record for t.google.com. | 131 // The last record is an imaginary TXT record for t.google.com. |
| 145 0x00, 0x03, 0x81, 0x80, 0x00, 0x01, 0x00, 0x08, | 132 0x00, 0x03, 0x81, 0x80, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 146 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, | 133 0x03, 0x77, 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x02, |
| 147 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x02, | 134 0x61, 0x7a, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05, 0x00, |
| 148 0x61, 0x7a, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, | 135 0x01, 0x00, 0x01, 0x50, 0x99, 0x00, 0x10, 0x03, 0x77, 0x77, 0x77, 0x06, |
| 149 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x50, | 136 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0xc0, |
| 150 0x99, 0x00, 0x10, 0x03, 0x77, 0x77, 0x77, 0x06, | 137 0x2b, 0x00, 0x05, 0x00, 0x01, 0x00, 0x02, 0x50, 0x99, 0x00, 0x08, 0x03, |
| 151 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, | 138 0x77, 0x77, 0x77, 0x01, 0x6c, 0xc0, 0x2f, 0xc0, 0x47, 0x00, 0x01, 0x00, |
| 152 0x6f, 0x6d, 0x00, 0xc0, 0x2b, 0x00, 0x05, 0x00, | 139 0x01, 0x00, 0x00, 0x04, 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb2, 0xc0, |
| 153 0x01, 0x00, 0x02, 0x50, 0x99, 0x00, 0x08, 0x03, | 140 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x30, 0x15, 0x00, 0x04, 0x4a, |
| 154 0x77, 0x77, 0x77, 0x01, 0x6c, 0xc0, 0x2f, 0xc0, | 141 0x7d, 0xe2, 0xb3, 0xc0, 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x20, |
| 155 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, | 142 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb4, 0xc0, 0x47, 0x00, 0x01, 0x00, |
| 156 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb2, 0xc0, | 143 0x01, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb0, 0xc0, |
| 157 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x30, | 144 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10, 0x15, 0x00, 0x04, 0x4a, |
| 158 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb3, 0xc0, | 145 0x7d, 0xe2, 0xb1, 0x01, 0x74, 0xc0, 0x2f, 0x00, 0x10, 0x00, 0x01, 0x00, |
| 159 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x20, | 146 0x00, 0x00, 0x01, 0x00, 0x04, 0xde, 0xad, 0xfe, 0xed}; |
| 160 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb4, 0xc0, | |
| 161 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, | |
| 162 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb0, 0xc0, | |
| 163 0x47, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10, | |
| 164 0x15, 0x00, 0x04, 0x4a, 0x7d, 0xe2, 0xb1, 0x01, | |
| 165 0x74, 0xc0, 0x2f, 0x00, 0x10, 0x00, 0x01, 0x00, | |
| 166 0x00, 0x00, 0x01, 0x00, 0x04, 0xde, 0xad, 0xfe, | |
| 167 0xed | |
| 168 }; | |
| 169 static const char* const kT3IpAddresses[] = { | 147 static const char* const kT3IpAddresses[] = { |
| 170 "74.125.226.178", "74.125.226.179", "74.125.226.180", | 148 "74.125.226.178", "74.125.226.179", "74.125.226.180", |
| 171 "74.125.226.176", "74.125.226.177" | 149 "74.125.226.176", "74.125.226.177" |
| 172 }; | 150 }; |
| 173 static const char kT3CanonName[] = "www.l.google.com"; | 151 static const char kT3CanonName[] = "www.l.google.com"; |
| 174 static const int kT3TTL = 0x00000015; | 152 static const int kT3TTL = 0x00000015; |
| 175 // +2 for the CNAME records, +1 for TXT record. | 153 // +2 for the CNAME records, +1 for TXT record. |
| 176 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3; | 154 static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3; |
| 177 | 155 |
| 178 class AddressSorter; | 156 class AddressSorter; |
| 179 class DnsClient; | 157 class DnsClient; |
| 180 class MockTransactionFactory; | 158 class MockTransactionFactory; |
| 181 | 159 |
| 182 struct MockDnsClientRule { | 160 struct MockDnsClientRule { |
| 183 enum Result { | 161 enum Result { |
| 184 FAIL, // Fail asynchronously with ERR_NAME_NOT_RESOLVED. | 162 FAIL, // Fail asynchronously with ERR_NAME_NOT_RESOLVED. |
| 185 TIMEOUT, // Fail asynchronously with ERR_DNS_TIMEOUT. | 163 TIMEOUT, // Fail asynchronously with ERR_DNS_TIMEOUT. |
| 186 EMPTY, // Return an empty response. | 164 EMPTY, // Return an empty response. |
| 187 OK, // Return a response with loopback address. | 165 OK, // Return a response with loopback address. |
| 188 }; | 166 }; |
| 189 | 167 |
| 190 // If |delay| is true, matching transactions will be delayed until triggered | 168 // If |delay| is true, matching transactions will be delayed until triggered |
| 191 // by the consumer. | 169 // by the consumer. |
| 192 MockDnsClientRule(const std::string& prefix_arg, | 170 MockDnsClientRule(const std::string& prefix_arg, |
| 193 uint16 qtype_arg, | 171 uint16_t qtype_arg, |
| 194 Result result_arg, | 172 Result result_arg, |
| 195 bool delay) | 173 bool delay) |
| 196 : result(result_arg), prefix(prefix_arg), qtype(qtype_arg), | 174 : result(result_arg), |
| 175 prefix(prefix_arg), |
| 176 qtype(qtype_arg), |
| 197 delay(delay) {} | 177 delay(delay) {} |
| 198 | 178 |
| 199 Result result; | 179 Result result; |
| 200 std::string prefix; | 180 std::string prefix; |
| 201 uint16 qtype; | 181 uint16_t qtype; |
| 202 bool delay; | 182 bool delay; |
| 203 }; | 183 }; |
| 204 | 184 |
| 205 typedef std::vector<MockDnsClientRule> MockDnsClientRuleList; | 185 typedef std::vector<MockDnsClientRule> MockDnsClientRuleList; |
| 206 | 186 |
| 207 // MockDnsClient provides MockTransactionFactory. | 187 // MockDnsClient provides MockTransactionFactory. |
| 208 class MockDnsClient : public DnsClient { | 188 class MockDnsClient : public DnsClient { |
| 209 public: | 189 public: |
| 210 MockDnsClient(const DnsConfig& config, const MockDnsClientRuleList& rules); | 190 MockDnsClient(const DnsConfig& config, const MockDnsClientRuleList& rules); |
| 211 ~MockDnsClient() override; | 191 ~MockDnsClient() override; |
| 212 | 192 |
| 213 // DnsClient interface: | 193 // DnsClient interface: |
| 214 void SetConfig(const DnsConfig& config) override; | 194 void SetConfig(const DnsConfig& config) override; |
| 215 const DnsConfig* GetConfig() const override; | 195 const DnsConfig* GetConfig() const override; |
| 216 DnsTransactionFactory* GetTransactionFactory() override; | 196 DnsTransactionFactory* GetTransactionFactory() override; |
| 217 AddressSorter* GetAddressSorter() override; | 197 AddressSorter* GetAddressSorter() override; |
| 218 | 198 |
| 219 // Completes all DnsTransactions that were delayed by a rule. | 199 // Completes all DnsTransactions that were delayed by a rule. |
| 220 void CompleteDelayedTransactions(); | 200 void CompleteDelayedTransactions(); |
| 221 | 201 |
| 222 private: | 202 private: |
| 223 DnsConfig config_; | 203 DnsConfig config_; |
| 224 scoped_ptr<MockTransactionFactory> factory_; | 204 scoped_ptr<MockTransactionFactory> factory_; |
| 225 scoped_ptr<AddressSorter> address_sorter_; | 205 scoped_ptr<AddressSorter> address_sorter_; |
| 226 }; | 206 }; |
| 227 | 207 |
| 228 } // namespace net | 208 } // namespace net |
| 229 | 209 |
| 230 #endif // NET_DNS_DNS_TEST_UTIL_H_ | 210 #endif // NET_DNS_DNS_TEST_UTIL_H_ |
| OLD | NEW |