| 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 "chrome/browser/net/dns_probe_job.h" | 5 #include "chrome/browser/net/dns_probe_job.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 DnsConfig config; | 47 DnsConfig config; |
| 48 config.nameservers.clear(); | 48 config.nameservers.clear(); |
| 49 IPAddressNumber dns_ip; | 49 IPAddressNumber dns_ip; |
| 50 ParseIPLiteralToNumber("192.168.1.1", &dns_ip); | 50 ParseIPLiteralToNumber("192.168.1.1", &dns_ip); |
| 51 const uint16 kDnsPort = net::dns_protocol::kDefaultPort; | 51 const uint16 kDnsPort = net::dns_protocol::kDefaultPort; |
| 52 config.nameservers.push_back(IPEndPoint(dns_ip, kDnsPort)); | 52 config.nameservers.push_back(IPEndPoint(dns_ip, kDnsPort)); |
| 53 | 53 |
| 54 const uint16 kTypeA = net::dns_protocol::kTypeA; | 54 const uint16 kTypeA = net::dns_protocol::kTypeA; |
| 55 MockDnsClientRuleList rules; | 55 MockDnsClientRuleList rules; |
| 56 rules.push_back(MockDnsClientRule("google.com", kTypeA, good_result)); | 56 rules.push_back(MockDnsClientRule("google.com", kTypeA, good_result)); |
| 57 rules.push_back(MockDnsClientRule("", kTypeA, bad_result)); | 57 rules.push_back(MockDnsClientRule(std::string(), kTypeA, bad_result)); |
| 58 | 58 |
| 59 scoped_ptr<DnsClient> dns_client = CreateMockDnsClient(config, rules); | 59 scoped_ptr<DnsClient> dns_client = CreateMockDnsClient(config, rules); |
| 60 dns_client->SetConfig(config); | 60 dns_client->SetConfig(config); |
| 61 | 61 |
| 62 NetLog* net_log = NULL; | 62 NetLog* net_log = NULL; |
| 63 DnsProbeJob::CallbackType callback = base::Bind( | 63 DnsProbeJob::CallbackType callback = base::Bind( |
| 64 &DnsProbeJobTest::OnProbeFinished, | 64 &DnsProbeJobTest::OnProbeFinished, |
| 65 base::Unretained(this)); | 65 base::Unretained(this)); |
| 66 | 66 |
| 67 // Need to set these before creating job, because it can call the callback | 67 // Need to set these before creating job, because it can call the callback |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const TestCase* test_case = &kTestCases[i]; | 118 const TestCase* test_case = &kTestCases[i]; |
| 119 RunProbe(test_case->good_result, test_case->bad_result); | 119 RunProbe(test_case->good_result, test_case->bad_result); |
| 120 EXPECT_TRUE(callback_called_); | 120 EXPECT_TRUE(callback_called_); |
| 121 EXPECT_EQ(test_case->expected_probe_result, callback_result_); | 121 EXPECT_EQ(test_case->expected_probe_result, callback_result_); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace | 125 } // namespace |
| 126 | 126 |
| 127 } // namespace chrome_browser_net | 127 } // namespace chrome_browser_net |
| OLD | NEW |