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

Side by Side Diff: chrome/browser/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: fix builders Created 4 years, 10 months 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 <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
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 IPAddressToStringWithEmpty(const net::IPAddressNumber& address) { 72 std::string IPAddressToStringWithInvalid(const net::IPAddress& address) {
73 if (address.empty()) return ""; 73 if (!address.IsValid())
74 return net::IPAddressToString(address); 74 return "";
75 return address.ToString();
75 } 76 }
76 77
77 void AddressCallback(bool resolved, 78 void AddressCallback(bool resolved,
78 const net::IPAddressNumber& address_ipv4, 79 const net::IPAddress& address_ipv4,
79 const net::IPAddressNumber& address_ipv6) { 80 const net::IPAddress& address_ipv6) {
80 AddressCallbackInternal(resolved, 81 AddressCallbackInternal(resolved,
81 IPAddressToStringWithEmpty(address_ipv4), 82 IPAddressToStringWithInvalid(address_ipv4),
82 IPAddressToStringWithEmpty(address_ipv6)); 83 IPAddressToStringWithInvalid(address_ipv6));
83 } 84 }
84 85
85 void RunFor(base::TimeDelta time_period) { 86 void RunFor(base::TimeDelta time_period) {
86 base::CancelableCallback<void()> callback( 87 base::CancelableCallback<void()> callback(
87 base::Bind(&base::MessageLoop::QuitWhenIdle, 88 base::Bind(&base::MessageLoop::QuitWhenIdle,
88 base::Unretained(base::MessageLoop::current()))); 89 base::Unretained(base::MessageLoop::current())));
89 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 90 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
90 FROM_HERE, callback.callback(), time_period); 91 FROM_HERE, callback.callback(), time_period);
91 92
92 base::MessageLoop::current()->Run(); 93 base::MessageLoop::current()->Run();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 resolver.Start(); 180 resolver.Start();
180 181
181 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); 182 EXPECT_CALL(*this, AddressCallbackInternal(false, "", ""));
182 183
183 RunFor(base::TimeDelta::FromSeconds(4)); 184 RunFor(base::TimeDelta::FromSeconds(4));
184 } 185 }
185 186
186 } // namespace 187 } // namespace
187 188
188 } // namespace local_discovery 189 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/endpoint_resolver.cc ('k') | chrome/browser/local_discovery/service_discovery_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698