Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/common/local_discovery/local_domain_resolver_unittest.cc

Issue 1534583002: Migrate Local Discovery from net::IPAddressNumber to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/location.h" 5 #include "base/location.h"
6 #include "base/single_thread_task_runner.h" 6 #include "base/single_thread_task_runner.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "chrome/common/local_discovery/service_discovery_client_impl.h" 8 #include "chrome/common/local_discovery/service_discovery_client_impl.h"
9 #include "net/dns/mdns_client_impl.h" 9 #include "net/dns/mdns_client_impl.h"
10 #include "net/dns/mock_mdns_socket_factory.h" 10 #include "net/dns/mock_mdns_socket_factory.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 0x00, 0x01, 0x00, 0x02, 60 0x00, 0x01, 0x00, 0x02,
61 0x00, 0x03, 0x00, 0x04, 61 0x00, 0x03, 0x00, 0x04,
62 }; 62 };
63 63
64 class LocalDomainResolverTest : public testing::Test { 64 class LocalDomainResolverTest : public testing::Test {
65 public: 65 public:
66 void SetUp() override { 66 void SetUp() override {
67 mdns_client_.StartListening(&socket_factory_); 67 mdns_client_.StartListening(&socket_factory_);
68 } 68 }
69 69
70 std::string IPAddressToStringWithEmpty(const net::IPAddressNumber& address) { 70 std::string IPAddressToStringWithEmpty(const net::IPAddress& address) {
71 if (address.empty()) return ""; 71 if (!address.IsIPv4() && !address.IsIPv6())
eroman 2015/12/21 20:47:33 !IsValid()
martijnc 2016/01/27 22:50:52 Done.
72 return net::IPAddressToString(address); 72 return "";
73 return address.ToString();
73 } 74 }
74 75
75 void AddressCallback(bool resolved, 76 void AddressCallback(bool resolved,
76 const net::IPAddressNumber& address_ipv4, 77 const net::IPAddress& address_ipv4,
77 const net::IPAddressNumber& address_ipv6) { 78 const net::IPAddress& address_ipv6) {
78 AddressCallbackInternal(resolved, 79 AddressCallbackInternal(resolved,
79 IPAddressToStringWithEmpty(address_ipv4), 80 IPAddressToStringWithEmpty(address_ipv4),
80 IPAddressToStringWithEmpty(address_ipv6)); 81 IPAddressToStringWithEmpty(address_ipv6));
81 } 82 }
82 83
83 void RunFor(base::TimeDelta time_period) { 84 void RunFor(base::TimeDelta time_period) {
84 base::CancelableCallback<void()> callback( 85 base::CancelableCallback<void()> callback(
85 base::Bind(&base::MessageLoop::QuitWhenIdle, 86 base::Bind(&base::MessageLoop::QuitWhenIdle,
86 base::Unretained(base::MessageLoop::current()))); 87 base::Unretained(base::MessageLoop::current())));
87 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 88 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 resolver.Start(); 178 resolver.Start();
178 179
179 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); 180 EXPECT_CALL(*this, AddressCallbackInternal(false, "", ""));
180 181
181 RunFor(base::TimeDelta::FromSeconds(4)); 182 RunFor(base::TimeDelta::FromSeconds(4));
182 } 183 }
183 184
184 } // namespace 185 } // namespace
185 186
186 } // namespace local_discovery 187 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698