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 #include "net/dns/dns_response.h" | 5 #include "net/dns/dns_response.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 }; | 205 }; |
206 | 206 |
207 DnsResponse resp; | 207 DnsResponse resp; |
208 memcpy(resp.io_buffer()->data(), response_data, sizeof(response_data)); | 208 memcpy(resp.io_buffer()->data(), response_data, sizeof(response_data)); |
209 | 209 |
210 // Reject too short. | 210 // Reject too short. |
211 EXPECT_FALSE(resp.InitParse(query->io_buffer()->size() - 1, *query)); | 211 EXPECT_FALSE(resp.InitParse(query->io_buffer()->size() - 1, *query)); |
212 EXPECT_FALSE(resp.IsValid()); | 212 EXPECT_FALSE(resp.IsValid()); |
213 | 213 |
214 // Reject wrong id. | 214 // Reject wrong id. |
215 scoped_ptr<DnsQuery> other_query(query->CloneWithNewId(0xbeef)); | 215 scoped_ptr<DnsQuery> other_query = query->CloneWithNewId(0xbeef); |
216 EXPECT_FALSE(resp.InitParse(sizeof(response_data), *other_query)); | 216 EXPECT_FALSE(resp.InitParse(sizeof(response_data), *other_query)); |
217 EXPECT_FALSE(resp.IsValid()); | 217 EXPECT_FALSE(resp.IsValid()); |
218 | 218 |
219 // Reject wrong question. | 219 // Reject wrong question. |
220 scoped_ptr<DnsQuery> wrong_query( | 220 scoped_ptr<DnsQuery> wrong_query( |
221 new DnsQuery(0xcafe, qname, dns_protocol::kTypeCNAME)); | 221 new DnsQuery(0xcafe, qname, dns_protocol::kTypeCNAME)); |
222 EXPECT_FALSE(resp.InitParse(sizeof(response_data), *wrong_query)); | 222 EXPECT_FALSE(resp.InitParse(sizeof(response_data), *wrong_query)); |
223 EXPECT_FALSE(resp.IsValid()); | 223 EXPECT_FALSE(resp.IsValid()); |
224 | 224 |
225 // Accept matching question. | 225 // Accept matching question. |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 AddressList addr_list; | 572 AddressList addr_list; |
573 base::TimeDelta ttl; | 573 base::TimeDelta ttl; |
574 EXPECT_EQ(t.expected_result, | 574 EXPECT_EQ(t.expected_result, |
575 response.ParseToAddressList(&addr_list, &ttl)); | 575 response.ParseToAddressList(&addr_list, &ttl)); |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 } // namespace | 579 } // namespace |
580 | 580 |
581 } // namespace net | 581 } // namespace net |
OLD | NEW |