| 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/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" | 
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" | 
| 10 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" | 10 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 62   0x00, 0x01, 0x00, 0x02, | 62   0x00, 0x01, 0x00, 0x02, | 
| 63   0x00, 0x03, 0x00, 0x04, | 63   0x00, 0x03, 0x00, 0x04, | 
| 64 }; | 64 }; | 
| 65 | 65 | 
| 66 class LocalDomainResolverTest : public testing::Test { | 66 class LocalDomainResolverTest : public testing::Test { | 
| 67  public: | 67  public: | 
| 68   void SetUp() override { | 68   void SetUp() override { | 
| 69     mdns_client_.StartListening(&socket_factory_); | 69     mdns_client_.StartListening(&socket_factory_); | 
| 70   } | 70   } | 
| 71 | 71 | 
| 72   std::string IPAddressToStringWithInvalid(const net::IPAddress& address) { | 72   std::string IPAddressToStringWithEmpty(const net::IPAddressNumber& address) { | 
| 73     if (!address.IsValid()) | 73     if (address.empty()) return ""; | 
| 74       return ""; | 74     return net::IPAddressToString(address); | 
| 75     return address.ToString(); |  | 
| 76   } | 75   } | 
| 77 | 76 | 
| 78   void AddressCallback(bool resolved, | 77   void AddressCallback(bool resolved, | 
| 79                        const net::IPAddress& address_ipv4, | 78                        const net::IPAddressNumber& address_ipv4, | 
| 80                        const net::IPAddress& address_ipv6) { | 79                        const net::IPAddressNumber& address_ipv6) { | 
| 81     AddressCallbackInternal(resolved, | 80       AddressCallbackInternal(resolved, | 
| 82                             IPAddressToStringWithInvalid(address_ipv4), | 81                               IPAddressToStringWithEmpty(address_ipv4), | 
| 83                             IPAddressToStringWithInvalid(address_ipv6)); | 82                               IPAddressToStringWithEmpty(address_ipv6)); | 
| 84   } | 83   } | 
| 85 | 84 | 
| 86   void RunFor(base::TimeDelta time_period) { | 85   void RunFor(base::TimeDelta time_period) { | 
| 87     base::CancelableCallback<void()> callback( | 86     base::CancelableCallback<void()> callback( | 
| 88         base::Bind(&base::MessageLoop::QuitWhenIdle, | 87         base::Bind(&base::MessageLoop::QuitWhenIdle, | 
| 89                    base::Unretained(base::MessageLoop::current()))); | 88                    base::Unretained(base::MessageLoop::current()))); | 
| 90     base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 89     base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 
| 91         FROM_HERE, callback.callback(), time_period); | 90         FROM_HERE, callback.callback(), time_period); | 
| 92 | 91 | 
| 93     base::MessageLoop::current()->Run(); | 92     base::MessageLoop::current()->Run(); | 
| (...skipping 86 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 | 
|---|