| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_runner.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 5 #include "base/bind.h" | 9 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 9 #include "chrome/browser/net/dns_probe_runner.h" | |
| 10 #include "chrome/browser/net/dns_probe_test_util.h" | 13 #include "chrome/browser/net/dns_probe_test_util.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "net/dns/dns_client.h" | 15 #include "net/dns/dns_client.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 17 |
| 15 using base::MessageLoopForIO; | 18 using base::MessageLoopForIO; |
| 16 using base::RunLoop; | 19 using base::RunLoop; |
| 17 using content::TestBrowserThreadBundle; | 20 using content::TestBrowserThreadBundle; |
| 18 using net::DnsClient; | 21 using net::DnsClient; |
| 19 using net::DnsConfig; | 22 using net::DnsConfig; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 TEST_F(DnsProbeRunnerTest, TwoProbes) { | 89 TEST_F(DnsProbeRunnerTest, TwoProbes) { |
| 87 RunTest(MockDnsClientRule::OK, DnsProbeRunner::CORRECT); | 90 RunTest(MockDnsClientRule::OK, DnsProbeRunner::CORRECT); |
| 88 RunTest(MockDnsClientRule::EMPTY, DnsProbeRunner::INCORRECT); | 91 RunTest(MockDnsClientRule::EMPTY, DnsProbeRunner::INCORRECT); |
| 89 } | 92 } |
| 90 | 93 |
| 91 TEST_F(DnsProbeRunnerTest, InvalidDnsConfig) { | 94 TEST_F(DnsProbeRunnerTest, InvalidDnsConfig) { |
| 92 scoped_ptr<DnsClient> dns_client(DnsClient::CreateClient(NULL)); | 95 scoped_ptr<DnsClient> dns_client(DnsClient::CreateClient(NULL)); |
| 93 DnsConfig empty_config; | 96 DnsConfig empty_config; |
| 94 dns_client->SetConfig(empty_config); | 97 dns_client->SetConfig(empty_config); |
| 95 ASSERT_EQ(NULL, dns_client->GetTransactionFactory()); | 98 ASSERT_EQ(NULL, dns_client->GetTransactionFactory()); |
| 96 runner_.SetClient(dns_client.Pass()); | 99 runner_.SetClient(std::move(dns_client)); |
| 97 | 100 |
| 98 TestDnsProbeRunnerCallback callback; | 101 TestDnsProbeRunnerCallback callback; |
| 99 | 102 |
| 100 runner_.RunProbe(callback.callback()); | 103 runner_.RunProbe(callback.callback()); |
| 101 EXPECT_TRUE(runner_.IsRunning()); | 104 EXPECT_TRUE(runner_.IsRunning()); |
| 102 | 105 |
| 103 RunLoop().RunUntilIdle(); | 106 RunLoop().RunUntilIdle(); |
| 104 EXPECT_FALSE(runner_.IsRunning()); | 107 EXPECT_FALSE(runner_.IsRunning()); |
| 105 EXPECT_TRUE(callback.called()); | 108 EXPECT_TRUE(callback.called()); |
| 106 EXPECT_EQ(DnsProbeRunner::UNKNOWN, runner_.result()); | 109 EXPECT_EQ(DnsProbeRunner::UNKNOWN, runner_.result()); |
| 107 } | 110 } |
| 108 | 111 |
| 109 } // namespace | 112 } // namespace |
| 110 | 113 |
| 111 } // namespace chrome_browser_net | 114 } // namespace chrome_browser_net |
| OLD | NEW |