| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/test/scoped_task_environment.h" | |
| 11 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" | 11 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" |
| 13 #include "net/dns/mdns_client_impl.h" | 12 #include "net/dns/mdns_client_impl.h" |
| 14 #include "net/dns/mock_mdns_socket_factory.h" | 13 #include "net/dns/mock_mdns_socket_factory.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 16 |
| 18 using ::testing::_; | 17 using ::testing::_; |
| 19 | 18 |
| 20 namespace local_discovery { | 19 namespace local_discovery { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 callback.Cancel(); | 93 callback.Cancel(); |
| 95 } | 94 } |
| 96 | 95 |
| 97 MOCK_METHOD3(AddressCallbackInternal, | 96 MOCK_METHOD3(AddressCallbackInternal, |
| 98 void(bool resolved, | 97 void(bool resolved, |
| 99 std::string address_ipv4, | 98 std::string address_ipv4, |
| 100 std::string address_ipv6)); | 99 std::string address_ipv6)); |
| 101 | 100 |
| 102 net::MockMDnsSocketFactory socket_factory_; | 101 net::MockMDnsSocketFactory socket_factory_; |
| 103 net::MDnsClientImpl mdns_client_; | 102 net::MDnsClientImpl mdns_client_; |
| 104 base::test::ScopedTaskEnvironment scoped_task_environment_; | 103 base::MessageLoop message_loop_; |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 TEST_F(LocalDomainResolverTest, ResolveDomainA) { | 106 TEST_F(LocalDomainResolverTest, ResolveDomainA) { |
| 108 LocalDomainResolverImpl resolver( | 107 LocalDomainResolverImpl resolver( |
| 109 "myhello.local", net::ADDRESS_FAMILY_IPV4, | 108 "myhello.local", net::ADDRESS_FAMILY_IPV4, |
| 110 base::Bind(&LocalDomainResolverTest::AddressCallback, | 109 base::Bind(&LocalDomainResolverTest::AddressCallback, |
| 111 base::Unretained(this)), &mdns_client_); | 110 base::Unretained(this)), &mdns_client_); |
| 112 | 111 |
| 113 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); // Twice per query | 112 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); // Twice per query |
| 114 | 113 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 resolver.Start(); | 179 resolver.Start(); |
| 181 | 180 |
| 182 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); | 181 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); |
| 183 | 182 |
| 184 RunFor(base::TimeDelta::FromSeconds(4)); | 183 RunFor(base::TimeDelta::FromSeconds(4)); |
| 185 } | 184 } |
| 186 | 185 |
| 187 } // namespace | 186 } // namespace |
| 188 | 187 |
| 189 } // namespace local_discovery | 188 } // namespace local_discovery |
| OLD | NEW |